From 27c45bf7f356aaea6f067c4c7d0d5845953176b6 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Mon, 10 Oct 2011 01:43:21 +0200 Subject: [PATCH] Fixed who command and detatched the argument reading a bit. --- .../massivecraft/factions/cmd/CmdShow.java | 8 +++-- .../massivecraft/factions/zcore/MCommand.java | 35 +++++++++++-------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/com/massivecraft/factions/cmd/CmdShow.java b/src/com/massivecraft/factions/cmd/CmdShow.java index 85150426..976cabd5 100644 --- a/src/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/com/massivecraft/factions/cmd/CmdShow.java @@ -33,8 +33,12 @@ public class CmdShow extends FCommand @Override public void perform() { - Faction faction = this.argAsFaction(0, myFaction); - if (faction == null) return; + Faction faction = myFaction; + if (this.argIsSet(0)) + { + faction = this.argAsFaction(0); + if (faction == null) return; + } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay if ( ! payForCommand(Conf.econCostShow)) return; diff --git a/src/com/massivecraft/factions/zcore/MCommand.java b/src/com/massivecraft/factions/zcore/MCommand.java index fb2905f6..1f978ec6 100644 --- a/src/com/massivecraft/factions/zcore/MCommand.java +++ b/src/com/massivecraft/factions/zcore/MCommand.java @@ -331,9 +331,8 @@ public abstract class MCommand } // INT ====================== - public int argAsInt(int idx, int def) + public int strAsInt(String str, int def) { - String str = this.argAsString(idx); if (str == null) return def; try { @@ -345,15 +344,18 @@ public abstract class MCommand return def; } } + public int argAsInt(int idx, int def) + { + return strAsInt(this.argAsString(idx), def); + } public int argAsInt(int idx) { return this.argAsInt(idx, -1); } // Double ====================== - public double argAsDouble(int idx, double def) + public double strAsDouble(String str, double def) { - String str = this.argAsString(idx); if (str == null) return def; try { @@ -365,6 +367,10 @@ public abstract class MCommand return def; } } + public double argAsDouble(int idx, double def) + { + return strAsDouble(this.argAsString(idx), def); + } public double argAsDouble(int idx) { return this.argAsDouble(idx, -1d); @@ -381,7 +387,6 @@ public abstract class MCommand } return false; } - public Boolean argAsBool(int idx, boolean def) { String str = this.argAsString(idx); @@ -395,12 +400,10 @@ public abstract class MCommand } // PLAYER ====================== - - public Player argAsPlayer(int idx, Player def, boolean msg) + public Player strAsPlayer(String name, Player def, boolean msg) { Player ret = def; - String name = this.argAsString(idx); if (name != null) { Player player = Bukkit.getServer().getPlayer(name); @@ -417,6 +420,11 @@ public abstract class MCommand return ret; } + + public Player argAsPlayer(int idx, Player def, boolean msg) + { + return this.strAsPlayer(this.argAsString(idx), def, msg); + } public Player argAsPlayer(int idx, Player def) { return this.argAsPlayer(idx, def, true); @@ -427,11 +435,10 @@ public abstract class MCommand } // BEST PLAYER MATCH ====================== - public Player argAsBestPlayerMatch(int idx, Player def, boolean msg) + public Player strAsBestPlayerMatch(String name, Player def, boolean msg) { Player ret = def; - String name = this.argAsString(idx); if (name != null) { List players = Bukkit.getServer().matchPlayer(name); @@ -448,6 +455,10 @@ public abstract class MCommand return ret; } + public Player argAsBestPlayerMatch(int idx, Player def, boolean msg) + { + return this.strAsBestPlayerMatch(this.argAsString(idx), def, msg); + } public Player argAsBestPlayerMatch(int idx, Player def) { return this.argAsBestPlayerMatch(idx, def, true); @@ -456,8 +467,4 @@ public abstract class MCommand { return this.argAsPlayer(idx, null); } - - - - }