Reuse delay on voiced commands?
Forum rules
READ NOW: L2j Forums Rules of Conduct
READ NOW: L2j Forums Rules of Conduct
-
- Advanced User
- Posts: 1440
- Joined: Wed Apr 15, 2009 10:07 am
Reuse delay on voiced commands?
Havent tried that before, any ideas how to begin, is there an example?
- guillermokiss
- Posts: 99
- Joined: Mon May 24, 2010 2:19 pm
- Location: Argentina
- Contact:
Re: Reuse delay on voiced commands?
See chat handlers and floodprotectors, there you may find some clues..
- Zoey76
- L2j Inner Circle
- Posts: 7008
- Joined: Tue Aug 11, 2009 3:36 am
Re: Reuse delay on voiced commands?
What do you mean by "reuse delay"?
Powered by Eclipse 4.34
| Eclipse Temurin 21
| MariaDB 11.3.2
| L2J Server 2.6.3.0 - High Five 
Join our Discord! 

-
- Advanced User
- Posts: 1440
- Joined: Wed Apr 15, 2009 10:07 am
Re: Reuse delay on voiced commands?
For example after someone has used the command he cant use it again after 30 seconds or something like that.Zoey76 wrote:What do you mean by "reuse delay"?
- Zoey76
- L2j Inner Circle
- Posts: 7008
- Joined: Tue Aug 11, 2009 3:36 am
Re: Reuse delay on voiced commands?
It's very simple to implement.
Powered by Eclipse 4.34
| Eclipse Temurin 21
| MariaDB 11.3.2
| L2J Server 2.6.3.0 - High Five 
Join our Discord! 

- Zoey76
- L2j Inner Circle
- Posts: 7008
- Joined: Tue Aug 11, 2009 3:36 am
Re: Reuse delay on voiced commands?
This is just an example, restart/shutdown will reset reuse and as long as the server is on the memory for this records will be used.
Gist by: Zoey76
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/L2J_DataPack/dist/game/data/scripts/handlers/voicedcommandhandlers/ChangePassword.java b/L2J_DataPack/dist/game/data/scripts/handlers/voicedcommandhandlers/ChangePassword.java | |
index f31bf55..ced0f5a 100644 | |
--- a/L2J_DataPack/dist/game/data/scripts/handlers/voicedcommandhandlers/ChangePassword.java | |
+++ b/L2J_DataPack/dist/game/data/scripts/handlers/voicedcommandhandlers/ChangePassword.java | |
@@ -18,7 +18,9 @@ | |
*/ | |
package handlers.voicedcommandhandlers; | |
+import java.util.Map; | |
import java.util.StringTokenizer; | |
+import java.util.concurrent.ConcurrentHashMap; | |
import java.util.logging.Level; | |
import com.l2jserver.gameserver.LoginServerThread; | |
@@ -32,6 +34,8 @@ | |
*/ | |
public class ChangePassword implements IVoicedCommandHandler | |
{ | |
+ private static final Map<Integer, Long> REUSES = new ConcurrentHashMap<>(); | |
+ private static final int REUSE = 30 * 60 * 1000; // 30 Min | |
private static final String[] _voicedCommands = | |
{ | |
"changepassword" | |
@@ -77,6 +81,13 @@ | |
return false; | |
} | |
+ final Long timeStamp = REUSES.get(activeChar.getObjectId()); | |
+ if ((timeStamp != null) && ((System.currentTimeMillis() - REUSE) < timeStamp.longValue())) | |
+ { | |
+ activeChar.sendMessage("You cannot change the password so often!"); | |
+ return false; | |
+ } | |
+ REUSES.put(activeChar.getObjectId(), System.currentTimeMillis()); | |
LoginServerThread.getInstance().sendChangePassword(activeChar.getAccountName(), activeChar.getName(), curpass, newpass); | |
} | |
else |
Powered by Eclipse 4.34
| Eclipse Temurin 21
| MariaDB 11.3.2
| L2J Server 2.6.3.0 - High Five 
Join our Discord! 

-
- Advanced User
- Posts: 1440
- Joined: Wed Apr 15, 2009 10:07 am
Re: Reuse delay on voiced commands?
Thats what i needed, thanks.Zoey76 wrote:This is just an example, restart/shutdown will reset reuse and as long as the server is on the memory for this records will be used.Gist by: Zoey76This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
diff --git a/L2J_DataPack/dist/game/data/scripts/handlers/voicedcommandhandlers/ChangePassword.java b/L2J_DataPack/dist/game/data/scripts/handlers/voicedcommandhandlers/ChangePassword.java index f31bf55..ced0f5a 100644 --- a/L2J_DataPack/dist/game/data/scripts/handlers/voicedcommandhandlers/ChangePassword.java +++ b/L2J_DataPack/dist/game/data/scripts/handlers/voicedcommandhandlers/ChangePassword.java @@ -18,7 +18,9 @@ */ package handlers.voicedcommandhandlers; +import java.util.Map; import java.util.StringTokenizer; +import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import com.l2jserver.gameserver.LoginServerThread; @@ -32,6 +34,8 @@ */ public class ChangePassword implements IVoicedCommandHandler { + private static final Map<Integer, Long> REUSES = new ConcurrentHashMap<>(); + private static final int REUSE = 30 * 60 * 1000; // 30 Min private static final String[] _voicedCommands = { "changepassword" @@ -77,6 +81,13 @@ return false; } + final Long timeStamp = REUSES.get(activeChar.getObjectId()); + if ((timeStamp != null) && ((System.currentTimeMillis() - REUSE) < timeStamp.longValue())) + { + activeChar.sendMessage("You cannot change the password so often!"); + return false; + } + REUSES.put(activeChar.getObjectId(), System.currentTimeMillis()); LoginServerThread.getInstance().sendChangePassword(activeChar.getAccountName(), activeChar.getName(), curpass, newpass); } else