From 28afd6530c63116578a7c679e6c2a12f33c467ad Mon Sep 17 00:00:00 2001 From: drtshock Date: Mon, 19 May 2014 13:03:26 -0500 Subject: [PATCH] Fix f who issue with looking up offline players. Fixes issue #8 --- src/main/java/com/massivecraft/factions/FPlayer.java | 7 ++++--- src/main/java/com/massivecraft/factions/Factions.java | 1 + src/main/java/com/massivecraft/factions/cmd/FCommand.java | 4 +--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/FPlayer.java b/src/main/java/com/massivecraft/factions/FPlayer.java index 5128b185..eb603f32 100644 --- a/src/main/java/com/massivecraft/factions/FPlayer.java +++ b/src/main/java/com/massivecraft/factions/FPlayer.java @@ -15,10 +15,12 @@ import com.massivecraft.factions.zcore.persist.PlayerEntity; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import java.util.HashSet; import java.util.Set; +import java.util.UUID; /** @@ -303,9 +305,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { if (isOnline()) { return getPlayer().getName(); } - /*OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString(getId())); - return player.getName() != null ? player.getName() : getId();*/ - return getId(); + OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString(getId())); + return player.getName() != null ? player.getName() : getId(); } public String getTag() { diff --git a/src/main/java/com/massivecraft/factions/Factions.java b/src/main/java/com/massivecraft/factions/Factions.java index 4a6ac175..749c9eda 100644 --- a/src/main/java/com/massivecraft/factions/Factions.java +++ b/src/main/java/com/massivecraft/factions/Factions.java @@ -133,6 +133,7 @@ public class Factions extends EntityCollection { return errors; } + // Loops through all faction tags. Case and color insensitive. public Faction getByTag(String str) { String compStr = MiscUtil.getComparisonString(str); for (Faction faction : this.get()) { diff --git a/src/main/java/com/massivecraft/factions/cmd/FCommand.java b/src/main/java/com/massivecraft/factions/cmd/FCommand.java index d79f7d65..95e4a4b6 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/FCommand.java @@ -185,7 +185,7 @@ public abstract class FCommand extends MCommand

{ // First we try an exact match if (faction == null) { - faction = Factions.i.getByTag(name); + faction = Factions.i.getByTag(name); // Checks for faction name match. } // Next we match faction tags @@ -196,11 +196,9 @@ public abstract class FCommand extends MCommand

{ // Next we match player names if (faction == null) { OfflinePlayer player = Bukkit.getOfflinePlayer(name); - if (player.hasPlayedBefore()) { FPlayer fplayer = FPlayers.i.get(player); if (fplayer != null) { faction = fplayer.getFaction(); - } } }