diff --git a/Minepacks/resources/config.yml b/Minepacks/resources/config.yml index ab3b6a9..3a4198c 100644 --- a/Minepacks/resources/config.yml +++ b/Minepacks/resources/config.yml @@ -41,7 +41,7 @@ Cooldown: # If enabled, cooldowns will be synced between servers (BungeeCord network). It will also allow keeping the cooldown through server restarts. # You should only use it with long cooldown times. Sync: false - # Adds the cooldown when the player joins the server + # Adds the cooldown when the player joins the server. Will be disabled if sync is enabled. AddOnJoin: true # Controls for the auto pickup on full inventory function diff --git a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Backend/MySQL.java b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Backend/MySQL.java index ecf9e7c..19b6d54 100644 --- a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Backend/MySQL.java +++ b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Backend/MySQL.java @@ -30,7 +30,7 @@ public class MySQL extends SQL { - public MySQL(@NotNull Minepacks plugin, @Nullable ConnectionProvider connectionProvider) throws SQLException + public MySQL(final @NotNull Minepacks plugin, final @Nullable ConnectionProvider connectionProvider) throws SQLException { super(plugin, (connectionProvider == null) ? new MySQLConnectionProvider(plugin.getLogger(), plugin.getDescription().getName(), plugin.getConfiguration()) : connectionProvider); } diff --git a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Backend/SQL.java b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Backend/SQL.java index 350254c..f68c28e 100644 --- a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Backend/SQL.java +++ b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Backend/SQL.java @@ -172,7 +172,7 @@ protected final void buildQueries() " WHERE {FieldUUID}=?;"; queryUpdatePlayerAdd = "INSERT INTO {TablePlayers} ({FieldName},{FieldUUID}) VALUES (?,?) ON DUPLICATE KEY UPDATE {FieldName}=?;"; queryGetBP = "SELECT * FROM {TableBackpacks} WHERE {FieldBPOwner}=?;"; - querySyncCooldown = "INSERT INTO {TableCooldowns} ({FieldCDPlayer},{FieldCDTime}) VALUE (?,?) ON DUPLICATE KEY UPDATE {FieldCDTime}=?;"; + querySyncCooldown = "INSERT INTO {TableCooldowns} ({FieldCDPlayer},{FieldCDTime}) VALUES (?,?) ON DUPLICATE KEY UPDATE {FieldCDTime}=?;"; queryDeleteOldCooldowns = "DELETE FROM {TableCooldowns} WHERE {FieldCDTime} getAllowedGameModes() diff --git a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/MinepacksPlayerData.java b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/MinepacksPlayerData.java index 215110c..77c0389 100644 --- a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/MinepacksPlayerData.java +++ b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/MinepacksPlayerData.java @@ -53,7 +53,7 @@ public class MinepacksPlayerData implements MinepacksPlayerExtended, ICacheableP @Getter private String backpackStyleName = MagicValues.BACKPACK_STYLE_NAME_DEFAULT; private ItemConfig backpackStyle = null; @Getter private Backpack backpack = null; - @Getter private long cooldown = 0; + @Getter private long cooldown = System.currentTimeMillis(); @Getter @Setter private boolean backpackLoadingRequested = false; @Getter @Setter private Object databaseKey = null; diff --git a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Listener/CooldownHandler.java b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Listener/CooldownHandler.java index d1b7606..87f7c6c 100644 --- a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Listener/CooldownHandler.java +++ b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Listener/CooldownHandler.java @@ -39,11 +39,8 @@ public CooldownHandler(final @NotNull Minepacks plugin) public long getRemainingCooldown(final @NotNull MinepacksPlayer player) { - long cd = player.getCooldown() + cooldown; - if(cd > System.currentTimeMillis()) - { - return cd - System.currentTimeMillis(); - } + long cd = player.getCooldown() + cooldown - System.currentTimeMillis(); + if(cd > 0) return cd; return 0; }