1 20 21 package freecs.commands; 22 import freecs.Server; 23 import freecs.interfaces.ICommand; 24 import freecs.interfaces.IGroupState; 25 import freecs.interfaces.IUserStates; 26 import freecs.content.MessageState; 27 28 33 public class CmdSetTheme extends AbstractCommand { 34 public final String cmd= "/t"; 35 private static final ICommand selve=new CmdSetTheme(); 36 37 private CmdSetTheme () { } 38 39 public static ICommand getInstance () { 40 return selve; 41 } 42 43 public boolean execute (MessageState msgState, String param) { 44 if (isPunished (msgState)) 45 return false; 46 msgState.targetGroup = msgState.sender.getGroup (); 47 if (!msgState.sender.hasRight(IUserStates.ROLE_VIP)) { 49 if (msgState.targetGroup.hasState(IGroupState.ENTRANCE)) { 50 msgState.msgTemplate = "error.noRight.noVipAdmin"; 51 msgState.sender.sendMessage (msgState.mp); 52 return false; 53 } else if (!msgState.targetGroup.usrIsSu (msgState.sender)) { 54 msgState.msgTemplate = "error.noRight.noSuVipAdmin"; 55 msgState.sender.sendMessage (msgState.mp); 56 return false; 57 } 58 } else if (!isVip(msgState.sender, msgState.targetGroup, msgState)) { 59 if (msgState.usrList.length > 1) 60 msgState.msgTemplate = "error.membership.notMember.many"; 61 else 62 msgState.msgTemplate = "error.membership.notMember"; 63 msgState.usercontext=null; 64 msgState.sender.sendMessage(msgState.mp); 65 return false; 66 } 67 if (param.length() < 1) { 68 if (msgState.sender.getGroup().getTheme()!= null) { 69 msgState.param = msgState.sender.getGroup().getTheme(); 70 } else msgState.param = ""; 71 msgState.sender.getGroup().setTheme(null); 72 msgState.msgTemplate="message.t.removed"; 73 msgState.sender.getGroup().sendMessage(msgState.mp); 74 return true; 75 } 76 if (Server.srv.MAX_GROUPTHEME_LENGTH > 0 && param.length() > Server.srv.MAX_GROUPTHEME_LENGTH) { 77 param = param.substring(0,Server.srv.MAX_GROUPTHEME_LENGTH); 78 } 79 msgState.param = msgState.targetGroup.getTheme(); 80 msgState.targetGroup.setTheme (param); 81 msgState.msgTemplate = "message.t"; 82 msgState.targetGroup.sendModeratedMessage (msgState.mp); 83 return true; 84 } 85 } 86 | Popular Tags |