Don't allow online players as command argument if not visible
This commit is contained in:
parent
f23b42e118
commit
1281173689
@ -111,14 +111,21 @@ public abstract class TypeSenderIdAbstract<T> extends TypeAbstract<T>
|
|||||||
// All of our subclasses return null if senderId is null.
|
// All of our subclasses return null if senderId is null.
|
||||||
// Thus we don't need to check for that being null, but only check ret.
|
// Thus we don't need to check for that being null, but only check ret.
|
||||||
|
|
||||||
|
// If presence is online or local ...
|
||||||
|
if (this.presence == SenderPresence.LOCAL || this.presence == SenderPresence.ONLINE)
|
||||||
|
{
|
||||||
|
// ... and the target is not visible for the sender ...
|
||||||
|
if (!MixinVisibility.get().isVisible(senderId, sender))
|
||||||
|
{
|
||||||
|
// .. throw an error.
|
||||||
|
throwError(arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create & populate Ret
|
// Create & populate Ret
|
||||||
T ret = this.getResultForSenderId(senderId);
|
T ret = this.getResultForSenderId(senderId);
|
||||||
|
|
||||||
if (ret == null)
|
if (ret == null) throwError(arg);
|
||||||
{
|
|
||||||
// No alternatives found
|
|
||||||
throw new MassiveException().addMessage(this.getErrorMessageForArg(arg));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return Ret
|
// Return Ret
|
||||||
return ret;
|
return ret;
|
||||||
@ -178,6 +185,11 @@ public abstract class TypeSenderIdAbstract<T> extends TypeAbstract<T>
|
|||||||
// UTIL
|
// UTIL
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public void throwError(String arg) throws MassiveException
|
||||||
|
{
|
||||||
|
throw new MassiveException().addMessage(this.getErrorMessageForArg(arg));
|
||||||
|
}
|
||||||
|
|
||||||
public String getErrorMessageForArg(String arg)
|
public String getErrorMessageForArg(String arg)
|
||||||
{
|
{
|
||||||
return Txt.parse("<b>No %s matches \"<h>%s<b>\".", this.getName(), arg);
|
return Txt.parse("<b>No %s matches \"<h>%s<b>\".", this.getName(), arg);
|
||||||
|
Loading…
Reference in New Issue
Block a user