@@ -61,6 +61,11 @@ public abstract class ProxyOperator implements Rule {
6161 */
6262 private Tuple <SimpleTime , String > delay ;
6363
64+ /**
65+ * The delay between the next time this rule can be fired up for the given sender, with optional warning message
66+ */
67+ private Tuple <SimpleTime , String > playerDelay ;
68+
6469 /**
6570 * List of commands to run as player when rule matches
6671 */
@@ -145,6 +150,11 @@ public abstract class ProxyOperator implements Rule {
145150 @ Getter
146151 private long lastExecuted = -1 ;
147152
153+ /**
154+ * The time the operator was last executed for the given player name(s)
155+ */
156+ private final Map <String , Long > lastExecutedForPlayers = new HashMap <>();
157+
148158 /**
149159 * @see Rule#onOperatorParse(java.lang.String[])
150160 */
@@ -175,14 +185,25 @@ public final boolean onOperatorParse(final String[] args) {
175185 }
176186 }
177187
178- else if ("delay" .equals (args [0 ])) {
179- this . checkNotSet ( this . delay , " delay") ;
188+ else if ("delay" .equals (args [0 ]) || "player delay" . equals ( param ) ) {
189+ final int offset = "player delay". equals ( param ) ? 1 : 0 ;
180190
181191 try {
182- final SimpleTime time = SimpleTime .fromString (CommonCore .joinRange (1 , 3 , args ));
183- final String message = args .length > 2 ? CommonCore .joinRange (3 , args ) : null ;
192+ final SimpleTime time = SimpleTime .fromString (CommonCore .joinRange (1 + offset , 3 + offset , args ));
193+ final String message = args .length > 2 ? CommonCore .joinRange (3 + offset , args ) : null ;
194+
195+ final Tuple <SimpleTime , String > tuple = new Tuple <>(time , message );
196+
197+ if ("delay" .equals (args [0 ])) {
198+ this .checkNotSet (this .delay , args [0 ]);
199+
200+ this .delay = tuple ;
201+
202+ } else {
203+ this .checkNotSet (this .playerDelay , param );
184204
185- this .delay = new Tuple <>(time , message );
205+ this .playerDelay = tuple ;
206+ }
186207
187208 } catch (final Throwable ex ) {
188209 CommonCore .throwError (ex , "Syntax error in 'delay' operator. Valid: <amount> <unit> (1 second, 2 minutes). Got: " + String .join (" " , args ));
@@ -336,6 +357,7 @@ protected SerializedMap collectOptions() {
336357 //"Save Keys", this.saveData,
337358 "Expires" , this .expires != -1 ? this .expires : null ,
338359 "Delay" , this .delay ,
360+ "Player Delay" , this .playerDelay != null ? this .playerDelay .getKey () + (this .playerDelay .getValue () != null && !this .playerDelay .getValue ().isEmpty () ? ", warnmessage=" + this .playerDelay .getValue () : "" ) : "" ,
339361 "Player Commands" , this .playerCommands ,
340362 //"Console Commands", this.consoleCommands,
341363 "Proxy Commands" , this .proxyCommands ,
@@ -376,6 +398,21 @@ public final String toDisplayableString() {
376398 return CompChatColor .stripColorCodes (this .toString ().replace ("\t " , " " ));
377399 }
378400
401+ /**
402+ * @param playerName
403+ * @return
404+ */
405+ protected final long getLastExecutedForPlayer (final String playerName ) {
406+ return this .lastExecutedForPlayers .getOrDefault (playerName , -1L );
407+ }
408+
409+ /**
410+ * @param playerName
411+ */
412+ protected final void setLastExecutedForPlayer (final String playerName ) {
413+ this .lastExecutedForPlayers .put (playerName , System .currentTimeMillis ());
414+ }
415+
379416 /**
380417 * @see java.lang.Object#equals(java.lang.Object)
381418 */
0 commit comments