From ad69019ba6f8152099eb529ec3eecec7daff8656 Mon Sep 17 00:00:00 2001 From: Driftay Date: Fri, 3 Jan 2020 18:53:01 -0500 Subject: [PATCH] Fixed F Chest Logging --- .../massivecraft/factions/cmd/CmdDisband.java | 4 +-- .../massivecraft/factions/cmd/CmdHelp.java | 2 +- .../factions/cmd/audit/FChestListener.java | 30 ++++++++++--------- .../factions/cmd/claim/CmdUnclaimall.java | 2 ++ .../factions/cmd/grace/CmdGrace.java | 2 ++ .../listeners/FactionsPlayerListener.java | 7 +++++ .../zcore/fupgrades/FUpgradesGUI.java | 1 + 7 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java index fa33c1f9..f32ce555 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java @@ -20,6 +20,7 @@ public class CmdDisband extends FCommand { * @author FactionsUUID Team */ + //TODO: Add Disband Confirmation GUI private static HashMap disbandMap = new HashMap<>(); @@ -27,12 +28,9 @@ public class CmdDisband extends FCommand { public CmdDisband() { super(); this.aliases.addAll(Aliases.disband); - this.optionalArgs.put("faction tag", "yours"); - this.requirements = new CommandRequirements.Builder(Permission.DISBAND) .build(); - } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java b/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java index f16c6b84..bddf7b2c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java @@ -18,7 +18,7 @@ public class CmdHelp extends FCommand { */ public ArrayList> helpPages; - + //TODO: Add Help GUI public CmdHelp() { super(); this.aliases.addAll(Aliases.help); diff --git a/src/main/java/com/massivecraft/factions/cmd/audit/FChestListener.java b/src/main/java/com/massivecraft/factions/cmd/audit/FChestListener.java index 3415f1a6..b8f8ea74 100644 --- a/src/main/java/com/massivecraft/factions/cmd/audit/FChestListener.java +++ b/src/main/java/com/massivecraft/factions/cmd/audit/FChestListener.java @@ -36,6 +36,7 @@ public class FChestListener implements Listener { e.getWhoClicked().sendMessage(CC.RedB + "(!) " + CC.Red + "You cannot drag items while viewing a /f chest!"); } + @EventHandler( priority = EventPriority.HIGHEST, ignoreCancelled = true @@ -43,7 +44,8 @@ public class FChestListener implements Listener { public void onPlayerClickInventory(InventoryClickEvent event) { Player player = (Player) event.getWhoClicked(); FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); - if (!fPlayer.isInFactionsChest()) return; + Faction faction; + if(!event.getView().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")))) return; if (event.getClick() == ClickType.UNKNOWN) { event.setCancelled(true); player.sendMessage(CC.RedB + "(!) " + CC.Red + "You cannot use that click type inside the /f chest!"); @@ -55,30 +57,30 @@ public class FChestListener implements Listener { ItemStack cursorItem = event.getCursor(); if (event.getClick() == ClickType.NUMBER_KEY) cursorItem = player.getInventory().getItem(event.getHotbarButton()); Material cursorItemType = cursorItem != null ? cursorItem.getType() : Material.AIR; - FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); - Faction faction; - if (fplayer == null || !(faction = fplayer.getFaction()).isNormal()) { + if (fPlayer == null || !(faction = fPlayer.getFaction()).isNormal()) { player.closeInventory(); player.sendMessage(CC.RedB + "(!) " + CC.Red + "You are no longer in your faction!"); return; } if (event.getClickedInventory() == null) return; - if (event.getView().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")))) { + if (event.getView().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title"))) && !event.getClick().isShiftClick()) { if (currentItemType != Material.AIR) { Inventory ours = faction.getChestInventory(); - if (ours == null || !ours.contains(currentItem)) { - event.setCancelled(true); - player.sendMessage(CC.RedB + "(!) That item not longer exists!"); - Bukkit.getLogger().info("[FactionChest] " + player.getName() + " tried to remove " + currentItem + " from /f chest when it didnt contain! Items: " + (ours == null ? "none" : Arrays.toString(ours.getContents()))); - player.closeInventory(); - return; + if(event.getClickedInventory() == ours) { + if (ours == null || !ours.contains(currentItem)) { + event.setCancelled(true); + player.sendMessage(CC.RedB + "(!) That item not longer exists!"); + Bukkit.getLogger().info("[FactionChest] " + player.getName() + " tried to remove " + currentItem + " from /f chest when it didnt contain! Items: " + (ours == null ? "none" : Arrays.toString(ours.getContents()))); + player.closeInventory(); + return; + } } - logRemoveItem(currentItem, fplayer, player); + logRemoveItem(currentItem, fPlayer, player); } else if (cursorItemType != Material.AIR && !event.isShiftClick()) { - logAddItem(cursorItem, fplayer, player); + logAddItem(cursorItem, fPlayer, player); } } else if (event.isShiftClick() && currentItemType != Material.AIR) { - logAddItem(currentItem, fplayer, player); + logAddItem(currentItem, fPlayer, player); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/claim/CmdUnclaimall.java b/src/main/java/com/massivecraft/factions/cmd/claim/CmdUnclaimall.java index 0db8f70b..b430306d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/claim/CmdUnclaimall.java +++ b/src/main/java/com/massivecraft/factions/cmd/claim/CmdUnclaimall.java @@ -20,6 +20,8 @@ public class CmdUnclaimall extends FCommand { * @author FactionsUUID Team */ + //TODO: Add UnclaimAll Confirmation GUI + public CmdUnclaimall() { this.aliases.addAll(Aliases.unclaim_all_unsafe); diff --git a/src/main/java/com/massivecraft/factions/cmd/grace/CmdGrace.java b/src/main/java/com/massivecraft/factions/cmd/grace/CmdGrace.java index 29a4e3f7..a7fc3a68 100644 --- a/src/main/java/com/massivecraft/factions/cmd/grace/CmdGrace.java +++ b/src/main/java/com/massivecraft/factions/cmd/grace/CmdGrace.java @@ -15,6 +15,8 @@ public class CmdGrace extends FCommand { * @author Driftay */ + //TODO: Make Timed Format For Grace Period + public CmdGrace() { super(); this.aliases.addAll(Aliases.grace); diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index f3c95f3e..8017755e 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -577,6 +577,13 @@ public class FactionsPlayerListener implements Listener { } + @EventHandler + public void onCommand(PlayerCommandPreprocessEvent e){ + if(e.getMessage().equalsIgnoreCase("/f outpost")){ + e.setMessage("/outpost"); + } + } + //inspect @EventHandler public void onInspect(PlayerInteractEvent e) { diff --git a/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradesGUI.java b/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradesGUI.java index 6eb56104..898ad478 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradesGUI.java +++ b/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradesGUI.java @@ -300,6 +300,7 @@ public class FUpgradesGUI implements Listener { faction.setChestSize(size * 9); } + private void updatePower(Faction faction) { int level = faction.getUpgrade(UpgradeType.POWER); double power = 0.0;