mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-01 14:07:46 +01:00
Little more command cleanup.
This commit is contained in:
parent
5655509c62
commit
a05f730e76
@ -16,15 +16,15 @@ public class Commandkickall extends EssentialsCommand
|
|||||||
@Override
|
@Override
|
||||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
{
|
{
|
||||||
for (Player onlinePlaer : server.getOnlinePlayers())
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (sender instanceof Player && onlinePlaer.getName().equalsIgnoreCase(((Player)sender).getName()))
|
if (sender instanceof Player && onlinePlayer.getName().equalsIgnoreCase(((Player)sender).getName()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
onlinePlaer.kickPlayer(args.length > 0 ? getFinalArg(args, 0) : Util.i18n("kickDefault"));
|
onlinePlayer.kickPlayer(args.length > 0 ? getFinalArg(args, 0) : Util.i18n("kickDefault"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,24 +15,24 @@ public class Commandkill extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
{
|
{
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player p : server.matchPlayer(args[0]))
|
for (Player matchPlayer : server.matchPlayer(args[0]))
|
||||||
{
|
{
|
||||||
final EntityDamageEvent ede = new EntityDamageEvent(p, sender instanceof Player && ((Player)sender).getName().equals(p.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, 1000);
|
final EntityDamageEvent ede = new EntityDamageEvent(matchPlayer, sender instanceof Player && ((Player)sender).getName().equals(matchPlayer.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, 1000);
|
||||||
server.getPluginManager().callEvent(ede);
|
server.getPluginManager().callEvent(ede);
|
||||||
if (ede.isCancelled() && !sender.hasPermission("essentials.kill.force"))
|
if (ede.isCancelled() && !sender.hasPermission("essentials.kill.force"))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.setHealth(0);
|
matchPlayer.setHealth(0);
|
||||||
sender.sendMessage(Util.format("kill", p.getDisplayName()));
|
sender.sendMessage(Util.format("kill", matchPlayer.getDisplayName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,11 +29,11 @@ public class Commandkit extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
final Map<String, Object> kits = ess.getSettings().getKits();
|
final Map<String, Object> kits = ess.getSettings().getKits();
|
||||||
final StringBuilder list = new StringBuilder();
|
final StringBuilder list = new StringBuilder();
|
||||||
for (String k : kits.keySet())
|
for (String kiteItem : kits.keySet())
|
||||||
{
|
{
|
||||||
if (user.isAuthorized("essentials.kit." + k.toLowerCase()))
|
if (user.isAuthorized("essentials.kit." + kiteItem.toLowerCase()))
|
||||||
{
|
{
|
||||||
list.append(" ").append(k);
|
list.append(" ").append(kiteItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (list.length() > 0)
|
if (list.length() > 0)
|
||||||
@ -74,9 +74,9 @@ public class Commandkit extends EssentialsCommand
|
|||||||
final Calendar c = new GregorianCalendar();
|
final Calendar c = new GregorianCalendar();
|
||||||
c.add(Calendar.SECOND, -(int)delay);
|
c.add(Calendar.SECOND, -(int)delay);
|
||||||
c.add(Calendar.MILLISECOND, -(int)((delay*1000.0)%1000.0));
|
c.add(Calendar.MILLISECOND, -(int)((delay*1000.0)%1000.0));
|
||||||
|
|
||||||
final long mintime = c.getTimeInMillis();
|
final long mintime = c.getTimeInMillis();
|
||||||
|
|
||||||
final Long lastTime = user.getKitTimestamp(kitName);
|
final Long lastTime = user.getKitTimestamp(kitName);
|
||||||
if (lastTime == null || lastTime < mintime) {
|
if (lastTime == null || lastTime < mintime) {
|
||||||
final Calendar now = new GregorianCalendar();
|
final Calendar now = new GregorianCalendar();
|
||||||
|
@ -15,7 +15,7 @@ public class Commandlightning extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
User user = null;
|
User user = null;
|
||||||
@ -34,16 +34,16 @@ public class Commandlightning extends EssentialsCommand
|
|||||||
throw new Exception(Util.i18n("playerNotFound"));
|
throw new Exception(Util.i18n("playerNotFound"));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player p : server.matchPlayer(args[0]))
|
for (Player matchPlayer : server.matchPlayer(args[0]))
|
||||||
{
|
{
|
||||||
sender.sendMessage(Util.format("lightningUse", p.getDisplayName()));
|
sender.sendMessage(Util.format("lightningUse", matchPlayer.getDisplayName()));
|
||||||
p.getWorld().strikeLightning(p.getLocation());
|
matchPlayer.getWorld().strikeLightning(matchPlayer.getLocation());
|
||||||
if (!ess.getUser(p).isGodModeEnabled()) {
|
if (!ess.getUser(matchPlayer).isGodModeEnabled()) {
|
||||||
p.setHealth(p.getHealth() < 5 ? 0 : p.getHealth() - 5);
|
matchPlayer.setHealth(matchPlayer.getHealth() < 5 ? 0 : matchPlayer.getHealth() - 5);
|
||||||
}
|
}
|
||||||
if (ess.getSettings().warnOnSmite())
|
if (ess.getSettings().warnOnSmite())
|
||||||
{
|
{
|
||||||
p.sendMessage(Util.i18n("lightningSmited"));
|
matchPlayer.sendMessage(Util.i18n("lightningSmited"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class Commandlist extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
{
|
{
|
||||||
boolean showhidden = false;
|
boolean showhidden = false;
|
||||||
if (sender instanceof Player)
|
if (sender instanceof Player)
|
||||||
@ -37,15 +37,15 @@ public class Commandlist extends EssentialsCommand
|
|||||||
showhidden = true;
|
showhidden = true;
|
||||||
}
|
}
|
||||||
int playerHidden = 0;
|
int playerHidden = 0;
|
||||||
for (Player p : server.getOnlinePlayers())
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (ess.getUser(p).isHidden())
|
if (ess.getUser(onlinePlayer).isHidden())
|
||||||
{
|
{
|
||||||
playerHidden++;
|
playerHidden++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//TODO: move these to messages file
|
//TODO: move these to messages file
|
||||||
StringBuilder online = new StringBuilder();
|
final StringBuilder online = new StringBuilder();
|
||||||
online.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length - playerHidden);
|
online.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length - playerHidden);
|
||||||
if (showhidden && playerHidden > 0)
|
if (showhidden && playerHidden > 0)
|
||||||
{
|
{
|
||||||
@ -58,29 +58,29 @@ public class Commandlist extends EssentialsCommand
|
|||||||
if (ess.getSettings().getSortListByGroups())
|
if (ess.getSettings().getSortListByGroups())
|
||||||
{
|
{
|
||||||
Map<String, List<User>> sort = new HashMap<String, List<User>>();
|
Map<String, List<User>> sort = new HashMap<String, List<User>>();
|
||||||
for (Player p : server.getOnlinePlayers())
|
for (Player OnlinePlayer : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
User u = ess.getUser(p);
|
final User player = ess.getUser(OnlinePlayer);
|
||||||
if (u.isHidden() && !showhidden)
|
if (player.isHidden() && !showhidden)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String group = u.getGroup();
|
final String group = player.getGroup();
|
||||||
List<User> list = sort.get(group);
|
List<User> list = sort.get(group);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
list = new ArrayList<User>();
|
list = new ArrayList<User>();
|
||||||
sort.put(group, list);
|
sort.put(group, list);
|
||||||
}
|
}
|
||||||
list.add(u);
|
list.add(player);
|
||||||
}
|
}
|
||||||
String[] groups = sort.keySet().toArray(new String[0]);
|
final String[] groups = sort.keySet().toArray(new String[0]);
|
||||||
Arrays.sort(groups, String.CASE_INSENSITIVE_ORDER);
|
Arrays.sort(groups, String.CASE_INSENSITIVE_ORDER);
|
||||||
for (String group : groups)
|
for (String group : groups)
|
||||||
{
|
{
|
||||||
StringBuilder groupString = new StringBuilder();
|
final StringBuilder groupString = new StringBuilder();
|
||||||
groupString.append(group).append(": ");
|
groupString.append(group).append(": ");
|
||||||
List<User> users = sort.get(group);
|
final List<User> users = sort.get(group);
|
||||||
Collections.sort(users);
|
Collections.sort(users);
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (User user : users)
|
for (User user : users)
|
||||||
@ -109,19 +109,19 @@ public class Commandlist extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<User> users = new ArrayList<User>();
|
final List<User> users = new ArrayList<User>();
|
||||||
for (Player p : server.getOnlinePlayers())
|
for (Player OnlinePlayer : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
final User u = ess.getUser(p);
|
final User player = ess.getUser(OnlinePlayer);
|
||||||
if (u.isHidden() && !showhidden)
|
if (player.isHidden() && !showhidden)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
users.add(u);
|
users.add(player);
|
||||||
}
|
}
|
||||||
Collections.sort(users);
|
Collections.sort(users);
|
||||||
|
|
||||||
StringBuilder onlineUsers = new StringBuilder();
|
final StringBuilder onlineUsers = new StringBuilder();
|
||||||
onlineUsers.append(Util.i18n("connectedPlayers"));
|
onlineUsers.append(Util.i18n("connectedPlayers"));
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (User user : users)
|
for (User user : users)
|
||||||
|
@ -16,20 +16,21 @@ public class Commandmail extends EssentialsCommand
|
|||||||
super("mail");
|
super("mail");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Tidy this up
|
||||||
@Override
|
@Override
|
||||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||||
{
|
{
|
||||||
if (args.length >= 1 && "read".equalsIgnoreCase(args[0]))
|
if (args.length >= 1 && "read".equalsIgnoreCase(args[0]))
|
||||||
{
|
{
|
||||||
List<String> mail = user.getMails();
|
final List<String> mail = user.getMails();
|
||||||
if (mail.isEmpty())
|
if (mail.isEmpty())
|
||||||
{
|
{
|
||||||
user.sendMessage(Util.i18n("noMail"));
|
user.sendMessage(Util.i18n("noMail"));
|
||||||
throw new NoChargeException();
|
throw new NoChargeException();
|
||||||
}
|
}
|
||||||
for (String s : mail)
|
for (String messages : mail)
|
||||||
{
|
{
|
||||||
user.sendMessage(s);
|
user.sendMessage(messages);
|
||||||
}
|
}
|
||||||
user.sendMessage(Util.i18n("mailClear"));
|
user.sendMessage(Util.i18n("mailClear"));
|
||||||
return;
|
return;
|
||||||
|
@ -14,15 +14,15 @@ public class Commandmute extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
{
|
{
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
User p = getPlayer(server, args, 0, true);
|
final User player = getPlayer(server, args, 0, true);
|
||||||
if (!p.isMuted() && p.isAuthorized("essentials.mute.exempt"))
|
if (!player.isMuted() && player.isAuthorized("essentials.mute.exempt"))
|
||||||
{
|
{
|
||||||
throw new Exception(Util.i18n("muteExempt"));
|
throw new Exception(Util.i18n("muteExempt"));
|
||||||
}
|
}
|
||||||
@ -32,15 +32,15 @@ public class Commandmute extends EssentialsCommand
|
|||||||
String time = getFinalArg(args, 1);
|
String time = getFinalArg(args, 1);
|
||||||
muteTimestamp = Util.parseDateDiff(time, true);
|
muteTimestamp = Util.parseDateDiff(time, true);
|
||||||
}
|
}
|
||||||
p.setMuteTimeout(muteTimestamp);
|
player.setMuteTimeout(muteTimestamp);
|
||||||
boolean muted = p.toggleMuted();
|
final boolean muted = player.toggleMuted();
|
||||||
sender.sendMessage(
|
sender.sendMessage(
|
||||||
muted
|
muted
|
||||||
? (muteTimestamp > 0
|
? (muteTimestamp > 0
|
||||||
? Util.format("mutedPlayerFor", p.getDisplayName(), Util.formatDateDiff(muteTimestamp))
|
? Util.format("mutedPlayerFor", player.getDisplayName(), Util.formatDateDiff(muteTimestamp))
|
||||||
: Util.format("mutedPlayer", p.getDisplayName()))
|
: Util.format("mutedPlayer", player.getDisplayName()))
|
||||||
: Util.format("unmutedPlayer", p.getDisplayName()));
|
: Util.format("unmutedPlayer", player.getDisplayName()));
|
||||||
p.sendMessage(
|
player.sendMessage(
|
||||||
muted
|
muted
|
||||||
? (muteTimestamp > 0
|
? (muteTimestamp > 0
|
||||||
? Util.format("playerMutedFor", Util.formatDateDiff(muteTimestamp))
|
? Util.format("playerMutedFor", Util.formatDateDiff(muteTimestamp))
|
||||||
|
@ -275,7 +275,7 @@ commands:
|
|||||||
usage: /<command> <mob>[:data][,<mount>[:data]] [amount]
|
usage: /<command> <mob>[:data][,<mount>[:data]] [amount]
|
||||||
aliases: [espawnmob]
|
aliases: [espawnmob]
|
||||||
sudo:
|
sudo:
|
||||||
description: Make another user do something.
|
description: Make another user perform a command.
|
||||||
usage: /<command> <player> <command [args]>
|
usage: /<command> <player> <command [args]>
|
||||||
aliases: [esudo]
|
aliases: [esudo]
|
||||||
suicide:
|
suicide:
|
||||||
@ -309,7 +309,7 @@ commands:
|
|||||||
tpa:
|
tpa:
|
||||||
description: Request to teleport to the specified player.
|
description: Request to teleport to the specified player.
|
||||||
usage: /<command> <player>
|
usage: /<command> <player>
|
||||||
aliases: [call,etpa,ecal]
|
aliases: [call,etpa,ecall]
|
||||||
tpaall:
|
tpaall:
|
||||||
description: Requests all players online to teleport to you.
|
description: Requests all players online to teleport to you.
|
||||||
usage: /<command> <player>
|
usage: /<command> <player>
|
||||||
|
Loading…
Reference in New Issue
Block a user