1 20 21 package freecs.commands; 22 import java.util.Enumeration ; 23 24 import freecs.interfaces.ICommand; 25 import freecs.core.UserManager; 26 import freecs.content.MessageState; 27 28 33 public class CmdListAllFriends extends AbstractCommand { 34 public final String cmd= "/fl"; 35 private static final ICommand selve=new CmdListAllFriends (); 36 37 private CmdListAllFriends () { } 38 39 public static ICommand getInstance () { 40 return selve; 41 } 42 43 public boolean execute (MessageState msgState, String param) { 44 if (msgState.sender.numberOfFriends () < 1) { 45 msgState.msgTemplate = "error.fl.nofriends"; 46 msgState.sender.sendMessage (msgState.mp); 47 return false; 48 } 49 msgState.msgTemplate = "message.fl.headline"; 50 msgState.sender.sendMessage (msgState.mp); 51 msgState.useRenderCache = false; 52 for (Enumeration e = msgState.sender.friends (); e.hasMoreElements (); ) { 53 String uname = (String ) e.nextElement (); 54 msgState.usercontext = UserManager.mgr.getUserByName (uname); 55 if (msgState.usercontext == null) { 56 msgState.msgTemplate = "message.fl.entry.offline"; 57 msgState.targetGroup = null; 58 msgState.param = uname; 59 } else { 60 msgState.msgTemplate = "message.fl.entry.online"; 61 msgState.targetGroup = msgState.usercontext.getGroup (); 62 msgState.param = ""; 63 } 64 msgState.sender.sendMessage (msgState.mp); 65 } 66 msgState.param = String.valueOf (msgState.sender.numberOfFriends ()); 67 msgState.msgTemplate = "message.fl.count"; 68 msgState.sender.sendMessage (msgState.mp); 69 return false; 70 } 71 } 72 | Popular Tags |