Fix issues with 1.13+

Signed-off-by: DroppingAnvil <dr0pping.4nvi1@gmail.com>
This commit is contained in:
DroppingAnvil 2019-11-05 18:31:17 -06:00
parent d3870731f4
commit 441382acdc
5 changed files with 28 additions and 4 deletions

View File

@ -30,6 +30,17 @@ public interface FPlayer extends EconomyParticipator {
boolean hasNotificationsEnabled();
/**
* Used to determine if a player is in their faction's chest
* @return if player is in their faction's as a boolean
*/
boolean isInFactionsChest();
/**
* Set if the player is inside of their faction's chest
*/
void setInFactionsChest(boolean b);
boolean isAlt();
void setAlt(boolean alt);

View File

@ -19,7 +19,7 @@ public class AntiChestListener implements Listener {
public void onInventoryClick(InventoryClickEvent e) {
Player player = (Player) e.getWhoClicked();
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
if (!e.getView().getTopInventory().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")))) return;
if (!fPlayer.isInFactionsChest()) return;
if (e.isCancelled()) return;
@ -49,7 +49,7 @@ public class AntiChestListener implements Listener {
Player p = (Player) e.getWhoClicked();
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(p);
if (!e.getView().getTopInventory().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")))) return;
if (!fPlayer.isInFactionsChest()) return;
if (e.isCancelled()) return;
ItemStack dragged = e.getOldCursor();

View File

@ -30,6 +30,7 @@ public class CmdChest extends FCommand {
return;
}
// This permission check is way too explicit but it's clean
context.fPlayer.setInFactionsChest(true);
context.player.openInventory(context.faction.getChestInventory());
}

View File

@ -791,8 +791,8 @@ public class FactionsPlayerListener implements Listener {
@EventHandler
public void onClose(InventoryCloseEvent e) {
FPlayer fme = FPlayers.getInstance().getById(e.getPlayer().getUniqueId().toString());
if (fme.isInVault())
fme.setInVault(false);
if (fme.isInVault()) fme.setInVault(false);
if (fme.isInFactionsChest()) fme.setInFactionsChest(false);
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@ -1011,6 +1011,11 @@ public class FactionsPlayerListener implements Listener {
}
}
}
@EventHandler
public void onDisconnect(PlayerQuitEvent e) {
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(e.getPlayer());
if (fPlayer.isInFactionsChest()) fPlayer.setInFactionsChest(false);
}
private static class InteractAttemptSpam {
private int attempts = 0;

View File

@ -41,6 +41,7 @@ import java.util.*;
*/
public abstract class MemoryFPlayer implements FPlayer {
public boolean inChest = false;
public boolean inVault = false;
protected HashMap<String, Long> commandCooldown = new HashMap<>();
protected String factionId;
@ -963,6 +964,12 @@ public abstract class MemoryFPlayer implements FPlayer {
isFlying = fly;
}
public boolean isInFactionsChest() {
return inChest;
}
public void setInFactionsChest(boolean b) {
inChest = b;
}
public boolean isInVault() {
return inVault;
}