From 130d1dc05e63f791b2b3f4e39e6ec39aea633df3 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 12 May 2017 15:07:48 -0400 Subject: [PATCH 1/5] Fix TNT being stuck on head --- .../game/arcade/game/games/castleassault/CastleAssault.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index 4df26278e..f746e3301 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -1420,7 +1420,7 @@ public class CastleAssault extends TeamGame UtilTextBottom.display(GetTeam(player).GetColor() + player.getName() + " has the TNT!", UtilServer.getPlayers()); UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.RED, false, false); - if (player.getInventory().getHelmet() == null || player.getInventory().getHelmet().getType() != Material.TNT) + if (player.getInventory().getHelmet() == null || player.getInventory().getHelmet().getType() == Material.AIR) { player.getInventory().setHelmet(_wearableTnt.build()); } From ea4f9aee62e07d0d3881cf40a902c966f8784ed8 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 12 May 2017 16:07:43 -0400 Subject: [PATCH 2/5] Tweak crown kill streak multipliers --- .../games/castleassault/CastleAssault.java | 39 ++++++------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index f746e3301..54ba4fa72 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -455,27 +455,22 @@ public class CastleAssault extends TeamGame } { - int crowns = 0; - for (GemData data : GetGems(player).values()) - { - crowns += data.Gems; - } int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); if (streak >= 2 && streak < 4) { - AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 10, streak + " Player Kill Streak", false, false); } else if (streak >= 4 && streak < 6) { - AddGems(player, crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 15, streak + " Player Kill Streak", false, false); } else if (streak >= 6 && streak < 8) { - AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 20, streak + " Player Kill Streak", false, false); } else if (streak >= 8) { - AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 25, streak + " Player Kill Streak", false, false); } } @@ -553,27 +548,22 @@ public class CastleAssault extends TeamGame } { - int crowns = 0; - for (GemData data : GetGems(player).values()) - { - crowns += data.Gems; - } int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); if (streak >= 2 && streak < 4) { - AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 10, streak + " Player Kill Streak", false, false); } else if (streak >= 4 && streak < 6) { - AddGems(player, crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 15, streak + " Player Kill Streak", false, false); } else if (streak >= 6 && streak < 8) { - AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 20, streak + " Player Kill Streak", false, false); } else if (streak >= 8) { - AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 25, streak + " Player Kill Streak", false, false); } } @@ -621,27 +611,22 @@ public class CastleAssault extends TeamGame } { - int crowns = 0; - for (GemData data : GetGems(player).values()) - { - crowns += data.Gems; - } int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); if (streak >= 2 && streak < 4) { - AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 10, streak + " Player Kill Streak", false, false); } else if (streak >= 4 && streak < 6) { - AddGems(player, crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 15, streak + " Player Kill Streak", false, false); } else if (streak >= 6 && streak < 8) { - AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 20, streak + " Player Kill Streak", false, false); } else if (streak >= 8) { - AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 25, streak + " Player Kill Streak", false, false); } } From a42e6ed9e46ade1dcd9424ab006effad284334d9 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 12 May 2017 18:44:05 -0400 Subject: [PATCH 3/5] Change crown calculations again --- .../games/castleassault/CastleAssault.java | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index 54ba4fa72..54e71d589 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -454,23 +454,29 @@ public class CastleAssault extends TeamGame AddGems(player, 10, "Participation", false, false); } + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + { int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); if (streak >= 2 && streak < 4) { - AddGems(player, 10, streak + " Player Kill Streak", false, false); + AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); } else if (streak >= 4 && streak < 6) { - AddGems(player, 15, streak + " Player Kill Streak", false, false); + AddGems(player, 1 * crowns, streak + " Player Kill Streak", false, false); } else if (streak >= 6 && streak < 8) { - AddGems(player, 20, streak + " Player Kill Streak", false, false); + AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); } else if (streak >= 8) { - AddGems(player, 25, streak + " Player Kill Streak", false, false); + AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); } } @@ -480,12 +486,6 @@ public class CastleAssault extends TeamGame int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); if (kitLevel > 0) { - int crowns = 0; - for (GemData data : GetGems(player).values()) - { - crowns += data.Gems; - } - AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); } } @@ -547,37 +547,40 @@ public class CastleAssault extends TeamGame AddGems(player, 10, "Participation", false, false); } + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + { int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); if (streak >= 2 && streak < 4) { - AddGems(player, 10, streak + " Player Kill Streak", false, false); + AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); } else if (streak >= 4 && streak < 6) { - AddGems(player, 15, streak + " Player Kill Streak", false, false); + AddGems(player, 1 * crowns, streak + " Player Kill Streak", false, false); } else if (streak >= 6 && streak < 8) { - AddGems(player, 20, streak + " Player Kill Streak", false, false); + AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); } else if (streak >= 8) { - AddGems(player, 25, streak + " Player Kill Streak", false, false); + AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); } } - KitPlayer kit = (KitPlayer) GetKit(player); - int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); - if (kitLevel > 0) + if (GetKit(player) != null) { - int crowns = 0; - for (GemData data : GetGems(player).values()) + KitPlayer kit = (KitPlayer) GetKit(player); + int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); + if (kitLevel > 0) { - crowns += data.Gems; + AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); } - - AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); } } } From 37d3b47995791ef57917df468e0acb35bf1abe8a Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 13 May 2017 01:00:10 -0400 Subject: [PATCH 4/5] Rebalance tank kit and set final values for kill streak crown rewards --- .../games/castleassault/CastleAssault.java | 68 +++++++------------ .../games/castleassault/kits/KitTank.java | 17 ++--- 2 files changed, 32 insertions(+), 53 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index 54e71d589..f4ed36446 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -6,11 +6,11 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.WeakHashMap; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.Color; import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Material; @@ -455,9 +455,12 @@ public class CastleAssault extends TeamGame } int crowns = 0; - for (GemData data : GetGems(player).values()) + for (Entry data : GetGems(player).entrySet()) { - crowns += data.Gems; + if (data.getKey().equals("Kills")) + { + crowns += data.getValue().Gems; + } } { @@ -479,16 +482,6 @@ public class CastleAssault extends TeamGame AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); } } - - if (GetKit(player) != null) - { - KitPlayer kit = (KitPlayer) GetKit(player); - int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); - if (kitLevel > 0) - { - AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); - } - } } } SetState(GameState.End); @@ -548,9 +541,12 @@ public class CastleAssault extends TeamGame } int crowns = 0; - for (GemData data : GetGems(player).values()) + for (Entry data : GetGems(player).entrySet()) { - crowns += data.Gems; + if (data.getKey().equals("Kills")) + { + crowns += data.getValue().Gems; + } } { @@ -572,16 +568,6 @@ public class CastleAssault extends TeamGame AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); } } - - if (GetKit(player) != null) - { - KitPlayer kit = (KitPlayer) GetKit(player); - int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); - if (kitLevel > 0) - { - AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); - } - } } } SetState(GameState.End); @@ -613,38 +599,34 @@ public class CastleAssault extends TeamGame AddGems(player, 10, "Participation", false, false); } + int crowns = 0; + for (Entry data : GetGems(player).entrySet()) + { + if (data.getKey().equals("Kills")) + { + crowns += data.getValue().Gems; + } + } + { int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); if (streak >= 2 && streak < 4) { - AddGems(player, 10, streak + " Player Kill Streak", false, false); + AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); } else if (streak >= 4 && streak < 6) { - AddGems(player, 15, streak + " Player Kill Streak", false, false); + AddGems(player, 1 * crowns, streak + " Player Kill Streak", false, false); } else if (streak >= 6 && streak < 8) { - AddGems(player, 20, streak + " Player Kill Streak", false, false); + AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); } else if (streak >= 8) { - AddGems(player, 25, streak + " Player Kill Streak", false, false); + AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); } } - - KitPlayer kit = (KitPlayer) GetKit(player); - int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); - if (kitLevel > 0) - { - int crowns = 0; - for (GemData data : GetGems(player).values()) - { - crowns += data.Gems; - } - - AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); - } } } SetState(GameState.End); @@ -1407,7 +1389,7 @@ public class CastleAssault extends TeamGame } UtilTextBottom.display(GetTeam(player).GetColor() + player.getName() + " has the TNT!", UtilServer.getPlayers()); - UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.RED, false, false); + UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, GetTeam(player).GetColorBase(), false, false); if (player.getInventory().getHelmet() == null || player.getInventory().getHelmet().getType() == Material.AIR) { player.getInventory().setHelmet(_wearableTnt.build()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java index 710781ebc..c6b01406f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java @@ -14,7 +14,6 @@ import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkIronSkin; public class KitTank extends KitPlayer { @@ -26,18 +25,16 @@ public class KitTank extends KitPlayer C.cGrayB + "Starting Kit:", C.cGray + "Diamond Sword", C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", - C.cGray + "Protection I on Iron Armor", - C.cGreenB + "Passive Ability:", - C.cGreen + "Iron Skin: Take half a heart less damage from all Attacks" + C.cGray + "Protection I on Iron Armor" }, new Perk[][] { - new Perk[] {new PerkIronSkin(1, false)}, - new Perk[] {new PerkIronSkin(1, false)}, - new Perk[] {new PerkIronSkin(1, false)}, - new Perk[] {new PerkIronSkin(1, false)}, - new Perk[] {new PerkIronSkin(1, false)}, - new Perk[] {new PerkIronSkin(1, false)} + new Perk[] {}, + new Perk[] {}, + new Perk[] {}, + new Perk[] {}, + new Perk[] {}, + new Perk[] {} }, new String[][] { From 9cf5fda540ff1b553e34cd42e9a41cdcc2169dfb Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 13 May 2017 01:02:06 -0400 Subject: [PATCH 5/5] Update leaderboards system to use more malleable seasons system --- .../leaderboard/LeaderboardRepository.java | 54 ++++--------------- 1 file changed, 11 insertions(+), 43 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java index 866a1e5b7..f9b286039 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java @@ -18,27 +18,25 @@ import mineplex.serverdata.database.RepositoryBase; public class LeaderboardRepository extends RepositoryBase { - private static final int SEASON = 1; - - private static final String CREATE_TOTAL = "CREATE TABLE accountStatsSeasonalTotal (accountId INT NOT NULL, statId INT NOT NULL, season SMALLINT NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId, season), INDEX valueIndex (value DESC), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; + private static final String CREATE_TOTAL = "CREATE TABLE accountStatsAllTime (accountId INT NOT NULL, statId INT NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; + private static final String CREATE_SEASONAL = "CREATE TABLE accountStatsSeasonal (accountId INT NOT NULL, statId INT NOT NULL, seasonId SMALLINT NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), INDEX seasonIndex (seasonId), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id), FOREIGN KEY (seasonId) REFERENCES statSeasons(id));"; private static final String CREATE_YEARLY = "CREATE TABLE accountStatsYearly (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), INDEX dateIndex (date), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; private static final String CREATE_MONTHLY = "CREATE TABLE accountStatsMonthly (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), INDEX dateIndex (date), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; private static final String CREATE_WEEKLY = "CREATE TABLE accountStatsWeekly (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), INDEX dateIndex (date), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; private static final String CREATE_DAILY = "CREATE TABLE accountStatsDaily (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), INDEX dateIndex (date), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; + private static final String CREATE_SEASON = "CREATE TABLE statSeasons (id SMALLINT NOT NULL, seasonName VARCHAR(50) NOT NULL, startDate TIMESTAMP NOT NULL DEFAULT '1969-12-31 18:00:01', endDate TIMESTAMP NOT NULL DEFAULT '1969-12-31 18:00:01', PRIMARY KEY (id), UNIQUE INDEX seasonIndex (seasonName), INDEX startIndex (startDate), INDEX endIndex (endDate));"; - private static final String INSERT_STAT = "INSERT INTO accountStatsSeasonalTotal (accountId, statId, season, value) VALUES (?, ?, " + SEASON + ", ?);"; - private static final String INSERT_STAT_ALL = "INSERT INTO accountStatsSeasonalTotal (accountId, statId, season, value) VALUES (?, ?, 0, ?);"; - private static final String UPDATE_STAT = "UPDATE accountStatsSeasonalTotal SET value=value + ? WHERE accountId=? AND statId=? AND season=" + SEASON + ";"; - private static final String UPDATE_STAT_ALL = "UPDATE accountStatsSeasonalTotal SET value=value + ? WHERE accountId=? AND statId=? AND season=0;"; + private static final String INSERT_STAT = "INSERT INTO accountStatsAllTime (accountId, statId, value) VALUES (?, ?, ?);"; + private static final String UPDATE_STAT = "UPDATE accountStatsAllTime SET value=value + ? WHERE accountId=? AND statId=?;"; - private static final String FETCH_STAT_ALL = "SELECT a.name, sl.value FROM accountStatsSeasonalTotal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% AND season=0 ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_ALL = "SELECT a.name, sl.value FROM accountStatsAllTime AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; private static final String FETCH_STAT_YEARLY = "SELECT a.name, sl.value FROM accountStatsYearly AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; private static final String FETCH_STAT_MONTHLY = "SELECT a.name, sl.value FROM accountStatsMonthly AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE MONTH(sl.date) = MONTH(CURDATE()) AND YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; private static final String FETCH_STAT_WEEKLY = "SELECT a.name, sl.value FROM accountStatsWeekly AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEARWEEK(sl.date, 1) = YEARWEEK(CURDATE(), 1) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; private static final String FETCH_STAT_DAILY = "SELECT a.name, sl.value FROM accountStatsDaily AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.date = CURDATE() AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_ALL_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonalTotal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_ALL_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% AND seasonId=(SELECT id FROM statSeasons WHERE now() BETWEEN startDate AND endDate LIMIT 1) ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; public LeaderboardRepository(JavaPlugin plugin) { @@ -52,9 +50,7 @@ public class LeaderboardRepository extends RepositoryBase try ( Connection c = getConnection(); PreparedStatement updateStat = c.prepareStatement(UPDATE_STAT); - PreparedStatement updateAllStats = c.prepareStatement(UPDATE_STAT_ALL); PreparedStatement insertStat = c.prepareStatement(INSERT_STAT); - PreparedStatement insertAllStats = c.prepareStatement(INSERT_STAT_ALL); ) { for (Integer accountId : stats.keySet()) @@ -65,38 +61,25 @@ public class LeaderboardRepository extends RepositoryBase updateStat.setInt(2, accountId); updateStat.setInt(3, statId); updateStat.addBatch(); - updateAllStats.setLong(1, stats.get(accountId).get(statId)); - updateAllStats.setInt(2, accountId); - updateAllStats.setInt(3, statId); - updateAllStats.addBatch(); } } - int[] rowsAffected1 = updateStat.executeBatch(); - int[] rowsAffected2 = updateAllStats.executeBatch(); + int[] rowsAffected = updateStat.executeBatch(); int i = 0; for (Integer accountId : stats.keySet()) { for (Integer statId : stats.get(accountId).keySet()) { - if (rowsAffected1[i] < 1) + if (rowsAffected[i] < 1) { insertStat.setInt(1, accountId); insertStat.setInt(2, statId); insertStat.setLong(3, stats.get(accountId).get(statId)); insertStat.addBatch(); } - if (rowsAffected2[i] < 1) - { - insertAllStats.setInt(1, accountId); - insertAllStats.setInt(2, statId); - insertAllStats.setLong(3, stats.get(accountId).get(statId)); - insertAllStats.addBatch(); - } i++; } } insertStat.executeBatch(); - insertAllStats.executeBatch(); } catch (SQLException e) { @@ -110,9 +93,7 @@ public class LeaderboardRepository extends RepositoryBase try ( Connection c = getConnection(); PreparedStatement updateStat = c.prepareStatement(UPDATE_STAT); - PreparedStatement updateAllStats = c.prepareStatement(UPDATE_STAT_ALL); PreparedStatement insertStat = c.prepareStatement(INSERT_STAT); - PreparedStatement insertAllStats = c.prepareStatement(INSERT_STAT_ALL); ) { for (Integer statId : stats.keySet()) @@ -121,34 +102,21 @@ public class LeaderboardRepository extends RepositoryBase updateStat.setInt(2, accountId); updateStat.setInt(3, statId); updateStat.addBatch(); - updateAllStats.setLong(1, stats.get(statId)); - updateAllStats.setInt(2, accountId); - updateAllStats.setInt(3, statId); - updateAllStats.addBatch(); } - int[] rowsAffected1 = updateStat.executeBatch(); - int[] rowsAffected2 = updateAllStats.executeBatch(); + int[] rowsAffected = updateStat.executeBatch(); int i = 0; for (Integer statId : stats.keySet()) { - if (rowsAffected1[i] < 1) + if (rowsAffected[i] < 1) { insertStat.setInt(1, accountId); insertStat.setInt(2, statId); insertStat.setLong(3, stats.get(statId)); insertStat.addBatch(); } - if (rowsAffected2[i] < 1) - { - insertAllStats.setInt(1, accountId); - insertAllStats.setInt(2, statId); - insertAllStats.setLong(3, stats.get(statId)); - insertAllStats.addBatch(); - } i++; } insertStat.executeBatch(); - insertAllStats.executeBatch(); } catch (SQLException e) {