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

修复gui bug

This commit is contained in:
GeekFrog 2017-07-16 07:35:53 +08:00
parent b92bf7893c
commit 277d091ce7
4 changed files with 26 additions and 4 deletions

View File

@ -24,7 +24,7 @@
- **调用vault API 设置玩家权限 -- 登录时(添加 移除)、游戏中(命令添加/移除 延迟移除)、退出时移除**
- **mysql保存数据**
- **支持跨服**
- **gui显示自己的权限包**(可以拿出gui的物品, 有待处理)
- **gui显示自己的权限包**
- 手动删除过期的或无效数据
- 语言支持整理

View File

@ -4,6 +4,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.config.LangCfg;
@ -37,6 +38,12 @@ public class MainCommand implements CommandExecutor {
if (isPlayer) {
Player player = (Player) sender;
if (sender.isOp() || player.hasPermission("permissionstime.reload")) {
for (Player p : pm.getServer().getOnlinePlayers()) {
InventoryView inventory = p.getOpenInventory();
if (StrUtil.messageFormat("&4===权限仓库===" + "&r&5&9&2&0&r").equals(inventory.getTitle())) {
inventory.close();
}
}
pm.getConfigManager().reloadConfig();
if (!sm.updateDatabase()) {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "数据库异常"));
@ -47,6 +54,14 @@ public class MainCommand implements CommandExecutor {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.NO_PERMISSION));
}
} else {
for (Player p : pm.getServer().getOnlinePlayers()) {
InventoryView inventory = p.getOpenInventory();
if (inventory != null) {
if (StrUtil.messageFormat("&4===权限仓库===" + "&r&5&9&2&0&r").equals(inventory.getTitle())) {
inventory.close();
}
}
}
pm.getConfigManager().reloadConfig();
if (!sm.updateDatabase()) {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "数据库异常"));

View File

@ -5,7 +5,6 @@ import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@ -16,7 +15,7 @@ import gg.frog.mc.permissionstime.utils.StrUtil;
public class PlayerPermissionShow {
public static void show(Player p, List<PlayerDataBean> pdbList) {
Inventory inventory = Bukkit.createInventory(null, (pdbList.size() % 9 == 0 ? pdbList.size() : (pdbList.size() / 9 + 1) * 9), StrUtil.messageFormat("&4你共有{0}种权限包", pdbList.size()));
Inventory inventory = Bukkit.createInventory(null, (pdbList.size() % 9 == 0 ? pdbList.size() : (pdbList.size() / 9 + 1) * 9), StrUtil.messageFormat("&4===权限仓库===" + "&r&5&9&2&0&r"));
for (PlayerDataBean pdb : pdbList) {
ItemStack item = PackagesCfg.PACKAGE_ITEMS.get(pdb.getPackageName());
if (item != null) {
@ -29,6 +28,6 @@ public class PlayerPermissionShow {
inventory.addItem(item);
}
}
InventoryView view = p.openInventory(inventory);
p.openInventory(inventory);
}
}

View File

@ -4,6 +4,7 @@ import java.util.List;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -70,4 +71,11 @@ public class MainListener implements Listener {
}
}).start();
}
@EventHandler
public void onPlayerClick(InventoryClickEvent event) {
if (StrUtil.messageFormat("&4===权限仓库===" + "&r&5&9&2&0&r").equals(event.getInventory().getName())) {
event.setCancelled(true);
}
}
}