mirror of
https://github.com/songoda/EpicFarming.git
synced 2025-02-22 15:31:34 +01:00
Auto stash before cherrypick of "fix"
This commit is contained in:
parent
674abf314e
commit
81fddfa1a0
@ -30,6 +30,8 @@ public class EFarm implements Farm {
|
||||
private Inventory inventory;
|
||||
private UUID placedBy;
|
||||
|
||||
private UUID viewing = null;
|
||||
|
||||
private long lastCached = 0;
|
||||
private final List<Block> cachedCrops = new ArrayList<>();
|
||||
|
||||
@ -45,9 +47,13 @@ public class EFarm implements Farm {
|
||||
if (!player.hasPermission("epicfarming.view"))
|
||||
return;
|
||||
|
||||
if (viewing != null) return;
|
||||
|
||||
setupOverview(player);
|
||||
|
||||
player.openInventory(inventory);
|
||||
this.viewing = player.getUniqueId();
|
||||
|
||||
PlayerData playerData = EpicFarmingPlugin.getInstance().getPlayerActionManager().getPlayerAction(player);
|
||||
|
||||
playerData.setFarm(this);
|
||||
@ -282,6 +288,14 @@ public class EFarm implements Farm {
|
||||
return false;
|
||||
}
|
||||
|
||||
public UUID getViewing() {
|
||||
return viewing;
|
||||
}
|
||||
|
||||
public void setViewing(UUID viewing) {
|
||||
this.viewing = viewing;
|
||||
}
|
||||
|
||||
public void addCachedCrop(Block block) {
|
||||
cachedCrops.add(block);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.songoda.epicfarming.listeners;
|
||||
import com.songoda.epicfarming.EpicFarmingPlugin;
|
||||
import com.songoda.epicfarming.api.farming.UpgradeType;
|
||||
import com.songoda.epicfarming.farming.EFarm;
|
||||
import com.songoda.epicfarming.player.PlayerActionManager;
|
||||
import com.songoda.epicfarming.player.PlayerData;
|
||||
import com.songoda.epicfarming.utils.Debugger;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -58,6 +59,12 @@ public class InventoryListeners implements Listener {
|
||||
@EventHandler
|
||||
public void onClose(InventoryCloseEvent event) {
|
||||
try {
|
||||
PlayerData playerData = instance.getPlayerActionManager().getPlayerAction((Player)event.getPlayer());
|
||||
|
||||
if (playerData.getFarm() != null) {
|
||||
playerData.getFarm().setViewing(null);
|
||||
}
|
||||
|
||||
instance.getPlayerActionManager().getPlayerAction((Player)event.getPlayer()).setFarm(null);
|
||||
} catch (Exception ex) {
|
||||
Debugger.runReport(ex);
|
||||
|
Loading…
Reference in New Issue
Block a user