1
1
mirror of https://github.com/geekfrog/PermissionsTime.git synced 2024-11-21 14:58:48 +00:00

调整目录结构

增加称号功能
This commit is contained in:
GeekFrog 2018-06-23 15:37:38 +08:00
parent 94c9c485e4
commit 77fb63bf56
43 changed files with 361 additions and 267 deletions

View File

@ -12,7 +12,7 @@ metrics: true
tagSystem: false
# 语言文件名称 在'lang'文件夹内.
# Language file name.
lang: en
lang: zh-cn
# 数据库相关.
# Database settings.
mysql:

View File

@ -1,6 +1,6 @@
name: ${project.name}
version: ${project.version}
main: gg.frog.mc.permissionstime.PluginMain
main: gg.frog.mc.base.PluginMain
author:
- GeekFrog
description: ${project.description}
@ -17,7 +17,7 @@ commands:
description: Aliases commands for permissionstime.
usage: /pt [param]
permissions:
permissionstime.*:
gg.frog.permissionstime.*:
description: Gives access to all PermissionsTime commands.
default: op
children:

View File

@ -15,6 +15,9 @@ 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则禁用刷新.
@ -25,7 +28,7 @@ refreshTagTime: -1
template:
lore:
- '&1-----------------'
- '&2效果展示:'
- '&2Preview:'
- '&3 %displayname%'
- '&4-----------------'
- '&5 %description%'

View File

@ -39,7 +39,7 @@
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>filoghost-repo</id>
<id>HD</id>
<url>https://ci.filoghost.me/plugin/repository/everything/</url>
</repository>
</repositories>

View File

