Better Online Command

Results 1 to 10 of 10
  1. #1
    Valued Member Red Tape is offline
    MemberRank
    Oct 2009 Join Date
    141Posts

    Better Online Command

    PHP Code:
                String online;
                for (
    int i 1<= ChannelServer.getAllInstances().size(); i++) {
                    
    online "[CHANNEL " "] ";
                    for (
    MapleCharacter chr ChannelServer.getInstance(i).getPlayerStorage().getAllCharacters())
                        
    online += MapleCharacter.makeMapleReadable(chr.getName()) + ", ";
                    
    player.message(online);
                } 


  2. #2
    GoldMember XkelvinchiaX is offline
    MemberRank
    Sep 2006 Join Date
    MalaysiaLocation
    286Posts

    Re: Better Online Command

    Nicely, 1st Post

  3. #3
    Waiting and waiting... Faithless is offline
    MemberRank
    Aug 2008 Join Date
    The NetherlandsLocation
    660Posts

    Re: Better Online Command

    Looks nice :) I remember I was searching for this long ago. Well done!

  4. #4
    Account Upgraded | Title Enabled! Emilyx3 is offline
    MemberRank
    Apr 2009 Join Date
    393Posts

    Re: Better Online Command

    Probably should switch to StringBuilders if your server has a lot of people and this command is made available to normal players.

  5. #5
    Banned SpottedCow is offline
    BannedRank
    Nov 2009 Join Date
    wtfdddddLocation
    208Posts

    Re: Better Online Command

    This isn't better.

  6. #6
    Valued Member GoldenKevin is offline
    MemberRank
    Oct 2008 Join Date
    117Posts

    Re: Better Online Command

    Where's the stringbuilder? It's costly to continually concatenate an immutable string compared to a mutable one.

  7. #7
    Valued Member Red Tape is offline
    MemberRank
    Oct 2009 Join Date
    141Posts

    Re: Better Online Command

    Quote Originally Posted by SpottedCow View Post
    This isn't better.
    yes because clearly, the one that only got one channel is better then getting from all channels

  8. #8
    Alpha Member watzmename is offline
    MemberRank
    Aug 2008 Join Date
    2,835Posts

    Re: Better Online Command

    Quote Originally Posted by Red Tape View Post
    yes because clearly, the one that only got one channel is better then getting from all channels
    There was an !onlinew
    Shows everyone on each channel.

  9. #9
    Valued Member Red Tape is offline
    MemberRank
    Oct 2009 Join Date
    141Posts

    Re: Better Online Command

    Quote Originally Posted by watzmename View Post
    There was an !onlinew
    Shows everyone on each channel.
    I have never had that ever

  10. #10
    Apprentice Klay is offline
    MemberRank
    Dec 2009 Join Date
    15Posts

    Re: Better Online Command

    Here's my improved version of the Online Command.
    Code:
    if (sp[0].equals("online")) {
        if (sp.length < 2) {
            int connected = 0;
    
            for (ChannelServer chs : ChannelServer.getAllInstances()) {
                int clients = chs.getPlayerStorage().getAllCharacters().size();
                connected += clients;
                mc.dropMessage(6, "Channel " + chs.getChannel() + " : " + clients);
            }
    
            mc.dropMessage(6, "Connected clients : " + connected);
        } else {
            int cId = Integer.parseInt(sp[1]);
            ChannelServer chs = ChannelServer.getInstance(cId);
    
            if (chs != null) {
                Collection<MapleCharacter> ch = new LinkedHashSet<MapleCharacter>(chs.getPlayerStorage().getAllCharacters());
                StringBuilder characters = new StringBuilder();
    
                for (MapleCharacter cha : ch)
                    characters.append(MapleCharacter.makeMapleReadable(cha.getName()) + ", ");
    
                mc.dropMessage(6, "Channel " + cId + " : " + ch.size());
                mc.dropMessage(6, characters.substring(0, characters.length() - 2));
            } else {
                mc.dropMessage(5, "Channel " + cId + " is offline.");
            }
        }
    }
    Last edited by Klay; 03-01-10 at 02:12 AM.



Advertisement