Check for a null destination

This commit is contained in:
Xephi59 2015-11-03 23:40:23 +01:00
parent 21ea54d604
commit f4d8e45733

View File

@ -1,5 +1,23 @@
package fr.xephi.authme.commands;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scheduler.BukkitTask;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
@ -14,23 +32,6 @@ import fr.xephi.authme.task.MessageTask;
import fr.xephi.authme.task.TimeoutTask;
import fr.xephi.authme.util.Utils;
import fr.xephi.authme.util.Utils.GroupType;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scheduler.BukkitTask;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class AdminCommand implements CommandExecutor {
@ -43,7 +44,7 @@ public class AdminCommand implements CommandExecutor {
@Override
public boolean onCommand(final CommandSender sender, Command cmnd,
String label, String[] args) {
String label, String[] args) {
if (args.length == 0) {
sender.sendMessage("Usage:");
sender.sendMessage("/authme reload - Reload the config");
@ -195,6 +196,7 @@ public class AdminCommand implements CommandExecutor {
} else {
final String[] arguments = args;
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
StringBuilder message = new StringBuilder("[AuthMe] ");
@ -262,6 +264,7 @@ public class AdminCommand implements CommandExecutor {
}
}
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@SuppressWarnings("deprecation")
@Override
public void run() {
@ -484,7 +487,7 @@ public class AdminCommand implements CommandExecutor {
Location spawn = plugin.getSpawnLocation(target);
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(target, target.getLocation(), spawn, false);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
if (!tpEvent.isCancelled() && tpEvent.getTo() != null) {
target.teleport(tpEvent.getTo());
}
}