@ -1,4 +1,4 @@
package gg.frog.mc.permissionstime;
package gg.frog.mc.base;
import java.text.MessageFormat;
import java.util.Locale;
@ -12,15 +12,16 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import gg.frog.mc.permissionstime.command.MainCommand;
import gg.frog.mc.permissionstime.config.ConfigManager;
import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.base.config.ConfigManager;
import gg.frog.mc.base.config.PluginCfg;
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.permissionstime.command.PtCommand;
import gg.frog.mc.permissionstime.database.SqlManager;
import gg.frog.mc.permissionstime.listener.MainListener;
import gg.frog.mc.permissionstime.placeholder.TagPlaceholder;
import gg.frog.mc.permissionstime.utils.FileUtil;
import gg.frog.mc.permissionstime.utils.StrUtil;
import gg.frog.mc.permissionstime.utils.UpdateCheck;
import net.milkbowl.vault.permission.Permission;
public class PluginMain extends JavaPlugin {
@ -60,12 +61,12 @@ public class PluginMain extends JavaPlugin {
public void run() {
if (!checkPluginDepends()) {
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Startup failure!"));
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Startup failure!"));
getServer().getPluginManager().disablePlugin(pm);
} else {
registerListeners();
registerCommands();
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&2Startup successful!"));
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§2Startup successful!"));
}
if (PluginCfg.IS_METRICS) {
try {
@ -85,6 +86,7 @@ public class PluginMain extends JavaPlugin {
*/
private void registerListeners() {
pm.getServer().getPluginManager().registerEvents(new MainListener(pm), pm);
pm.getServer().getPluginManager().registerEvents(new TagsListener(pm), pm);
}
/**
@ -92,12 +94,12 @@ public class PluginMain extends JavaPlugin {
* 这里可以注册多个一般注册一个就够用
*/
private void registerCommands() {
MainCommand mcmd = new MainCommand(pm);
if (getDescription().getCommands().containsKey(PLUGIN_NAME_LOWER_CASE)) {
getCommand(PLUGIN_NAME_LOWER_CASE).setExecutor(mcmd);
PtCommand ptCmd = new PtCommand(pm);
if (getDescription().getCommands().containsKey("permissionstime")) {
getCommand(PLUGIN_NAME_LOWER_CASE).setExecutor(ptCmd);
}
if (getDescription().getCommands().containsKey("pt")) {
getCommand("pt").setExecutor(mcmd);
getCommand("pt").setExecutor(ptCmd);
}
}
@ -121,22 +123,22 @@ public class PluginMain extends JavaPlugin {
boolean needDepend = false;
for (String name : DEPEND_PLUGIN.split(",")) {
if (!getServer().getPluginManager().isPluginEnabled(name)) {
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Need depend plugins : " + name + "."));
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Need depend plugins : " + name + "."));
needDepend = true;
}
}
if (!needDepend && !setupPermissions()) {
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;
}
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;
}
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."));
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 {
@ -145,14 +147,14 @@ public class PluginMain extends JavaPlugin {
}
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."));
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."));
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) {

View File

@ -1,4 +1,4 @@
package gg.frog.mc.permissionstime.config;
package gg.frog.mc.base.config;
import java.io.File;
import java.io.FileOutputStream;
@ -8,12 +8,14 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
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.utils.FileUtil;
import gg.frog.mc.permissionstime.utils.FileUtil.FindFilesDo;
import gg.frog.mc.permissionstime.utils.config.PluginConfig;
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;
/**
* 配置文件管理

View File

@ -1,7 +1,7 @@
package gg.frog.mc.permissionstime.config;
package gg.frog.mc.base.config;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.utils.config.PluginConfig;
import gg.frog.mc.base.PluginMain;
import gg.frog.mc.base.utils.config.PluginConfig;
/**
* 语言支持
@ -20,6 +20,9 @@ public class LangCfg extends PluginConfig {
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;
@ -84,6 +87,9 @@ public class LangCfg extends PluginConfig {
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("tag", "&6&lName Style");
TAG_PREFIX_ITEM_NAME = getConfig().getString("tag", "&6&lTag Prefix");
TAG_SUFFIX_ITEM_NAME = getConfig().getString("tag", "&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.");

View File

@ -1,7 +1,7 @@
package gg.frog.mc.permissionstime.config;
package gg.frog.mc.base.config;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.utils.config.PluginConfig;
import gg.frog.mc.base.PluginMain;
import gg.frog.mc.base.utils.config.PluginConfig;
/**
* 插件默认配置
@ -34,7 +34,7 @@ public class PluginCfg extends PluginConfig {
@Override
protected void loadToDo() {
PLUGIN_PREFIX = setGetDefault("pluginPrefix", "&b[" + pm.PLUGIN_NAME + "] ") + "&r";
PLUGIN_PREFIX = setGetDefault("pluginPrefix", "§b[" + pm.PLUGIN_NAME + "] ") + "§r";
IS_DEBUG = setGetDefault("debug", false);
IS_METRICS = setGetDefault("metrics", true);
TAG_SYSTEM = setGetDefault("tagSystem", false);

View File

@ -1,4 +1,4 @@
package gg.frog.mc.permissionstime.utils;
package gg.frog.mc.base.utils;
import java.io.File;
import java.io.FileWriter;

View File

@ -1,4 +1,4 @@
package gg.frog.mc.permissionstime.utils;
package gg.frog.mc.base.utils;
import java.text.MessageFormat;
import java.util.Date;
@ -6,8 +6,8 @@ import java.util.Date;
import org.apache.commons.lang.time.DateFormatUtils;
import org.bukkit.entity.Player;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.config.LangCfg;
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;
@ -18,12 +18,14 @@ public class StrUtil {
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");
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());
String message = MessageFormat.format(src, args).replaceAll("&", "§").replaceAll("\\\\n", "\n").replaceAll("%player%", player.getPlayer().getDisplayName());
if (PluginMain.enabledPlaceholder) {
message = PlaceholderAPI.setPlaceholders(player, message);
}

View File

@ -1,4 +1,4 @@
package gg.frog.mc.permissionstime.utils;
package gg.frog.mc.base.utils;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
@ -7,8 +7,8 @@ import java.net.URL;
import org.bukkit.configuration.file.YamlConfiguration;
import com.google.common.base.Charsets;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.base.PluginMain;
import gg.frog.mc.base.config.PluginCfg;
public class UpdateCheck implements Runnable {
@ -29,9 +29,9 @@ public class UpdateCheck implements Runnable {
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));
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."));
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§2No new version available."));
}
} catch (Exception e) {
e.printStackTrace();

View File

@ -1,4 +1,4 @@
package gg.frog.mc.permissionstime.utils.config;
package gg.frog.mc.base.utils.config;
import org.bukkit.configuration.MemorySection;
import org.bukkit.configuration.file.YamlConfiguration;

View File

@ -1,4 +1,4 @@
package gg.frog.mc.permissionstime.utils.config;
package gg.frog.mc.base.utils.config;
import java.io.File;
import java.io.FileNotFoundException;
@ -17,9 +17,9 @@ import org.bukkit.configuration.file.YamlConfiguration;
import com.google.common.base.Charsets;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.utils.StrUtil;
import gg.frog.mc.base.PluginMain;
import gg.frog.mc.base.config.PluginCfg;
import gg.frog.mc.base.utils.StrUtil;
/**
* 配置操作

View File

@ -1,6 +1,6 @@
package gg.frog.mc.permissionstime.utils.database;
package gg.frog.mc.base.utils.database;
import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.base.config.PluginCfg;
import gg.frog.mc.permissionstime.database.SqlManager;
import lib.PatPeter.SQLibrary.Database;

View File

@ -1,13 +1,13 @@
package gg.frog.mc.permissionstime.utils.nms;
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.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.utils.StrUtil;
import gg.frog.mc.base.PluginMain;
import gg.frog.mc.base.config.PluginCfg;
import gg.frog.mc.base.utils.StrUtil;
public class ItemUtil {

View File

@ -1,4 +1,4 @@
package gg.frog.mc.permissionstime.utils.nms;
package gg.frog.mc.base.utils.nms;
import org.bukkit.Bukkit;

View File

@ -1,4 +1,4 @@
package gg.frog.mc.permissionstime.command;
package gg.frog.mc.nametags.command;
import java.util.ArrayList;
import java.util.List;
@ -8,13 +8,13 @@ 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;
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 {
@ -67,7 +67,7 @@ public class TagCmd implements Runnable {
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."));
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Only player can use this command."));
}
}
}

View File

@ -1,4 +1,4 @@
package gg.frog.mc.permissionstime.config;
package gg.frog.mc.nametags.config;
import java.util.ArrayList;
import java.util.List;
@ -14,12 +14,14 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.scoreboard.Scoreboard;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.model.PlayerTagBean;
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;
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 {
@ -28,6 +30,7 @@ public class TagNameCfg extends PluginConfig {
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<String, TagPackageBean> PACKAGES = new ConcurrentHashMap<>();
public static List<String> TEMPLATE_LORE = null;
@ -65,6 +68,7 @@ public class TagNameCfg extends PluginConfig {
DEFAULT_SUFFIX = setGetDefault("defaultSuffix", "");
CHANGE_DISPLAYNAME = setGetDefault("changeDisplayname", true);
USE_HD_PLUGIN = setGetDefault("useHdPlugin", false);
ONE_LINE_DISPLAY = setGetDefault("oneLineDisplay", true);
REFRESH_TAG_TIME = setGetDefault("refreshTagTime", -1);
PACKAGES = getObjMap("packages", TagPackageBean.class);
TEMPLATE_LORE = getConfig().getStringList("template.lore");
@ -110,6 +114,7 @@ public class TagNameCfg extends PluginConfig {
SUFFIX_ITEMS.put(e.getValue().getPermissions(), items);
}
}
if (task != null) {
task.cancel();
}
@ -138,15 +143,15 @@ public class TagNameCfg extends PluginConfig {
Map<String, List<String>> tagPermissions = null;
if (tagType == TagType.NAMECOLOR_TYPE) {
tags = tpb.getNamecolor();
itemDisplayName = "&6&l昵称效果&r ";
itemDisplayName = LangCfg.TAG_COLOR_ITEM_NAME + "§1§r ";
tagPermissions = NAMECOLOR_PERMISSIONS;
} else if (tagType == TagType.PREFIX_TYPE) {
tags = tpb.getPrefix();
itemDisplayName = "&6&l昵称前缀&r ";
itemDisplayName = LangCfg.TAG_PREFIX_ITEM_NAME + "§2§r ";
tagPermissions = PREFIX_PERMISSIONS;
} else if (tagType == TagType.SUFFIX_TYPE) {
tags = tpb.getSuffix();
itemDisplayName = "&6&l昵称后缀&r ";
itemDisplayName = LangCfg.TAG_SUFFIX_ITEM_NAME + "§3§r ";
tagPermissions = SUFFIX_PERMISSIONS;
}
if (tags != null) {

View File

@ -1,4 +1,4 @@
package gg.frog.mc.permissionstime.gui;
package gg.frog.mc.nametags.gui;
import java.util.List;
@ -8,13 +8,13 @@ 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.PlayerTagBean;
import gg.frog.mc.permissionstime.utils.StrUtil;
import gg.frog.mc.permissionstime.utils.nms.ItemUtil;
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 {
@ -22,7 +22,7 @@ public class PlayerTagShow {
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&r"));
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§r"));
String uuid = player.getUniqueId().toString();
PlayerTagBean playerTag = null;
if (TagNameCfg.PLAYER_TAG.containsKey(uuid)) {

View File

@ -0,0 +1,102 @@
package gg.frog.mc.nametags.listener;
import java.util.List;
import org.bukkit.OfflinePlayer;
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.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) {
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().getName());
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().getName());
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().getName());
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§r").equals(event.getInventory().getName())) {
if (event.getCurrentItem() != null && event.getCurrentItem().getItemMeta() != null && event.getCurrentItem().getItemMeta().hasLore()) {
List<String> lores = event.getCurrentItem().getItemMeta().getLore();
if (lores.size() > 1) {
String permissions = lores.get(lores.size() - 2);
permissions = permissions.length() > 4 ? permissions.substring(4) : "";
OfflinePlayer player = this.pm.getOfflinePlayer(event.getWhoClicked().getName());
String uuid = player.getUniqueId().toString();
if (permissions.length() == 0 || player.getPlayer().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 {
event.setCancelled(true);
return;
}
playerTag.setPlayerDisplayName(player.getPlayer(), true);
playerTag.saveConfig();
player.getPlayer().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_TAG_SET_SUCCESS));
}
} else {
player.getPlayer().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_PERMISSION));
}
}
}
event.setCancelled(true);
}
}
}

View File

@ -1,4 +1,4 @@
package gg.frog.mc.permissionstime.model;
package gg.frog.mc.nametags.model;
import org.bukkit.Location;
import org.bukkit.configuration.MemorySection;
@ -9,13 +9,13 @@ import org.bukkit.scoreboard.Team;
import com.gmail.filoghost.holographicdisplays.api.Hologram;
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
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;
import gg.frog.mc.permissionstime.utils.nms.NMSUtil;
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;
/**
* 玩家标签包实体类
@ -127,8 +127,8 @@ public class PlayerTagBean extends PluginConfig implements IConfigBean, Cloneabl
}
}
if (forceSet || namecolor_flag || prefix_flag || suffix_flag) {
displayPrefix = StrUtil.messageFormat(player, prefix + "&r" + namecolor);
displaySuffix = StrUtil.messageFormat(player, "&r" + suffix);
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);
@ -180,25 +180,35 @@ public class PlayerTagBean extends PluginConfig implements IConfigBean, Cloneabl
}
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()) {
Location loc = player.getLocation();
loc = new Location(loc.getWorld(), loc.getX(), loc.getY() + 2.75, loc.getZ());
holograms = HologramsAPI.createHologram(pm, loc);
holograms.getVisibilityManager().hideTo(player);
} else {
holograms.teleport(loc);
}
holograms.clearLines();
holograms.appendTextLine(StrUtil.messageFormat(player, prefix));
holograms.appendTextLine(StrUtil.messageFormat(player, namecolor + player.getName()));
holograms.appendTextLine(StrUtil.messageFormat(player, suffix));
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();
holograms.teleport(loc.getWorld(), loc.getX(), loc.getY() + 2.75, loc.getZ());
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();
@ -206,7 +216,7 @@ public class PlayerTagBean extends PluginConfig implements IConfigBean, Cloneabl
}
public String getDisplayNameStr(Player player) {
return StrUtil.messageFormat(prefix + "&r" + namecolor + player.getName() + "&r" + suffix);
return StrUtil.messageFormat(prefix + "§r" + namecolor + player.getName() + "§r" + suffix);
}
@Override

View File

@ -1,11 +1,11 @@
package gg.frog.mc.permissionstime.placeholder;
package gg.frog.mc.nametags.placeholder;
import org.bukkit.entity.Player;
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.model.PlayerTagBean;
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 {

View File

@ -4,14 +4,14 @@ import java.util.List;
import org.bukkit.command.CommandSender;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.config.LangCfg;
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.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;
import gg.frog.mc.permissionstime.utils.StrUtil;
public class GetCmd implements Runnable {

View File

@ -6,14 +6,14 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.config.LangCfg;
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.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;
import gg.frog.mc.permissionstime.utils.StrUtil;
public class GiveCmd implements Runnable {

View File

@ -5,13 +5,13 @@ import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.config.LangCfg;
import gg.frog.mc.permissionstime.config.PluginCfg;
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.permissionstime.database.SqlManager;
import gg.frog.mc.permissionstime.gui.PlayerPermissionShow;
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
import gg.frog.mc.permissionstime.utils.StrUtil;
public class MeCmd implements Runnable {
@ -42,7 +42,7 @@ public class MeCmd implements Runnable {
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_ME, pm.PLUGIN_NAME_LOWER_CASE));
}
} else {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Only player can use this command."));
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Only player can use this command."));
}
}
}

View File

@ -4,12 +4,12 @@ import java.util.Map.Entry;
import org.bukkit.command.CommandSender;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.config.LangCfg;
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.permissionstime.config.PackagesCfg;
import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean;
import gg.frog.mc.permissionstime.utils.StrUtil;
public class PackagesCmd implements Runnable {

View File

@ -11,26 +11,34 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.config.LangCfg;
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.command.GetCmd;
import gg.frog.mc.permissionstime.command.GiveCmd;
import gg.frog.mc.permissionstime.command.MeCmd;
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.PackagesCfg;
import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.database.SqlManager;
import gg.frog.mc.permissionstime.utils.StrUtil;
public class MainCommand implements CommandExecutor, TabCompleter {
public class PtCommand implements CommandExecutor, TabCompleter {
private PluginMain pm;
private SqlManager sm;
public MainCommand(PluginMain pm) {
public PtCommand(PluginMain pm) {
this.pm = pm;
this.sm = pm.getSqlManager();
}
@Override
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
if (commandLabel.equalsIgnoreCase(pm.PLUGIN_NAME_LOWER_CASE) || commandLabel.equalsIgnoreCase("pt")) {
if (commandLabel.equalsIgnoreCase("permissionstime") || commandLabel.equalsIgnoreCase("pt")) {
boolean isPlayer = false;
if (sender instanceof Player) {
isPlayer = true;
@ -46,13 +54,13 @@ public class MainCommand 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&r").equals(inventory.getTitle()) || StrUtil.messageFormat(LangCfg.TAG_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();
}
}
pm.getConfigManager().reloadConfig();
if (!sm.updateDatabase()) {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Database exceptions."));
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Database exceptions."));
}
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_CONFIG_RELOADED));
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_CONFIG_RELOADED));
@ -62,13 +70,13 @@ public class MainCommand 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&r").equals(inventory.getTitle()) || StrUtil.messageFormat(LangCfg.TAG_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();
}
}
pm.getConfigManager().reloadConfig();
if (!sm.updateDatabase()) {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Database exceptions."));
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Database exceptions."));
}
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_CONFIG_RELOADED));
}
@ -127,7 +135,7 @@ public class MainCommand implements CommandExecutor, TabCompleter {
}
private void getHelp(CommandSender sender, boolean isPlayer) {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "\n&a===== " + pm.PLUGIN_NAME + " Version:" + pm.PLUGIN_VERSION + (pm.getDescription().getCommands().containsKey("pt") ? " Aliases:/pt" : "") + " ====="));
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "\n§a===== " + pm.PLUGIN_NAME + " Version:" + pm.PLUGIN_VERSION + (pm.getDescription().getCommands().containsKey("pt") ? " Aliases:/pt" : "") + " ====="));
if (isPlayer && (sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".me"))) {
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_ME, pm.PLUGIN_NAME_LOWER_CASE));
}

View File

@ -6,13 +6,13 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.config.LangCfg;
import gg.frog.mc.permissionstime.config.PluginCfg;
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.permissionstime.database.SqlManager;
import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean;
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
import gg.frog.mc.permissionstime.utils.StrUtil;
public class RemoveAllCmd implements Runnable {

View File

@ -6,14 +6,14 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.config.LangCfg;
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.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;
import gg.frog.mc.permissionstime.utils.StrUtil;
public class RemoveCmd implements Runnable {

View File

@ -6,14 +6,14 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.config.LangCfg;
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.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;
import gg.frog.mc.permissionstime.utils.StrUtil;
public class SetCmd implements Runnable {

View File

@ -15,11 +15,12 @@ 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.base.PluginMain;
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.permissionstime.model.cfg.PermissionPackageBean;
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 PackagesCfg extends PluginConfig {
@ -103,7 +104,7 @@ public class PackagesCfg extends PluginConfig {
if (type != null) {
ItemStack item = new ItemStack(type, 1, (short) 0, (byte) exid);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(StrUtil.messageFormat(ppb.getDisplayName() + "&r(" + name + ")"));
meta.setDisplayName(StrUtil.messageFormat(ppb.getDisplayName() + "§r(" + name + ")"));
List<String> lores = new ArrayList<String>();
for (String lore : ppb.getLores()) {
lores.add(StrUtil.messageFormat(lore));

View File

@ -3,8 +3,8 @@ package gg.frog.mc.permissionstime.database;
import java.util.Collections;
import java.util.List;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.base.PluginMain;
import gg.frog.mc.base.config.PluginCfg;
import gg.frog.mc.permissionstime.database.impl.MySQLPlayerDataDao;
import gg.frog.mc.permissionstime.database.impl.SqlitePlayerDataDao;
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;

View File

@ -5,14 +5,14 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import gg.frog.mc.permissionstime.PluginMain;
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.database.DatabaseUtil;
import gg.frog.mc.permissionstime.config.PackagesCfg;
import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.database.IPlayerDataDao;
import gg.frog.mc.permissionstime.database.SqlManager;
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
import gg.frog.mc.permissionstime.utils.StrUtil;
import gg.frog.mc.permissionstime.utils.database.DatabaseUtil;
public class MySQLPlayerDataDao extends DatabaseUtil implements IPlayerDataDao {
@ -37,7 +37,7 @@ public class MySQLPlayerDataDao extends DatabaseUtil implements IPlayerDataDao {
return false;
} catch (Exception e) {
pm.getServer().getConsoleSender()
.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't check table is exist."));
.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Can't check table is exist."));
throw e;
}
}
@ -51,7 +51,7 @@ public class MySQLPlayerDataDao extends DatabaseUtil implements IPlayerDataDao {
return true;
} catch (Exception e) {
pm.getServer().getConsoleSender()
.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't creat table."));
.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Can't creat table."));
throw e;
}
}
@ -80,7 +80,7 @@ public class MySQLPlayerDataDao extends DatabaseUtil implements IPlayerDataDao {
return true;
} catch (Exception e) {
pm.getServer().getConsoleSender()
.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't creat data: {0}", pdb));
.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Can't creat data: {0}", pdb));
throw e;
}
}
@ -141,7 +141,7 @@ public class MySQLPlayerDataDao extends DatabaseUtil implements IPlayerDataDao {
return true;
} catch (Exception e) {
pm.getServer().getConsoleSender().sendMessage(
StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't update data: {0}", pdb));
StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Can't update data: {0}", pdb));
throw e;
}
}
@ -170,7 +170,7 @@ public class MySQLPlayerDataDao extends DatabaseUtil implements IPlayerDataDao {
return pdbList;
} catch (Exception e) {
pm.getServer().getConsoleSender().sendMessage(
StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't find data by UUID: {0}", uuid));
StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Can't find data by UUID: {0}", uuid));
throw e;
}
}
@ -201,7 +201,7 @@ public class MySQLPlayerDataDao extends DatabaseUtil implements IPlayerDataDao {
return null;
} catch (Exception e) {
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(
PluginCfg.PLUGIN_PREFIX + "&4Can't find data by UUID: {0}, packageName: {1}", uuid, packageName));
PluginCfg.PLUGIN_PREFIX + "§4Can't find data by UUID: {0}, packageName: {1}", uuid, packageName));
throw e;
}
}
@ -232,7 +232,7 @@ public class MySQLPlayerDataDao extends DatabaseUtil implements IPlayerDataDao {
return pdbList;
} catch (Exception e) {
pm.getServer().getConsoleSender().sendMessage(
StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't find data by UUID: {0}", uuid));
StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Can't find data by UUID: {0}", uuid));
throw e;
}
}
@ -246,7 +246,7 @@ public class MySQLPlayerDataDao extends DatabaseUtil implements IPlayerDataDao {
return true;
} catch (Exception e) {
pm.getServer().getConsoleSender()
.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't delete data by ID: {0}", id));
.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Can't delete data by ID: {0}", id));
throw e;
}
}
@ -265,7 +265,7 @@ public class MySQLPlayerDataDao extends DatabaseUtil implements IPlayerDataDao {
return true;
} catch (Exception e) {
pm.getServer().getConsoleSender().sendMessage(
StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't delete data by UUID: {0}", uuid));
StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Can't delete data by UUID: {0}", uuid));
throw e;
}
}
@ -284,7 +284,7 @@ public class MySQLPlayerDataDao extends DatabaseUtil implements IPlayerDataDao {
return true;
} catch (Exception e) {
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(
PluginCfg.PLUGIN_PREFIX + "&4Can't delete data by UUID: {0}, packageName: {1}", uuid, packageName));
PluginCfg.PLUGIN_PREFIX + "§4Can't delete data by UUID: {0}, packageName: {1}", uuid, packageName));
throw e;
}
}

View File

@ -5,14 +5,14 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import gg.frog.mc.permissionstime.PluginMain;
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.database.DatabaseUtil;
import gg.frog.mc.permissionstime.config.PackagesCfg;
import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.database.IPlayerDataDao;
import gg.frog.mc.permissionstime.database.SqlManager;
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
import gg.frog.mc.permissionstime.utils.StrUtil;
import gg.frog.mc.permissionstime.utils.database.DatabaseUtil;
public class SqlitePlayerDataDao extends DatabaseUtil implements IPlayerDataDao {
@ -34,7 +34,7 @@ public class SqlitePlayerDataDao extends DatabaseUtil implements IPlayerDataDao
}
return false;
} catch (Exception e) {
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't check table is exist."));
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Can't check table is exist."));
throw e;
}
}
@ -46,7 +46,7 @@ public class SqlitePlayerDataDao extends DatabaseUtil implements IPlayerDataDao
getDB().query(sql);
return true;
} catch (Exception e) {
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't creat table."));
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Can't creat table."));
throw e;
}
}
@ -64,7 +64,7 @@ public class SqlitePlayerDataDao extends DatabaseUtil implements IPlayerDataDao
getDB().query(sql);
return true;
} catch (Exception e) {
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't creat data: {0}", pdb));
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Can't creat data: {0}", pdb));
throw e;
}
}
@ -103,7 +103,7 @@ public class SqlitePlayerDataDao extends DatabaseUtil implements IPlayerDataDao
getDB().query(sql);
return true;
} catch (Exception e) {
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't update data: {0}", pdb));
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Can't update data: {0}", pdb));
throw e;
}
}
@ -126,7 +126,7 @@ public class SqlitePlayerDataDao extends DatabaseUtil implements IPlayerDataDao
}
return pdbList;
} catch (Exception e) {
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't find data by UUID: {0}", uuid));
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Can't find data by UUID: {0}", uuid));
throw e;
}
}
@ -146,7 +146,7 @@ public class SqlitePlayerDataDao extends DatabaseUtil implements IPlayerDataDao
}
return null;
} catch (Exception e) {
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't find data by UUID: {0}, packageName: {1}", uuid, packageName));
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Can't find data by UUID: {0}, packageName: {1}", uuid, packageName));
throw e;
}
}
@ -170,7 +170,7 @@ public class SqlitePlayerDataDao extends DatabaseUtil implements IPlayerDataDao
}
return pdbList;
} catch (Exception e) {
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't find data by UUID: {0}", uuid));
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Can't find data by UUID: {0}", uuid));
throw e;
}
}
@ -182,7 +182,7 @@ public class SqlitePlayerDataDao extends DatabaseUtil implements IPlayerDataDao
getDB().query(sql);
return true;
} catch (Exception e) {
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't delete data by ID: {0}", id));
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Can't delete data by ID: {0}", id));
throw e;
}
}
@ -194,7 +194,7 @@ public class SqlitePlayerDataDao extends DatabaseUtil implements IPlayerDataDao
getDB().query(sql);
return true;
} catch (Exception e) {
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't delete data by UUID: {0}", uuid));
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Can't delete data by UUID: {0}", uuid));
throw e;
}
}
@ -206,7 +206,7 @@ public class SqlitePlayerDataDao extends DatabaseUtil implements IPlayerDataDao
getDB().query(sql);
return true;
} catch (Exception e) {
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Can't delete data by UUID: {0}, packageName: {1}", uuid, packageName));
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Can't delete data by UUID: {0}, packageName: {1}", uuid, packageName));
throw e;
}
}

View File

@ -8,12 +8,12 @@ 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.base.config.LangCfg;
import gg.frog.mc.base.config.PluginCfg;
import gg.frog.mc.base.utils.StrUtil;
import gg.frog.mc.permissionstime.config.PackagesCfg;
import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean;
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
import gg.frog.mc.permissionstime.utils.StrUtil;
public class PlayerPermissionShow {
@ -21,7 +21,7 @@ public class PlayerPermissionShow {
Inventory inventory = null;
int size = 0;
if (pdbList.size() > 0) {
inventory = Bukkit.createInventory(null, (pdbList.size() % 9 == 0 ? pdbList.size() : (pdbList.size() / 9 + 1) * 9), StrUtil.messageFormat(LangCfg.TAG_INVENTORY_NAME + "&r&5&9&2&0&r"));
inventory = Bukkit.createInventory(null, (pdbList.size() % 9 == 0 ? pdbList.size() : (pdbList.size() / 9 + 1) * 9), StrUtil.messageFormat(LangCfg.TAG_INVENTORY_NAME + "§r§5§9§2§0§r"));
for (PlayerDataBean pdb : pdbList) {
PermissionPackageBean ppb = PackagesCfg.PACKAGES.get(pdb.getPackageName());
if (ppb != null && pdb.getGlobal() == ppb.getGlobal()) {

View File

@ -2,24 +2,20 @@ package gg.frog.mc.permissionstime.listener;
import java.util.List;
import org.bukkit.OfflinePlayer;
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.PlayerKickEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
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.model.PlayerTagBean;
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.permissionstime.model.cfg.PermissionPackageBean;
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
import gg.frog.mc.permissionstime.utils.StrUtil;
public class MainListener implements Listener {
@ -42,9 +38,6 @@ public class MainListener implements Listener {
e.printStackTrace();
event.getPlayer().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_FAIL_SET_PERMISSION));
}
if (PluginCfg.TAG_SYSTEM) {
PlayerTagBean.initPlayerTag(event.getPlayer(), pm);
}
}
}).start();
}
@ -56,11 +49,6 @@ public class MainListener implements Listener {
public void run() {
try {
PermissionPackageBean.delPlayerAllPermissions(event.getPlayer(), pm);
if (PluginCfg.TAG_SYSTEM && TagNameCfg.USE_HD_PLUGIN) {
String uuid = pm.getPlayerUUIDByName(event.getPlayer().getName());
PlayerTagBean playerTag = TagNameCfg.PLAYER_TAG.get(uuid);
playerTag.delHologramsName();
}
} catch (Exception e) {
e.printStackTrace();
}
@ -84,53 +72,9 @@ public class MainListener implements Listener {
pm.getPlayerMap().remove(event.getPlayer().getName());
}
@EventHandler
public void onMove(PlayerMoveEvent event) {
if (PluginCfg.TAG_SYSTEM && TagNameCfg.USE_HD_PLUGIN) {
String uuid = this.pm.getPlayerUUIDByName(event.getPlayer().getName());
PlayerTagBean playerTag = TagNameCfg.PLAYER_TAG.get(uuid);
if (playerTag != null) {
playerTag.moveHologramsName(event.getPlayer());
}
}
}
@EventHandler
public void onPlayerClick(InventoryClickEvent event) {
if (StrUtil.messageFormat(LangCfg.INVENTORY_NAME + "&r&5&9&2&0&r").equals(event.getInventory().getName())) {
event.setCancelled(true);
}
if (StrUtil.messageFormat(LangCfg.TAG_INVENTORY_NAME + "&r&5&9&2&0&r").equals(event.getInventory().getName())) {
if (event.getCurrentItem() != null && event.getCurrentItem().getItemMeta() != null && event.getCurrentItem().getItemMeta().hasLore()) {
List<String> lores = event.getCurrentItem().getItemMeta().getLore();
if (lores.size() > 1) {
String permissions = lores.get(lores.size() - 2);
permissions = permissions.length() > 4 ? permissions.substring(4) : "";
OfflinePlayer player = this.pm.getOfflinePlayer(event.getWhoClicked().getName());
String uuid = player.getUniqueId().toString();
if (permissions.length() == 0 || player.getPlayer().hasPermission(permissions)) {
if (TagNameCfg.PLAYER_TAG.containsKey(uuid)) {
String itemName = event.getCurrentItem().getItemMeta().getDisplayName();
PlayerTagBean playerTag = TagNameCfg.PLAYER_TAG.get(uuid);
if (itemName.startsWith("§6§l昵称效果§r ")) {
playerTag.setNamecolor(lores.get(lores.size() - 1).substring(2));
} else if (itemName.startsWith("§6§l昵称前缀§r ")) {
playerTag.setPrefix(lores.get(lores.size() - 1).substring(2));
} else if (itemName.startsWith("§6§l昵称后缀§r ")) {
playerTag.setSuffix(lores.get(lores.size() - 1).substring(2));
} else {
event.setCancelled(true);
return;
}
playerTag.setPlayerDisplayName(player.getPlayer(), true);
playerTag.saveConfig();
player.getPlayer().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_TAG_SET_SUCCESS));
}
} else {
player.getPlayer().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_PERMISSION));
}
}
}
if (StrUtil.messageFormat(LangCfg.INVENTORY_NAME + "§r§5§9§2§0§r").equals(event.getInventory().getName())) {
event.setCancelled(true);
}
}

View File

@ -13,13 +13,13 @@ import org.bukkit.configuration.MemorySection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.scheduler.BukkitTask;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.config.LangCfg;
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.IConfigBean;
import gg.frog.mc.permissionstime.config.PackagesCfg;
import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
import gg.frog.mc.permissionstime.utils.StrUtil;
import gg.frog.mc.permissionstime.utils.config.IConfigBean;
import net.milkbowl.vault.permission.Permission;
/**

View File

@ -6,7 +6,7 @@ import java.util.List;
import org.bukkit.configuration.MemorySection;
import org.bukkit.configuration.file.YamlConfiguration;
import gg.frog.mc.permissionstime.utils.config.IConfigBean;
import gg.frog.mc.base.utils.config.IConfigBean;
/**
* 标签包实体类

View File

@ -12,7 +12,7 @@ metrics: true
tagSystem: false
# 语言文件名称 在'lang'文件夹内.
# Language file name.
lang: en
lang: zh-cn
# 数据库相关.
# Database settings.
mysql:

View File

@ -7,6 +7,9 @@ timeUnitH: 'hour(s)'
timeUnitM: 'minute(s)'
timeForever: 'Forever'
tag: 'Tag/Prefix'
tagColorItemName: '&6&lName Style'
tagPrefixItemName: '&6&lTag Prefix'
tagSuffixItemName: '&6&lTag Suffix'
msg:
parameterMismatch: '&4Parameter mismatch.'
timeParameterIncorrect: '&4The number of time is incorrect. Please enter a nonzero integer.'

View File

@ -7,6 +7,9 @@ timeUnitH: '小时'
timeUnitM: '分钟'
timeForever: '永久'
tag: '标签/称号'
tagColorItemName: '&6&l昵称效果'
tagPrefixItemName: '&6&l昵称前缀'
tagSuffixItemName: '&6&l昵称后缀'
msg:
parameterMismatch: '&4参数不匹配.'
timeParameterIncorrect: '&4时间参数不正确,请输入非零整数.'

View File

@ -1,6 +1,6 @@
name: ${project.name}
version: ${project.version}
main: gg.frog.mc.permissionstime.PluginMain
version: 0.4.1-SNAPSHOT
main: gg.frog.mc.base.PluginMain
author:
- GeekFrog
description: ${project.description}
@ -17,7 +17,7 @@ commands:
description: Aliases commands for permissionstime.
usage: /pt [param]
permissions:
permissionstime.*:
gg.frog.permissionstime.*:
description: Gives access to all PermissionsTime commands.
default: op
children:

View File

@ -15,6 +15,9 @@ 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则禁用刷新.
@ -25,7 +28,7 @@ refreshTagTime: -1
template:
lore:
- '&1-----------------'
- '&2效果展示:'
- '&2Preview:'
- '&3 %displayname%'
- '&4-----------------'
- '&5 %description%'