Fix f who issue with looking up offline players. Fixes issue #8

This commit is contained in:
drtshock 2014-05-19 13:03:26 -05:00
parent 9a7ecf33a7
commit 28afd6530c
3 changed files with 6 additions and 6 deletions

View File

@ -15,10 +15,12 @@ import com.massivecraft.factions.zcore.persist.PlayerEntity;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID;
/** /**
@ -303,9 +305,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
if (isOnline()) { if (isOnline()) {
return getPlayer().getName(); return getPlayer().getName();
} }
/*OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString(getId())); OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString(getId()));
return player.getName() != null ? player.getName() : getId();*/ return player.getName() != null ? player.getName() : getId();
return getId();
} }
public String getTag() { public String getTag() {

View File

@ -133,6 +133,7 @@ public class Factions extends EntityCollection<Faction> {
return errors; return errors;
} }
// Loops through all faction tags. Case and color insensitive.
public Faction getByTag(String str) { public Faction getByTag(String str) {
String compStr = MiscUtil.getComparisonString(str); String compStr = MiscUtil.getComparisonString(str);
for (Faction faction : this.get()) { for (Faction faction : this.get()) {

View File

@ -185,7 +185,7 @@ public abstract class FCommand extends MCommand<P> {
// First we try an exact match // First we try an exact match
if (faction == null) { if (faction == null) {
faction = Factions.i.getByTag(name); faction = Factions.i.getByTag(name); // Checks for faction name match.
} }
// Next we match faction tags // Next we match faction tags
@ -196,11 +196,9 @@ public abstract class FCommand extends MCommand<P> {
// Next we match player names // Next we match player names
if (faction == null) { if (faction == null) {
OfflinePlayer player = Bukkit.getOfflinePlayer(name); OfflinePlayer player = Bukkit.getOfflinePlayer(name);
if (player.hasPlayedBefore()) {
FPlayer fplayer = FPlayers.i.get(player); FPlayer fplayer = FPlayers.i.get(player);
if (fplayer != null) { if (fplayer != null) {
faction = fplayer.getFaction(); faction = fplayer.getFaction();
}
} }
} }