diff --git a/pom.xml b/pom.xml
index 7b55a1a..85d8271 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,120 +1,120 @@
- 4.0.0
- pw.yumc
- Residence
- 2.8.3.5
- Residence
- 重制版本的领地插件 - 喵♂呜
-
- ${project.name}
-
-
- src/main/resources
- true
-
-
-
-
- maven-compiler-plugin
- 3.1
-
-
- 1.7
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- 2.3
-
- false
- true
-
-
- cn.citycraft:PluginHelper
-
-
-
-
- cn.citycraft.PluginHelper
- ${project.groupId}.${project.artifactId}
-
-
-
-
-
- package
-
- shade
-
-
-
-
-
-
-
- Jenkins
- http://ci.yumc.pw/job/${project.artifactId}/
-
-
- &6GUI菜单上线(&c测试版本&6)...
-
- &b2.8.3.5 - &c修复世界限制失效问题...;
- &b2.8.3.4 - &c圈地世界限制忽略OP和管理...;
- &b2.8.3.3 - &c添加圈地世界限制(详见dany.yml)...;
-
- Debug
- UTF-8
-
-
-
- spigot-repo
- https://hub.spigotmc.org/nexus/content/groups/public/
-
-
- yumc-repo
- http://repo.yumc.pw/content/groups/public/
-
-
-
-
- jtb
- YUMC
- http://repo.yumc.pw/content/repositories/yumcenter/
-
-
-
-
- org.spigotmc
- spigot-api
- jar
- 1.9-R0.1-SNAPSHOT
-
-
- com.earth2me
- essentials
- 2.9.6
- system
- ${project.basedir}/lib/Essentials.jar
-
-
- net.milkbowl.vault
- Vault
- 1.5.6
-
-
- com.sk89q
- WorldEdit
- 5.4.5
- system
- ${project.basedir}/lib/WorldEdit.jar
-
-
- cn.citycraft
- PluginHelper
- jar
- 1.0
-
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ pw.yumc
+ Residence
+ 2.8.3.6
+ Residence
+ 重制版本的领地插件 - 喵♂呜
+
+ ${project.name}
+
+
+ src/main/resources
+ true
+
+
+
+
+ maven-compiler-plugin
+ 3.1
+
+
+ 1.7
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.3
+
+ false
+ true
+
+
+ cn.citycraft:PluginHelper
+
+
+
+
+ cn.citycraft.PluginHelper
+ ${project.groupId}.${project.artifactId}
+
+
+
+
+
+ package
+
+ shade
+
+
+
+
+
+
+
+ Jenkins
+ http://ci.yumc.pw/job/${project.artifactId}/
+
+
+ §6GUI菜单完善...
+
+ §b2.8.3.6 - §c修复GUI刷物品的问题...;
+ §b2.8.3.5 - §c修复世界限制失效问题...;
+ §b2.8.3.4 - §c圈地世界限制忽略OP和管理...;
+
+ Debug
+ UTF-8
+
+
+
+ spigot-repo
+ https://hub.spigotmc.org/nexus/content/groups/public/
+
+
+ yumc-repo
+ http://repo.yumc.pw/content/groups/public/
+
+
+
+
+ jtb
+ YUMC
+ http://repo.yumc.pw/content/repositories/yumcenter/
+
+
+
+
+ org.spigotmc
+ spigot-api
+ jar
+ 1.11.2-R0.1-SNAPSHOT
+
+
+ com.earth2me
+ essentials
+ 2.9.6
+ system
+ ${project.basedir}/lib/Essentials.jar
+
+
+ net.milkbowl.vault
+ Vault
+ 1.5.6
+
+
+ com.sk89q
+ WorldEdit
+ 5.4.5
+ system
+ ${project.basedir}/lib/WorldEdit.jar
+
+
+ cn.citycraft
+ PluginHelper
+ jar
+ 1.0
+
+
\ No newline at end of file
diff --git a/src/main/java/pw/yumc/Residence/gui/FlagUtil.java b/src/main/java/pw/yumc/Residence/gui/FlagUtil.java
index e95efbd..13ea654 100644
--- a/src/main/java/pw/yumc/Residence/gui/FlagUtil.java
+++ b/src/main/java/pw/yumc/Residence/gui/FlagUtil.java
@@ -13,7 +13,6 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
import cn.citycraft.PluginHelper.config.FileConfig;
import pw.yumc.Residence.ResidenceMain;
-import pw.yumc.Residence.listeners.ResidenceGUIListener;
public class FlagUtil {
public static FileConfig conf;
@@ -27,6 +26,9 @@ public class FlagUtil {
}
public static void open(final ClaimedResidence area, final Player player, final String target, final boolean resadmin) {
+ if (!conf.getBoolean("Enable")) {
+
+ return; }
final SetFlag flag = new SetFlag(area, player, resadmin);
if (StringUtils.isEmpty(target)) {
flag.recalculateResidence(area);
@@ -34,7 +36,6 @@ public class FlagUtil {
flag.setTargePlayer(target);
flag.recalculatePlayer(area);
}
- ResidenceGUIListener.GUI.put(player.getName(), flag);
player.openInventory(flag.getInventory());
player.sendMessage("§a已打开领地 " + area.getName() + " 的管理界面!");
}
diff --git a/src/main/java/pw/yumc/Residence/gui/GuiHolder.java b/src/main/java/pw/yumc/Residence/gui/GuiHolder.java
new file mode 100644
index 0000000..244b473
--- /dev/null
+++ b/src/main/java/pw/yumc/Residence/gui/GuiHolder.java
@@ -0,0 +1,21 @@
+package pw.yumc.Residence.gui;
+
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.InventoryHolder;
+
+public class GuiHolder implements InventoryHolder {
+ SetFlag flag;
+
+ public GuiHolder(SetFlag flag) {
+ this.flag = flag;
+ }
+
+ public SetFlag getFlag() {
+ return flag;
+ }
+
+ @Override
+ public Inventory getInventory() {
+ return null;
+ }
+}
diff --git a/src/main/java/pw/yumc/Residence/gui/SetFlag.java b/src/main/java/pw/yumc/Residence/gui/SetFlag.java
index 76d6699..a1d0308 100644
--- a/src/main/java/pw/yumc/Residence/gui/SetFlag.java
+++ b/src/main/java/pw/yumc/Residence/gui/SetFlag.java
@@ -52,7 +52,7 @@ public class SetFlag {
if (FlagUtil.description.containsKey(one.getKey())) {
lore.addAll(FlagUtil.description.get(one.getKey()));
}
- switch (one.getValue().intValue()) {
+ switch (one.getValue()) {
case 0:
lore.add(ChatColor.GOLD + "权限状态: " + ChatColor.RED + "关闭");
break;
@@ -79,7 +79,7 @@ public class SetFlag {
}
public ItemStack getStatuItem(final Entry one) {
- switch (one.getValue().intValue()) {
+ switch (one.getValue()) {
case 0:
return Residence.getFlagUtilManager().getGuiFalse();
case 1:
@@ -114,7 +114,7 @@ public class SetFlag {
resFlags.put(one.getKey(), one.getValue());
}
}
- Map pFlags = null;
+ Map pFlags;
if (this.targetPlayer != null) {
final ArrayList PosibleResPFlags = res.getPermissions().getposibleFlags();
final Map temp = new HashMap<>();
@@ -131,22 +131,30 @@ public class SetFlag {
}
}
}
+ String title = String.format(FlagUtil.getConfig().getMessage("GUI.Pset.Title"), this.targetPlayer, res.getName());
+ recalculate(title, globalFlags, resFlags, res.getPermissions().getFlags(), flags);
+ }
+
+ public void recalculate(String title, Map globalFlags, Map resFlags, Map resPerm, List flags) {
final LinkedHashMap TempPermMap = new LinkedHashMap<>();
+ for (final Entry one : resPerm.entrySet()) {
+ if (flags.contains(one.getKey())) {
+ resFlags.put(one.getKey(), one.getValue());
+ }
+ }
for (final Entry one : globalFlags.entrySet()) {
if (flags.contains(one.getKey())) {
if (resFlags.containsKey(one.getKey())) {
TempPermMap.put(one.getKey(), resFlags.get(one.getKey()) ? 1 : 0);
} else {
- TempPermMap.put(one.getKey(), Integer.valueOf(2));
+ TempPermMap.put(one.getKey(), 2);
}
}
}
- String title = "";
- title = String.format(FlagUtil.getConfig().getMessage("GUI.Pset.Title"), this.targetPlayer, res.getName());
if (title.length() > 32) {
title = title.substring(0, Math.min(title.length(), 32));
}
- final Inventory GuiInv = Bukkit.createInventory(null, 54, title);
+ final Inventory GuiInv = Bukkit.createInventory(new GuiHolder(this), 54, title);
final FlagData flagData = Residence.getFlagUtilManager().getFlagData();
this.pageCount = ((int) Math.ceil(TempPermMap.size() / 45.0D));
final int start = this.page * 45 - 45;
@@ -168,7 +176,7 @@ public class SetFlag {
if (flagData.contains(one.getKey())) {
MiscInfo = flagData.getItem(one.getKey());
}
- if (one.getValue().intValue() == 1) {
+ if (one.getValue() == 1) {
final ItemMeta im = MiscInfo.getItemMeta();
im.addEnchant(Enchantment.LUCK, 1, true);
MiscInfo.setItemMeta(im);
@@ -193,65 +201,8 @@ public class SetFlag {
final Map globalFlags = Residence.getPermissionManager().getAllFlags().getFlags();
final Map resFlags = new HashMap<>();
final LinkedHashMap TempPermMap = new LinkedHashMap<>();
- for (final Entry one : res.getPermissions().getFlags().entrySet()) {
- if (flags.contains(one.getKey())) {
- resFlags.put(one.getKey(), one.getValue());
- }
- }
- for (final Entry one : globalFlags.entrySet()) {
- if (flags.contains(one.getKey())) {
- if (resFlags.containsKey(one.getKey())) {
- TempPermMap.put(one.getKey(), resFlags.get(one.getKey()) ? 1 : 0);
- } else {
- TempPermMap.put(one.getKey(), 2);
- }
- }
- }
- String title = "";
- title = String.format(FlagUtil.getConfig().getMessage("GUI.Set.Title"), res.getName());
- if (title.length() > 32) {
- title = title.substring(0, Math.min(title.length(), 32));
- }
- final Inventory GuiInv = Bukkit.createInventory(null, 54, title);
- final FlagData flagData = Residence.getFlagUtilManager().getFlagData();
- this.pageCount = ((int) Math.ceil(TempPermMap.size() / 45.0D));
- final int start = this.page * 45 - 45;
- final int end = this.page * 45;
- int count = -1;
- this.permMap.clear();
- for (final Entry one : TempPermMap.entrySet()) {
- count++;
- if (count >= end) {
- break;
- }
- if (count >= start) {
- this.permMap.put(one.getKey(), one.getValue());
- }
- }
- int i = 0;
- for (final Entry one : this.permMap.entrySet()) {
- ItemStack MiscInfo = getStatuItem(one);
- if (flagData.contains(one.getKey())) {
- MiscInfo = flagData.getItem(one.getKey());
- }
- if (one.getValue().intValue() == 1) {
- final ItemMeta im = MiscInfo.getItemMeta();
- im.addEnchant(Enchantment.LUCK, 1, true);
- MiscInfo.setItemMeta(im);
- } else {
- MiscInfo.removeEnchantment(Enchantment.LUCK);
- }
- final ItemMeta MiscInfoMeta = MiscInfo.getItemMeta();
- MiscInfoMeta.setDisplayName(ChatColor.GREEN + one.getKey());
- MiscInfoMeta.setLore(getFlagLore(one));
- MiscInfo.setItemMeta(MiscInfoMeta);
- GuiInv.setItem(i, MiscInfo);
- i++;
- if (i > 53) {
- break;
- }
- }
- setPageItem(GuiInv);
+ String title = String.format(FlagUtil.getConfig().getMessage("GUI.Set.Title"), res.getName());
+ recalculate(title, globalFlags, resFlags, res.getPermissions().getFlags(), flags);
}
public void setAdmin(final boolean state) {
@@ -278,9 +229,7 @@ public class SetFlag {
final ClickType click = event.getClick();
final InventoryAction action = event.getAction();
final ItemStack item = this.inventory.getItem(slot);
- if (item == null) {
- return;
- }
+ if (item == null) { return; }
if (slot == 53) {
if (this.page < this.pageCount) {
this.page += 1;
@@ -302,13 +251,10 @@ public class SetFlag {
command = "false";
} else if ((click.isLeftClick()) && (action == InventoryAction.MOVE_TO_OTHER_INVENTORY)) {
command = "remove";
- } else if ((click.isRightClick()) && (action == InventoryAction.MOVE_TO_OTHER_INVENTORY)) {
- return;
- }
- String flag = "";
+ } else if ((click.isRightClick()) && (action == InventoryAction.MOVE_TO_OTHER_INVENTORY)) { return; }
int i = 0;
for (final Entry one : this.permMap.entrySet()) {
- flag = one.getKey();
+ String flag = one.getKey();
if (i == slot) {
if (this.targetPlayer == null) {
if (this.admin) {
diff --git a/src/main/java/pw/yumc/Residence/listeners/ResidenceGUIListener.java b/src/main/java/pw/yumc/Residence/listeners/ResidenceGUIListener.java
index 8cb7cff..d077a74 100644
--- a/src/main/java/pw/yumc/Residence/listeners/ResidenceGUIListener.java
+++ b/src/main/java/pw/yumc/Residence/listeners/ResidenceGUIListener.java
@@ -1,39 +1,25 @@
package pw.yumc.Residence.listeners;
-import java.util.HashMap;
-import java.util.Map;
-
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.inventory.InventoryCloseEvent;
+import org.bukkit.inventory.InventoryHolder;
+import pw.yumc.Residence.gui.GuiHolder;
import pw.yumc.Residence.gui.SetFlag;
public class ResidenceGUIListener implements Listener {
- public static Map GUI = new HashMap<>();
-
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onFlagGuiClick(final InventoryClickEvent event) {
final String player = event.getWhoClicked().getName();
- if (GUI.size() == 0 || !GUI.containsKey(player)) {
- return;
- }
- event.setCancelled(true);
- final int slot = event.getRawSlot();
- if ((slot > 53) || (slot < 0)) {
- return;
- }
- final SetFlag setFlag = GUI.get(player);
- setFlag.toggleFlag(event);
- }
-
- @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
- public void onFlagGuiClose(final InventoryCloseEvent event) {
- final String player = event.getPlayer().getName();
- if (GUI.size() != 0 & GUI.containsKey(player)) {
- GUI.remove(player);
+ InventoryHolder guiHolder = event.getInventory().getHolder();
+ if (guiHolder instanceof GuiHolder) {
+ event.setCancelled(true);
+ final int slot = event.getRawSlot();
+ if ((slot > 53) || (slot < 0)) { return; }
+ final SetFlag setFlag = ((GuiHolder) guiHolder).getFlag();
+ setFlag.toggleFlag(event);
}
}
}
diff --git a/src/main/resources/gui.yml b/src/main/resources/gui.yml
index 2898822..9ddfbaf 100644
--- a/src/main/resources/gui.yml
+++ b/src/main/resources/gui.yml
@@ -1,3 +1,7 @@
+Version: 1.0
+
+#是否开启领地GUI
+Enable: true
# 图形化界面的按钮显示
GUI:
setTrue: