Fixed dupe bug when removing farms.

This commit is contained in:
Fernando Pettinelli 2021-01-25 22:42:30 -03:00 committed by Brianna
parent 25bb3b1c4e
commit e6ecdb5deb
3 changed files with 11 additions and 0 deletions

View File

@ -65,6 +65,14 @@ public class Farm {
EpicFarming.getInstance().getGuiManager().showGUI(player, opened);
}
public void forceMenuClose() {
if (opened == null) {
return;
}
opened.close();
}
public void upgrade(UpgradeType type, Player player) {
EpicFarming instance = EpicFarming.getInstance();
if (instance.getLevelManager().getLevels().containsKey(this.level.getLevel() + 1)) {

View File

@ -112,6 +112,7 @@ public class BlockListeners implements Listener {
if (farm == null) return;
plugin.getDataManager().deleteFarm(farm);
farm.forceMenuClose();
FarmTask.getCrops(farm, false);
@ -140,6 +141,7 @@ public class BlockListeners implements Listener {
FarmTask.getCrops(farm, false);
plugin.getDataManager().deleteFarm(farm);
farm.forceMenuClose();
event.setCancelled(true);

View File

@ -110,6 +110,7 @@ public class EntityListeners implements Listener {
Farm farm = plugin.getFarmManager().removeFarm(block.getLocation());
plugin.getDataManager().deleteFarm(farm);
farm.forceMenuClose();
FarmTask.getCrops(farm, false);