Improvements, now works with latest bukkit

This commit is contained in:
nossr50 2011-01-15 19:29:06 -08:00
parent 30f144b21b
commit 7deb6f3e84
3 changed files with 10 additions and 5 deletions

View File

@ -36,20 +36,24 @@ public class vPlayerListener extends PlayerListener {
}
//Message to be sent when a player uses /list
public void onPlayerCommand(PlayerChatEvent event) {
log.log(Level.INFO, event.getMessage() + "|" + event.getPlayer().getName());
String[] split = event.getMessage().split(" ");
Player player = event.getPlayer();
if(split[0].equalsIgnoreCase("/list") || split[0].equalsIgnoreCase("/who")){
event.setCancelled(true);
String tempList = "";
int x = 0;
for(Player p : plugin.getServer().getOnlinePlayers())
{
if(p != null){
tempList+= p.getName();
if(p != null && x < playerCount()){
tempList+= p.getName() +", ";
x++;
}
if(x >= playerCount())
tempList+= p.getName();
}
//Output the player list
player.sendMessage(ChatColor.RED + "Player List (" + tempList +")");
player.sendMessage(ChatColor.RED + "Player List ("+ChatColor.WHITE + tempList +ChatColor.RED+")");
player.sendMessage(ChatColor.RED + "Total Players: " + ChatColor.GREEN + playerCount());
}
}
}

View File

@ -33,6 +33,7 @@ public class vPlayersOnline extends JavaPlugin {
PluginManager pm = getServer().getPluginManager();
pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this);
//Displays a message when plugin is loaded
PluginDescriptionFile pdfFile = this.getDescription();
System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );

View File

@ -1,3 +1,3 @@
name: vPlayersOnline
main: com.bukkit.nossr50.vPlayersOnline.vPlayersOnline
version: 1.1
version: 1.2