1 20 21 package freecs.commands; 22 import java.util.Iterator ; 23 import java.util.Vector ; 24 25 import freecs.interfaces.ICommand; 26 import freecs.interfaces.IUserStates; 27 import freecs.content.MessageState; 28 import freecs.core.User; 29 import freecs.Server; 30 31 36 public class CmdIgnore extends AbstractCommand { 37 public final String cmd= "/ig"; 38 private static final ICommand selve= new CmdIgnore(); 39 40 private CmdIgnore () { } 41 42 public static ICommand getInstance () { 43 return selve; 44 } 45 46 public boolean execute (MessageState msgState, String param) { 47 if (param.length () < 1) { 48 msgState.msgTemplate = "error.ig.noArg"; 49 msgState.sender.sendMessage (msgState.mp); 50 return false; 51 } 52 Vector found = getMultibleUsers(msgState, param); 53 for (Iterator e = found.iterator(); e.hasNext(); ) { 54 User cu = (User) e.next(); 55 if (cu == null) 56 continue; 57 if (cu.hasRight (IUserStates.ROLE_VIP)) { 58 e.remove(); 59 continue; 60 } 61 if (cu.equals(msgState.sender)) { 62 e.remove(); 63 continue; 64 } 65 msgState.usercontext = cu; 66 StringBuffer tsb = new StringBuffer ("User ").append (msgState.sender.getName ()).append (" is ignoring ").append (cu.getName ()); 67 Server.log (this, tsb.toString (), Server.MSG_STATE, Server.LVL_VERBOSE); 68 msgState.sender.ignoreUser(msgState.usercontext); 69 } 70 if (found.size()==0) 71 return false; 72 if (found.size()==1) { 73 msgState.msgTemplate="message.ig.singular"; 74 } else { 75 msgState.msgTemplate="message.ig.plural"; 76 msgState.usrList = found.toArray(); 77 } 78 msgState.sender.sendMessage(msgState.mp); 79 return true; 80 } 81 82 public String toString() { 83 return ("[CmdIgnore]"); 84 } 85 } 86 | Popular Tags |