Преглед изворни кода

Make database command cooldown configurable

TfT_02 пре 11 година
родитељ
комит
458dc7db42

+ 1 - 0
Changelog.txt

@@ -22,6 +22,7 @@ Version 1.4.08-dev
  + Added Ender Dragon, Wither, and Witch to combat experience multipliers - they do not give XP by default
  + Added Ender Dragon, Wither, and Witch to combat experience multipliers - they do not give XP by default
  + Added support for multiple mod config files, naming can be done as either armor.<modname>.yml or <modname>.armor.yml
  + Added support for multiple mod config files, naming can be done as either armor.<modname>.yml or <modname>.armor.yml
  + Added config options to configure the items used in "Call of the Wild"
  + Added config options to configure the items used in "Call of the Wild"
+ + Added config option to configure the database command cooldown
  = Fixed bug where healthbars wouldn't display if skills were disabled
  = Fixed bug where healthbars wouldn't display if skills were disabled
  = Fixed bug with "Call of the Wild" entities despawning
  = Fixed bug with "Call of the Wild" entities despawning
  = Fixed bug with updating (very) old user data.
  = Fixed bug with updating (very) old user data.

+ 2 - 2
src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java

@@ -14,7 +14,6 @@ import com.gmail.nossr50.config.Config;
 import com.gmail.nossr50.datatypes.player.McMMOPlayer;
 import com.gmail.nossr50.datatypes.player.McMMOPlayer;
 import com.gmail.nossr50.locale.LocaleLoader;
 import com.gmail.nossr50.locale.LocaleLoader;
 import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
 import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
-import com.gmail.nossr50.util.Misc;
 import com.gmail.nossr50.util.Permissions;
 import com.gmail.nossr50.util.Permissions;
 import com.gmail.nossr50.util.commands.CommandUtils;
 import com.gmail.nossr50.util.commands.CommandUtils;
 import com.gmail.nossr50.util.player.UserManager;
 import com.gmail.nossr50.util.player.UserManager;
@@ -82,8 +81,9 @@ public class McrankCommand implements TabExecutor {
     private void display(CommandSender sender, String playerName) {
     private void display(CommandSender sender, String playerName) {
         if (sender instanceof Player) {
         if (sender instanceof Player) {
             McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
             McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
+            long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750);
 
 
-            if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
+            if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
                 sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
                 sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
                 return;
                 return;
             }
             }

+ 2 - 2
src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java

@@ -15,7 +15,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
 import com.gmail.nossr50.datatypes.skills.SkillType;
 import com.gmail.nossr50.datatypes.skills.SkillType;
 import com.gmail.nossr50.locale.LocaleLoader;
 import com.gmail.nossr50.locale.LocaleLoader;
 import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
 import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
-import com.gmail.nossr50.util.Misc;
 import com.gmail.nossr50.util.Permissions;
 import com.gmail.nossr50.util.Permissions;
 import com.gmail.nossr50.util.StringUtils;
 import com.gmail.nossr50.util.StringUtils;
 import com.gmail.nossr50.util.commands.CommandUtils;
 import com.gmail.nossr50.util.commands.CommandUtils;
@@ -85,8 +84,9 @@ public class MctopCommand implements TabExecutor {
 
 
         if (sender instanceof Player) {
         if (sender instanceof Player) {
             McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
             McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
+            long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750);
 
 
-            if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
+            if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
                 sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
                 sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
                 return;
                 return;
             }
             }

+ 1 - 0
src/main/java/com/gmail/nossr50/config/Config.java

@@ -248,6 +248,7 @@ public class Config extends AutoUpdateConfigLoader {
     public boolean getAdminDisplayNames() { return config.getBoolean("Commands.adminchat.Use_Display_Names", true); }
     public boolean getAdminDisplayNames() { return config.getBoolean("Commands.adminchat.Use_Display_Names", true); }
 
 
     public boolean getMatchOfflinePlayers() { return config.getBoolean("Commands.Generic.Match_OfflinePlayers", false); }
     public boolean getMatchOfflinePlayers() { return config.getBoolean("Commands.Generic.Match_OfflinePlayers", false); }
+    public long getDatabasePlayerCooldown() { return config.getLong("Commands.Database.Player_Cooldown", 1750); }
 
 
     public boolean getLevelUpSoundsEnabled() { return config.getBoolean("General.LevelUp_Sounds", true); }
     public boolean getLevelUpSoundsEnabled() { return config.getBoolean("General.LevelUp_Sounds", true); }
 
 

+ 0 - 1
src/main/java/com/gmail/nossr50/util/Misc.java

@@ -22,7 +22,6 @@ public final class Misc {
     public static final int TIME_CONVERSION_FACTOR = 1000;
     public static final int TIME_CONVERSION_FACTOR = 1000;
     public static final int TICK_CONVERSION_FACTOR = 20;
     public static final int TICK_CONVERSION_FACTOR = 20;
 
 
-    public static final long PLAYER_DATABASE_COOLDOWN_MILLIS = 1750;
     public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5;
     public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5;
     public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
     public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
 
 

+ 4 - 0
src/main/resources/config.yml

@@ -395,6 +395,10 @@ Commands:
         # If true, when using partial names in commands mcMMO will try to look for a match from
         # If true, when using partial names in commands mcMMO will try to look for a match from
         # the offline players. Enabling this might slow the server down if there are a lot of offline players.
         # the offline players. Enabling this might slow the server down if there are a lot of offline players.
         Match_OfflinePlayers: false
         Match_OfflinePlayers: false
+    Database:
+        # Database command cooldown in milliseconds, cannot be changed below the default value. (1750)
+        # Prevents players from spamming /mctop or /mcrank
+        Player_Cooldown: 1750
     mcmmo:
     mcmmo:
         Donate_Message: true
         Donate_Message: true
     inspect:
     inspect: