1 20 21 package freecs.commands; 22 import freecs.interfaces.ICommand; 23 import freecs.content.MessageState; 24 25 30 public class CmdRepeatedPrivateMessage extends AbstractCommand { 31 public final String cmd= "/"; 32 private static final ICommand selve=new CmdRepeatedPrivateMessage(); 33 34 private CmdRepeatedPrivateMessage () { } 35 36 public static ICommand getInstance () { 37 return selve; 38 } 39 40 public boolean execute (MessageState msgState, String param) { 41 if (param.length () < 1) { 42 msgState.msgTemplate = "error.m.noMessage"; 43 msgState.sender.sendMessage (msgState.mp); 44 return false; 45 } 46 msgState.message = param.trim (); 47 msgState.usercontext = msgState.sender.getPrivateUser (); 48 if (msgState.usercontext == null) 49 return false; 50 if (!msgState.usercontext.isLoggedIn ()) { 51 msgState.param = msgState.usercontext.getName() ; 52 msgState.msgTemplate = "error.user.notOnServer.singular"; 53 msgState.sender.sendMessage (msgState.mp); 54 msgState.sender.setPrivateUser(null); 55 return false; 56 } 57 if (!msgState.usercontext.usrMayWhisper(msgState.sender)) { 58 msgState.msgTemplate = "error.m.cantHearYou"; 59 msgState.sender.sendMessage(msgState.mp); 60 return false; 61 } 62 sendPrivateMessage (msgState, msgState.usercontext, param); 63 return true; 64 } 65 } 66 | Popular Tags |