KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > freecs > commands > CmdRespectUser


1 /**
2  * Copyright (C) 2003 Manfred Andres
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  * Created on 28.09.2003
19  */

20
21 package freecs.commands;
22 import java.util.Iterator JavaDoc;
23 import java.util.Vector JavaDoc;
24
25 import freecs.interfaces.ICommand;
26 import freecs.content.MessageState;
27 import freecs.core.User;
28 import freecs.Server;
29
30 /**
31  * @author Manfred Andres
32  *
33  * freecs.commands
34  */

35 public class CmdRespectUser extends AbstractCommand {
36     public final String JavaDoc cmd= "/rgag";
37     private static final ICommand selve=new CmdRespectUser();
38
39     private CmdRespectUser () { }
40     
41     public static ICommand getInstance () {
42         return selve;
43     }
44     
45     public boolean execute (MessageState msgState, String JavaDoc param) {
46         if (param.length () < 1) {
47             msgState.msgTemplate = "error.rig.noArg";
48             msgState.sender.sendMessage (msgState.mp);
49             return false;
50         }
51         Vector JavaDoc found = getMultibleUsers(msgState, param);
52         for (Iterator JavaDoc e = found.iterator(); e.hasNext(); ) {
53             msgState.usercontext = (User) e.next();
54             StringBuffer JavaDoc tsb = new StringBuffer JavaDoc ("User ").append (msgState.sender.getName ()).append (" is respecting ").append (msgState.usercontext.getName ()).append (" again");
55             Server.log (this, tsb.toString (), Server.MSG_STATE, Server.LVL_VERBOSE);
56             msgState.sender.respectUser (msgState.usercontext);
57         }
58         if (found.size()==0)
59             return false;
60         if (found.size()==1) {
61             msgState.msgTemplate="message.rig.singular";
62         } else {
63             msgState.msgTemplate="message.rig.plural";
64             msgState.usrList = found.toArray();
65         }
66         msgState.sender.sendMessage(msgState.mp);
67         return true;
68     }
69     
70     public String JavaDoc toString () {
71         return ("[CmdRespectUser]");
72     }
73 }
74
Popular Tags