mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-07-27 07:52:06 +00:00
Cleanup player argument matching in loops
Cleanup ess cleanup timestamp matching
This commit is contained in:
parent
2d70bb19f7
commit
162b67aaa6
10 changed files with 212 additions and 156 deletions
|
@ -237,6 +237,7 @@ public class Commandessentials extends EssentialsCommand
|
|||
@Override
|
||||
public void run()
|
||||
{
|
||||
Long currTime = System.currentTimeMillis();
|
||||
for (String u : userMap.getAllUniqueUsers())
|
||||
{
|
||||
final User user = ess.getUserMap().getUser(u);
|
||||
|
@ -246,8 +247,18 @@ public class Commandessentials extends EssentialsCommand
|
|||
}
|
||||
|
||||
int ban = user.getBanReason().equals("") ? 0 : 1;
|
||||
|
||||
long lastLog = user.getLastLogout();
|
||||
long timeDiff = System.currentTimeMillis() - lastLog;
|
||||
if (lastLog == 0)
|
||||
{
|
||||
lastLog = user.getLastLogin();
|
||||
}
|
||||
if (lastLog == 0)
|
||||
{
|
||||
user.setLastLogin(currTime);
|
||||
}
|
||||
|
||||
long timeDiff = currTime - lastLog;
|
||||
long milliDays = daysArg * 24L * 60L * 60L * 1000L;
|
||||
int homeCount = user.getHomes().size();
|
||||
double moneyCount = user.getMoney().doubleValue();
|
||||
|
|
|
@ -36,7 +36,12 @@ public class Commandext extends EssentialsCommand
|
|||
return;
|
||||
}
|
||||
|
||||
extinguishPlayers(server, user, commandLabel);
|
||||
if (args[0].trim().length() < 2)
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
|
||||
extinguishPlayers(server, user, args[0]);
|
||||
}
|
||||
|
||||
private void extinguishPlayers(final Server server, final CommandSender sender, final String name) throws Exception
|
||||
|
|
|
@ -21,12 +21,23 @@ public class Commandfeed extends EssentialsCommand
|
|||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.feed.others"))
|
||||
{
|
||||
feedOtherPlayers(server, user, args[0]);
|
||||
}
|
||||
else
|
||||
if (args[0].trim().length() < 2)
|
||||
{
|
||||
feedPlayer(user, user);
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
if (!user.isAuthorized("essentials.heal.cooldown.bypass"))
|
||||
{
|
||||
user.healCooldown();
|
||||
}
|
||||
feedOtherPlayers(server, user, args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!user.isAuthorized("essentials.heal.cooldown.bypass"))
|
||||
{
|
||||
user.healCooldown();
|
||||
}
|
||||
feedPlayer(user, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -41,12 +41,20 @@ public class Commandfly extends EssentialsCommand
|
|||
}
|
||||
else if (user.isAuthorized("essentials.fly.others"))
|
||||
{
|
||||
if (args[0].trim().length() < 2)
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
flyOtherPlayers(server, user, args);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (args.length == 2 && user.isAuthorized("essentials.fly.others"))
|
||||
{
|
||||
if (args[0].trim().length() < 2)
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
flyOtherPlayers(server, user, args);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -29,8 +29,12 @@ public class Commandgod extends EssentialsCommand
|
|||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.god.others"))
|
||||
if (args.length > 0 && user.isAuthorized("essentials.god.others"))
|
||||
{
|
||||
if (args[0].trim().length() < 2)
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
godOtherPlayers(server, user, args);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,10 @@ public class Commandheal extends EssentialsCommand
|
|||
|
||||
if (args.length > 0 && user.isAuthorized("essentials.heal.others"))
|
||||
{
|
||||
if (args[0].trim().length() < 2)
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
if (!user.isAuthorized("essentials.heal.cooldown.bypass"))
|
||||
{
|
||||
user.healCooldown();
|
||||
|
|
|
@ -43,6 +43,11 @@ public class Commandlightning extends EssentialsCommand
|
|||
}
|
||||
}
|
||||
|
||||
if (args[0].trim().length() < 2)
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
|
||||
final List<Player> matchedPlayers = server.matchPlayer(args[0]);
|
||||
for (Player matchPlayer : matchedPlayers)
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@ public class Commandpweather extends EssentialsCommand
|
|||
}
|
||||
|
||||
User user = ess.getUser(sender);
|
||||
if (user != null && (!users.contains(user) || users.size() > 1)&& !user.isAuthorized("essentials.pweather.others"))
|
||||
if (user != null && (!users.contains(user) || users.size() > 1) && !user.isAuthorized("essentials.pweather.others"))
|
||||
{
|
||||
user.sendMessage(_("pWeatherOthersPermission"));
|
||||
return;
|
||||
|
@ -90,7 +90,7 @@ public class Commandpweather extends EssentialsCommand
|
|||
/**
|
||||
* Used to set the time and inform of the change
|
||||
*/
|
||||
private void setUsersWeather(final CommandSender sender, final Collection<User> users, final String weatherType ) throws Exception
|
||||
private void setUsersWeather(final CommandSender sender, final Collection<User> users, final String weatherType) throws Exception
|
||||
{
|
||||
|
||||
final StringBuilder msg = new StringBuilder();
|
||||
|
|
|
@ -49,6 +49,10 @@ public class Commandspeed extends EssentialsCommand
|
|||
speed = getMoveSpeed(args[1]);
|
||||
if (args.length > 2 && user.isAuthorized("essentials.speed.others"))
|
||||
{
|
||||
if (args[2].trim().length() < 2)
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
speedOtherPlayers(server, user, isFly, isBypass, speed, args[2]);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -29,8 +29,12 @@ public class Commandtptoggle extends EssentialsCommand
|
|||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.tptoggle.others"))
|
||||
if (args.length > 0 && user.isAuthorized("essentials.tptoggle.others"))
|
||||
{
|
||||
if (args[0].trim().length() < 2)
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
toggleOtherPlayers(server, user, args);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue