mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-11-01 09:59:18 +00:00
fix that cooldown error, will require a table reset of pk_cooldowns, also make having database cooldowns configureable
This commit is contained in:
parent
2cf4ecdbd8
commit
61a0f1e713
|
@ -1,22 +1,5 @@
|
|||
package com.projectkorra.projectkorra;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.projectkorra.projectkorra.Element.SubElement;
|
||||
import com.projectkorra.projectkorra.ability.Ability;
|
||||
import com.projectkorra.projectkorra.ability.AvatarAbility;
|
||||
|
@ -33,6 +16,18 @@ import com.projectkorra.projectkorra.storage.DBConnection;
|
|||
import com.projectkorra.projectkorra.util.Cooldown;
|
||||
import com.projectkorra.projectkorra.util.DBCooldownManager;
|
||||
import com.projectkorra.projectkorra.waterbending.blood.Bloodbending;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Class that presents a player and stores all bending information about the
|
||||
|
@ -152,17 +147,18 @@ public class BendingPlayer {
|
|||
|
||||
public Map<String, Cooldown> loadCooldowns() {
|
||||
final Map<String, Cooldown> cooldowns = new ConcurrentHashMap<>();
|
||||
try (ResultSet rs = DBConnection.sql.readQuery("SELECT * FROM pk_cooldowns WHERE uuid = '" + this.uuid.toString() + "'")) {
|
||||
while (rs.next()) {
|
||||
final int cooldownId = rs.getInt("cooldown_id");
|
||||
final long value = rs.getLong("value");
|
||||
final String name = cooldownManager.getCooldownName(cooldownId);
|
||||
cooldowns.put(name, new Cooldown(value, true));
|
||||
if (ProjectKorra.isDatabaseCooldownsEnabled()) {
|
||||
try (ResultSet rs = DBConnection.sql.readQuery("SELECT * FROM pk_cooldowns WHERE uuid = '" + this.uuid.toString() + "'")) {
|
||||
while (rs.next()) {
|
||||
final int cooldownId = rs.getInt("cooldown_id");
|
||||
final long value = rs.getLong("value");
|
||||
final String name = cooldownManager.getCooldownName(cooldownId);
|
||||
cooldowns.put(name, new Cooldown(value, true));
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
catch (final SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return cooldowns;
|
||||
}
|
||||
|
||||
|
|
|
@ -1153,7 +1153,9 @@ public class PKListener implements Listener {
|
|||
Manager.getManager(StatisticsManager.class).store(player.getUniqueId());
|
||||
}
|
||||
if (bPlayer != null) {
|
||||
bPlayer.saveCooldowns();
|
||||
if (ProjectKorra.isDatabaseCooldownsEnabled()) {
|
||||
bPlayer.saveCooldowns();
|
||||
}
|
||||
|
||||
if (TOGGLED_OUT.contains(player.getUniqueId()) && bPlayer.isToggled()) {
|
||||
TOGGLED_OUT.remove(player.getUniqueId());
|
||||
|
|
|
@ -1,21 +1,8 @@
|
|||
package com.projectkorra.projectkorra;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.bekvon.bukkit.residence.protection.FlagPermissions;
|
||||
import com.projectkorra.projectkorra.ability.CoreAbility;
|
||||
import com.projectkorra.projectkorra.ability.util.CollisionInitializer;
|
||||
import com.projectkorra.projectkorra.ability.util.CollisionManager;
|
||||
import com.projectkorra.projectkorra.ability.util.ComboManager;
|
||||
import com.projectkorra.projectkorra.ability.util.MultiAbilityManager;
|
||||
import com.projectkorra.projectkorra.ability.util.PassiveManager;
|
||||
import com.projectkorra.projectkorra.ability.util.*;
|
||||
import com.projectkorra.projectkorra.airbending.util.AirbendingManager;
|
||||
import com.projectkorra.projectkorra.chiblocking.util.ChiblockingManager;
|
||||
import com.projectkorra.projectkorra.command.Commands;
|
||||
|
@ -24,12 +11,16 @@ import com.projectkorra.projectkorra.earthbending.util.EarthbendingManager;
|
|||
import com.projectkorra.projectkorra.firebending.util.FirebendingManager;
|
||||
import com.projectkorra.projectkorra.object.Preset;
|
||||
import com.projectkorra.projectkorra.storage.DBConnection;
|
||||
import com.projectkorra.projectkorra.util.Metrics;
|
||||
import com.projectkorra.projectkorra.util.RevertChecker;
|
||||
import com.projectkorra.projectkorra.util.StatisticsManager;
|
||||
import com.projectkorra.projectkorra.util.TempBlock;
|
||||
import com.projectkorra.projectkorra.util.Updater;
|
||||
import com.projectkorra.projectkorra.util.*;
|
||||
import com.projectkorra.projectkorra.waterbending.util.WaterbendingManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ProjectKorra extends JavaPlugin {
|
||||
|
||||
|
@ -152,7 +143,7 @@ public class ProjectKorra extends JavaPlugin {
|
|||
Manager.getManager(StatisticsManager.class).save(player.getUniqueId(), false);
|
||||
}
|
||||
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||
if (bPlayer != null) {
|
||||
if (bPlayer != null && isDatabaseCooldownsEnabled()) {
|
||||
bPlayer.saveCooldowns();
|
||||
}
|
||||
}
|
||||
|
@ -181,5 +172,8 @@ public class ProjectKorra extends JavaPlugin {
|
|||
public static boolean isStatisticsEnabled() {
|
||||
return ConfigManager.getConfig().getBoolean("Properties.Statistics");
|
||||
}
|
||||
public static boolean isDatabaseCooldownsEnabled() {
|
||||
return ConfigManager.getConfig().getBoolean("Properties.DatabaseCooldowns");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -541,6 +541,7 @@ public class ConfigManager {
|
|||
|
||||
config.addDefault("Properties.UpdateChecker", true);
|
||||
config.addDefault("Properties.Statistics", true);
|
||||
config.addDefault("Properties.DatabaseCooldowns", true);
|
||||
config.addDefault("Properties.BendingPreview", true);
|
||||
config.addDefault("Properties.BendingAffectFallingSand.Normal", true);
|
||||
config.addDefault("Properties.BendingAffectFallingSand.NormalStrengthMultiplier", 1.0);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package com.projectkorra.projectkorra.storage;
|
||||
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class DBConnection {
|
||||
|
||||
public static Database sql;
|
||||
|
@ -66,7 +66,7 @@ public class DBConnection {
|
|||
}
|
||||
if (!sql.tableExists("pk_cooldowns")) {
|
||||
ProjectKorra.log.info("Creating pk_cooldowns table");
|
||||
final String query = "CREATE TABLE `pk_cooldowns` (uuid VARCHAR(36) PRIMARY KEY, cooldown_id INTEGER NOT NULL, value BIGINT);";
|
||||
final String query = "CREATE TABLE `pk_cooldowns` (uuid VARCHAR(36) NOT NULL, cooldown_id INTEGER NOT NULL, value BIGINT);";
|
||||
sql.modifyQuery(query, false);
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue