Rework the ARFaction. No best match. Matching is slow and dangerous.

This commit is contained in:
Olof Larsson
2014-10-13 08:11:00 +02:00
parent 6974c82bb6
commit b54293577d
4 changed files with 27 additions and 30 deletions

View File

@@ -5,6 +5,7 @@ import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.cmd.arg.ArgReaderAbstract;
import com.massivecraft.massivecore.cmd.arg.ArgResult;
import com.massivecraft.massivecore.util.IdUtil;
@@ -28,12 +29,22 @@ public class ARFaction extends ArgReaderAbstract<Faction>
{
ArgResult<Faction> result = new ArgResult<Faction>();
// Faction Name Exact
result.setResult(FactionColl.get().getByName(str));
if (result.hasResult()) return result;
// Nothing/Remove targets Wilderness
if (MassiveCore.NOTHING_REMOVE.contains(str))
{
result.setResult(FactionColl.get().getNone());
return result;
}
// Faction Name Match
result.setResult(FactionColl.get().getBestNameMatch(str));
// Faction Id Exact
if (FactionColl.get().containsId(str))
{
result.setResult(FactionColl.get().get(str));
if (result.hasResult()) return result;
}
// Faction Name Exact
result.setResult(FactionColl.get().getByName(str));
if (result.hasResult()) return result;
// MPlayer Name Exact