Fix arbitrary command order for ARSenderIdAbstract.

This commit is contained in:
Olof Larsson 2015-05-11 22:10:37 +02:00
parent be7c3da1b7
commit d42c363086

View File

@ -8,6 +8,7 @@ import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.store.SenderIdSource;
import com.massivecraft.massivecore.util.IdUtil;
import com.massivecraft.massivecore.util.MUtil;
public abstract class ARSenderIdAbstract<T> extends ARAbstract<T>
{
@ -71,6 +72,23 @@ public abstract class ARSenderIdAbstract<T> extends ARAbstract<T>
return ret;
}
// This is used for arbitrary command order.
// There might be no matching sender at this time, but that does not matter.
// As long as the format is correct the arg is valid.
@Override
public boolean isValid(String arg, CommandSender sender)
{
// Allow names and uuid by format.
if (MUtil.isValidPlayerName(arg)) return true;
if (MUtil.isValidUUID(arg)) return true;
// Check data presence. This handles specials like "@console".
if (IdUtil.getIdToData().containsKey(arg)) return true;
if (IdUtil.getNameToData().containsKey(arg)) return true;
return false;
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //