mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-07-24 06:23:59 +00:00
#571 test jailing offline players. Person needs to have visited the server at least once and have a players.yml file
This commit is contained in:
parent
4d3e8332a8
commit
ce14779d2b
2 changed files with 20 additions and 3 deletions
|
@ -22,8 +22,12 @@ public class Commandtogglejail extends EssentialsCommand
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
User p = getPlayer(server, args, 0);
|
User p = getPlayer(server, args, 0, true);
|
||||||
|
|
||||||
|
if(p == null)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
if (p.isAuthorized("essentials.jail.exempt"))
|
if (p.isAuthorized("essentials.jail.exempt"))
|
||||||
{
|
{
|
||||||
sender.sendMessage(Util.i18n("mayNotJail"));
|
sender.sendMessage(Util.i18n("mayNotJail"));
|
||||||
|
|
|
@ -22,7 +22,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEssentials(IEssentials ess)
|
public void setEssentials(IEssentials ess)
|
||||||
{
|
{
|
||||||
this.ess = ess;
|
this.ess = ess;
|
||||||
|
@ -34,10 +34,23 @@ public abstract class EssentialsCommand implements IEssentialsCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
protected User getPlayer(Server server, String[] args, int pos) throws NoSuchFieldException, NotEnoughArgumentsException
|
protected User getPlayer(Server server, String[] args, int pos) throws NoSuchFieldException, NotEnoughArgumentsException
|
||||||
|
{
|
||||||
|
return getPlayer(server, args, pos, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected User getPlayer(Server server, String[] args, int pos, boolean getOffline) throws NoSuchFieldException, NotEnoughArgumentsException
|
||||||
{
|
{
|
||||||
if (args.length <= pos) throw new NotEnoughArgumentsException();
|
if (args.length <= pos) throw new NotEnoughArgumentsException();
|
||||||
List<Player> matches = server.matchPlayer(args[pos]);
|
List<Player> matches = server.matchPlayer(args[pos]);
|
||||||
if (matches.size() < 1) throw new NoSuchFieldException(Util.i18n("playerNotFound"));
|
|
||||||
|
if (matches.size() < 1)
|
||||||
|
{
|
||||||
|
if (!getOffline) throw new NoSuchFieldException(Util.i18n("playerNotFound"));
|
||||||
|
User u = ess.getOfflineUser(args[pos]);
|
||||||
|
if (u == null) throw new NoSuchFieldException(Util.i18n("playerNotFound"));
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
|
||||||
for (Player p : matches)
|
for (Player p : matches)
|
||||||
{
|
{
|
||||||
if (p.getDisplayName().startsWith(args[pos]))
|
if (p.getDisplayName().startsWith(args[pos]))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue