Record basic game stats (game type, timestamp, duration, winners, losers)
This commit is contained in:
parent
c550e59d45
commit
c5ff9da552
@ -12,6 +12,8 @@
|
||||
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.Core" />
|
||||
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.ClassCombat" />
|
||||
<orderEntry type="library" name="craftbukkit" level="project" />
|
||||
<orderEntry type="library" name="jooq" level="project" />
|
||||
<orderEntry type="module" module-name="Mineplex.Database" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
@ -4,19 +4,8 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import mineplex.core.leaderboard.LeaderboardRepository;
|
||||
import nautilus.game.arcade.addons.*;
|
||||
import nautilus.game.arcade.command.*;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.GameServerConfig;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import nautilus.game.arcade.managers.*;
|
||||
import nautilus.game.arcade.shop.ArcadeShop;
|
||||
import nautilus.game.arcade.world.FireworkHandler;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -38,41 +27,31 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
|
||||
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||
import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager;
|
||||
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
import mineplex.minecraft.game.classcombat.item.ItemFactory;
|
||||
import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent;
|
||||
import mineplex.minecraft.game.classcombat.shop.ClassCombatShop;
|
||||
import mineplex.minecraft.game.classcombat.shop.ClassShopManager;
|
||||
import mineplex.minecraft.game.core.IRelation;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import mineplex.minecraft.game.core.fire.Fire;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.antistack.AntiStack;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.blood.Blood;
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.creature.Creature;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.movement.Movement;
|
||||
import mineplex.core.elo.EloManager;
|
||||
import mineplex.core.energy.Energy;
|
||||
import mineplex.core.explosion.Explosion;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.movement.Movement;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
@ -82,6 +61,42 @@ import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.teleport.Teleport;
|
||||
import mineplex.core.timing.TimingManager;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||
import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager;
|
||||
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
import mineplex.minecraft.game.classcombat.item.ItemFactory;
|
||||
import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent;
|
||||
import mineplex.minecraft.game.classcombat.shop.ClassCombatShop;
|
||||
import mineplex.minecraft.game.classcombat.shop.ClassShopManager;
|
||||
import mineplex.minecraft.game.core.IRelation;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import mineplex.minecraft.game.core.fire.Fire;
|
||||
import nautilus.game.arcade.addons.CompassAddon;
|
||||
import nautilus.game.arcade.addons.SoupAddon;
|
||||
import nautilus.game.arcade.addons.TeamArmorAddon;
|
||||
import nautilus.game.arcade.command.GameCommand;
|
||||
import nautilus.game.arcade.command.WriteCommand;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.GameServerConfig;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import nautilus.game.arcade.managers.GameAchievementManager;
|
||||
import nautilus.game.arcade.managers.GameChatManager;
|
||||
import nautilus.game.arcade.managers.GameCreationManager;
|
||||
import nautilus.game.arcade.managers.GameFlagManager;
|
||||
import nautilus.game.arcade.managers.GameGemManager;
|
||||
import nautilus.game.arcade.managers.GameLobbyManager;
|
||||
import nautilus.game.arcade.managers.GameManager;
|
||||
import nautilus.game.arcade.managers.GamePlayerManager;
|
||||
import nautilus.game.arcade.managers.GameWorldManager;
|
||||
import nautilus.game.arcade.managers.IdleManager;
|
||||
import nautilus.game.arcade.managers.MiscManager;
|
||||
import nautilus.game.arcade.shop.ArcadeShop;
|
||||
import nautilus.game.arcade.world.FireworkHandler;
|
||||
|
||||
public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
{
|
||||
@ -102,16 +117,16 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
private ProjectileManager _projectileManager;
|
||||
|
||||
private Portal _portal;
|
||||
private ArcadeShop _arcadeShop;
|
||||
private ArcadeShop _arcadeShop;
|
||||
|
||||
// Managers
|
||||
private GameFactory _gameFactory;
|
||||
private GameCreationManager _gameCreationManager;
|
||||
private GameGemManager _gameGemManager;
|
||||
private GameManager _gameManager;
|
||||
private GameManager _gameManager;
|
||||
private GameLobbyManager _gameLobbyManager;
|
||||
private GamePlayerManager _gamePlayerManager;
|
||||
private GameWorldManager _gameWorldManager;
|
||||
private GameWorldManager _gameWorldManager;
|
||||
private ServerStatusManager _serverStatusManager;
|
||||
private InventoryManager _inventoryManager;
|
||||
private CosmeticManager _cosmeticManager;
|
||||
@ -123,7 +138,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
private ClassShopManager _classShopManager;
|
||||
private ClassCombatShop _classShop;
|
||||
private TaskManager _taskManager;
|
||||
private LeaderboardRepository _leaderboardRepository;
|
||||
private ArcadeRepository _arcadeRepository;
|
||||
|
||||
private EloManager _eloManager;
|
||||
|
||||
@ -135,14 +150,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
// Games
|
||||
private Game _game;
|
||||
|
||||
|
||||
private HashMap<String, String> _tournamentTeam = new HashMap<String, String>();
|
||||
|
||||
public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig,
|
||||
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
|
||||
DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, AntiStack antistack,
|
||||
Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler,
|
||||
CosmeticManager cosmeticManager, ProjectileManager projectileManager, String webAddress)
|
||||
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
|
||||
DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, AntiStack antistack,
|
||||
Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler,
|
||||
CosmeticManager cosmeticManager, ProjectileManager projectileManager, String webAddress)
|
||||
{
|
||||
super("Game Manager", plugin);
|
||||
|
||||
@ -207,7 +222,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
}
|
||||
|
||||
_statsManager = new StatsManager(plugin);
|
||||
_taskManager = new TaskManager(plugin, webAddress);
|
||||
_taskManager = new TaskManager(plugin, webAddress);
|
||||
_achievementManager = new AchievementManager(_statsManager, clientManager, donationManager);
|
||||
_inventoryManager = inventoryManager;
|
||||
_cosmeticManager = cosmeticManager;
|
||||
@ -232,7 +247,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
new MiscManager(this);
|
||||
new IdleManager(this);
|
||||
|
||||
_leaderboardRepository = new LeaderboardRepository(plugin);
|
||||
_arcadeRepository = new ArcadeRepository(plugin);
|
||||
// Game Addons
|
||||
new CompassAddon(plugin, this);
|
||||
new SoupAddon(plugin, this);
|
||||
@ -350,7 +365,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
{
|
||||
return _gameLobbyManager;
|
||||
}
|
||||
|
||||
|
||||
public TaskManager GetTaskManager()
|
||||
{
|
||||
return _taskManager;
|
||||
@ -463,7 +478,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
{
|
||||
String extrainformation = "|" + _serverConfig.ServerType + "|" + (_game == null ? "Unknown" : _game.GetName())
|
||||
+ "|" + ((_game == null || _game.WorldData == null) ? "Unknown" : _game.WorldData.MapName);
|
||||
|
||||
|
||||
//Always Joinable
|
||||
if (_game.JoinInProgress)
|
||||
{
|
||||
@ -472,7 +487,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
//UHC Timed
|
||||
else if (_game != null && _game.GetType() == GameType.UHC)
|
||||
{
|
||||
event.setMotd(((UHC)_game).getMotdStatus() + extrainformation);
|
||||
event.setMotd(((UHC) _game).getMotdStatus() + extrainformation);
|
||||
}
|
||||
//Recruiting
|
||||
else if (_game == null || _game.GetState() == GameState.Recruit)
|
||||
@ -509,7 +524,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
event.setQuitMessage(F.sys("Quit", GetColor(event.getPlayer()) + event.getPlayer().getName()));
|
||||
else
|
||||
event.setQuitMessage(null);
|
||||
|
||||
|
||||
_tournamentTeam.remove(event.getPlayer().getName());
|
||||
}
|
||||
|
||||
@ -537,11 +552,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
{
|
||||
if (!IsHotbarHubClock())
|
||||
return;
|
||||
|
||||
if (_game != null && !_game.GiveClock)
|
||||
|
||||
if (_game != null && !_game.GiveClock)
|
||||
return;
|
||||
|
||||
if (player.getOpenInventory().getType() != InventoryType.CRAFTING &&
|
||||
if (player.getOpenInventory().getType() != InventoryType.CRAFTING &&
|
||||
player.getOpenInventory().getType() != InventoryType.CREATIVE)
|
||||
return;
|
||||
|
||||
@ -550,12 +565,12 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
player.getInventory().setItem(
|
||||
8,
|
||||
ItemStackFactory.Instance.CreateStack(Material.WATCH, (byte) 0, 1, (short) 0, C.cGreen
|
||||
+ "Return to Hub", new String[] { "", ChatColor.RESET + "Click while holding this",
|
||||
ChatColor.RESET + "to return to the Hub." }));
|
||||
+ "Return to Hub", new String[]{"", ChatColor.RESET + "Click while holding this",
|
||||
ChatColor.RESET + "to return to the Hub."}));
|
||||
|
||||
UtilInv.Update(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Login(PlayerLoginEvent event)
|
||||
@ -606,7 +621,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
else if (_clientManager.Get(event.getPlayer().getName()).GetRank()
|
||||
.Has(event.getPlayer(), Rank.ULTRA, false)
|
||||
|| _donationManager.Get(event.getPlayer().getName()).OwnsUnknownPackage(
|
||||
_serverConfig.ServerType + " ULTRA"))
|
||||
_serverConfig.ServerType + " ULTRA"))
|
||||
{
|
||||
event.allow();
|
||||
event.setResult(PlayerLoginEvent.Result.ALLOWED);
|
||||
@ -636,7 +651,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
player.setSprinting(false);
|
||||
player.setSneaking(false);
|
||||
|
||||
|
||||
player.setFoodLevel(20);
|
||||
player.setSaturation(3f);
|
||||
player.setExhaustion(0f);
|
||||
@ -658,7 +673,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
//Remove all conditions
|
||||
GetCondition().EndCondition(player, null, null);
|
||||
|
||||
|
||||
HubClock(player);
|
||||
|
||||
GetDisguise().undisguise(player);
|
||||
@ -714,7 +729,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
public void openClassShop(Player player)
|
||||
{
|
||||
_classShop.attemptShopOpen(player);
|
||||
_classShop.attemptShopOpen(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -828,67 +843,67 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
{
|
||||
return _serverConfig.Tournament;
|
||||
}
|
||||
|
||||
|
||||
public boolean IsTeamRejoin()
|
||||
{
|
||||
return _serverConfig.TeamRejoin;
|
||||
}
|
||||
|
||||
|
||||
public boolean IsTeamAutoJoin()
|
||||
{
|
||||
return _serverConfig.TeamAutoJoin;
|
||||
}
|
||||
|
||||
|
||||
public boolean IsGameAutoStart()
|
||||
{
|
||||
return _serverConfig.GameAutoStart;
|
||||
}
|
||||
|
||||
|
||||
public boolean IsGameTimeout()
|
||||
{
|
||||
return _serverConfig.GameTimeout;
|
||||
}
|
||||
|
||||
|
||||
public boolean IsTeamBalance()
|
||||
{
|
||||
return _serverConfig.TeamForceBalance;
|
||||
}
|
||||
|
||||
|
||||
public boolean IsRewardGems()
|
||||
{
|
||||
return _serverConfig.RewardGems;
|
||||
}
|
||||
|
||||
|
||||
public boolean IsRewardItems()
|
||||
{
|
||||
return _serverConfig.RewardItems;
|
||||
}
|
||||
|
||||
|
||||
public boolean IsRewardStats()
|
||||
{
|
||||
return _serverConfig.RewardStats;
|
||||
}
|
||||
|
||||
|
||||
public boolean IsRewardAchievements()
|
||||
{
|
||||
return _serverConfig.RewardAchievements;
|
||||
}
|
||||
|
||||
|
||||
public boolean IsHotbarInventory()
|
||||
{
|
||||
return _serverConfig.HotbarInventory;
|
||||
}
|
||||
|
||||
|
||||
public boolean IsHotbarHubClock()
|
||||
{
|
||||
return _serverConfig.HotbarHubClock;
|
||||
}
|
||||
|
||||
|
||||
public boolean IsPlayerKickIdle()
|
||||
{
|
||||
return _serverConfig.PlayerKickIdle;
|
||||
}
|
||||
|
||||
|
||||
public int GetDesiredPlayerAmount()
|
||||
{
|
||||
return _serverConfig.MaxPlayers;
|
||||
@ -921,37 +936,37 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
if (getCosmeticManager().isShowingInterface())
|
||||
{
|
||||
getCosmeticManager().setActive(false);
|
||||
getCosmeticManager().disableItemsForGame();
|
||||
getCosmeticManager().disableItemsForGame();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setTournamentTeam(Player player, GameTeam team)
|
||||
{
|
||||
if (!IsTeamRejoin())
|
||||
return;
|
||||
|
||||
|
||||
_tournamentTeam.put(player.getName(), team.GetName());
|
||||
}
|
||||
|
||||
|
||||
public void rejoinTournamentTeam(Player player)
|
||||
{
|
||||
if (_game == null)
|
||||
return;
|
||||
|
||||
|
||||
if (!_tournamentTeam.containsKey(player.getName()))
|
||||
return;
|
||||
|
||||
GameTeam curPref = _game.GetTeamPreference(player);
|
||||
if (curPref != null)
|
||||
return;
|
||||
|
||||
|
||||
GameTeam curTeam = _game.GetTeam(player);
|
||||
if (curTeam != null)
|
||||
return;
|
||||
|
||||
String teamName = _tournamentTeam.get(player.getName());
|
||||
|
||||
|
||||
for (GameTeam team : _game.GetTeamList())
|
||||
{
|
||||
if (team.GetName().equalsIgnoreCase(teamName))
|
||||
@ -962,8 +977,53 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
}
|
||||
}
|
||||
|
||||
public LeaderboardRepository getLeaderboardRepository()
|
||||
public ArcadeRepository getArcadeRepository()
|
||||
{
|
||||
return _leaderboardRepository;
|
||||
return _arcadeRepository;
|
||||
}
|
||||
|
||||
public void saveBasicStats(final Game game)
|
||||
{
|
||||
final Map<UUID, Boolean> data = new HashMap<>();
|
||||
|
||||
for (Player loser : game.getLosers())
|
||||
data.put(loser.getUniqueId(), false);
|
||||
|
||||
for (Player winner : game.getWinners())
|
||||
data.put(winner.getUniqueId(), true);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
getArcadeRepository().saveBasicStats(game.GetType(), IsTournamentServer(), (int) (System.currentTimeMillis() - game.getGameLiveTime()), data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void saveLeaderboardStats(Game game)
|
||||
{
|
||||
final TournamentType type = TournamentType.getTournamentType(game.GetType());
|
||||
|
||||
if (type != null)
|
||||
{
|
||||
final Map<UUID, Boolean> data = new HashMap<>();
|
||||
|
||||
for (Player loser : game.getLosers())
|
||||
data.put(loser.getUniqueId(), false);
|
||||
|
||||
for (Player winner : game.getWinners())
|
||||
data.put(winner.getUniqueId(), true);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
getArcadeRepository().saveLeaderboardStats(0, type.ordinal(), data);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.leaderboard;
|
||||
package nautilus.game.arcade;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -9,13 +9,14 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.database.Tables;
|
||||
import mineplex.database.tables.records.GamesRecord;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.impl.DSL;
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
public class LeaderboardRepository extends RepositoryBase
|
||||
public class ArcadeRepository extends RepositoryBase
|
||||
{
|
||||
public LeaderboardRepository(JavaPlugin plugin)
|
||||
public ArcadeRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
}
|
||||
@ -32,7 +33,7 @@ public class LeaderboardRepository extends RepositoryBase
|
||||
|
||||
}
|
||||
|
||||
public void saveStats(int tournamentId, int gameId, Map<UUID, Boolean> wins)
|
||||
public void saveBasicStats(GameType type, boolean tournament, int duration, Map<UUID, Boolean> players)
|
||||
{
|
||||
DSLContext context;
|
||||
|
||||
@ -41,9 +42,42 @@ public class LeaderboardRepository extends RepositoryBase
|
||||
context = DSL.using(getConnection());
|
||||
}
|
||||
|
||||
List<Query> queryList = new ArrayList<>(wins.size());
|
||||
GamesRecord record = context.newRecord(Tables.games);
|
||||
record.setDuration(duration);
|
||||
record.setTournament(tournament);
|
||||
record.setType(type.name());
|
||||
record.store();
|
||||
|
||||
for (Map.Entry<UUID, Boolean> entry : wins.entrySet())
|
||||
List<Query> queryList = new ArrayList<>(players.size());
|
||||
|
||||
for (Map.Entry<UUID, Boolean> entry : players.entrySet())
|
||||
{
|
||||
Query query = context
|
||||
.insertInto(Tables.gamePlayers)
|
||||
.set(Tables.gamePlayers.gameId, record.getId())
|
||||
.set(Tables.gamePlayers.accountId, DSL.select(Tables.accounts.id)
|
||||
.from(Tables.accounts)
|
||||
.where(Tables.accounts.uuid.eq(entry.getKey().toString())))
|
||||
.set(Tables.gamePlayers.winner, entry.getValue());
|
||||
|
||||
queryList.add(query);
|
||||
}
|
||||
|
||||
context.batch(queryList).execute();
|
||||
}
|
||||
|
||||
public void saveLeaderboardStats(int tournamentId, int gameId, Map<UUID, Boolean> players)
|
||||
{
|
||||
DSLContext context;
|
||||
|
||||
synchronized (this)
|
||||
{
|
||||
context = DSL.using(getConnection());
|
||||
}
|
||||
|
||||
List<Query> queryList = new ArrayList<>(players.size());
|
||||
|
||||
for (Map.Entry<UUID, Boolean> entry : players.entrySet())
|
||||
{
|
||||
int winIncrement = entry.getValue() ? 1 : 0;
|
||||
|
@ -1,16 +1,45 @@
|
||||
package nautilus.game.arcade.game;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Hanging;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTitle;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.ArcadeFormat;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.TournamentType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
|
||||
import nautilus.game.arcade.events.PlayerStateChangeEvent;
|
||||
@ -32,27 +61,18 @@ import nautilus.game.arcade.stats.TeamKillsStatTracker;
|
||||
import nautilus.game.arcade.stats.WinStatTracker;
|
||||
import nautilus.game.arcade.world.WorldData;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Hanging;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public abstract class Game implements Listener
|
||||
{
|
||||
public long getGameLiveTime()
|
||||
{
|
||||
return _gameLiveTime;
|
||||
}
|
||||
|
||||
public void setGameLiveTime(long gameLiveTime)
|
||||
{
|
||||
_gameLiveTime = gameLiveTime;
|
||||
}
|
||||
|
||||
public enum GameState
|
||||
{
|
||||
Loading,
|
||||
@ -74,8 +94,9 @@ public abstract class Game implements Listener
|
||||
|
||||
//State
|
||||
private GameState _gameState = GameState.Loading;
|
||||
private long _gameLiveTime;
|
||||
private long _gameStateTime = System.currentTimeMillis();
|
||||
|
||||
|
||||
private boolean _prepareCountdown = false;
|
||||
|
||||
private int _countdown = -1;
|
||||
@ -88,15 +109,15 @@ public abstract class Game implements Listener
|
||||
|
||||
//Teams
|
||||
private ArrayList<GameTeam> _teamList = new ArrayList<GameTeam>();
|
||||
|
||||
|
||||
//Player Preferences
|
||||
protected NautHashMap<Player, Kit> _playerKit = new NautHashMap<Player, Kit>();
|
||||
protected NautHashMap<Player, Kit> _playerKit = new NautHashMap<Player, Kit>();
|
||||
private NautHashMap<GameTeam, ArrayList<Player>> _teamPreference = new NautHashMap<GameTeam, ArrayList<Player>>();
|
||||
|
||||
|
||||
//Player Data
|
||||
private NautHashMap<Player, HashMap<String,GemData>> _gemCount = new NautHashMap<Player, HashMap<String,GemData>>();
|
||||
private NautHashMap<Player, HashMap<String,Integer>> _stats = new NautHashMap<Player, HashMap<String,Integer>>();
|
||||
|
||||
private NautHashMap<Player, HashMap<String, GemData>> _gemCount = new NautHashMap<Player, HashMap<String, GemData>>();
|
||||
private NautHashMap<Player, HashMap<String, Integer>> _stats = new NautHashMap<Player, HashMap<String, Integer>>();
|
||||
|
||||
//Player Location Store
|
||||
private NautHashMap<String, Location> _playerLocationStore = new NautHashMap<String, Location>();
|
||||
|
||||
@ -114,14 +135,14 @@ public abstract class Game implements Listener
|
||||
|
||||
//Gameplay Flags
|
||||
public long GameTimeout = 1200000;
|
||||
|
||||
|
||||
public boolean Damage = true;
|
||||
public boolean DamagePvP = true;
|
||||
public boolean DamagePvE = true;
|
||||
public boolean DamageEvP = true;
|
||||
public boolean DamageSelf = true;
|
||||
public boolean DamageTeamSelf = false;
|
||||
public boolean DamageTeamOther = true;
|
||||
public boolean DamageTeamOther = true;
|
||||
|
||||
public boolean BlockBreak = false;
|
||||
public HashSet<Integer> BlockBreakAllow = new HashSet<Integer>();
|
||||
@ -181,19 +202,19 @@ public abstract class Game implements Listener
|
||||
public boolean AnnounceSilence = true;
|
||||
|
||||
public boolean DisplayLobbySide = true;
|
||||
|
||||
|
||||
public GameState KitRegisterState = GameState.Live;
|
||||
|
||||
|
||||
public boolean JoinInProgress = false;
|
||||
|
||||
//Addons
|
||||
public boolean CompassEnabled = false;
|
||||
public boolean CompassGiveItem = true;
|
||||
|
||||
|
||||
public boolean SoupEnabled = true;
|
||||
public boolean TeamArmor = false;
|
||||
public boolean TeamArmorHotbar = false;
|
||||
|
||||
|
||||
public boolean GiveClock = true;
|
||||
|
||||
public double GemMultiplier = 1;
|
||||
@ -211,9 +232,9 @@ public abstract class Game implements Listener
|
||||
|
||||
public boolean EloRanking = false;
|
||||
public int EloStart = 1000;
|
||||
|
||||
|
||||
public boolean CanAddStats = true;
|
||||
|
||||
|
||||
public ArrayList<String> GemBoosters = new ArrayList<String>();
|
||||
private final Set<StatTracker<? extends Game>> _statTrackers = new HashSet<>();
|
||||
|
||||
@ -227,7 +248,7 @@ public abstract class Game implements Listener
|
||||
|
||||
//Kits
|
||||
_kits = kits;
|
||||
|
||||
|
||||
//Scoreboard
|
||||
Scoreboard = new GameScoreboard(this);
|
||||
|
||||
@ -244,10 +265,10 @@ public abstract class Game implements Listener
|
||||
System.out.print("Map Preference: " + cur);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (matches.size() > 0)
|
||||
_files = matches;
|
||||
|
||||
|
||||
Manager.GetGameCreationManager().MapPref = null;
|
||||
}
|
||||
WorldData = new WorldData(this);
|
||||
@ -281,13 +302,13 @@ public abstract class Game implements Listener
|
||||
{
|
||||
return _gameType.GetName();
|
||||
}
|
||||
|
||||
|
||||
public String GetMode()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public GameType GetType()
|
||||
public GameType GetType()
|
||||
{
|
||||
return _gameType;
|
||||
}
|
||||
@ -347,7 +368,7 @@ public abstract class Game implements Listener
|
||||
return _playerKit;
|
||||
}
|
||||
|
||||
public NautHashMap<Player, HashMap<String,GemData>> GetPlayerGems()
|
||||
public NautHashMap<Player, HashMap<String, GemData>> GetPlayerGems()
|
||||
{
|
||||
return _gemCount;
|
||||
}
|
||||
@ -362,11 +383,14 @@ public abstract class Game implements Listener
|
||||
return _gameState;
|
||||
}
|
||||
|
||||
public void SetState(GameState state)
|
||||
public void SetState(GameState state)
|
||||
{
|
||||
_gameState = state;
|
||||
_gameStateTime = System.currentTimeMillis();
|
||||
|
||||
if (_gameState == GameState.Live)
|
||||
setGameLiveTime(_gameStateTime);
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
player.leaveVehicle();
|
||||
|
||||
@ -376,12 +400,12 @@ public abstract class Game implements Listener
|
||||
|
||||
System.out.println(GetName() + " state set to " + state.toString());
|
||||
}
|
||||
|
||||
|
||||
public void SetStateTime(long time)
|
||||
{
|
||||
_gameStateTime = time;
|
||||
}
|
||||
|
||||
|
||||
public long GetStateTime()
|
||||
{
|
||||
return _gameStateTime;
|
||||
@ -407,14 +431,14 @@ public abstract class Game implements Listener
|
||||
|
||||
System.out.println("Created Team: " + team.GetName());
|
||||
}
|
||||
|
||||
|
||||
public void RemoveTeam(GameTeam team)
|
||||
{
|
||||
if (GetTeamList().remove(team))
|
||||
System.out.println("Deleted Team: " + team.GetName());
|
||||
}
|
||||
|
||||
public boolean HasTeam(GameTeam team)
|
||||
public boolean HasTeam(GameTeam team)
|
||||
{
|
||||
for (GameTeam cur : GetTeamList())
|
||||
if (cur.equals(team))
|
||||
@ -423,12 +447,12 @@ public abstract class Game implements Listener
|
||||
return false;
|
||||
}
|
||||
|
||||
public void RestrictKits()
|
||||
public void RestrictKits()
|
||||
{
|
||||
//Null Default
|
||||
}
|
||||
|
||||
public void RegisterKits()
|
||||
public void RegisterKits()
|
||||
{
|
||||
for (Kit kit : _kits)
|
||||
{
|
||||
@ -439,7 +463,7 @@ public abstract class Game implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
public void DeregisterKits()
|
||||
public void DeregisterKits()
|
||||
{
|
||||
for (Kit kit : _kits)
|
||||
{
|
||||
@ -447,14 +471,14 @@ public abstract class Game implements Listener
|
||||
|
||||
for (Perk perk : kit.GetPerks())
|
||||
HandlerList.unregisterAll(perk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ParseData()
|
||||
{
|
||||
//Nothing by default,
|
||||
//Use this to parse in extra location data from maps
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPlayerTeam(Player player, GameTeam team, boolean in)
|
||||
{
|
||||
@ -475,17 +499,17 @@ public abstract class Game implements Listener
|
||||
|
||||
//Lobby Scoreboard
|
||||
Manager.GetLobby().AddPlayerToScoreboards(player, team.GetName().toUpperCase());
|
||||
|
||||
|
||||
//Save Tournament Team
|
||||
Manager.setTournamentTeam(player, team);
|
||||
}
|
||||
|
||||
public GameTeam ChooseTeam(Player player)
|
||||
public GameTeam ChooseTeam(Player player)
|
||||
{
|
||||
GameTeam team = null;
|
||||
|
||||
//Random Team
|
||||
for (int i=0 ; i<_teamList.size() ; i++)
|
||||
for (int i = 0; i < _teamList.size(); i++)
|
||||
{
|
||||
if (team == null || _teamList.get(i).GetSize() < team.GetSize())
|
||||
{
|
||||
@ -526,11 +550,11 @@ public abstract class Game implements Listener
|
||||
if (!countAmount && gems < 1)
|
||||
gems = 1;
|
||||
|
||||
if (GetGems(player).containsKey(reason))
|
||||
if (GetGems(player).containsKey(reason))
|
||||
{
|
||||
GetGems(player).get(reason).AddGems(gems);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
GetGems(player).put(reason, new GemData(gems, countAmount));
|
||||
}
|
||||
@ -556,7 +580,7 @@ public abstract class Game implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
public void SetKit(Player player, Kit kit, boolean announce)
|
||||
public void SetKit(Player player, Kit kit, boolean announce)
|
||||
{
|
||||
GameTeam team = GetTeam(player);
|
||||
if (team != null)
|
||||
@ -588,17 +612,17 @@ public abstract class Game implements Listener
|
||||
kit.ApplyKit(player);
|
||||
}
|
||||
|
||||
public Kit GetKit(Player player)
|
||||
public Kit GetKit(Player player)
|
||||
{
|
||||
return _playerKit.get(player);
|
||||
}
|
||||
|
||||
public Kit[] GetKits()
|
||||
public Kit[] GetKits()
|
||||
{
|
||||
return _kits;
|
||||
}
|
||||
|
||||
public boolean HasKit(Kit kit)
|
||||
public boolean HasKit(Kit kit)
|
||||
{
|
||||
for (Kit cur : GetKits())
|
||||
if (cur.equals(kit))
|
||||
@ -631,7 +655,7 @@ public abstract class Game implements Listener
|
||||
|
||||
//Event
|
||||
PlayerStateChangeEvent playerStateEvent = new PlayerStateChangeEvent(this, player, PlayerState.OUT);
|
||||
UtilServer.getServer().getPluginManager().callEvent(playerStateEvent);
|
||||
UtilServer.getServer().getPluginManager().callEvent(playerStateEvent);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -647,7 +671,7 @@ public abstract class Game implements Listener
|
||||
|
||||
//Event
|
||||
PlayerGameRespawnEvent event = new PlayerGameRespawnEvent(this, player);
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
//Re-Give Kit
|
||||
Manager.GetPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
|
||||
@ -655,7 +679,7 @@ public abstract class Game implements Listener
|
||||
public void run()
|
||||
{
|
||||
GetKit(player).ApplyKit(player);
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
@ -674,7 +698,7 @@ public abstract class Game implements Listener
|
||||
return team.IsAlive(player);
|
||||
}
|
||||
|
||||
public ArrayList<Player> GetPlayers(boolean aliveOnly)
|
||||
public ArrayList<Player> GetPlayers(boolean aliveOnly)
|
||||
{
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
|
||||
@ -684,7 +708,7 @@ public abstract class Game implements Listener
|
||||
return players;
|
||||
}
|
||||
|
||||
public GameTeam GetTeam(String player, boolean aliveOnly)
|
||||
public GameTeam GetTeam(String player, boolean aliveOnly)
|
||||
{
|
||||
for (GameTeam team : _teamList)
|
||||
if (team.HasPlayer(player, aliveOnly))
|
||||
@ -693,11 +717,11 @@ public abstract class Game implements Listener
|
||||
return null;
|
||||
}
|
||||
|
||||
public GameTeam GetTeam(Player player)
|
||||
public GameTeam GetTeam(Player player)
|
||||
{
|
||||
if (player == null)
|
||||
return null;
|
||||
|
||||
|
||||
for (GameTeam team : _teamList)
|
||||
if (team.HasPlayer(player))
|
||||
return team;
|
||||
@ -705,7 +729,7 @@ public abstract class Game implements Listener
|
||||
return null;
|
||||
}
|
||||
|
||||
public GameTeam GetTeam(ChatColor color)
|
||||
public GameTeam GetTeam(ChatColor color)
|
||||
{
|
||||
for (GameTeam team : _teamList)
|
||||
if (team.GetColor() == color)
|
||||
@ -719,21 +743,21 @@ public abstract class Game implements Listener
|
||||
if (SpectatorSpawn != null)
|
||||
return SpectatorSpawn;
|
||||
|
||||
Vector vec = new Vector(0,0,0);
|
||||
Vector vec = new Vector(0, 0, 0);
|
||||
double count = 0;
|
||||
|
||||
for (GameTeam team : this.GetTeamList())
|
||||
{
|
||||
for (Location spawn : team.GetSpawns())
|
||||
{
|
||||
{
|
||||
count++;
|
||||
vec.add(spawn.toVector());
|
||||
}
|
||||
}
|
||||
|
||||
SpectatorSpawn = new Location(this.WorldData.World, 0,0,0);
|
||||
SpectatorSpawn = new Location(this.WorldData.World, 0, 0, 0);
|
||||
|
||||
vec.multiply(1d/count);
|
||||
vec.multiply(1d / count);
|
||||
|
||||
SpectatorSpawn.setX(vec.getX());
|
||||
SpectatorSpawn.setY(vec.getY());
|
||||
@ -748,7 +772,7 @@ public abstract class Game implements Listener
|
||||
int Up = 0;
|
||||
|
||||
//Move Up - Through Air
|
||||
for (int i=0 ; i<15 ; i++)
|
||||
for (int i = 0; i < 15; i++)
|
||||
{
|
||||
if (UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP)))
|
||||
{
|
||||
@ -776,7 +800,7 @@ public abstract class Game implements Listener
|
||||
return SpectatorSpawn;
|
||||
}
|
||||
|
||||
public void SetSpectator(Player player)
|
||||
public void SetSpectator(Player player)
|
||||
{
|
||||
Manager.Clear(player);
|
||||
|
||||
@ -784,14 +808,14 @@ public abstract class Game implements Listener
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
player.setFlying(true);
|
||||
player.setFlySpeed(0.1f);
|
||||
((CraftPlayer)player).getHandle().spectating = true;
|
||||
((CraftPlayer)player).getHandle().k = false;
|
||||
((CraftPlayer) player).getHandle().spectating = true;
|
||||
((CraftPlayer) player).getHandle().k = false;
|
||||
|
||||
Manager.GetCondition().Factory().Cloak("Spectator", player, player, 7777, true, true);
|
||||
|
||||
Scoreboard.SetPlayerTeam(player, "SPEC");
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void eloStart(PlayerLoginEvent event)
|
||||
{
|
||||
@ -820,7 +844,7 @@ public abstract class Game implements Listener
|
||||
|
||||
public boolean CanJoinTeam(GameTeam team)
|
||||
{
|
||||
return Manager.IsTeamBalance() ? team.GetSize() < Math.max(1, UtilServer.getPlayers().length/GetTeamList().size()) : true;
|
||||
return Manager.IsTeamBalance() ? team.GetSize() < Math.max(1, UtilServer.getPlayers().length / GetTeamList().size()) : true;
|
||||
}
|
||||
|
||||
public GameTeam GetTeamPreference(Player player)
|
||||
@ -844,10 +868,10 @@ public abstract class Game implements Listener
|
||||
{
|
||||
for (ArrayList<Player> queue : _teamPreference.values())
|
||||
{
|
||||
for (int i=0 ; i<queue.size() ; i++)
|
||||
for (int i = 0; i < queue.size(); i++)
|
||||
{
|
||||
if (queue.get(i).equals(player))
|
||||
return (i+1) + "/" + queue.size();
|
||||
return (i + 1) + "/" + queue.size();
|
||||
}
|
||||
}
|
||||
|
||||
@ -869,7 +893,7 @@ public abstract class Game implements Listener
|
||||
{
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
AnnounceGame(player);
|
||||
|
||||
|
||||
if (AnnounceSilence)
|
||||
Manager.GetChat().Silence(9000, false);
|
||||
}
|
||||
@ -878,12 +902,12 @@ public abstract class Game implements Listener
|
||||
{
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f);
|
||||
|
||||
for (int i=0 ; i<6-GetDesc().length ; i++)
|
||||
for (int i = 0; i < 6 - GetDesc().length; i++)
|
||||
UtilPlayer.message(player, "");
|
||||
|
||||
UtilPlayer.message(player, ArcadeFormat.Line);
|
||||
|
||||
UtilPlayer.message(player, C.cGreen + "Game - " + C.cYellow+ C.Bold + this.GetName());
|
||||
UtilPlayer.message(player, C.cGreen + "Game - " + C.cYellow + C.Bold + this.GetName());
|
||||
UtilPlayer.message(player, "");
|
||||
|
||||
for (String line : this.GetDesc())
|
||||
@ -892,7 +916,7 @@ public abstract class Game implements Listener
|
||||
}
|
||||
|
||||
UtilPlayer.message(player, "");
|
||||
UtilPlayer.message(player, C.cGreen + "Map - " + C.cYellow + C.Bold + WorldData.MapName + ChatColor.RESET + C.cGray + " created by " + C.cYellow+ C.Bold + WorldData.MapAuthor);
|
||||
UtilPlayer.message(player, C.cGreen + "Map - " + C.cYellow + C.Bold + WorldData.MapName + ChatColor.RESET + C.cGray + " created by " + C.cYellow + C.Bold + WorldData.MapAuthor);
|
||||
|
||||
UtilPlayer.message(player, ArcadeFormat.Line);
|
||||
}
|
||||
@ -901,9 +925,9 @@ public abstract class Game implements Listener
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
|
||||
String winnerText = ChatColor.WHITE + "§lNobody won the game...";
|
||||
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f);
|
||||
@ -919,10 +943,10 @@ public abstract class Game implements Listener
|
||||
{
|
||||
WinnerTeam = team;
|
||||
Winner = team.GetName() + " Team";
|
||||
|
||||
|
||||
winnerText = team.GetColor() + C.Bold + team.GetName() + " won the game!";
|
||||
UtilPlayer.message(player, winnerText);
|
||||
}
|
||||
UtilPlayer.message(player, winnerText);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(player, winnerText);
|
||||
@ -935,7 +959,7 @@ public abstract class Game implements Listener
|
||||
|
||||
UtilPlayer.message(player, ArcadeFormat.Line);
|
||||
}
|
||||
|
||||
|
||||
UtilTitle.display(winnerText, _customWinLine, 20, 120, 20);
|
||||
|
||||
if (AnnounceSilence)
|
||||
@ -945,7 +969,7 @@ public abstract class Game implements Listener
|
||||
public void AnnounceEnd(List<Player> places)
|
||||
{
|
||||
String winnerText = ChatColor.WHITE + "§lNobody won the game...";
|
||||
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f);
|
||||
@ -961,15 +985,15 @@ public abstract class Game implements Listener
|
||||
UtilPlayer.message(player, "");
|
||||
UtilPlayer.message(player, ChatColor.WHITE + "§lNobody won the game...");
|
||||
UtilPlayer.message(player, "");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (places.size() >= 1)
|
||||
{
|
||||
Winner = places.get(0).getName();
|
||||
|
||||
|
||||
winnerText = C.cYellow + C.Bold + places.get(0).getName() + " won the game!";
|
||||
|
||||
|
||||
UtilPlayer.message(player, C.cRed + C.Bold + "1st Place" + C.cWhite + " - " + places.get(0).getName());
|
||||
}
|
||||
|
||||
@ -978,7 +1002,7 @@ public abstract class Game implements Listener
|
||||
{
|
||||
UtilPlayer.message(player, C.cGold + C.Bold + "2nd Place" + C.cWhite + " - " + places.get(1).getName());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (places.size() >= 3)
|
||||
{
|
||||
@ -993,18 +1017,17 @@ public abstract class Game implements Listener
|
||||
}
|
||||
|
||||
UtilTitle.display(winnerText, null, 20, 120, 20);
|
||||
|
||||
|
||||
if (AnnounceSilence)
|
||||
Manager.GetChat().Silence(5000, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void Announce(String message)
|
||||
{
|
||||
Announce(message, true);
|
||||
}
|
||||
|
||||
|
||||
public void Announce(String message, boolean playSound)
|
||||
{
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
@ -1018,12 +1041,12 @@ public abstract class Game implements Listener
|
||||
System.out.println("[Announcement] " + message);
|
||||
}
|
||||
|
||||
public boolean AdvertiseText(GameLobbyManager gameLobbyManager, int _advertiseStage)
|
||||
public boolean AdvertiseText(GameLobbyManager gameLobbyManager, int _advertiseStage)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean CanThrowTNT(Location location)
|
||||
public boolean CanThrowTNT(Location location)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -1059,7 +1082,7 @@ public abstract class Game implements Listener
|
||||
UtilPlayer.message(player, msg);
|
||||
}
|
||||
|
||||
_helpIndex = (_helpIndex + 1)%_help.length;
|
||||
_helpIndex = (_helpIndex + 1) % _help.length;
|
||||
}
|
||||
|
||||
public void StartPrepareCountdown()
|
||||
@ -1071,12 +1094,12 @@ public abstract class Game implements Listener
|
||||
{
|
||||
return _prepareCountdown;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void TeamPlayerPlacement(PlayerStateChangeEvent event)
|
||||
{
|
||||
GameTeam team = GetTeam(event.GetPlayer());
|
||||
|
||||
|
||||
if (team != null)
|
||||
team.SetPlacement(event.GetPlayer(), event.GetState());
|
||||
}
|
||||
@ -1085,7 +1108,7 @@ public abstract class Game implements Listener
|
||||
{
|
||||
SetState(GameState.End);
|
||||
}
|
||||
|
||||
|
||||
public void AddGemBooster(Player player)
|
||||
{
|
||||
if (GemBoosters.size() >= 4)
|
||||
@ -1093,48 +1116,48 @@ public abstract class Game implements Listener
|
||||
UtilPlayer.message(player, F.main("Game", "Games cannot have more than " + F.elem("4 Gem Boosters")) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (GemBoosters.contains(player.getName()))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Game", "You can only use " + F.elem("1 Gem Booster")) + " per game.");
|
||||
return;
|
||||
}
|
||||
|
||||
Announce(F.elem(player.getName()) + " used a " + F.elem(C.cGreen + "Gem Booster") + " for " + F.elem("+" + (100-(GemBoosters.size()*25)) + "% Gems") + "!");
|
||||
|
||||
Announce(F.elem(player.getName()) + " used a " + F.elem(C.cGreen + "Gem Booster") + " for " + F.elem("+" + (100 - (GemBoosters.size() * 25)) + "% Gems") + "!");
|
||||
|
||||
GemBoosters.add(player.getName());
|
||||
}
|
||||
|
||||
public double GetGemBoostAmount()
|
||||
{
|
||||
if (GemBoosters.size() == 1) return 1;
|
||||
if (GemBoosters.size() == 2) return 1.75;
|
||||
if (GemBoosters.size() == 3) return 2.25;
|
||||
if (GemBoosters.size() == 4) return 2.5;
|
||||
|
||||
if (GemBoosters.size() == 1) return 1;
|
||||
if (GemBoosters.size() == 2) return 1.75;
|
||||
if (GemBoosters.size() == 3) return 2.25;
|
||||
if (GemBoosters.size() == 4) return 2.5;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public void AddStat(Player player, String stat, int amount, boolean limitTo1, boolean global)
|
||||
{
|
||||
if (!Manager.IsRewardStats())
|
||||
return;
|
||||
|
||||
|
||||
if (!_stats.containsKey(player))
|
||||
_stats.put(player, new HashMap<String, Integer>());
|
||||
|
||||
|
||||
if (global)
|
||||
stat = "Global." + stat;
|
||||
else
|
||||
stat = GetName() + "." + stat;
|
||||
|
||||
|
||||
if (Manager.IsTournamentServer())
|
||||
stat += ".Tournament";
|
||||
|
||||
|
||||
int past = 0;
|
||||
if (_stats.get(player).containsKey(stat))
|
||||
past = _stats.get(player).get(stat);
|
||||
|
||||
|
||||
_stats.get(player).put(stat, limitTo1 ? Math.min(1, past + amount) : past + amount);
|
||||
}
|
||||
|
||||
@ -1164,38 +1187,21 @@ public abstract class Game implements Listener
|
||||
for (StatTracker tracker : getStatTrackers())
|
||||
HandlerList.unregisterAll(tracker);
|
||||
|
||||
if (Manager.IsTournamentServer() && CanAddStats)
|
||||
//if (CanAddStats)
|
||||
{
|
||||
final TournamentType type = TournamentType.getTournamentType(GetType());
|
||||
Manager.saveBasicStats(this);
|
||||
|
||||
if (type != null)
|
||||
{
|
||||
final Map<UUID, Boolean> data = new HashMap<>();
|
||||
|
||||
for (Player loser : getLosers())
|
||||
data.put(loser.getUniqueId(), false);
|
||||
|
||||
for (Player winner : getWinners())
|
||||
data.put(winner.getUniqueId(), true);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Manager.GetPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Manager.getLeaderboardRepository().saveStats(0, type.ordinal(), data);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (Manager.IsTournamentServer())
|
||||
Manager.saveLeaderboardStats(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<StatTracker<? extends Game>> getStatTrackers()
|
||||
{
|
||||
return _statTrackers;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onHangingBreak(HangingBreakEvent event)
|
||||
{
|
||||
@ -1207,21 +1213,21 @@ public abstract class Game implements Listener
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onDamageHanging(EntityDamageEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Hanging)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void deRegisterStats()
|
||||
{
|
||||
for (StatTracker<? extends Game> tracker : _statTrackers)
|
||||
HandlerList.unregisterAll(tracker);
|
||||
|
||||
|
||||
_statTrackers.clear();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user