Reset quest compass target on changing worlds or respawning

This commit is contained in:
Nathan Wolf 2016-03-07 11:28:26 -08:00
parent 41cadcdc0a
commit afdc5760ae
2 changed files with 28 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import net.citizensnpcs.api.CitizensAPI;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
@ -35,6 +36,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerFishEvent.State;
@ -43,6 +45,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerShearEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.projectiles.ProjectileSource;
@ -860,6 +863,29 @@ public class PlayerListener implements Listener, ColorUtil {
}
@EventHandler
public void onPlayerChangeWorld(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
if (plugin.checkQuester(player.getUniqueId()) == false) {
Quester quester = plugin.getQuester(player.getUniqueId());
quester.findCompassTarget();
}
}
@EventHandler
public void onPlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
if (plugin.checkQuester(player.getUniqueId()) == false) {
final Quester quester = plugin.getQuester(player.getUniqueId());
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
quester.findCompassTarget();
}
}, 10);
}
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent evt) {

View File

@ -194,8 +194,8 @@ public class Quest {
{
targetLocation = nextStage.locationsToReach.getFirst();
}
if (targetLocation != null) {
// org.bukkit.Bukkit.getLogger().info(" setting compass target for " + quester.getPlayer().getName() + " to " + targetLocation);
if (targetLocation != null && targetLocation.getWorld().equals(quester.getPlayer().getWorld())) {
// plugin.getLogger().info("Setting compass target for " + quester.getPlayer().getName() + " to " + targetLocation);
quester.getPlayer().setCompassTarget(targetLocation);
}