mirror of
https://github.com/geekfrog/PermissionsTime.git
synced 2024-11-21 23:08:48 +00:00
修复超多BUG
This commit is contained in:
parent
209290dbba
commit
6aa80bd290
@ -21,7 +21,7 @@ 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.listener.PtListener;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
public class PluginMain extends JavaPlugin {
|
||||
@ -57,17 +57,17 @@ 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));
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "==============================="));
|
||||
getServer().getScheduler().runTask(pm, new Runnable() {
|
||||
|
||||
public void run() {
|
||||
if (!checkPluginDepends()) {
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Startup failure!"));
|
||||
getServer().getPluginManager().disablePlugin(pm);
|
||||
} else {
|
||||
cm.initConfig();
|
||||
registerListeners();
|
||||
registerCommands();
|
||||
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§2Startup successful!"));
|
||||
}
|
||||
getServer().getScheduler().runTask(pm, new Runnable() {
|
||||
public void run() {
|
||||
if (PluginCfg.IS_METRICS) {
|
||||
try {
|
||||
new Metrics(pm);
|
||||
@ -85,7 +85,7 @@ public class PluginMain extends JavaPlugin {
|
||||
* 这里可以注册多个
|
||||
*/
|
||||
private void registerListeners() {
|
||||
pm.getServer().getPluginManager().registerEvents(new MainListener(pm), pm);
|
||||
pm.getServer().getPluginManager().registerEvents(new PtListener(pm), pm);
|
||||
pm.getServer().getPluginManager().registerEvents(new TagsListener(pm), pm);
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,8 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import gg.frog.mc.base.PluginMain;
|
||||
import gg.frog.mc.base.config.LangCfg;
|
||||
import gg.frog.mc.base.config.PluginCfg;
|
||||
@ -33,17 +35,20 @@ public class ConfigManager {
|
||||
copyLangFilesFromJar();
|
||||
// 添加到配置列表
|
||||
cfgMap.put("plugin", new PluginCfg(pm));
|
||||
}
|
||||
|
||||
public void initConfig() {
|
||||
cfgMap.put("lang", new LangCfg("lang/" + PluginCfg.LANG + ".yml", pm));
|
||||
cfgMap.put("packages", new PackagesCfg("packages.yml", pm));
|
||||
cfgMap.put("tagNames", new TagNameCfg("tagNames.yml", pm));
|
||||
}
|
||||
|
||||
public void reloadConfig() {
|
||||
public void reloadConfig(CommandSender sender) {
|
||||
for (Entry<String, PluginConfig> entry : cfgMap.entrySet()) {
|
||||
if ("lang".equals(entry.getKey())) {
|
||||
entry.setValue(new LangCfg("lang/" + PluginCfg.LANG + ".yml", pm));
|
||||
}
|
||||
entry.getValue().reloadConfig();
|
||||
entry.getValue().reloadConfig(sender);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package gg.frog.mc.base.config;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import gg.frog.mc.base.PluginMain;
|
||||
import gg.frog.mc.base.utils.config.PluginConfig;
|
||||
|
||||
@ -77,7 +79,7 @@ public class LangCfg extends PluginConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadToDo() {
|
||||
protected void loadToDo(CommandSender sender) {
|
||||
INVENTORY_NAME = getConfig().getString("inventoryName", "&4===Permissions Packages===");
|
||||
TAG_INVENTORY_NAME = getConfig().getString("tagInventoryName", "&4===Tag Packages===");
|
||||
EXPIRATION_TIME = getConfig().getString("expirationTime", "&4Expiration time: {0}");
|
||||
@ -87,9 +89,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");
|
||||
TAG_COLOR_ITEM_NAME = getConfig().getString("tagColorItemName", "&6&lName Style");
|
||||
TAG_PREFIX_ITEM_NAME = getConfig().getString("tagPrefixItemName", "&6&lTag Prefix");
|
||||
TAG_SUFFIX_ITEM_NAME = getConfig().getString("tagSuffixItemName", "&6&lTag Suffix");
|
||||
|
||||
MSG_PARAMETER_MISMATCH = getConfig().getString("msg.parameterMismatch", "&4Parameter mismatch.");
|
||||
MSG_TIME_PARAMETER_INCORRECT = getConfig().getString("msg.timeParameterIncorrect", "&4The number of time is incorrect. Please enter a nonzero integer.");
|
||||
|
@ -1,5 +1,7 @@
|
||||
package gg.frog.mc.base.config;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import gg.frog.mc.base.PluginMain;
|
||||
import gg.frog.mc.base.utils.config.PluginConfig;
|
||||
|
||||
@ -33,7 +35,7 @@ public class PluginCfg extends PluginConfig {
|
||||
protected void init() {}
|
||||
|
||||
@Override
|
||||
protected void loadToDo() {
|
||||
protected void loadToDo(CommandSender sender) {
|
||||
PLUGIN_PREFIX = setGetDefault("pluginPrefix", "§b[" + pm.PLUGIN_NAME + "] ") + "§r";
|
||||
IS_DEBUG = setGetDefault("debug", false);
|
||||
IS_METRICS = setGetDefault("metrics", true);
|
||||
|
@ -10,6 +10,7 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.MemorySection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -77,7 +78,7 @@ public abstract class PluginConfig {
|
||||
/**
|
||||
* 加载配置后调用
|
||||
*/
|
||||
protected abstract void loadToDo();
|
||||
protected abstract void loadToDo(CommandSender sender);
|
||||
|
||||
/**
|
||||
* 获取配置(首次)
|
||||
@ -127,10 +128,24 @@ public abstract class PluginConfig {
|
||||
reloadConfig(folder, fileName, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置重载
|
||||
*/
|
||||
public void reloadConfig(CommandSender sender) {
|
||||
reloadConfig(folder, fileName, false, sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置重载
|
||||
*/
|
||||
private void reloadConfig(File folder, String fileName, boolean useRes) {
|
||||
reloadConfig(folder, fileName, useRes, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置重载
|
||||
*/
|
||||
private void reloadConfig(File folder, String fileName, boolean useRes, CommandSender sender) {
|
||||
YamlConfiguration tempConfig = new YamlConfiguration();
|
||||
try {
|
||||
tempConfig.load(configFile);
|
||||
@ -150,10 +165,10 @@ public abstract class PluginConfig {
|
||||
}
|
||||
config.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream, Charsets.UTF_8)));
|
||||
}
|
||||
loadToDo();
|
||||
// if (tempConfig != null) {
|
||||
// saveConfig();
|
||||
// }
|
||||
loadToDo(sender);
|
||||
// if (tempConfig != null) {
|
||||
// saveConfig();
|
||||
// }
|
||||
}
|
||||
|
||||
protected void setObj(String path, Map<String, ? extends IConfigBean> o) {
|
||||
|
@ -8,6 +8,7 @@ import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@ -62,12 +63,22 @@ public class TagNameCfg extends PluginConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadToDo() {
|
||||
protected void loadToDo(CommandSender sender) {
|
||||
DEFAULT_NAMECOLOR = setGetDefault("defaultNamecolor", "");
|
||||
DEFAULT_PREFIX = setGetDefault("defaultPrefix", "");
|
||||
DEFAULT_SUFFIX = setGetDefault("defaultSuffix", "");
|
||||
CHANGE_DISPLAYNAME = setGetDefault("changeDisplayname", true);
|
||||
USE_HD_PLUGIN = setGetDefault("useHdPlugin", false);
|
||||
if (USE_HD_PLUGIN && !PluginMain.enabledHdPlugin) {
|
||||
USE_HD_PLUGIN = false;
|
||||
if (sender != null) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§eHolographicDisplays is not installed or not enabled. "));
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§eBut you enabled some func need HolographicDisplays."));
|
||||
} else {
|
||||
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§eHolographicDisplays is not installed or not enabled. "));
|
||||
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§eBut you enabled some func need HolographicDisplays."));
|
||||
}
|
||||
}
|
||||
ONE_LINE_DISPLAY = setGetDefault("oneLineDisplay", true);
|
||||
REFRESH_TAG_TIME = setGetDefault("refreshTagTime", -1);
|
||||
PACKAGES = getObjMap("packages", TagPackageBean.class);
|
||||
|
@ -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§2§r"));
|
||||
String uuid = player.getUniqueId().toString();
|
||||
PlayerTagBean playerTag = null;
|
||||
if (TagNameCfg.PLAYER_TAG.containsKey(uuid)) {
|
||||
|
@ -65,7 +65,7 @@ public class TagsListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerClick(InventoryClickEvent event) {
|
||||
if (StrUtil.messageFormat(LangCfg.TAG_INVENTORY_NAME + "§r§5§9§2§0§r").equals(event.getInventory().getName())) {
|
||||
if (StrUtil.messageFormat(LangCfg.TAG_INVENTORY_NAME + "§r§5§9§2§0§2§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) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package gg.frog.mc.nametags.model;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.MemorySection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -54,7 +55,7 @@ public class PlayerTagBean extends PluginConfig implements IConfigBean, Cloneabl
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadToDo() {
|
||||
protected void loadToDo(CommandSender sender) {
|
||||
namecolor = getConfig().getString("namecolor", TagNameCfg.DEFAULT_NAMECOLOR);
|
||||
prefix = getConfig().getString("prefix", TagNameCfg.DEFAULT_PREFIX);
|
||||
suffix = getConfig().getString("suffix", TagNameCfg.DEFAULT_SUFFIX);
|
||||
|
@ -58,7 +58,7 @@ public class PtCommand implements CommandExecutor, TabCompleter {
|
||||
inventory.close();
|
||||
}
|
||||
}
|
||||
pm.getConfigManager().reloadConfig();
|
||||
pm.getConfigManager().reloadConfig(sender);
|
||||
if (!sm.updateDatabase()) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Database exceptions."));
|
||||
}
|
||||
@ -74,7 +74,7 @@ public class PtCommand implements CommandExecutor, TabCompleter {
|
||||
inventory.close();
|
||||
}
|
||||
}
|
||||
pm.getConfigManager().reloadConfig();
|
||||
pm.getConfigManager().reloadConfig(sender);
|
||||
if (!sm.updateDatabase()) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Database exceptions."));
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
@ -36,10 +37,11 @@ public class PackagesCfg extends PluginConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {}
|
||||
protected void init() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadToDo() {
|
||||
protected void loadToDo(CommandSender sender) {
|
||||
PACKAGES_VERSION = setGetDefault("version", "1.00");
|
||||
DEFAULT_GROUP = setGetDefault("defaultGroup", "Default");
|
||||
PACKAGES = getObjMap("packages", PermissionPackageBean.class);
|
||||
@ -58,6 +60,9 @@ public class PackagesCfg extends PluginConfig {
|
||||
PACKAGE_ITEMS.put(e.getKey(), item);
|
||||
} else {
|
||||
PluginMain.LOG.log(Level.SEVERE, "Packages of " + e.getKey() + " has problem.");
|
||||
if (sender != null) {
|
||||
sender.sendMessage("Packages of " + e.getKey() + " has problem.");
|
||||
}
|
||||
}
|
||||
allPermissions.addAll(e.getValue().getPermissions());
|
||||
allGroups.addAll(e.getValue().getGroups());
|
||||
|
@ -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§1§r"));
|
||||
for (PlayerDataBean pdb : pdbList) {
|
||||
PermissionPackageBean ppb = PackagesCfg.PACKAGES.get(pdb.getPackageName());
|
||||
if (ppb != null && pdb.getGlobal() == ppb.getGlobal()) {
|
||||
|
@ -17,11 +17,11 @@ import gg.frog.mc.base.utils.StrUtil;
|
||||
import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean;
|
||||
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
|
||||
|
||||
public class MainListener implements Listener {
|
||||
public class PtListener implements Listener {
|
||||
|
||||
private PluginMain pm;
|
||||
|
||||
public MainListener(PluginMain pm) {
|
||||
public PtListener(PluginMain pm) {
|
||||
this.pm = pm;
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ public class MainListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerClick(InventoryClickEvent event) {
|
||||
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§1§r").equals(event.getInventory().getName())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user