Skip to content

Commit

Permalink
Fixed teleporting to warps from the menu opens the previous one
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Dec 9, 2022
1 parent 0650ded commit e0c70e3
Showing 1 changed file with 9 additions and 3 deletions.
Expand Up @@ -28,7 +28,6 @@
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -78,8 +77,15 @@ public void simulateClick(SuperiorPlayer superiorPlayer, Island island, IslandWa
}

BukkitExecutor.sync(() -> {
superiorPlayer.runIfOnline(Player::closeInventory);
island.warpPlayer(superiorPlayer, islandWarp.getName());
superiorPlayer.runIfOnline(player -> {
MenuView<?, ?> currentView = superiorPlayer.getOpenedView();
if (currentView == null) {
player.closeInventory();
} else {
currentView.closeView();
}
island.warpPlayer(superiorPlayer, islandWarp.getName());
});
}, 1L);
}

Expand Down

0 comments on commit e0c70e3

Please sign in to comment.