mirror of
https://github.com/geekfrog/PermissionsTime.git
synced 2025-09-09 13:05:08 +00:00
修复超多BUG
This commit is contained in:
@ -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;
|
||||
|
||||
@ -24,103 +25,107 @@ import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean;
|
||||
|
||||
public class PackagesCfg extends PluginConfig {
|
||||
|
||||
public static String PACKAGES_VERSION = null;
|
||||
public static String DEFAULT_GROUP = null;
|
||||
public static Map<String, PermissionPackageBean> PACKAGES = 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> allGroups = Collections.synchronizedSet(new HashSet<String>());
|
||||
public static String PACKAGES_VERSION = null;
|
||||
public static String DEFAULT_GROUP = null;
|
||||
public static Map<String, PermissionPackageBean> PACKAGES = 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> allGroups = Collections.synchronizedSet(new HashSet<String>());
|
||||
|
||||
public PackagesCfg(String fileName, PluginMain pm) {
|
||||
super(fileName, pm);
|
||||
}
|
||||
public PackagesCfg(String fileName, PluginMain pm) {
|
||||
super(fileName, pm);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {}
|
||||
@Override
|
||||
protected void init() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadToDo() {
|
||||
PACKAGES_VERSION = setGetDefault("version", "1.00");
|
||||
DEFAULT_GROUP = setGetDefault("defaultGroup", "Default");
|
||||
PACKAGES = getObjMap("packages", PermissionPackageBean.class);
|
||||
setObj("packages", PACKAGES);
|
||||
if (PluginCfg.IS_DEBUG) {
|
||||
System.out.println("packages vresion:" + PACKAGES_VERSION);
|
||||
System.out.println("defaultGroup:" + DEFAULT_GROUP);
|
||||
for (Entry<String, PermissionPackageBean> p : PACKAGES.entrySet()) {
|
||||
System.out.println(p.getKey() + ":" + p.getValue());
|
||||
}
|
||||
}
|
||||
PACKAGE_ITEMS.clear();
|
||||
for (Entry<String, PermissionPackageBean> e : PACKAGES.entrySet()) {
|
||||
ItemStack item = getPackageItem(e.getKey(), e.getValue());
|
||||
if (item != null) {
|
||||
PACKAGE_ITEMS.put(e.getKey(), item);
|
||||
} else {
|
||||
PluginMain.LOG.log(Level.SEVERE, "Packages of " + e.getKey() + " has problem.");
|
||||
}
|
||||
allPermissions.addAll(e.getValue().getPermissions());
|
||||
allGroups.addAll(e.getValue().getGroups());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void loadToDo(CommandSender sender) {
|
||||
PACKAGES_VERSION = setGetDefault("version", "1.00");
|
||||
DEFAULT_GROUP = setGetDefault("defaultGroup", "Default");
|
||||
PACKAGES = getObjMap("packages", PermissionPackageBean.class);
|
||||
setObj("packages", PACKAGES);
|
||||
if (PluginCfg.IS_DEBUG) {
|
||||
System.out.println("packages vresion:" + PACKAGES_VERSION);
|
||||
System.out.println("defaultGroup:" + DEFAULT_GROUP);
|
||||
for (Entry<String, PermissionPackageBean> p : PACKAGES.entrySet()) {
|
||||
System.out.println(p.getKey() + ":" + p.getValue());
|
||||
}
|
||||
}
|
||||
PACKAGE_ITEMS.clear();
|
||||
for (Entry<String, PermissionPackageBean> e : PACKAGES.entrySet()) {
|
||||
ItemStack item = getPackageItem(e.getKey(), e.getValue());
|
||||
if (item != null) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack getPackageItem(String name, PermissionPackageBean ppb) {
|
||||
if (ppb != null) {
|
||||
Material type = null;
|
||||
int exid = 0;
|
||||
String skullOwner = null;
|
||||
if (ppb.getType() != null) {
|
||||
String[] args = ppb.getType().split(":");
|
||||
type = Material.getMaterial(args[0].toUpperCase(Locale.ENGLISH));
|
||||
if (args.length == 2) {
|
||||
try {
|
||||
exid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
if (Material.SKULL_ITEM.equals(type)) {
|
||||
exid = 3;
|
||||
skullOwner = args[1];
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ppb.getId() != null) {
|
||||
String[] args = ppb.getId().split(":");
|
||||
int id = Integer.parseInt(args[0]);
|
||||
type = Material.getMaterial(id);
|
||||
if (args.length == 2) {
|
||||
try {
|
||||
exid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
if (Material.SKULL_ITEM.equals(type)) {
|
||||
exid = 3;
|
||||
skullOwner = args[1];
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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 + ")"));
|
||||
List<String> lores = new ArrayList<String>();
|
||||
for (String lore : ppb.getLores()) {
|
||||
lores.add(StrUtil.messageFormat(lore));
|
||||
}
|
||||
lores.add("");
|
||||
meta.setLore(lores);
|
||||
item.setItemMeta(meta);
|
||||
if (ppb.getGlowing() && !meta.hasEnchants()) {
|
||||
item = ItemUtil.addEnchantLight(item);
|
||||
}
|
||||
if (skullOwner != null) {
|
||||
item = ItemUtil.addSkullOwner(item, skullOwner);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private ItemStack getPackageItem(String name, PermissionPackageBean ppb) {
|
||||
if (ppb != null) {
|
||||
Material type = null;
|
||||
int exid = 0;
|
||||
String skullOwner = null;
|
||||
if (ppb.getType() != null) {
|
||||
String[] args = ppb.getType().split(":");
|
||||
type = Material.getMaterial(args[0].toUpperCase(Locale.ENGLISH));
|
||||
if (args.length == 2) {
|
||||
try {
|
||||
exid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
if (Material.SKULL_ITEM.equals(type)) {
|
||||
exid = 3;
|
||||
skullOwner = args[1];
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ppb.getId() != null) {
|
||||
String[] args = ppb.getId().split(":");
|
||||
int id = Integer.parseInt(args[0]);
|
||||
type = Material.getMaterial(id);
|
||||
if (args.length == 2) {
|
||||
try {
|
||||
exid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
if (Material.SKULL_ITEM.equals(type)) {
|
||||
exid = 3;
|
||||
skullOwner = args[1];
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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 + ")"));
|
||||
List<String> lores = new ArrayList<String>();
|
||||
for (String lore : ppb.getLores()) {
|
||||
lores.add(StrUtil.messageFormat(lore));
|
||||
}
|
||||
lores.add("");
|
||||
meta.setLore(lores);
|
||||
item.setItemMeta(meta);
|
||||
if (ppb.getGlowing() && !meta.hasEnchants()) {
|
||||
item = ItemUtil.addEnchantLight(item);
|
||||
}
|
||||
if (skullOwner != null) {
|
||||
item = ItemUtil.addSkullOwner(item, skullOwner);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user