Merge remote-tracking branch 'refs/remotes/origin/develop' into feature/alien-invasion
This commit is contained in:
commit
c8f20f3df5
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
@ -454,12 +454,16 @@ public class CastleAssault extends TeamGame
|
||||
AddGems(player, 10, "Participation", false, false);
|
||||
}
|
||||
|
||||
{
|
||||
int crowns = 0;
|
||||
for (GemData data : GetGems(player).values())
|
||||
for (Entry<String, GemData> data : GetGems(player).entrySet())
|
||||
{
|
||||
crowns += data.Gems;
|
||||
if (data.getKey().equals("Kills"))
|
||||
{
|
||||
crowns += data.getValue().Gems;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak();
|
||||
if (streak >= 2 && streak < 4)
|
||||
{
|
||||
@ -467,7 +471,7 @@ public class CastleAssault extends TeamGame
|
||||
}
|
||||
else if (streak >= 4 && streak < 6)
|
||||
{
|
||||
AddGems(player, crowns, streak + " Player Kill Streak", false, false);
|
||||
AddGems(player, 1 * crowns, streak + " Player Kill Streak", false, false);
|
||||
}
|
||||
else if (streak >= 6 && streak < 8)
|
||||
{
|
||||
@ -478,22 +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)
|
||||
{
|
||||
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);
|
||||
@ -552,12 +540,16 @@ public class CastleAssault extends TeamGame
|
||||
AddGems(player, 10, "Participation", false, false);
|
||||
}
|
||||
|
||||
{
|
||||
int crowns = 0;
|
||||
for (GemData data : GetGems(player).values())
|
||||
for (Entry<String, GemData> data : GetGems(player).entrySet())
|
||||
{
|
||||
crowns += data.Gems;
|
||||
if (data.getKey().equals("Kills"))
|
||||
{
|
||||
crowns += data.getValue().Gems;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak();
|
||||
if (streak >= 2 && streak < 4)
|
||||
{
|
||||
@ -565,7 +557,7 @@ public class CastleAssault extends TeamGame
|
||||
}
|
||||
else if (streak >= 4 && streak < 6)
|
||||
{
|
||||
AddGems(player, crowns, streak + " Player Kill Streak", false, false);
|
||||
AddGems(player, 1 * crowns, streak + " Player Kill Streak", false, false);
|
||||
}
|
||||
else if (streak >= 6 && streak < 8)
|
||||
{
|
||||
@ -576,19 +568,6 @@ public class CastleAssault extends TeamGame
|
||||
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);
|
||||
@ -620,12 +599,16 @@ public class CastleAssault extends TeamGame
|
||||
AddGems(player, 10, "Participation", false, false);
|
||||
}
|
||||
|
||||
{
|
||||
int crowns = 0;
|
||||
for (GemData data : GetGems(player).values())
|
||||
for (Entry<String, GemData> data : GetGems(player).entrySet())
|
||||
{
|
||||
crowns += data.Gems;
|
||||
if (data.getKey().equals("Kills"))
|
||||
{
|
||||
crowns += data.getValue().Gems;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak();
|
||||
if (streak >= 2 && streak < 4)
|
||||
{
|
||||
@ -633,7 +616,7 @@ public class CastleAssault extends TeamGame
|
||||
}
|
||||
else if (streak >= 4 && streak < 6)
|
||||
{
|
||||
AddGems(player, crowns, streak + " Player Kill Streak", false, false);
|
||||
AddGems(player, 1 * crowns, streak + " Player Kill Streak", false, false);
|
||||
}
|
||||
else if (streak >= 6 && streak < 8)
|
||||
{
|
||||
@ -644,19 +627,6 @@ public class CastleAssault extends TeamGame
|
||||
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);
|
||||
@ -1419,8 +1389,8 @@ 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)
|
||||
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());
|
||||
}
|
||||
|
@ -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[][]
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user