2011-03-19 22:39:51 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
|
|
|
import com.earth2me.essentials.User;
|
2011-05-10 21:52:07 +00:00
|
|
|
import com.earth2me.essentials.Util;
|
2011-11-18 17:42:26 +00:00
|
|
|
import java.util.*;
|
2011-03-19 22:39:51 +00:00
|
|
|
import org.bukkit.ChatColor;
|
2011-11-18 17:42:26 +00:00
|
|
|
import org.bukkit.Server;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
2011-03-19 22:39:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
public class Commandlist extends EssentialsCommand
|
|
|
|
{
|
|
|
|
public Commandlist()
|
|
|
|
{
|
|
|
|
super("list");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-11-18 13:48:31 +00:00
|
|
|
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
2011-03-19 22:39:51 +00:00
|
|
|
{
|
2011-07-18 01:42:21 +00:00
|
|
|
boolean showhidden = false;
|
|
|
|
if (sender instanceof Player)
|
|
|
|
{
|
|
|
|
if (ess.getUser(sender).isAuthorized("essentials.list.hidden"))
|
|
|
|
{
|
|
|
|
showhidden = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
showhidden = true;
|
|
|
|
}
|
|
|
|
int playerHidden = 0;
|
2011-11-18 13:48:31 +00:00
|
|
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
2011-07-18 01:42:21 +00:00
|
|
|
{
|
2011-11-18 13:48:31 +00:00
|
|
|
if (ess.getUser(onlinePlayer).isHidden())
|
2011-07-18 01:42:21 +00:00
|
|
|
{
|
|
|
|
playerHidden++;
|
|
|
|
}
|
|
|
|
}
|
2011-08-21 16:08:32 +00:00
|
|
|
//TODO: move these to messages file
|
2011-11-18 13:48:31 +00:00
|
|
|
final StringBuilder online = new StringBuilder();
|
2011-07-18 01:42:21 +00:00
|
|
|
online.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length - playerHidden);
|
2011-07-18 03:45:05 +00:00
|
|
|
if (showhidden && playerHidden > 0)
|
2011-07-18 01:42:21 +00:00
|
|
|
{
|
|
|
|
online.append(ChatColor.GRAY).append("/").append(playerHidden);
|
|
|
|
}
|
2011-03-19 22:39:51 +00:00
|
|
|
online.append(ChatColor.BLUE).append(" out of a maximum ").append(ChatColor.RED).append(server.getMaxPlayers());
|
|
|
|
online.append(ChatColor.BLUE).append(" players online.");
|
|
|
|
sender.sendMessage(online.toString());
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
|
|
|
|
if (ess.getSettings().getSortListByGroups())
|
|
|
|
{
|
2011-03-19 22:39:51 +00:00
|
|
|
Map<String, List<User>> sort = new HashMap<String, List<User>>();
|
2011-11-18 13:48:31 +00:00
|
|
|
for (Player OnlinePlayer : server.getOnlinePlayers())
|
2011-03-19 22:39:51 +00:00
|
|
|
{
|
2011-11-18 13:48:31 +00:00
|
|
|
final User player = ess.getUser(OnlinePlayer);
|
|
|
|
if (player.isHidden() && !showhidden)
|
2011-07-18 01:42:21 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2011-11-18 13:48:31 +00:00
|
|
|
final String group = player.getGroup();
|
2011-03-19 22:39:51 +00:00
|
|
|
List<User> list = sort.get(group);
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
if (list == null)
|
|
|
|
{
|
2011-03-19 22:39:51 +00:00
|
|
|
list = new ArrayList<User>();
|
|
|
|
sort.put(group, list);
|
|
|
|
}
|
2011-11-18 13:48:31 +00:00
|
|
|
list.add(player);
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
2011-11-18 13:48:31 +00:00
|
|
|
final String[] groups = sort.keySet().toArray(new String[0]);
|
2011-03-19 22:39:51 +00:00
|
|
|
Arrays.sort(groups, String.CASE_INSENSITIVE_ORDER);
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
for (String group : groups)
|
|
|
|
{
|
2011-11-18 13:48:31 +00:00
|
|
|
final StringBuilder groupString = new StringBuilder();
|
2011-03-19 22:39:51 +00:00
|
|
|
groupString.append(group).append(": ");
|
2011-11-18 13:48:31 +00:00
|
|
|
final List<User> users = sort.get(group);
|
2011-03-19 22:39:51 +00:00
|
|
|
Collections.sort(users);
|
|
|
|
boolean first = true;
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
for (User user : users)
|
|
|
|
{
|
|
|
|
if (!first)
|
|
|
|
{
|
2011-03-19 22:39:51 +00:00
|
|
|
groupString.append(", ");
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-19 22:39:51 +00:00
|
|
|
first = false;
|
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
if (user.isAfk())
|
|
|
|
{
|
2011-04-05 15:54:59 +00:00
|
|
|
groupString.append("§7[AFK]§f");
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
2011-07-18 01:42:21 +00:00
|
|
|
if (user.isHidden())
|
|
|
|
{
|
|
|
|
groupString.append("§7[HIDDEN]§f");
|
|
|
|
}
|
2011-03-19 22:39:51 +00:00
|
|
|
groupString.append(user.getDisplayName());
|
2011-07-22 22:46:54 +00:00
|
|
|
groupString.append("§f");
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
|
|
|
sender.sendMessage(groupString.toString());
|
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-18 13:48:31 +00:00
|
|
|
final List<User> users = new ArrayList<User>();
|
|
|
|
for (Player OnlinePlayer : server.getOnlinePlayers())
|
2011-03-19 22:39:51 +00:00
|
|
|
{
|
2011-11-18 13:48:31 +00:00
|
|
|
final User player = ess.getUser(OnlinePlayer);
|
|
|
|
if (player.isHidden() && !showhidden)
|
2011-07-18 01:42:21 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2011-11-18 13:48:31 +00:00
|
|
|
users.add(player);
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
|
|
|
Collections.sort(users);
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
|
2011-11-18 13:48:31 +00:00
|
|
|
final StringBuilder onlineUsers = new StringBuilder();
|
2011-05-10 21:52:07 +00:00
|
|
|
onlineUsers.append(Util.i18n("connectedPlayers"));
|
2011-03-19 22:39:51 +00:00
|
|
|
boolean first = true;
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
for (User user : users)
|
|
|
|
{
|
|
|
|
if (!first)
|
|
|
|
{
|
2011-03-19 22:39:51 +00:00
|
|
|
onlineUsers.append(", ");
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-19 22:39:51 +00:00
|
|
|
first = false;
|
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
if (user.isAfk())
|
|
|
|
{
|
2011-04-05 15:54:59 +00:00
|
|
|
onlineUsers.append("§7[AFK]§f");
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
2011-07-18 01:42:21 +00:00
|
|
|
if (user.isHidden())
|
|
|
|
{
|
|
|
|
onlineUsers.append("§7[HIDDEN]§f");
|
|
|
|
}
|
2011-03-19 22:39:51 +00:00
|
|
|
onlineUsers.append(user.getDisplayName());
|
2011-07-22 22:46:54 +00:00
|
|
|
onlineUsers.append("§f");
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
|
|
|
sender.sendMessage(onlineUsers.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|