1 18 package freecs.core; 19 20 import freecs.Server; 21 22 27 public class ScheduledAction { 28 public static short UNPUNISH = 1; 29 30 User usr = null, sender = null; 31 short action = 0; 32 long startTime = 0; 33 34 public ScheduledAction (short action, long startTime, User target, User sender) { 35 this.action = action; 36 this.startTime = startTime; 37 this.usr = target; 38 this.sender = sender; 39 if (Server.TRACE_CREATE_AND_FINALIZE) 40 Server.log (this, "++++++++++++++++++++++++++++++++++++++++CREATE", Server.MSG_STATE, Server.LVL_VERY_VERBOSE); 41 } 42 43 public long getStartTime () { return startTime; } 44 45 public void execute () { 46 if (action == 0) return; 47 MessageParser mp = new MessageParser (); 48 if (action == UNPUNISH) { 49 usr.setPunish (false); 50 mp.setMessageTemplate ("message.rgag.singular"); 51 mp.setUsercontext (usr); 52 mp.setSender (sender); 53 } 54 Group g = usr.getGroup (); 55 if (g != null) 56 g.sendMessage (mp); 57 } 58 59 public boolean equals (Object o) { 60 if (!(o instanceof ScheduledAction)) 61 return false; 62 ScheduledAction sa = (ScheduledAction) o; 63 return this.action == sa.getAction () && this.usr == sa.getUser () && this.sender == sa.getSender (); 64 } 65 public short getAction () { return action; } 66 public User getUser () { return usr; } 67 public User getSender () { return sender; } 68 public int hashCode () { return usr.hashCode (); } 69 70 public void finalize() { 71 if (Server.TRACE_CREATE_AND_FINALIZE) 72 Server.log(this, "----------------------------------------FINALIZED", Server.MSG_STATE, Server.LVL_VERY_VERBOSE); 73 } 74 } | Popular Tags |