Fix island upgrades persisting after leaving island

This commit is contained in:
Esophose 2019-02-21 19:43:30 -07:00
parent 2234462424
commit 761e94bfd8

View File

@ -1,5 +1,18 @@
package me.goodandevil.skyblock.listeners;
import java.io.File;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.scheduler.BukkitRunnable;
import me.goodandevil.skyblock.SkyBlock;
import me.goodandevil.skyblock.api.event.player.PlayerIslandEnterEvent;
import me.goodandevil.skyblock.api.event.player.PlayerIslandExitEvent;
@ -17,17 +30,6 @@ import me.goodandevil.skyblock.utils.version.NMSUtil;
import me.goodandevil.skyblock.utils.version.Sounds;
import me.goodandevil.skyblock.visit.Visit;
import me.goodandevil.skyblock.world.WorldManager;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import java.io.File;
import java.util.UUID;
public class Teleport implements Listener {
@ -51,7 +53,14 @@ public class Teleport implements Listener {
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
islandManager.removeUpgrades(player, false);
// Needs to be called after the teleport occurs otherwise the player location hasn't updated yet
new BukkitRunnable() {
@Override
public void run() {
islandManager.removeUpgrades(player, false);
}
}.runTaskLater(SkyBlock.getInstance(), 1);
islandManager.loadPlayer(player);
if (worldManager.isIslandWorld(player.getWorld())) {