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.nametags.placeholder.TagPlaceholder;
|
||||||
import gg.frog.mc.permissionstime.command.PtCommand;
|
import gg.frog.mc.permissionstime.command.PtCommand;
|
||||||
import gg.frog.mc.permissionstime.database.SqlManager;
|
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;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
|
||||||
public class PluginMain extends JavaPlugin {
|
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 + " 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 + "==============================="));
|
||||||
|
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() {
|
getServer().getScheduler().runTask(pm, new Runnable() {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!checkPluginDepends()) {
|
|
||||||
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!"));
|
|
||||||
}
|
|
||||||
if (PluginCfg.IS_METRICS) {
|
if (PluginCfg.IS_METRICS) {
|
||||||
try {
|
try {
|
||||||
new Metrics(pm);
|
new Metrics(pm);
|
||||||
@ -85,7 +85,7 @@ public class PluginMain extends JavaPlugin {
|
|||||||
* 这里可以注册多个
|
* 这里可以注册多个
|
||||||
*/
|
*/
|
||||||
private void registerListeners() {
|
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);
|
pm.getServer().getPluginManager().registerEvents(new TagsListener(pm), pm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import gg.frog.mc.base.PluginMain;
|
import gg.frog.mc.base.PluginMain;
|
||||||
import gg.frog.mc.base.config.LangCfg;
|
import gg.frog.mc.base.config.LangCfg;
|
||||||
import gg.frog.mc.base.config.PluginCfg;
|
import gg.frog.mc.base.config.PluginCfg;
|
||||||
@ -25,66 +27,69 @@ import gg.frog.mc.permissionstime.config.PackagesCfg;
|
|||||||
*/
|
*/
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
|
|
||||||
private PluginMain pm;
|
private PluginMain pm;
|
||||||
private Map<String, PluginConfig> cfgMap = new LinkedHashMap<>();
|
private Map<String, PluginConfig> cfgMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
public ConfigManager(PluginMain pm) {
|
public ConfigManager(PluginMain pm) {
|
||||||
this.pm = pm;
|
this.pm = pm;
|
||||||
copyLangFilesFromJar();
|
copyLangFilesFromJar();
|
||||||
// 添加到配置列表
|
// 添加到配置列表
|
||||||
cfgMap.put("plugin", new PluginCfg(pm));
|
cfgMap.put("plugin", new PluginCfg(pm));
|
||||||
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 initConfig() {
|
||||||
for (Entry<String, PluginConfig> entry : cfgMap.entrySet()) {
|
cfgMap.put("lang", new LangCfg("lang/" + PluginCfg.LANG + ".yml", pm));
|
||||||
if ("lang".equals(entry.getKey())) {
|
cfgMap.put("packages", new PackagesCfg("packages.yml", pm));
|
||||||
entry.setValue(new LangCfg("lang/" + PluginCfg.LANG + ".yml", pm));
|
cfgMap.put("tagNames", new TagNameCfg("tagNames.yml", pm));
|
||||||
}
|
}
|
||||||
entry.getValue().reloadConfig();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, PluginConfig> getCfgMap() {
|
public void reloadConfig(CommandSender sender) {
|
||||||
return cfgMap;
|
for (Entry<String, PluginConfig> entry : cfgMap.entrySet()) {
|
||||||
}
|
if ("lang".equals(entry.getKey())) {
|
||||||
|
entry.setValue(new LangCfg("lang/" + PluginCfg.LANG + ".yml", pm));
|
||||||
|
}
|
||||||
|
entry.getValue().reloadConfig(sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void copyLangFilesFromJar() {
|
public Map<String, PluginConfig> getCfgMap() {
|
||||||
FileUtil.findFilesFromJar(new FindFilesDo() {
|
return cfgMap;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
private void copyLangFilesFromJar() {
|
||||||
public void process(String fileName, InputStream is) {
|
FileUtil.findFilesFromJar(new FindFilesDo() {
|
||||||
File f = new File(pm.getDataFolder(), fileName);
|
|
||||||
File parentFolder = f.getParentFile();
|
|
||||||
if (!parentFolder.exists()) {
|
|
||||||
parentFolder.mkdirs();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
OutputStream os = new FileOutputStream(f);
|
|
||||||
int bytesRead = 0;
|
|
||||||
byte[] buffer = new byte[8192];
|
|
||||||
while ((bytesRead = is.read(buffer, 0, 8192)) != -1) {
|
|
||||||
os.write(buffer, 0, bytesRead);
|
|
||||||
}
|
|
||||||
os.close();
|
|
||||||
is.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isProcess(String fileName) {
|
public void process(String fileName, InputStream is) {
|
||||||
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);
|
File parentFolder = f.getParentFile();
|
||||||
if (!f.exists()) {
|
if (!parentFolder.exists()) {
|
||||||
return true;
|
parentFolder.mkdirs();
|
||||||
}
|
}
|
||||||
}
|
try {
|
||||||
return false;
|
OutputStream os = new FileOutputStream(f);
|
||||||
}
|
int bytesRead = 0;
|
||||||
}, this.getClass());
|
byte[] buffer = new byte[8192];
|
||||||
}
|
while ((bytesRead = is.read(buffer, 0, 8192)) != -1) {
|
||||||
|
os.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
os.close();
|
||||||
|
is.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isProcess(String 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);
|
||||||
|
if (!f.exists()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}, this.getClass());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package gg.frog.mc.base.config;
|
package gg.frog.mc.base.config;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import gg.frog.mc.base.PluginMain;
|
import gg.frog.mc.base.PluginMain;
|
||||||
import gg.frog.mc.base.utils.config.PluginConfig;
|
import gg.frog.mc.base.utils.config.PluginConfig;
|
||||||
|
|
||||||
@ -77,7 +79,7 @@ public class LangCfg extends PluginConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadToDo() {
|
protected void loadToDo(CommandSender sender) {
|
||||||
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===");
|
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}");
|
||||||
@ -87,9 +89,9 @@ public class LangCfg extends PluginConfig {
|
|||||||
TIME_UNIT_M = getConfig().getString("timeUnitM", "minute(s)");
|
TIME_UNIT_M = getConfig().getString("timeUnitM", "minute(s)");
|
||||||
TIME_FOREVER = getConfig().getString("timeForever", "Forever");
|
TIME_FOREVER = getConfig().getString("timeForever", "Forever");
|
||||||
TAG = getConfig().getString("tag", "Tag/Prefix");
|
TAG = getConfig().getString("tag", "Tag/Prefix");
|
||||||
TAG_COLOR_ITEM_NAME = getConfig().getString("tag", "&6&lName Style");
|
TAG_COLOR_ITEM_NAME = getConfig().getString("tagColorItemName", "&6&lName Style");
|
||||||
TAG_PREFIX_ITEM_NAME = getConfig().getString("tag", "&6&lTag Prefix");
|
TAG_PREFIX_ITEM_NAME = getConfig().getString("tagPrefixItemName", "&6&lTag Prefix");
|
||||||
TAG_SUFFIX_ITEM_NAME = getConfig().getString("tag", "&6&lTag Suffix");
|
TAG_SUFFIX_ITEM_NAME = getConfig().getString("tagSuffixItemName", "&6&lTag Suffix");
|
||||||
|
|
||||||
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.");
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package gg.frog.mc.base.config;
|
package gg.frog.mc.base.config;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import gg.frog.mc.base.PluginMain;
|
import gg.frog.mc.base.PluginMain;
|
||||||
import gg.frog.mc.base.utils.config.PluginConfig;
|
import gg.frog.mc.base.utils.config.PluginConfig;
|
||||||
|
|
||||||
@ -33,7 +35,7 @@ public class PluginCfg extends PluginConfig {
|
|||||||
protected void init() {}
|
protected void init() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadToDo() {
|
protected void loadToDo(CommandSender sender) {
|
||||||
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);
|
||||||
|
@ -10,6 +10,7 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.MemorySection;
|
import org.bukkit.configuration.MemorySection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
@ -29,192 +30,206 @@ import gg.frog.mc.base.utils.StrUtil;
|
|||||||
*/
|
*/
|
||||||
public abstract class PluginConfig {
|
public abstract class PluginConfig {
|
||||||
|
|
||||||
protected PluginMain pm;
|
protected PluginMain pm;
|
||||||
private FileConfiguration config = null;
|
private FileConfiguration config = null;
|
||||||
private File folder = null;
|
private File folder = null;
|
||||||
private String fileName = null;
|
private String fileName = null;
|
||||||
private File configFile = null;
|
private File configFile = null;
|
||||||
|
|
||||||
protected PluginConfig(PluginMain pm) {
|
protected PluginConfig(PluginMain pm) {
|
||||||
this.pm = pm;
|
this.pm = pm;
|
||||||
initConfig(pm.getDataFolder(), "config.yml");
|
initConfig(pm.getDataFolder(), "config.yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PluginConfig(String fileName, PluginMain pm) {
|
protected PluginConfig(String fileName, PluginMain pm) {
|
||||||
this.pm = pm;
|
this.pm = pm;
|
||||||
initConfig(pm.getDataFolder(), fileName);
|
initConfig(pm.getDataFolder(), fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PluginConfig(File folder, String fileName, PluginMain pm) {
|
protected PluginConfig(File folder, String fileName, PluginMain pm) {
|
||||||
this.pm = pm;
|
this.pm = pm;
|
||||||
initConfig(folder, fileName);
|
initConfig(folder, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化
|
* 初始化
|
||||||
*
|
*
|
||||||
* @param folder
|
* @param folder
|
||||||
* @param fileName
|
* @param fileName
|
||||||
*/
|
*/
|
||||||
private void initConfig(File folder, String fileName) {
|
private void initConfig(File folder, String fileName) {
|
||||||
this.folder = folder;
|
this.folder = folder;
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
configFile = new File(folder, fileName);
|
configFile = new File(folder, fileName);
|
||||||
if (!configFile.exists()) {
|
if (!configFile.exists()) {
|
||||||
getConfig(folder, fileName).options().copyDefaults(true);
|
getConfig(folder, fileName).options().copyDefaults(true);
|
||||||
init();
|
init();
|
||||||
saveAndReloadConfig();
|
saveAndReloadConfig();
|
||||||
} else {
|
} else {
|
||||||
reloadConfig();
|
reloadConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 首次生成文件调用
|
* 首次生成文件调用
|
||||||
*/
|
*/
|
||||||
protected abstract void init();
|
protected abstract void init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载配置后调用
|
||||||
|
*/
|
||||||
|
protected abstract void loadToDo(CommandSender sender);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载配置后调用
|
* 获取配置(首次)
|
||||||
*/
|
*
|
||||||
protected abstract void loadToDo();
|
* @return
|
||||||
|
*/
|
||||||
|
private FileConfiguration getConfig(File folder, String fileName) {
|
||||||
|
if (config == null) {
|
||||||
|
reloadConfig(folder, fileName, true);
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取配置(首次)
|
* 获取配置
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private FileConfiguration getConfig(File folder, String fileName) {
|
protected FileConfiguration getConfig() {
|
||||||
if (config == null) {
|
return config;
|
||||||
reloadConfig(folder, fileName, true);
|
}
|
||||||
}
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取配置
|
* 保存配置
|
||||||
*
|
*/
|
||||||
* @return
|
public void saveConfig() {
|
||||||
*/
|
try {
|
||||||
protected FileConfiguration getConfig() {
|
getConfig().save(configFile);
|
||||||
return config;
|
} catch (IOException ex) {
|
||||||
}
|
PluginMain.LOG.log(Level.SEVERE, StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "Could not save config to " + configFile), ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
public void saveAndReloadConfig() {
|
||||||
* 保存配置
|
try {
|
||||||
*/
|
getConfig().save(configFile);
|
||||||
public void saveConfig() {
|
reloadConfig();
|
||||||
try {
|
} catch (IOException ex) {
|
||||||
getConfig().save(configFile);
|
PluginMain.LOG.log(Level.SEVERE, StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "Could not save config to " + configFile), ex);
|
||||||
} catch (IOException ex) {
|
}
|
||||||
PluginMain.LOG.log(Level.SEVERE, StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "Could not save config to " + configFile), ex);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveAndReloadConfig() {
|
/**
|
||||||
try {
|
* 配置重载
|
||||||
getConfig().save(configFile);
|
*/
|
||||||
reloadConfig();
|
public void reloadConfig() {
|
||||||
} catch (IOException ex) {
|
reloadConfig(folder, fileName, false);
|
||||||
PluginMain.LOG.log(Level.SEVERE, StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "Could not save config to " + configFile), ex);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 配置重载
|
* 配置重载
|
||||||
*/
|
*/
|
||||||
public void reloadConfig() {
|
public void reloadConfig(CommandSender sender) {
|
||||||
reloadConfig(folder, fileName, false);
|
reloadConfig(folder, fileName, false, sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 配置重载
|
* 配置重载
|
||||||
*/
|
*/
|
||||||
private void reloadConfig(File folder, String fileName, boolean useRes) {
|
private void reloadConfig(File folder, String fileName, boolean useRes) {
|
||||||
YamlConfiguration tempConfig = new YamlConfiguration();
|
reloadConfig(folder, fileName, useRes, null);
|
||||||
try {
|
}
|
||||||
tempConfig.load(configFile);
|
|
||||||
config = tempConfig;
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
} catch (IOException | InvalidConfigurationException e1) {
|
|
||||||
tempConfig = null;
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
if (config == null) {
|
|
||||||
config = new YamlConfiguration();
|
|
||||||
}
|
|
||||||
if (useRes) {
|
|
||||||
final InputStream defConfigStream = pm.getResource(fileName);
|
|
||||||
if (defConfigStream == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
config.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream, Charsets.UTF_8)));
|
|
||||||
}
|
|
||||||
loadToDo();
|
|
||||||
// if (tempConfig != null) {
|
|
||||||
// saveConfig();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setObj(String path, Map<String, ? extends IConfigBean> o) {
|
/**
|
||||||
for (Entry<String, ? extends IConfigBean> configBean : o.entrySet()) {
|
* 配置重载
|
||||||
setObj(path + "." + configBean.getKey(), configBean.getValue());
|
*/
|
||||||
}
|
private void reloadConfig(File folder, String fileName, boolean useRes, CommandSender sender) {
|
||||||
}
|
YamlConfiguration tempConfig = new YamlConfiguration();
|
||||||
|
try {
|
||||||
|
tempConfig.load(configFile);
|
||||||
|
config = tempConfig;
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
} catch (IOException | InvalidConfigurationException e1) {
|
||||||
|
tempConfig = null;
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
if (config == null) {
|
||||||
|
config = new YamlConfiguration();
|
||||||
|
}
|
||||||
|
if (useRes) {
|
||||||
|
final InputStream defConfigStream = pm.getResource(fileName);
|
||||||
|
if (defConfigStream == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
config.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream, Charsets.UTF_8)));
|
||||||
|
}
|
||||||
|
loadToDo(sender);
|
||||||
|
// if (tempConfig != null) {
|
||||||
|
// saveConfig();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
protected void setObj(String path, IConfigBean o) {
|
protected void setObj(String path, Map<String, ? extends IConfigBean> o) {
|
||||||
getConfig().set(path, o.toConfig());
|
for (Entry<String, ? extends IConfigBean> configBean : o.entrySet()) {
|
||||||
}
|
setObj(path + "." + configBean.getKey(), configBean.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected <T extends IConfigBean> Map<String, T> getObjMap(String path, Class<T> clazz) {
|
protected void setObj(String path, IConfigBean o) {
|
||||||
Map<String, T> map = new HashMap<>();
|
getConfig().set(path, o.toConfig());
|
||||||
MemorySection configMap = (MemorySection) getConfig().get(path);
|
}
|
||||||
if (configMap != null) {
|
|
||||||
for (String key : configMap.getKeys(false)) {
|
|
||||||
T bean = getObj(path + "." + key, clazz);
|
|
||||||
if (bean != null) {
|
|
||||||
map.put(key, bean);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected <T extends IConfigBean> T getObj(String path, Class<T> clazz) {
|
protected <T extends IConfigBean> Map<String, T> getObjMap(String path, Class<T> clazz) {
|
||||||
Object beanConfig = getConfig().get(path);
|
Map<String, T> map = new HashMap<>();
|
||||||
if (beanConfig != null && beanConfig instanceof MemorySection) {
|
MemorySection configMap = (MemorySection) getConfig().get(path);
|
||||||
try {
|
if (configMap != null) {
|
||||||
T bean = clazz.newInstance();
|
for (String key : configMap.getKeys(false)) {
|
||||||
bean.toConfigBean((MemorySection) beanConfig);
|
T bean = getObj(path + "." + key, clazz);
|
||||||
return bean;
|
if (bean != null) {
|
||||||
} catch (Exception e) {
|
map.put(key, bean);
|
||||||
e.printStackTrace();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String setGetDefault(String path, String def) {
|
protected <T extends IConfigBean> T getObj(String path, Class<T> clazz) {
|
||||||
if (!getConfig().contains(path)) {
|
Object beanConfig = getConfig().get(path);
|
||||||
getConfig().set(path, def);
|
if (beanConfig != null && beanConfig instanceof MemorySection) {
|
||||||
return def;
|
try {
|
||||||
}
|
T bean = clazz.newInstance();
|
||||||
return getConfig().getString(path);
|
bean.toConfigBean((MemorySection) beanConfig);
|
||||||
}
|
return bean;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
protected int setGetDefault(String path, int def) {
|
protected String setGetDefault(String path, String def) {
|
||||||
if (!getConfig().contains(path)) {
|
if (!getConfig().contains(path)) {
|
||||||
getConfig().set(path, def);
|
getConfig().set(path, def);
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
return getConfig().getInt(path);
|
return getConfig().getString(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean setGetDefault(String path, boolean def) {
|
protected int setGetDefault(String path, int def) {
|
||||||
if (!getConfig().contains(path)) {
|
if (!getConfig().contains(path)) {
|
||||||
getConfig().set(path, def);
|
getConfig().set(path, def);
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
return getConfig().getBoolean(path);
|
return getConfig().getInt(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean setGetDefault(String path, boolean def) {
|
||||||
|
if (!getConfig().contains(path)) {
|
||||||
|
getConfig().set(path, def);
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
return getConfig().getBoolean(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import java.util.Map.Entry;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
@ -62,12 +63,22 @@ public class TagNameCfg extends PluginConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadToDo() {
|
protected void loadToDo(CommandSender sender) {
|
||||||
DEFAULT_NAMECOLOR = setGetDefault("defaultNamecolor", "");
|
DEFAULT_NAMECOLOR = setGetDefault("defaultNamecolor", "");
|
||||||
DEFAULT_PREFIX = setGetDefault("defaultPrefix", "");
|
DEFAULT_PREFIX = setGetDefault("defaultPrefix", "");
|
||||||
DEFAULT_SUFFIX = setGetDefault("defaultSuffix", "");
|
DEFAULT_SUFFIX = setGetDefault("defaultSuffix", "");
|
||||||
CHANGE_DISPLAYNAME = setGetDefault("changeDisplayname", true);
|
CHANGE_DISPLAYNAME = setGetDefault("changeDisplayname", true);
|
||||||
USE_HD_PLUGIN = setGetDefault("useHdPlugin", false);
|
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);
|
ONE_LINE_DISPLAY = setGetDefault("oneLineDisplay", true);
|
||||||
REFRESH_TAG_TIME = setGetDefault("refreshTagTime", -1);
|
REFRESH_TAG_TIME = setGetDefault("refreshTagTime", -1);
|
||||||
PACKAGES = getObjMap("packages", TagPackageBean.class);
|
PACKAGES = getObjMap("packages", TagPackageBean.class);
|
||||||
@ -114,7 +125,7 @@ public class TagNameCfg extends PluginConfig {
|
|||||||
SUFFIX_ITEMS.put(e.getValue().getPermissions(), items);
|
SUFFIX_ITEMS.put(e.getValue().getPermissions(), items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
task.cancel();
|
task.cancel();
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class PlayerTagShow {
|
|||||||
Inventory inventory = null;
|
Inventory inventory = null;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
if (itemList.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();
|
String uuid = player.getUniqueId().toString();
|
||||||
PlayerTagBean playerTag = null;
|
PlayerTagBean playerTag = null;
|
||||||
if (TagNameCfg.PLAYER_TAG.containsKey(uuid)) {
|
if (TagNameCfg.PLAYER_TAG.containsKey(uuid)) {
|
||||||
|
@ -65,7 +65,7 @@ public class TagsListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerClick(InventoryClickEvent event) {
|
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()) {
|
if (event.getCurrentItem() != null && event.getCurrentItem().getItemMeta() != null && event.getCurrentItem().getItemMeta().hasLore()) {
|
||||||
List<String> lores = event.getCurrentItem().getItemMeta().getLore();
|
List<String> lores = event.getCurrentItem().getItemMeta().getLore();
|
||||||
if (lores.size() > 1) {
|
if (lores.size() > 1) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package gg.frog.mc.nametags.model;
|
package gg.frog.mc.nametags.model;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.MemorySection;
|
import org.bukkit.configuration.MemorySection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -54,7 +55,7 @@ public class PlayerTagBean extends PluginConfig implements IConfigBean, Cloneabl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadToDo() {
|
protected void loadToDo(CommandSender sender) {
|
||||||
namecolor = getConfig().getString("namecolor", TagNameCfg.DEFAULT_NAMECOLOR);
|
namecolor = getConfig().getString("namecolor", TagNameCfg.DEFAULT_NAMECOLOR);
|
||||||
prefix = getConfig().getString("prefix", TagNameCfg.DEFAULT_PREFIX);
|
prefix = getConfig().getString("prefix", TagNameCfg.DEFAULT_PREFIX);
|
||||||
suffix = getConfig().getString("suffix", TagNameCfg.DEFAULT_SUFFIX);
|
suffix = getConfig().getString("suffix", TagNameCfg.DEFAULT_SUFFIX);
|
||||||
|
@ -58,7 +58,7 @@ public class PtCommand implements CommandExecutor, TabCompleter {
|
|||||||
inventory.close();
|
inventory.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pm.getConfigManager().reloadConfig();
|
pm.getConfigManager().reloadConfig(sender);
|
||||||
if (!sm.updateDatabase()) {
|
if (!sm.updateDatabase()) {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Database exceptions."));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Database exceptions."));
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ public class PtCommand implements CommandExecutor, TabCompleter {
|
|||||||
inventory.close();
|
inventory.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pm.getConfigManager().reloadConfig();
|
pm.getConfigManager().reloadConfig(sender);
|
||||||
if (!sm.updateDatabase()) {
|
if (!sm.updateDatabase()) {
|
||||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Database exceptions."));
|
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Database exceptions."));
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
@ -24,103 +25,107 @@ import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean;
|
|||||||
|
|
||||||
public class PackagesCfg extends PluginConfig {
|
public class PackagesCfg extends PluginConfig {
|
||||||
|
|
||||||
public static String PACKAGES_VERSION = null;
|
public static String PACKAGES_VERSION = null;
|
||||||
public static String DEFAULT_GROUP = null;
|
public static String DEFAULT_GROUP = null;
|
||||||
public static Map<String, PermissionPackageBean> PACKAGES = new ConcurrentHashMap<>();
|
public static Map<String, PermissionPackageBean> PACKAGES = new ConcurrentHashMap<>();
|
||||||
public static Map<String, ItemStack> PACKAGE_ITEMS = new ConcurrentHashMap<>();
|
public static Map<String, ItemStack> PACKAGE_ITEMS = new ConcurrentHashMap<>();
|
||||||
public static Set<String> allPermissions = Collections.synchronizedSet(new HashSet<String>());
|
public static Set<String> allPermissions = Collections.synchronizedSet(new HashSet<String>());
|
||||||
public static Set<String> allGroups = Collections.synchronizedSet(new HashSet<String>());
|
public static Set<String> allGroups = Collections.synchronizedSet(new HashSet<String>());
|
||||||
|
|
||||||
public PackagesCfg(String fileName, PluginMain pm) {
|
public PackagesCfg(String fileName, PluginMain pm) {
|
||||||
super(fileName, pm);
|
super(fileName, pm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init() {}
|
protected void init() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadToDo() {
|
protected void loadToDo(CommandSender sender) {
|
||||||
PACKAGES_VERSION = setGetDefault("version", "1.00");
|
PACKAGES_VERSION = setGetDefault("version", "1.00");
|
||||||
DEFAULT_GROUP = setGetDefault("defaultGroup", "Default");
|
DEFAULT_GROUP = setGetDefault("defaultGroup", "Default");
|
||||||
PACKAGES = getObjMap("packages", PermissionPackageBean.class);
|
PACKAGES = getObjMap("packages", PermissionPackageBean.class);
|
||||||
setObj("packages", PACKAGES);
|
setObj("packages", PACKAGES);
|
||||||
if (PluginCfg.IS_DEBUG) {
|
if (PluginCfg.IS_DEBUG) {
|
||||||
System.out.println("packages vresion:" + PACKAGES_VERSION);
|
System.out.println("packages vresion:" + PACKAGES_VERSION);
|
||||||
System.out.println("defaultGroup:" + DEFAULT_GROUP);
|
System.out.println("defaultGroup:" + DEFAULT_GROUP);
|
||||||
for (Entry<String, PermissionPackageBean> p : PACKAGES.entrySet()) {
|
for (Entry<String, PermissionPackageBean> p : PACKAGES.entrySet()) {
|
||||||
System.out.println(p.getKey() + ":" + p.getValue());
|
System.out.println(p.getKey() + ":" + p.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PACKAGE_ITEMS.clear();
|
PACKAGE_ITEMS.clear();
|
||||||
for (Entry<String, PermissionPackageBean> e : PACKAGES.entrySet()) {
|
for (Entry<String, PermissionPackageBean> e : PACKAGES.entrySet()) {
|
||||||
ItemStack item = getPackageItem(e.getKey(), e.getValue());
|
ItemStack item = getPackageItem(e.getKey(), e.getValue());
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
PACKAGE_ITEMS.put(e.getKey(), item);
|
PACKAGE_ITEMS.put(e.getKey(), item);
|
||||||
} else {
|
} else {
|
||||||
PluginMain.LOG.log(Level.SEVERE, "Packages of " + e.getKey() + " has problem.");
|
PluginMain.LOG.log(Level.SEVERE, "Packages of " + e.getKey() + " has problem.");
|
||||||
}
|
if (sender != null) {
|
||||||
allPermissions.addAll(e.getValue().getPermissions());
|
sender.sendMessage("Packages of " + e.getKey() + " has problem.");
|
||||||
allGroups.addAll(e.getValue().getGroups());
|
}
|
||||||
}
|
}
|
||||||
}
|
allPermissions.addAll(e.getValue().getPermissions());
|
||||||
|
allGroups.addAll(e.getValue().getGroups());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private ItemStack getPackageItem(String name, PermissionPackageBean ppb) {
|
private ItemStack getPackageItem(String name, PermissionPackageBean ppb) {
|
||||||
if (ppb != null) {
|
if (ppb != null) {
|
||||||
Material type = null;
|
Material type = null;
|
||||||
int exid = 0;
|
int exid = 0;
|
||||||
String skullOwner = null;
|
String skullOwner = null;
|
||||||
if (ppb.getType() != null) {
|
if (ppb.getType() != null) {
|
||||||
String[] args = ppb.getType().split(":");
|
String[] args = ppb.getType().split(":");
|
||||||
type = Material.getMaterial(args[0].toUpperCase(Locale.ENGLISH));
|
type = Material.getMaterial(args[0].toUpperCase(Locale.ENGLISH));
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
try {
|
try {
|
||||||
exid = Integer.parseInt(args[1]);
|
exid = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
if (Material.SKULL_ITEM.equals(type)) {
|
if (Material.SKULL_ITEM.equals(type)) {
|
||||||
exid = 3;
|
exid = 3;
|
||||||
skullOwner = args[1];
|
skullOwner = args[1];
|
||||||
} else {
|
} else {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (ppb.getId() != null) {
|
} else if (ppb.getId() != null) {
|
||||||
String[] args = ppb.getId().split(":");
|
String[] args = ppb.getId().split(":");
|
||||||
int id = Integer.parseInt(args[0]);
|
int id = Integer.parseInt(args[0]);
|
||||||
type = Material.getMaterial(id);
|
type = Material.getMaterial(id);
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
try {
|
try {
|
||||||
exid = Integer.parseInt(args[1]);
|
exid = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
if (Material.SKULL_ITEM.equals(type)) {
|
if (Material.SKULL_ITEM.equals(type)) {
|
||||||
exid = 3;
|
exid = 3;
|
||||||
skullOwner = args[1];
|
skullOwner = args[1];
|
||||||
} else {
|
} else {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
ItemStack item = new ItemStack(type, 1, (short) 0, (byte) exid);
|
ItemStack item = new ItemStack(type, 1, (short) 0, (byte) exid);
|
||||||
ItemMeta meta = item.getItemMeta();
|
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>();
|
List<String> lores = new ArrayList<String>();
|
||||||
for (String lore : ppb.getLores()) {
|
for (String lore : ppb.getLores()) {
|
||||||
lores.add(StrUtil.messageFormat(lore));
|
lores.add(StrUtil.messageFormat(lore));
|
||||||
}
|
}
|
||||||
lores.add("");
|
lores.add("");
|
||||||
meta.setLore(lores);
|
meta.setLore(lores);
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
if (ppb.getGlowing() && !meta.hasEnchants()) {
|
if (ppb.getGlowing() && !meta.hasEnchants()) {
|
||||||
item = ItemUtil.addEnchantLight(item);
|
item = ItemUtil.addEnchantLight(item);
|
||||||
}
|
}
|
||||||
if (skullOwner != null) {
|
if (skullOwner != null) {
|
||||||
item = ItemUtil.addSkullOwner(item, skullOwner);
|
item = ItemUtil.addSkullOwner(item, skullOwner);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public class PlayerPermissionShow {
|
|||||||
Inventory inventory = null;
|
Inventory inventory = null;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
if (pdbList.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) {
|
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()) {
|
||||||
|
@ -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.cfg.PermissionPackageBean;
|
||||||
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
|
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
|
||||||
|
|
||||||
public class MainListener implements Listener {
|
public class PtListener implements Listener {
|
||||||
|
|
||||||
private PluginMain pm;
|
private PluginMain pm;
|
||||||
|
|
||||||
public MainListener(PluginMain pm) {
|
public PtListener(PluginMain pm) {
|
||||||
this.pm = pm;
|
this.pm = pm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ public class MainListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerClick(InventoryClickEvent event) {
|
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);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user