1 20 21 package freecs.commands; 22 import freecs.interfaces.ICommand; 23 import freecs.core.Group; 24 import freecs.core.User; 25 import freecs.content.MessageState; 26 27 32 public class CmdJoinUser extends AbstractCommand { 33 public final String cmd= "/ju"; 34 private static final ICommand selve=new CmdJoinUser(); 35 36 private CmdJoinUser () { } 37 38 public static ICommand getInstance () { 39 return selve; 40 } 41 42 public boolean execute (MessageState msgState, String param) { 43 User u; 44 if (param.length () < 1) { 45 msgState.msgTemplate="error.ju.noArg"; 46 msgState.sender.sendMessage (msgState.mp); 47 return false; 48 } else if (param.indexOf (" ") > -1) { 49 u = getUser (msgState, param.substring(0, param.indexOf (" "))); 50 } else { 51 u = getUser (msgState, param); 52 } 53 if (u == null) 54 return false; 55 Group g = u.getGroup (); 56 if (g == null) return false; 57 if (g.equals (msgState.sender.getGroup ())) { 58 msgState.targetGroup = g; 59 msgState.usercontext = u; 60 msgState.msgTemplate="error.ju.alreadyHere"; 61 msgState.sender.sendMessage (msgState.mp); 62 return false; 63 } 64 ICommand ic = CommandSet.getCommandSet().getCommand("/j"); 65 return ic.execute (msgState, g.getRawName()); 66 } 67 } | Popular Tags |