Merge branch 'features/elo' into develop
This commit is contained in:
commit
d73b720323
@ -1,5 +1,6 @@
|
||||
package mineplex.core.account;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@ -378,7 +379,12 @@ public class CoreClientManager extends MiniPlugin
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName()));
|
||||
try {
|
||||
client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName()));
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
_clientLoginLock.remove(client.GetPlayerName());
|
||||
}
|
||||
});
|
||||
|
@ -57,7 +57,7 @@ public class AccountRepository extends MinecraftRepository
|
||||
//executeUpdate(CREATE_ACCOUNT_TABLE);
|
||||
}
|
||||
|
||||
public int login(final List<ILoginProcessor> loginProcessors, final UUID uuid, final String name)
|
||||
public int login(final List<ILoginProcessor> loginProcessors, final UUID uuid, final String name) throws SQLException
|
||||
{
|
||||
// First we try to grab the account id from cache - this saves an extra trip to database
|
||||
int accountId = PlayerCache.getInstance().getAccountId(uuid);
|
||||
@ -117,10 +117,7 @@ public class AccountRepository extends MinecraftRepository
|
||||
statement.getMoreResults();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
return accountId;
|
||||
}
|
||||
|
@ -4,5 +4,5 @@ import mineplex.core.common.util.NautHashMap;
|
||||
|
||||
public class EloClientData
|
||||
{
|
||||
public NautHashMap<String, Integer> Elos = new NautHashMap<String, Integer>();
|
||||
public NautHashMap<Integer, Integer> Elos = new NautHashMap<Integer, Integer>();
|
||||
}
|
||||
|
72
Plugins/Mineplex.Core/src/mineplex/core/elo/EloDivision.java
Normal file
72
Plugins/Mineplex.Core/src/mineplex/core/elo/EloDivision.java
Normal file
@ -0,0 +1,72 @@
|
||||
package mineplex.core.elo;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
public class EloDivision
|
||||
{
|
||||
private byte _divisionPercentile;
|
||||
private int _playerElo;
|
||||
private UUID _uuid;
|
||||
private String _divisionName;
|
||||
|
||||
//If I understand MaterialData objects correctly,
|
||||
private Material _divisionMaterial;
|
||||
private byte _divisionMaterialValue;
|
||||
private MaterialData _divisionMaterialData;
|
||||
|
||||
public EloDivision(UUID userID, byte divPercent, int pElo)
|
||||
{
|
||||
_uuid = userID;
|
||||
_divisionPercentile = divPercent;
|
||||
_playerElo = pElo;
|
||||
_divisionName = calculateDivision(divPercent, _playerElo);
|
||||
|
||||
}
|
||||
|
||||
public String calculateDivision(double divPercent, int _playerElo)
|
||||
{
|
||||
|
||||
if (divPercent > 99 && _playerElo > 3500) { return "Diamond"; }
|
||||
if (_playerElo >= 3500) { return "Emerald 3"; }
|
||||
if (_playerElo < 3500 && _playerElo >= 3300) { return "Emerald 2"; }
|
||||
if (_playerElo < 3300 && _playerElo >= 3100) { return "Emerald 1"; }
|
||||
if (_playerElo < 3100 && _playerElo >= 2900) { return "Lapis 3"; }
|
||||
if (_playerElo < 2900 && _playerElo >= 2700) { return "Lapis 2"; }
|
||||
if (_playerElo < 2700 && _playerElo >= 2500) { return "Lapis 1"; }
|
||||
if (_playerElo < 2500 && _playerElo >= 2300) { return "Gold 3"; }
|
||||
if (_playerElo < 2300 && _playerElo >= 2100) { return "Gold 2"; }
|
||||
if (_playerElo < 2100 && _playerElo >= 1900) { return "Gold 1"; }
|
||||
if (_playerElo < 1900 && _playerElo >= 1700) { return "Iron 3"; }
|
||||
if (_playerElo < 1700 && _playerElo >= 1500) { return "Iron 2"; }
|
||||
if (_playerElo < 1500 && _playerElo >= 1300) { return "Iron 1"; }
|
||||
if (_playerElo < 1300 && _playerElo >= 800) { return "Coal 3"; }
|
||||
if (_playerElo < 800 && _playerElo >= 600) { return "Coal 2"; }
|
||||
if (_playerElo < 600) { return "Coal 1"; }
|
||||
|
||||
//if none of the above are true, a player is in the bottom 20%
|
||||
return "Coal 1";
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
//method to set icon's material(since it will change with player's ELO)
|
||||
public void setDivisionIcon(Material divMat, byte divData)
|
||||
{
|
||||
_divisionMaterial = divMat;
|
||||
_divisionMaterialValue = divData;
|
||||
_divisionMaterialData = new MaterialData(_divisionMaterial, _divisionMaterialValue);
|
||||
}
|
||||
|
||||
public MaterialData getMaterialData()
|
||||
{
|
||||
return _divisionMaterialData;
|
||||
}
|
||||
|
||||
public String getDivisionName()
|
||||
{
|
||||
return _divisionName;
|
||||
}
|
||||
|
||||
}
|
@ -2,105 +2,147 @@ package mineplex.core.elo;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
import java.util.HashSet;
|
||||
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class EloManager extends MiniDbClientPlugin<EloClientData>
|
||||
{
|
||||
private static Object _playerEloLock = new Object();
|
||||
|
||||
private EloRepository _repository;
|
||||
private EloRatingSystem _ratingSystem;
|
||||
private NautHashMap<String, NautHashMap<String, Integer>> _playerElos;
|
||||
private NautHashMap<String, EloTeam> _eloTeams = new NautHashMap<>();
|
||||
|
||||
public EloManager(JavaPlugin plugin, CoreClientManager clientManager)
|
||||
{
|
||||
super("Elo Rating", plugin, clientManager);
|
||||
|
||||
_repository = new EloRepository(plugin);
|
||||
_ratingSystem = new EloRatingSystem(new KFactor(0, 1200, 25), new KFactor(1201, 1600, 20), new KFactor(1601, 2000, 15), new KFactor(2001, 2500, 10));
|
||||
_playerElos = new NautHashMap<String, NautHashMap<String, Integer>>();
|
||||
_ratingSystem = new EloRatingSystem
|
||||
(
|
||||
new KFactor(0, 1299, 50),
|
||||
new KFactor(1300, 1899, 45),
|
||||
new KFactor(1900, 2499, 40),
|
||||
new KFactor(2500, 3099, 30),
|
||||
new KFactor(3100, 3699, 20),
|
||||
new KFactor(3700, 5000, 10)
|
||||
);
|
||||
}
|
||||
|
||||
public int getElo(UUID uuid, String gameType)
|
||||
|
||||
public int getElo(Player player, int gameType)
|
||||
{
|
||||
int elo = 1000;
|
||||
if (!Get(player).Elos.containsKey(gameType))
|
||||
Get(player).Elos.put(gameType, 1000);
|
||||
|
||||
synchronized (_playerEloLock)
|
||||
{
|
||||
if (_playerElos.containsKey(uuid.toString()))
|
||||
{
|
||||
if (_playerElos.get(uuid.toString()).containsKey(gameType))
|
||||
{
|
||||
elo = _playerElos.get(uuid.toString()).get(gameType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return elo;
|
||||
return Get(player).Elos.get(gameType);
|
||||
}
|
||||
|
||||
public EloTeam getNewRatings(EloTeam teamA, EloTeam teamB, GameResult result)
|
||||
{
|
||||
EloTeam newTeam = new EloTeam();
|
||||
|
||||
System.out.println("Old " + result + " Team Rating:" + teamA.TotalElo);
|
||||
|
||||
|
||||
int newTotal = _ratingSystem.getNewRating(teamA.TotalElo / teamA.getPlayers().size(), teamB.TotalElo / teamB.getPlayers().size(), result) * teamA.getPlayers().size();
|
||||
|
||||
System.out.println("New " + result + " Team Rating:" + newTotal);
|
||||
int kTotal = 0;
|
||||
|
||||
for (EloPlayer player : teamA.getPlayers())
|
||||
{
|
||||
EloPlayer newPlayer = new EloPlayer();
|
||||
newPlayer.UniqueId = player.UniqueId;
|
||||
newPlayer.Rating = (int)(player.Rating + ((double)player.Rating / (double)teamA.TotalElo) * (newTotal - teamA.TotalElo));
|
||||
|
||||
System.out.println("Old:");
|
||||
player.printInfo();
|
||||
|
||||
System.out.println("New:");
|
||||
newPlayer.printInfo();
|
||||
|
||||
kTotal += _ratingSystem.getKFactor(player.getRating());
|
||||
}
|
||||
|
||||
for (EloPlayer player : teamA.getPlayers())
|
||||
{
|
||||
int newRating = (int)(player.getRating() + ((double)_ratingSystem.getKFactor(player.getRating()) / (double)kTotal) * (newTotal - teamA.TotalElo));
|
||||
EloPlayer newPlayer = new EloPlayer(player.getPlayer(), player.getAccountId(), newRating);
|
||||
|
||||
newTeam.addPlayer(newPlayer);
|
||||
}
|
||||
|
||||
return newTeam;
|
||||
}
|
||||
|
||||
public void saveElo(UUID uuid, String gameType, int elo)
|
||||
public void saveElo(final Player player, final int accountId, final int gameType, final int oldElo, final int elo)
|
||||
{
|
||||
saveElo(uuid.toString(), gameType, elo);
|
||||
}
|
||||
|
||||
public void saveElo(final String uuid, final String gameType, final int elo)
|
||||
{
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_repository.saveElo(uuid, gameType, elo);
|
||||
boolean success = false;
|
||||
|
||||
synchronized (_playerEloLock)
|
||||
try
|
||||
{
|
||||
if (_playerElos.containsKey(uuid))
|
||||
success = _repository.saveElo(accountId, gameType, oldElo, elo);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
System.out.println("Saving " + accountId + "'s new elo rating of " + elo + " for gameType " + gameType + (success ? " SUCCEEDED." : " FAILED."));
|
||||
}
|
||||
|
||||
final boolean finalSuccess = success;
|
||||
|
||||
runSync(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (_playerElos.get(uuid).containsKey(gameType))
|
||||
if (finalSuccess)
|
||||
{
|
||||
_playerElos.get(uuid).put(gameType, elo);
|
||||
if (player.isOnline())
|
||||
Get(player).Elos.put(gameType, elo);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public String getPlayerDivision(Player player, int gameType)
|
||||
{
|
||||
int playerElo = getElo(player, gameType);
|
||||
String divisionName = "Player's division";
|
||||
|
||||
if (playerElo >= 3700)
|
||||
divisionName = "Diamond";
|
||||
else if (playerElo < 3700 && playerElo >= 3500)
|
||||
divisionName = "Emerald 3";
|
||||
else if (playerElo < 3500 && playerElo >= 3300)
|
||||
divisionName = "Emerald 2";
|
||||
else if (playerElo < 3300 && playerElo >= 3100)
|
||||
divisionName = "Emerald 1";
|
||||
else if (playerElo < 3100 && playerElo >= 2900)
|
||||
divisionName = "Lapis 3";
|
||||
else if (playerElo < 2900 && playerElo >= 2700)
|
||||
divisionName = "Lapis 2";
|
||||
else if (playerElo < 2700 && playerElo >= 2500)
|
||||
divisionName = "Lapis 1";
|
||||
else if (playerElo < 2500 && playerElo >= 2300)
|
||||
divisionName = "Gold 3";
|
||||
else if (playerElo < 2300 && playerElo >= 2100)
|
||||
divisionName = "Gold 2";
|
||||
else if (playerElo < 2100 && playerElo >= 1900)
|
||||
divisionName = "Gold 1";
|
||||
else if (playerElo < 1900 && playerElo >= 1700)
|
||||
divisionName = "Iron 3";
|
||||
else if (playerElo < 1700 && playerElo >= 1500)
|
||||
divisionName = "Iron 2";
|
||||
else if (playerElo < 1500 && playerElo >= 1300)
|
||||
divisionName = "Iron 1";
|
||||
else if (playerElo < 1300 && playerElo >= 1100)
|
||||
divisionName = "Coal 3";
|
||||
else if (playerElo < 1100 && playerElo >= 900)
|
||||
divisionName = "Coal 2";
|
||||
else if (playerElo < 900)
|
||||
divisionName = "Coal 1";
|
||||
|
||||
return divisionName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EloClientData AddPlayer(String player)
|
||||
{
|
||||
@ -116,6 +158,46 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
|
||||
@Override
|
||||
public String getQuery(int accountId, String uuid, String name)
|
||||
{
|
||||
return "SELECT gameType, elo FROM eloRating WHERE uuid = '" + uuid + "';";
|
||||
return "SELECT gameType, elo FROM eloRating WHERE accountId = '" + accountId + "';";
|
||||
}
|
||||
|
||||
public void addTeam(String displayName, EloTeam eloTeam)
|
||||
{
|
||||
_eloTeams.put(displayName, eloTeam);
|
||||
}
|
||||
|
||||
public void setWinningTeam(String displayName)
|
||||
{
|
||||
_eloTeams.get(displayName).Winner = true;
|
||||
}
|
||||
|
||||
public void endMatch(int gameId)
|
||||
{
|
||||
EloTeam teamWinner = null;
|
||||
EloTeam teamLoser = null;
|
||||
|
||||
for (EloTeam team : _eloTeams.values())
|
||||
{
|
||||
if (team.Winner)
|
||||
teamWinner = team;
|
||||
else
|
||||
teamLoser = team;
|
||||
}
|
||||
|
||||
EloTeam teamWinnerNew = getNewRatings(teamWinner, teamLoser, GameResult.Win);
|
||||
EloTeam teamLoserNew = getNewRatings(teamLoser, teamWinner, GameResult.Loss);
|
||||
|
||||
// Use teams to calculate Elo
|
||||
for (EloPlayer eloPlayer : teamWinnerNew.getPlayers())
|
||||
{
|
||||
saveElo(eloPlayer.getPlayer(), eloPlayer.getAccountId(), gameId, teamWinner.getPlayer(eloPlayer.getPlayer().getUniqueId().toString()).getRating(), eloPlayer.getRating());
|
||||
}
|
||||
|
||||
for (EloPlayer eloPlayer : teamLoserNew.getPlayers())
|
||||
{
|
||||
saveElo(eloPlayer.getPlayer(), eloPlayer.getAccountId(), gameId, teamLoser.getPlayer(eloPlayer.getPlayer().getUniqueId().toString()).getRating(), eloPlayer.getRating());
|
||||
}
|
||||
|
||||
_eloTeams.clear();
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,37 @@
|
||||
package mineplex.core.elo;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class EloPlayer
|
||||
{
|
||||
public String UniqueId;
|
||||
public int Rating;
|
||||
private Player _player;
|
||||
private int _accountId;
|
||||
private int _rating;
|
||||
|
||||
public EloPlayer(Player player, int accountId, int rating)
|
||||
{
|
||||
_player = player;
|
||||
_accountId = accountId;
|
||||
_rating = rating;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public int getRating()
|
||||
{
|
||||
return _rating;
|
||||
}
|
||||
|
||||
public int getAccountId()
|
||||
{
|
||||
return _accountId;
|
||||
}
|
||||
|
||||
public void printInfo()
|
||||
{
|
||||
System.out.println(UniqueId + "'s elo is " + Rating);
|
||||
System.out.println(_player.getName() + "'s elo is " + _rating);
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class EloRatingSystem
|
||||
return oldRating + (int) (kFactor * (score - expectedScore));
|
||||
}
|
||||
|
||||
private double getKFactor(int rating)
|
||||
double getKFactor(int rating)
|
||||
{
|
||||
for (int i = 0; i < _kFactors.length; i++)
|
||||
{
|
||||
|
@ -4,17 +4,16 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class EloRepository extends MinecraftRepository
|
||||
{
|
||||
private static String CREATE_ELO_TABLE = "CREATE TABLE IF NOT EXISTS eloRating (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), gameType VARCHAR(256), elo INT, PRIMARY KEY (id), UNIQUE INDEX uuid_gameType_index (uuid, gameType));";
|
||||
private static String INSERT_ELO = "INSERT INTO eloRating (uuid, gameType, elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE elo=VALUES(elo);";
|
||||
{
|
||||
private static String INSERT_ELO = "INSERT INTO eloRating (accountId, gameType, elo) VALUES (?, ?, ?);";
|
||||
private static String UPDATE_ELO = "UPDATE eloRating SET elo = elo + ? WHERE accountId = ? AND gameType = ?;";
|
||||
private static String UPDATE_ELO_ONLY_IF_MATCH = "UPDATE eloRating SET elo = elo + ? WHERE accountId = ? AND gameType = ? AND elo = ?;";
|
||||
|
||||
public EloRepository(JavaPlugin plugin)
|
||||
{
|
||||
@ -23,14 +22,26 @@ public class EloRepository extends MinecraftRepository
|
||||
initialize();
|
||||
}
|
||||
|
||||
public void initialize()
|
||||
public void initialize() { }
|
||||
|
||||
public boolean saveElo(int accountId, int gameType, int oldElo, int elo) throws SQLException
|
||||
{
|
||||
//executeUpdate(CREATE_ELO_TABLE);
|
||||
}
|
||||
boolean updateSucceeded = false;
|
||||
|
||||
// If we're increasing in elo we verify the server version matches the database version (prevent d/c and double wins with concurrent matches)
|
||||
// Otherwise we always take their elo down if they lose.
|
||||
if (elo > oldElo)
|
||||
updateSucceeded = executeUpdate(UPDATE_ELO_ONLY_IF_MATCH, new ColumnInt("elo", elo - oldElo), new ColumnInt("accountId", accountId), new ColumnInt("gameType", gameType), new ColumnInt("elo", oldElo)) > 0;
|
||||
else
|
||||
{
|
||||
updateSucceeded = executeUpdate(UPDATE_ELO, new ColumnInt("elo", elo - oldElo), new ColumnInt("accountId", accountId), new ColumnInt("gameType", gameType)) > 0;
|
||||
|
||||
if (!updateSucceeded && executeUpdate(INSERT_ELO, new ColumnInt("accountId", accountId), new ColumnInt("gameType", gameType), new ColumnInt("elo", elo)) > 0)
|
||||
updateSucceeded = true;
|
||||
}
|
||||
|
||||
public void saveElo(String uuid, String gameType, int elo)
|
||||
{
|
||||
executeUpdate(INSERT_ELO, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("gameType", 100, gameType), new ColumnInt("elo", elo));
|
||||
|
||||
return updateSucceeded;
|
||||
}
|
||||
|
||||
public EloClientData loadClientInformation(ResultSet resultSet) throws SQLException
|
||||
@ -39,7 +50,7 @@ public class EloRepository extends MinecraftRepository
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
clientData.Elos.put(resultSet.getString(1), resultSet.getInt(2));
|
||||
clientData.Elos.put(resultSet.getInt(1), resultSet.getInt(2));
|
||||
}
|
||||
|
||||
return clientData;
|
||||
|
@ -1,23 +1,29 @@
|
||||
package mineplex.core.elo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
|
||||
public class EloTeam
|
||||
{
|
||||
private List<EloPlayer> _players = new ArrayList<EloPlayer>();
|
||||
|
||||
private NautHashMap<String, EloPlayer> _players = new NautHashMap<>();
|
||||
public int TotalElo = 0;
|
||||
public boolean Winner = false;
|
||||
|
||||
public void addPlayer(EloPlayer player)
|
||||
{
|
||||
TotalElo += player.Rating;
|
||||
TotalElo += player.getRating();
|
||||
|
||||
_players.add(player);
|
||||
_players.put(player.getPlayer().getUniqueId().toString(), player);
|
||||
}
|
||||
|
||||
public List<EloPlayer> getPlayers()
|
||||
public EloPlayer getPlayer(String uuid)
|
||||
{
|
||||
return _players;
|
||||
return _players.get(uuid);
|
||||
}
|
||||
|
||||
public Collection<EloPlayer> getPlayers()
|
||||
{
|
||||
return _players.values();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
package mineplex.core.incognito.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called when an Incognito player is getting hidden from all other players.
|
||||
*/
|
||||
public class IncognitoHidePlayerEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Player _player;
|
||||
private boolean _cancelled;
|
||||
|
||||
public IncognitoHidePlayerEvent(Player player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled)
|
||||
{
|
||||
_cancelled = cancelled;
|
||||
}
|
||||
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancelled;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
@ -187,7 +187,7 @@ public class SiegeManager extends MiniPlugin
|
||||
|
||||
if (UnsyncedSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId)))
|
||||
continue;
|
||||
|
||||
|
||||
runAsync(() -> {
|
||||
_repository.updateWeapon(token);
|
||||
});
|
||||
|
@ -5,10 +5,6 @@ import java.util.EnumMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.chat.Chat;
|
||||
@ -24,12 +20,15 @@ import mineplex.core.scoreboard.ScoreboardManager;
|
||||
import mineplex.core.scoreboard.elements.ScoreboardElement;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.siege.SiegeManager;
|
||||
import mineplex.game.clans.message.ClansMessageManager;
|
||||
import mineplex.game.clans.tutorial.command.TutorialCommand;
|
||||
import mineplex.game.clans.tutorial.gui.TutorialShop;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class TutorialManager extends MiniPlugin implements ScoreboardElement
|
||||
{
|
||||
private CoreClientManager _clientManager;
|
||||
|
@ -4,6 +4,44 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent;
|
||||
import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent;
|
||||
import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent;
|
||||
import mineplex.game.clans.clans.event.PreEnergyShopBuyEvent;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import mineplex.game.clans.economy.GoldManager;
|
||||
import mineplex.game.clans.message.ClansMessageManager;
|
||||
import mineplex.game.clans.spawn.Spawn;
|
||||
import mineplex.game.clans.tutorial.Tutorial;
|
||||
import mineplex.game.clans.tutorial.TutorialRegion;
|
||||
import mineplex.game.clans.tutorial.TutorialSession;
|
||||
import mineplex.game.clans.tutorial.TutorialWorldManager;
|
||||
import mineplex.game.clans.tutorial.map.TutorialMapManager;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.AttackEnemyObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClassesObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.EnergyObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.FieldsObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.FinalObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.PurchaseItemsObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.ShopsObjective;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Effect;
|
||||
@ -26,45 +64,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent;
|
||||
import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent;
|
||||
import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent;
|
||||
import mineplex.game.clans.clans.event.PreEnergyShopBuyEvent;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import mineplex.game.clans.clans.siege.SiegeManager;
|
||||
import mineplex.game.clans.economy.GoldManager;
|
||||
import mineplex.game.clans.message.ClansMessageManager;
|
||||
import mineplex.game.clans.spawn.Spawn;
|
||||
import mineplex.game.clans.tutorial.Tutorial;
|
||||
import mineplex.game.clans.tutorial.TutorialRegion;
|
||||
import mineplex.game.clans.tutorial.TutorialSession;
|
||||
import mineplex.game.clans.tutorial.TutorialWorldManager;
|
||||
import mineplex.game.clans.tutorial.map.TutorialMapManager;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.AttackEnemyObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClassesObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.EnergyObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.FieldsObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.FinalObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.PurchaseItemsObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.ShopsObjective;
|
||||
//import mineplex.game.clans.tutorial.tutorials.clans.repository.TutorialRepository;
|
||||
|
||||
public class ClansMainTutorial extends Tutorial
|
||||
{
|
||||
|
@ -5,19 +5,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftZombie;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.DefaultHashMap;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.EnclosedObject;
|
||||
@ -31,7 +18,6 @@ import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.siege.SiegeManager;
|
||||
import mineplex.game.clans.clans.siege.weapon.Cannon;
|
||||
import mineplex.game.clans.tutorial.TutorialRegion;
|
||||
import mineplex.game.clans.tutorial.TutorialSession;
|
||||
@ -39,11 +25,22 @@ import mineplex.game.clans.tutorial.objective.OrderedObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.HoldItemGoal;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.BlowUpWallGoal;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.ClanInfoGoal;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.GetMapGoal;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.LoadCannonGoal;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.MountCannonGoal;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.StealEnemyPotatoesGoal;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.ClanInfoGoal;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class AttackEnemyObjective extends OrderedObjective<ClansMainTutorial>
|
||||
{
|
||||
|
@ -1,16 +1,6 @@
|
||||
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.siege.SiegeManager;
|
||||
import mineplex.game.clans.clans.siege.events.MountSiegeWeaponEvent;
|
||||
import mineplex.game.clans.clans.siege.weapon.Cannon;
|
||||
import mineplex.game.clans.tutorial.TutorialRegion;
|
||||
@ -20,6 +10,10 @@ import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial.Point;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.AttackEnemyObjective;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
public class MountCannonGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||
{
|
||||
private ClansManager _clansManager;
|
||||
|
@ -73,7 +73,7 @@ public class QueueManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void queuePlayer(final String gameType, final Player...players)
|
||||
public void queuePlayer(final int gameType, final Player...players)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
@ -103,7 +103,7 @@ public class QueueManager extends MiniPlugin
|
||||
|
||||
for (Player player : players)
|
||||
{
|
||||
eloCumulative = _eloManager.getElo(player.getUniqueId(), gameType);
|
||||
eloCumulative = _eloManager.getElo(player, gameType);
|
||||
}
|
||||
|
||||
final int elo = eloCumulative / players.length;
|
||||
@ -116,7 +116,7 @@ public class QueueManager extends MiniPlugin
|
||||
|
||||
synchronized (_queueLock)
|
||||
{
|
||||
_queuedPlayerMatchList.put(players[0].getName(), matchStatus);
|
||||
_queuedPlayerMatchList.put(players[0].getName(), matchStatus);
|
||||
}
|
||||
|
||||
synchronized (_queuePlayerListLock)
|
||||
|
@ -12,7 +12,7 @@ public class QueueRepository
|
||||
{
|
||||
private boolean _us = true;
|
||||
|
||||
private static String CREATE_ELO_QUEUE_TABLE = "CREATE TABLE IF NOT EXISTS playerQueue (id INT NOT NULL AUTO_INCREMENT, playerList VARCHAR(256), gameType VARCHAR(256), playerCount INT, elo INT, state VARCHAR(256), time LONG, assignedMatch INT, US BOOLEAN NOT NULL DEFAULT '1', PRIMARY KEY (id), UNIQUE INDEX name_gametype (playerList, gameType));";
|
||||
private static String CREATE_ELO_QUEUE_TABLE = "CREATE TABLE IF NOT EXISTS playerQueue (id INT NOT NULL AUTO_INCREMENT, playerList VARCHAR(256), gameType INT, playerCount INT, elo INT, state VARCHAR(256), time LONG, assignedMatch INT, US BOOLEAN NOT NULL DEFAULT '1', PRIMARY KEY (id), UNIQUE INDEX name_gametype (playerList, gameType));";
|
||||
private static String SAVE_STATE_VALUE = "UPDATE playerQueue SET state = ? WHERE id = ?;";
|
||||
private static String DELETE_QUEUE_RECORD = "DELETE FROM playerQueue WHERE id = ?;";
|
||||
private static String INSERT_ACCOUNT = "INSERT INTO playerQueue (playerList, gameType, elo, state, time, playerCount, assignedMatch) VALUES (?, ?, ?, 'Awaiting Match', now(), ?, -1) ON DUPLICATE KEY UPDATE time=VALUES(time);";
|
||||
@ -100,7 +100,7 @@ public class QueueRepository
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerMatchStatus addQueueRecord(String playerList, int playerCount, String gameType, int elo)
|
||||
public PlayerMatchStatus addQueueRecord(String playerList, int playerCount, int gameType, int elo)
|
||||
{
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
@ -110,7 +110,7 @@ public class QueueRepository
|
||||
{
|
||||
preparedStatement = connection.prepareStatement(INSERT_ACCOUNT, Statement.RETURN_GENERATED_KEYS);
|
||||
preparedStatement.setString(1, playerList);
|
||||
preparedStatement.setString(2, gameType);
|
||||
preparedStatement.setInt(2, gameType);
|
||||
preparedStatement.setInt(3, elo);
|
||||
//preparedStatement.setBoolean(4, _us);
|
||||
preparedStatement.setInt(4, playerCount);
|
||||
|
@ -105,7 +105,8 @@ public class QueuePage extends ShopPageBase<QueueManager, QueueShop>
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
queuePlayer("Dominate", player);
|
||||
// TODO GAMEID?
|
||||
queuePlayer(1, player);
|
||||
}
|
||||
};
|
||||
|
||||
@ -128,7 +129,7 @@ public class QueuePage extends ShopPageBase<QueueManager, QueueShop>
|
||||
buildPage();
|
||||
}
|
||||
|
||||
private void queuePlayer(String gameType, Player player)
|
||||
private void queuePlayer(int gameType, Player player)
|
||||
{
|
||||
Party party = getPlugin().getPartyManager().GetParty(player);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package nautilus.game.arcade.game;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@ -55,6 +56,9 @@ import mineplex.core.common.util.UtilTabTitle;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||
import mineplex.core.elo.EloPlayer;
|
||||
import mineplex.core.elo.EloTeam;
|
||||
import mineplex.core.elo.GameResult;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.packethandler.IPacketHandler;
|
||||
import mineplex.core.packethandler.PacketInfo;
|
||||
@ -309,10 +313,11 @@ public abstract class Game implements Listener
|
||||
|
||||
public String Winner = "Nobody";
|
||||
public GameTeam WinnerTeam = null;
|
||||
|
||||
|
||||
//ELO
|
||||
public boolean EloRanking = false;
|
||||
public int EloStart = 1000;
|
||||
|
||||
|
||||
public boolean CanAddStats = true;
|
||||
public boolean CanGiveLoot = true;
|
||||
|
||||
@ -438,7 +443,7 @@ public abstract class Game implements Listener
|
||||
{
|
||||
return _gameType.GetName();
|
||||
}
|
||||
|
||||
|
||||
public GameType[] GetWorldHostNames()
|
||||
{
|
||||
GameType[] mapSource = new GameType[]
|
||||
@ -595,7 +600,7 @@ public abstract class Game implements Listener
|
||||
// Event
|
||||
GameStateChangeEvent stateEvent = new GameStateChangeEvent(this, state);
|
||||
UtilServer.getServer().getPluginManager().callEvent(stateEvent);
|
||||
|
||||
|
||||
System.out.println(GetName() + " state set to " + state.toString());
|
||||
}
|
||||
|
||||
@ -1032,18 +1037,6 @@ public abstract class Game implements Listener
|
||||
return SpectatorSpawn;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void eloStart(PlayerLoginEvent event)
|
||||
{
|
||||
if (EloRanking)
|
||||
{
|
||||
if (Manager.getEloManager().getElo(event.getPlayer().getUniqueId(), GetName()) == -1)
|
||||
{
|
||||
Manager.getEloManager().saveElo(event.getPlayer().getUniqueId(), GetName(), EloStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public abstract void ScoreboardUpdate(UpdateEvent event);
|
||||
|
||||
@ -1206,9 +1199,11 @@ public abstract class Game implements Listener
|
||||
}
|
||||
|
||||
UtilTextMiddle.display(winnerText, subColor + "won the game", 20, 120, 20);
|
||||
|
||||
|
||||
if (AnnounceSilence)
|
||||
Manager.GetChat().Silence(5000, false);
|
||||
|
||||
endElo();
|
||||
}
|
||||
|
||||
public void AnnounceEnd(List<Player> places)
|
||||
@ -1263,9 +1258,11 @@ public abstract class Game implements Listener
|
||||
}
|
||||
|
||||
UtilTextMiddle.display(winnerText, subColor + "won the game", 20, 120, 20);
|
||||
|
||||
|
||||
if (AnnounceSilence)
|
||||
Manager.GetChat().Silence(5000, false);
|
||||
|
||||
endElo();
|
||||
}
|
||||
|
||||
public void Announce(String message)
|
||||
@ -1288,7 +1285,7 @@ public abstract class Game implements Listener
|
||||
|
||||
System.out.println("[Announcement] " + message);
|
||||
}
|
||||
|
||||
|
||||
public boolean AdvertiseText(GameLobbyManager gameLobbyManager, int _advertiseStage)
|
||||
{
|
||||
return false;
|
||||
@ -1564,11 +1561,49 @@ public abstract class Game implements Listener
|
||||
if (player.isOnline())
|
||||
AddGems(player, 10, "Participation", false, false);
|
||||
}
|
||||
|
||||
|
||||
endElo();
|
||||
|
||||
// End
|
||||
SetState(GameState.End);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onGameStart(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() == GameState.Live)
|
||||
{
|
||||
if (EloRanking)
|
||||
{
|
||||
// Populate teams
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
EloTeam eloTeam = new EloTeam();
|
||||
|
||||
for (Player player : team.GetPlayers(false))
|
||||
{
|
||||
eloTeam.addPlayer(new EloPlayer(player, Manager.GetClients().getAccountId(player), Manager.getEloManager().getElo(player, GetType().getGameId())));
|
||||
}
|
||||
|
||||
Manager.getEloManager().addTeam(team.getDisplayName(), eloTeam);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle Elo at end of game -- method can be overridden in different game modes to meet their individual needs
|
||||
protected void endElo()
|
||||
{
|
||||
if (EloRanking)
|
||||
{
|
||||
if (WinnerTeam != null)
|
||||
Manager.getEloManager().setWinningTeam(WinnerTeam.getDisplayName());
|
||||
|
||||
Manager.getEloManager().endMatch(GetType().getGameId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void handleInteractEntityPacket(GameStateChangeEvent event)
|
||||
{
|
||||
|
@ -0,0 +1,51 @@
|
||||
/*Every GameOption will have SetOption and GetOption methods
|
||||
* However, since each GameOption class will have a different return type
|
||||
* and take different parameters, there isn't much need to create any here at this time
|
||||
*/
|
||||
|
||||
package nautilus.game.arcade.game;
|
||||
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
public class GameOption
|
||||
{
|
||||
//Store the name and Description of each option - Literally every GameOption should have these
|
||||
private String _optionName;
|
||||
private String _optionDescription;
|
||||
private MaterialData _optionMaterialData;
|
||||
|
||||
public GameOption(String optName, String optDesc)
|
||||
{
|
||||
_optionName = optName;
|
||||
_optionDescription = optDesc;
|
||||
}
|
||||
|
||||
public GameOption(MaterialData _optMat, String optName, String optDesc)
|
||||
{
|
||||
_optionName = optName;
|
||||
_optionDescription = optDesc;
|
||||
_optionMaterialData = _optMat;
|
||||
}
|
||||
|
||||
//Get methods for name of option and description
|
||||
public String GetOptionName()
|
||||
{
|
||||
return _optionName;
|
||||
}
|
||||
|
||||
public String GetOptionDescription()
|
||||
{
|
||||
return _optionDescription;
|
||||
}
|
||||
|
||||
public MaterialData GetOptionMaterialData()
|
||||
{
|
||||
if(_optionMaterialData != null)
|
||||
{
|
||||
return _optionMaterialData;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -71,7 +71,6 @@ public class ChampionsCTF extends CaptureTheFlag
|
||||
|
||||
InventoryOpenChest = true;
|
||||
|
||||
EloRanking = false;
|
||||
EloStart = 1000;
|
||||
|
||||
this.DontAllowOverfill = true;
|
||||
|
@ -66,7 +66,6 @@ public class ChampionsDominate extends Domination
|
||||
|
||||
InventoryOpenChest = true;
|
||||
|
||||
EloRanking = false;
|
||||
EloStart = 1000;
|
||||
|
||||
this.DontAllowOverfill = true;
|
||||
|
@ -66,7 +66,6 @@ public class ChampionsTDM extends TeamDeathmatch
|
||||
this.StrictAntiHack = true;
|
||||
|
||||
InventoryOpenChest = true;
|
||||
|
||||
this.DisableKillCommand = false;
|
||||
|
||||
this.DontAllowOverfill = true;
|
||||
|
@ -551,51 +551,10 @@ public class CaptureTheFlag extends TeamGame
|
||||
if (player.isOnline())
|
||||
AddGems(player, 10, "Participation", false, false);
|
||||
}
|
||||
|
||||
if (EloRanking)
|
||||
{
|
||||
EloTeam teamWinner = new EloTeam();
|
||||
EloTeam teamLoser = new EloTeam();
|
||||
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
if (WinnerTeam != null && team.equals(WinnerTeam))
|
||||
{
|
||||
for (Player player : WinnerTeam.GetPlayers(false))
|
||||
{
|
||||
EloPlayer eloPlayer = new EloPlayer();
|
||||
eloPlayer.UniqueId = player.getUniqueId().toString();
|
||||
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
|
||||
|
||||
teamWinner.addPlayer(eloPlayer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Player player : team.GetPlayers(false))
|
||||
{
|
||||
EloPlayer eloPlayer = new EloPlayer();
|
||||
eloPlayer.UniqueId = player.getUniqueId().toString();
|
||||
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
|
||||
|
||||
teamLoser.addPlayer(eloPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamWinner, teamLoser, GameResult.Win).getPlayers())
|
||||
{
|
||||
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
|
||||
}
|
||||
|
||||
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamLoser, teamWinner, GameResult.Loss).getPlayers())
|
||||
{
|
||||
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
|
||||
}
|
||||
}
|
||||
endElo();
|
||||
|
||||
//End
|
||||
SetState(GameState.End);
|
||||
SetState(GameState.End);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -315,47 +315,7 @@ public class Domination extends TeamGame
|
||||
AddGems(player, 10, "Participation", false, false);
|
||||
}
|
||||
|
||||
if (EloRanking)
|
||||
{
|
||||
EloTeam teamWinner = new EloTeam();
|
||||
EloTeam teamLoser = new EloTeam();
|
||||
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
if (WinnerTeam != null && team.equals(WinnerTeam))
|
||||
{
|
||||
for (Player player : WinnerTeam.GetPlayers(false))
|
||||
{
|
||||
EloPlayer eloPlayer = new EloPlayer();
|
||||
eloPlayer.UniqueId = player.getUniqueId().toString();
|
||||
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
|
||||
|
||||
teamWinner.addPlayer(eloPlayer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Player player : team.GetPlayers(false))
|
||||
{
|
||||
EloPlayer eloPlayer = new EloPlayer();
|
||||
eloPlayer.UniqueId = player.getUniqueId().toString();
|
||||
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
|
||||
|
||||
teamLoser.addPlayer(eloPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamWinner, teamLoser, GameResult.Win).getPlayers())
|
||||
{
|
||||
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
|
||||
}
|
||||
|
||||
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamLoser, teamWinner, GameResult.Loss).getPlayers())
|
||||
{
|
||||
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
|
||||
}
|
||||
}
|
||||
endElo();
|
||||
|
||||
//End
|
||||
SetState(GameState.End);
|
||||
|
@ -3,11 +3,30 @@ package nautilus.game.arcade.game.games.common;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.games.common.dominate_data.CapturePointTDM;
|
||||
import nautilus.game.arcade.game.games.common.dominate_data.Resupply;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -18,38 +37,6 @@ import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.elo.EloPlayer;
|
||||
import mineplex.core.elo.EloTeam;
|
||||
import mineplex.core.elo.GameResult;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||
import nautilus.game.arcade.game.games.champions.kits.KitAssassin;
|
||||
import nautilus.game.arcade.game.games.champions.kits.KitBrute;
|
||||
import nautilus.game.arcade.game.games.champions.kits.KitKnight;
|
||||
import nautilus.game.arcade.game.games.champions.kits.KitMage;
|
||||
import nautilus.game.arcade.game.games.champions.kits.KitRanger;
|
||||
import nautilus.game.arcade.game.games.common.dominate_data.CapturePoint;
|
||||
import nautilus.game.arcade.game.games.common.dominate_data.CapturePointTDM;
|
||||
import nautilus.game.arcade.game.games.common.dominate_data.Emerald;
|
||||
import nautilus.game.arcade.game.games.common.dominate_data.Resupply;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
public class TeamDeathmatch extends TeamGame
|
||||
{
|
||||
private ArrayList<CapturePointTDM> _points = new ArrayList<CapturePointTDM>();
|
||||
@ -78,7 +65,22 @@ public class TeamDeathmatch extends TeamGame
|
||||
this.HungerSet = 20;
|
||||
this.WorldTimeSet = 2000;
|
||||
this.CompassEnabled = true;
|
||||
|
||||
|
||||
//this.EloRanking = true;
|
||||
//this.EloSetting.setEloSetting(2);
|
||||
|
||||
//this.addEloColumn();
|
||||
|
||||
/*
|
||||
try
|
||||
{
|
||||
this.Manager.getEloManager().addGameToDatabase("ALTER TABLE Accounts.eloRatingTest ADD [Champions TDM Team Deathmatch] INT;");
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
*/
|
||||
|
||||
this.Manager.GetDamage().UseSimpleWeaponDamage = false;
|
||||
|
||||
//_healthObj = GetScoreboard().registerNewObjective("HP", "dummy");
|
||||
@ -127,7 +129,7 @@ public class TeamDeathmatch extends TeamGame
|
||||
{
|
||||
if (!(event.GetEvent().getEntity() instanceof Player))
|
||||
return;
|
||||
|
||||
|
||||
Player killed = (Player)event.GetEvent().getEntity();
|
||||
SetPlayerState(killed, PlayerState.OUT);
|
||||
|
||||
@ -158,7 +160,7 @@ public class TeamDeathmatch extends TeamGame
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void Health(GameStateChangeEvent event)
|
||||
{
|
||||
@ -334,9 +336,6 @@ public class TeamDeathmatch extends TeamGame
|
||||
|
||||
ScoreboardWrite();
|
||||
|
||||
//Announce
|
||||
AnnounceEnd(winner);
|
||||
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
if (WinnerTeam != null && team.equals(WinnerTeam))
|
||||
@ -349,53 +348,28 @@ public class TeamDeathmatch extends TeamGame
|
||||
if (player.isOnline())
|
||||
AddGems(player, 10, "Participation", false, false);
|
||||
}
|
||||
|
||||
if (EloRanking)
|
||||
{
|
||||
EloTeam teamWinner = new EloTeam();
|
||||
EloTeam teamLoser = new EloTeam();
|
||||
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
if (WinnerTeam != null && team.equals(WinnerTeam))
|
||||
{
|
||||
for (Player player : WinnerTeam.GetPlayers(false))
|
||||
{
|
||||
EloPlayer eloPlayer = new EloPlayer();
|
||||
eloPlayer.UniqueId = player.getUniqueId().toString();
|
||||
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
|
||||
|
||||
teamWinner.addPlayer(eloPlayer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Player player : team.GetPlayers(false))
|
||||
{
|
||||
EloPlayer eloPlayer = new EloPlayer();
|
||||
eloPlayer.UniqueId = player.getUniqueId().toString();
|
||||
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
|
||||
|
||||
teamLoser.addPlayer(eloPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamWinner, teamLoser, GameResult.Win).getPlayers())
|
||||
{
|
||||
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
|
||||
}
|
||||
|
||||
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamLoser, teamWinner, GameResult.Loss).getPlayers())
|
||||
{
|
||||
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Announce End
|
||||
AnnounceEnd(winner);
|
||||
|
||||
//End
|
||||
SetState(GameState.End);
|
||||
}
|
||||
|
||||
/*//call endElo (Game.Java) if the game ends
|
||||
@EventHandler
|
||||
public void EloCalc(GameStateChangeEvent event)
|
||||
{
|
||||
//relevant if we decide to move this to Game.java
|
||||
if(EloRanking)
|
||||
{
|
||||
if (event.GetState() == GameState.End)
|
||||
{
|
||||
endElo();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void UsableInteract(PlayerInteractEvent event)
|
||||
{
|
||||
|
@ -44,6 +44,9 @@ import mineplex.core.common.util.UtilGear;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.elo.EloPlayer;
|
||||
import mineplex.core.elo.EloTeam;
|
||||
import mineplex.core.elo.GameResult;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
@ -851,9 +854,12 @@ public class TurfForts extends TeamGame
|
||||
AddGems(player, 10, "Participation", false, false);
|
||||
}
|
||||
|
||||
endElo();
|
||||
|
||||
//End
|
||||
SetState(GameState.End);
|
||||
}
|
||||
|
||||
|
||||
public Long getEnemyTurfEntranceTime(Player player)
|
||||
{
|
||||
|
@ -19,17 +19,13 @@ import mineplex.core.common.util.UtilBlockText.TextAlign;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.cosmetic.event.ActivateGemBoosterEvent;
|
||||
import mineplex.core.donation.Donor;
|
||||
import mineplex.core.event.CustomTagEvent;
|
||||
import mineplex.core.packethandler.IPacketHandler;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.packethandler.PacketInfo;
|
||||
import mineplex.core.packethandler.PacketVerifier;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
@ -43,9 +39,6 @@ import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.kit.KitAvailability;
|
||||
import nautilus.game.arcade.kit.KitSorter;
|
||||
import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -106,6 +99,7 @@ public class GameLobbyManager implements Listener
|
||||
private NautHashMap<Player, Scoreboard> _scoreboardMap = new NautHashMap<Player, Scoreboard>();
|
||||
private NautHashMap<Player, Integer> _gemMap = new NautHashMap<Player, Integer>();
|
||||
private NautHashMap<Player, Integer> _eloMap = new NautHashMap<Player, Integer>();
|
||||
private NautHashMap<Player, String> _divisionMap = new NautHashMap<Player, String>();
|
||||
private NautHashMap<Player, String> _kitMap = new NautHashMap<Player, String>();
|
||||
|
||||
private int _oldPlayerCount = 0;
|
||||
@ -1119,14 +1113,14 @@ public class GameLobbyManager implements Listener
|
||||
entry.getValue().resetScores(_kitMap.get(entry.getKey()) + "");
|
||||
|
||||
// Set new
|
||||
objective.getScore(" ").setScore(line--);
|
||||
objective.getScore(" ").setScore(line--);
|
||||
objective.getScore(teamColor + C.Bold + "Kit").setScore(line--);
|
||||
objective.getScore(kitName + "").setScore(line--);
|
||||
|
||||
_kitMap.put(entry.getKey(), kitName + "");
|
||||
}
|
||||
|
||||
objective.getScore(" ").setScore(line--);
|
||||
objective.getScore(" ").setScore(line--);
|
||||
objective.getScore(C.cGreen + C.Bold + "Gems").setScore(line--);
|
||||
|
||||
// Remove old
|
||||
@ -1137,21 +1131,21 @@ public class GameLobbyManager implements Listener
|
||||
_gemMap.put(entry.getKey(), Manager.GetDonation().Get(entry.getKey().getName()).GetGems());
|
||||
|
||||
//Server
|
||||
objective.getScore(" ").setScore(line--);
|
||||
objective.getScore(" ").setScore(line--);
|
||||
objective.getScore(C.cAqua + C.Bold + "Server").setScore(line--);
|
||||
objective.getScore(_serverName).setScore(line--);
|
||||
|
||||
//ELO
|
||||
|
||||
// ELO DIVISION
|
||||
if (Manager.GetGame() != null && Manager.GetGame().EloRanking)
|
||||
{
|
||||
objective.getScore(" ").setScore(line--);
|
||||
objective.getScore(C.cPurple + C.Bold + "Elo").setScore(line--);
|
||||
objective.getScore(C.cPurpleB + C.Bold + "Division").setScore(line--);
|
||||
|
||||
// Remove old
|
||||
entry.getValue().resetScores(_eloMap.get(entry.getKey()) + " ");
|
||||
entry.getValue().resetScores(_divisionMap.get(entry.getKey()) + " ");
|
||||
// Set new
|
||||
objective.getScore(Manager.getEloManager().getElo(entry.getKey().getUniqueId(), Manager.GetGame().GetName()) + " ").setScore(line--);
|
||||
|
||||
|
||||
objective.getScore(Manager.getEloManager().getPlayerDivision(entry.getKey(), Manager.GetGame().GetType().getGameId()) + " ").setScore(line--);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user