From 7ebed6db9c275d66194bd79c9acd326daa028b75 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Sat, 22 Oct 2011 17:42:13 +0200 Subject: [PATCH] Improving the faction tag matching --- src/com/massivecraft/factions/Faction.java | 13 ++++++++----- src/com/massivecraft/factions/cmd/FCommand.java | 15 +++++++++++++-- src/com/massivecraft/factions/util/MiscUtil.java | 1 + 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/com/massivecraft/factions/Faction.java b/src/com/massivecraft/factions/Faction.java index 8666cd95..8b872aeb 100644 --- a/src/com/massivecraft/factions/Faction.java +++ b/src/com/massivecraft/factions/Faction.java @@ -188,7 +188,7 @@ public class Faction extends Entity implements EconomyParticipator // ------------------------------- - // Relation and relation colors TODO + // Relation and relation colors // ------------------------------- @Override @@ -298,7 +298,7 @@ public class Faction extends Entity implements EconomyParticipator } // ------------------------------- - // Fplayers + // FPlayers // ------------------------------- public ArrayList getFPlayers() @@ -347,12 +347,15 @@ public class Faction extends Entity implements EconomyParticipator return null; } - public ArrayList getFPlayersWhereRole(Role role) { + public ArrayList getFPlayersWhereRole(Role role) + { ArrayList ret = new ArrayList(); if ( ! this.isNormal()) return ret; - for (FPlayer fplayer : FPlayers.i.get()) { - if (fplayer.getFaction() == this && fplayer.getRole() == role) { + for (FPlayer fplayer : FPlayers.i.get()) + { + if (fplayer.getFaction() == this && fplayer.getRole() == role) + { ret.add(fplayer); } } diff --git a/src/com/massivecraft/factions/cmd/FCommand.java b/src/com/massivecraft/factions/cmd/FCommand.java index edb95b64..5863cbf6 100644 --- a/src/com/massivecraft/factions/cmd/FCommand.java +++ b/src/com/massivecraft/factions/cmd/FCommand.java @@ -223,9 +223,20 @@ public abstract class FCommand extends MCommand

if (name != null) { - // First we match faction tags - Faction faction = Factions.i.getBestTagMatch(name); + Faction faction = null; + // First we try an exact match + if (faction == null) + { + faction = Factions.i.getByTag(name); + } + + // Next we match faction tags + if (faction == null) + { + faction = Factions.i.getBestTagMatch(name); + } + // Next we match player names if (faction == null) { diff --git a/src/com/massivecraft/factions/util/MiscUtil.java b/src/com/massivecraft/factions/util/MiscUtil.java index 4569c78e..cb1878fe 100644 --- a/src/com/massivecraft/factions/util/MiscUtil.java +++ b/src/com/massivecraft/factions/util/MiscUtil.java @@ -53,6 +53,7 @@ public class MiscUtil String ret = ""; str = ChatColor.stripColor(str); + str = str.toLowerCase(); for (char c : str.toCharArray()) {