Merge branch 'feature/elo' of github.com:Mineplex-LLC/Minecraft-PC into alex/elofix

This commit is contained in:
AlexTheCoder 2016-04-17 12:27:23 -04:00
commit ee30012011
19 changed files with 922 additions and 106 deletions

View File

@ -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()
{
try {
client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName()));
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
_clientLoginLock.remove(client.GetPlayerName());
}
});

View File

@ -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;
}

View 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;
}
}

View File

@ -2,13 +2,18 @@ package mineplex.core.elo;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.UUID;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.NautHashMap;
import mineplex.serverdata.database.column.ColumnInt;
import mineplex.serverdata.database.column.ColumnVarChar;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class EloManager extends MiniDbClientPlugin<EloClientData>
@ -18,6 +23,9 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
private EloRepository _repository;
private EloRatingSystem _ratingSystem;
private NautHashMap<String, NautHashMap<String, Integer>> _playerElos;
private NautHashMap<String, NautHashMap<String, String>> _playerDivisions;
private EloDivision _division;
public EloManager(JavaPlugin plugin, CoreClientManager clientManager)
{
@ -26,12 +34,47 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
_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>>();
}
//add an EloPlayer's info to _playerElos
public void addToPlayerElos(EloPlayer player, String gameType)
{
NautHashMap<String, Integer> playerInfo = new NautHashMap<String, Integer>();
playerInfo.put(player.getUniqueId(), player.Rating);
_playerElos.put(gameType, playerInfo);
}
/*
* fill _playerElos with information from database
* If no entry exists, create one
*/
public void generatePlayerElos(ArrayList<Player> players, String gameType)
{
for (Player player : players)
{
int elo = getElo(player.getUniqueId(), gameType);
_playerElos.get(player.getUniqueId().toString()).put(gameType, elo);
}
}
public int getElo(UUID uuid, String gameType)
{
int elo = 1000;
//let's try getting Elo directly from the repository
//If this works, we will never hit the return at the bottom
try
{
elo = _repository.getRepoElo(uuid.toString(), gameType);
Bukkit.broadcastMessage("Fetching Elo...");
return elo;
}
catch (SQLException e)
{
e.printStackTrace();
}
synchronized (_playerEloLock)
{
if (_playerElos.containsKey(uuid.toString()))
@ -59,7 +102,7 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
for (EloPlayer player : teamA.getPlayers())
{
EloPlayer newPlayer = new EloPlayer();
newPlayer.UniqueId = player.UniqueId;
newPlayer.setUniqueId(player.getUniqueId());
newPlayer.Rating = (int)(player.Rating + ((double)player.Rating / (double)teamA.TotalElo) * (newTotal - teamA.TotalElo));
System.out.println("Old:");
@ -76,24 +119,43 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
public void saveElo(UUID uuid, String gameType, int elo)
{
//Bukkit.broadcastMessage("SAVE_ELO - EloManager (uuid type) called");
//String playerDiv = getPlayerDivision(uuid, gameType);
saveElo(uuid.toString(), gameType, elo);
//saveDivision(uuid.toString(), gameType, playerDiv);
}
public void saveElo(final String uuid, final String gameType, final int elo)
{
//Bukkit.broadcastMessage("SAVE_ELO - EloManager (String type) called");
Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
{
public void run()
{
_repository.saveElo(uuid, gameType, elo);
try {
//it hits this, but doesn't hit the message below.
_repository.saveElo(uuid, gameType, elo);
Bukkit.broadcastMessage("Attempting to save " + elo + " as Elo from repository...");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Bukkit.broadcastMessage("EloManager SaveElo (string) - CATCH hit");
}
//Doesn't hit any of this, to my knowledge - JP
synchronized (_playerEloLock)
{
//Bukkit.broadcastMessage("EloManager SaveElo (string) - _playerEloLock synchronized...");
if (_playerElos.containsKey(uuid))
{
//Bukkit.broadcastMessage("EloManager SaveElo (string) - uuid found in _playerElos");
if (_playerElos.get(uuid).containsKey(gameType))
{
//Bukkit.broadcastMessage("EloManager SaveElo (string) - gameType found in _playerElos");
_playerElos.get(uuid).put(gameType, elo);
//Bukkit.broadcastMessage("Attempting to save " + elo + " as Elo from hash map...");
}
}
}
@ -101,6 +163,96 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
});
}
//save divisons the same way that we're saving Elos
public void saveDivision(final String uuid, final String gameType, final String division)
{
Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
{
public void run()
{
try {
_repository.saveDivision(uuid, gameType, division);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
synchronized (_playerEloLock)
{
if (_playerDivisions.containsKey(uuid))
{
if (_playerDivisions.get(uuid).containsKey(gameType))
{
_playerDivisions.get(uuid).put(gameType, division);
}
}
}
}
});
}
//get a player's Division
public String getPlayerDivision(UUID uuid, String gameType)
{
//get playerElo for gameType (need to store this to check it against other Elo's)
int playerElo = 1000;
try {
playerElo = _repository.getRepoElo(uuid.toString(), gameType);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//this list will be filled with ELO's from other players (but only for the same game type
ArrayList<Integer> allElos = new ArrayList<Integer>();
for(int i = 0; i < _playerElos.size(); i++)
{
//we're only concerned with this Game Type
if(_playerElos.containsKey(gameType))
{
//add elo's to the list
allElos.add(_playerElos.get(uuid.toString()).get(gameType));
}
}
//sort list of Elos (needed for percentile calculations)
Collections.sort(allElos);
//Calculate how much going up one spot is worth
double individualValue = (100/allElos.size());
/* lastIndexOf gets the last instance of player's Elo
* Consequently, it should be easier for rank to go up than down
* and everyone at the same Elo should be in the same division
*/
double percentile = allElos.lastIndexOf(playerElo) * individualValue;
return CalculateDivision(playerElo, percentile);
}
public String CalculateDivision(int playerElo, double divPercent)
{
if (playerElo >= 3500 && divPercent > 99) 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 && playerElo >= 400) return "Coal 1";
return "Result not found";
}
@Override
protected EloClientData AddPlayer(String player)
{

View File

@ -2,11 +2,22 @@ package mineplex.core.elo;
public class EloPlayer
{
public String UniqueId;
private String _uniqueId;
public int Rating;
public void printInfo()
{
System.out.println(UniqueId + "'s elo is " + Rating);
System.out.println(_uniqueId + "'s elo is " + Rating);
}
public String getUniqueId()
{
return _uniqueId;
}
public void setUniqueId(String uuid)
{
_uniqueId = uuid;
}
}

View File

@ -1,11 +1,19 @@
package mineplex.core.elo;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import mineplex.core.database.MinecraftRepository;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import com.mysql.jdbc.PreparedStatement;
import com.mysql.jdbc.Statement;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.RepositoryBase;
import mineplex.serverdata.database.column.ColumnInt;
@ -13,8 +21,14 @@ 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 CREATE_ELO_TABLE = "CREATE TABLE IF NOT EXISTS eloRating (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), gameType VARCHAR(256), elo INT, division VARCHAR(256), 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_DIVISION = "INSERT INTO eloRating (uuid, gameType, division) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE division=VALUES(division);";
private static String UPDATE_ELO = "UPDATE eloRating SET elo=? WHERE uuid=?;";
private static String SELECT_ELO_BY_UUID = "SELECT elo FROM eloRating WHERE uuid = ? LIMIT 1";
private static String SELECT_DIVISION_BY_UUID = "SELECT division FROM eloRating WHERE uuid = ? LIMIT 1";
private static String UPDATE_DIVISION = "UPDATE eloRating SET division=? WHERE uuid=?;";
private static String ELO_NEW = "INSERT INTO eloRating (uuid, gameType, elo), values(?, ?, ?);";
public EloRepository(JavaPlugin plugin)
{
@ -28,9 +42,92 @@ public class EloRepository extends MinecraftRepository
//executeUpdate(CREATE_ELO_TABLE);
}
public void saveElo(String uuid, String gameType, int elo)
//get an elo from the database
public int getRepoElo(String uuid, String gameType) throws SQLException
{
executeUpdate(INSERT_ELO, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("gameType", 100, gameType), new ColumnInt("elo", elo));
//elo set to 1000 by default
int elo = 1000;
try (Connection con = getConnection(); java.sql.PreparedStatement pStatement = con.prepareStatement(SELECT_ELO_BY_UUID);)
{
pStatement.execute(SELECT_ELO_BY_UUID);
pStatement.setString(1, uuid.toString());
ResultSet resultSet = pStatement.executeQuery();
//if something was found, return the elo
if(resultSet.next())
{
elo = resultSet.getInt("elo");
Bukkit.broadcastMessage("getRepoElo pulled " + elo + "from database for " + uuid);
return elo;
}
else
{
saveElo(uuid, gameType, elo);
}
}
return elo;
}
public void saveElo(String uuid, String gameType, int elo) throws SQLException
{
Connection con = getConnection();
java.sql.PreparedStatement stmt = con.prepareStatement(SELECT_ELO_BY_UUID);
stmt.setString(1, uuid.toString());
ResultSet rs = stmt.executeQuery();
boolean contains = false;
Bukkit.broadcastMessage("SAVE_ELO - EloRepository called");
Bukkit.broadcastMessage("Pre-loop - Result Set Boolean:" + rs.toString());
while (rs.next())
{
Bukkit.broadcastMessage("Result Set Boolean:" + rs.toString());
contains = true;
//update elo
java.sql.PreparedStatement updateStatement = con.prepareStatement(UPDATE_ELO);
updateStatement.setInt(1, elo);
updateStatement.setString(2, uuid.toString());
updateStatement.executeUpdate();
//executeUpdate(UPDATE_ELO, new ColumnInt("elo", elo));
Bukkit.broadcastMessage("SAVE_ELO - EloRepository: Updating existing elo to " + elo);
}
if(!contains)
{
//insert elo
java.sql.PreparedStatement updateStatement = con.prepareStatement(INSERT_ELO);
updateStatement.setInt(1, elo);
updateStatement.setString(2, uuid.toString());
updateStatement.executeUpdate();
//executeUpdate(INSERT_ELO, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("gameType", 100, gameType), new ColumnInt("elo", elo));
Bukkit.broadcastMessage("SAVE_ELO - EloRepository: Adding " + elo + " to " + gameType +" elo database...");
}
Bukkit.broadcastMessage("SAVE_ELO - EloRepository: Adding " + elo + " to " + gameType +" elo database...");
}
public void saveDivision(String uuid, String gameType, String division) throws SQLException
{
Connection con = getConnection();
java.sql.Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_UPDATABLE);
String selectQuery = "SELECT gameType, division FROM eloRating WHERE uuid = '" + uuid + "';";
ResultSet rs = stmt.executeQuery(selectQuery);
boolean contains = false;
while(rs.next())
{
String updateQuery = "UPDATE eloRating SET division='" + division + "' WHERE uuid = '" + uuid + "' AND gametype = '" + gameType + "';";
executeUpdate(updateQuery, new ColumnVarChar("elo", 100, uuid));
}
if(!contains)
{
executeUpdate(INSERT_DIVISION, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("gameType", 100, gameType), new ColumnVarChar("division", 100, division));
}
}
public EloClientData loadClientInformation(ResultSet resultSet) throws SQLException

View File

@ -0,0 +1,57 @@
package mineplex.core.elo;
public class EloSettings {
private boolean _fullElo = false;
private boolean _backendElo = false;
private boolean _eloDisabled = true;
public EloSettings(int setElo)
{
setEloSetting(setElo);
}
public int getEloSetting()
{
int settingNum = 0;
if(_backendElo)
{
settingNum = 1;
}
else if (_fullElo)
{
settingNum = 2;
}
return settingNum;
}
public void setEloSetting(int newSetting)
{
switch(newSetting)
{
case 0:
_fullElo = false;
_backendElo = false;
_eloDisabled = true;
break;
case 1:
_fullElo = false;
_backendElo = true;
_eloDisabled = false;
break;
case 2:
_fullElo = true;
_backendElo = false;
_eloDisabled = false;
break;
default:
_fullElo = false;
_backendElo = false;
_eloDisabled = true;
}
}
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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
{

View File

@ -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>
{

View File

@ -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;

View File

@ -55,6 +55,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.EloSettings;
import mineplex.core.elo.EloTeam;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketInfo;
@ -310,6 +313,9 @@ public abstract class Game implements Listener
public String Winner = "Nobody";
public GameTeam WinnerTeam = null;
//EloSetting - (0 = disabled, 1 = background, 2 = full)
public EloSettings EloSetting = new EloSettings(0);
public boolean EloRanking = false;
public int EloStart = 1000;
@ -1035,6 +1041,7 @@ public abstract class Game implements Listener
@EventHandler
public void eloStart(PlayerLoginEvent event)
{
Bukkit.broadcastMessage("eloStart called in Game. Player's Elo should be saved.");
if (EloRanking)
{
if (Manager.getEloManager().getElo(event.getPlayer().getUniqueId(), GetName()) == -1)
@ -1207,6 +1214,9 @@ public abstract class Game implements Listener
UtilTextMiddle.display(winnerText, subColor + "won the game", 20, 120, 20);
//try to do Elo stuff
handleElo();
if (AnnounceSilence)
Manager.GetChat().Silence(5000, false);
}
@ -1264,6 +1274,9 @@ public abstract class Game implements Listener
UtilTextMiddle.display(winnerText, subColor + "won the game", 20, 120, 20);
//call adjustPlayerElo
adjustPlayerElo(places);
if (AnnounceSilence)
Manager.GetChat().Silence(5000, false);
}
@ -1289,6 +1302,169 @@ public abstract class Game implements Listener
System.out.println("[Announcement] " + message);
}
//calculate the elo multiplier for a player based on the average elo of all players
public int calculateEloMultiplier(int currentElo, int averageElo)
{
int eloDifference = averageElo - currentElo;
if (Math.abs(eloDifference) <= 50)
{
return 0;
}
if (eloDifference >= 200)
{
return 3;
}
if (eloDifference >= 100)
{
return 2;
}
if (eloDifference > 50)
{
return 1;
}
if (eloDifference <= -200)
{
return -3;
}
if (eloDifference <= -100)
{
return -2;
}
if (eloDifference < -50)
{
return -1;
}
return 0;
}
//adjust the elo's of every player, depending on their ranking in the game mode
public void adjustPlayerElo(List<Player> places)
{
int averageElo = 0;
for (Player player : UtilServer.getPlayers())
{
averageElo += Manager.getEloManager().getElo(player.getUniqueId(), GetName());
}
//average Elo of all players
averageElo = averageElo/places.size();
//update Elos of all players
assignEloPoints(places, averageElo);
}
//method to loop through every player and assign their new Elo
public void assignEloPoints(List<Player> places, int averageElo)
{
for (Player player : UtilServer.getPlayers())
{
int currentElo = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
int lossMultiplier = 1;
int sizeModifier = 3;
int eloMultiplier = calculateEloMultiplier(currentElo, averageElo);
//nobody won, add 10 points to all players
//Profitable enough see the match through to the end, but not enough for a stale-mate to be a more desirable outcome than 3rd place
if (places == null || places.isEmpty())
{
int newElo = currentElo + 10;
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
}
//Top 3 players get 25, 20, and 15 points, respectively
else
{
if (places.size() >= 1)
{
if (player.getUniqueId() == places.get(0).getUniqueId())
{
int newElo = currentElo + 25 + (5 * eloMultiplier);
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
}
}
if (places.size() >= 5)
{
if (player.getUniqueId() == places.get(1).getUniqueId())
{
int newElo = currentElo + 20 + (5 * eloMultiplier);
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
}
}
if (places.size() >= 6)
{
if (player.getUniqueId() == places.get(2).getUniqueId())
{
if (eloMultiplier < -2)
{
eloMultiplier = -2;
}
int newElo = currentElo + 15 + (5 * eloMultiplier);
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
}
}
if (places.size() > 6 && places.size() <= 7)
{
if (player.getUniqueId() == places.get(5).getUniqueId())
{
if(eloMultiplier > 1)
{
eloMultiplier = 0;
}
int newElo = currentElo - 5 + (5 * eloMultiplier);
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
}
}
if (places.size() == 7)
{
if (player.getUniqueId() == places.get(6).getUniqueId())
{
if(eloMultiplier > 2)
{
eloMultiplier = 2;
}
int newElo = currentElo - 10 + (5 * eloMultiplier);
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
}
}
if (places.size() >= 8)
{
//for games with 8+ players, this if statement is just going to run 3 times to check 3 different places
while(lossMultiplier != 0)
{
if (player.getUniqueId() == places.get(places.size() - sizeModifier).getUniqueId())
{
if(eloMultiplier > lossMultiplier)
{
eloMultiplier = lossMultiplier;
}
int newElo = currentElo - (5 * lossMultiplier) + (5 * eloMultiplier);
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
if(sizeModifier >= 1)
{
lossMultiplier++;
sizeModifier--;
}
else
{
lossMultiplier = 0;
}
}
}
}
}
}
}
public boolean AdvertiseText(GameLobbyManager gameLobbyManager, int _advertiseStage)
{
return false;
@ -1565,10 +1741,75 @@ public abstract class Game implements Listener
AddGems(player, 10, "Participation", false, false);
}
handleElo();
// End
SetState(GameState.End);
}
public void handleElo()
{
UtilTextMiddle.display("HandleElo Called", "at Game AnnounceEnd (team)");
//Bukkit.broadcastMessage("handleElo called");
if (EloRanking)
{
Bukkit.broadcastMessage("Game Class EloRanking = True");
EloTeam teamWinner = new EloTeam();
EloTeam teamLoser = new EloTeam();
//EloManager may make most of the code below redundant. leaving inactive, pending testing
//Manager.getEloManager().getNewRatings(teamA, teamB, result)
for (GameTeam team : GetTeamList())
{
if (WinnerTeam != null && team.equals(WinnerTeam))
{
for (Player player : WinnerTeam.GetPlayers(false))
{
Bukkit.broadcastMessage("Game Class WinnerTeam For Loop Reached");
EloPlayer eloPlayer = new EloPlayer();
eloPlayer.setUniqueId(player.getUniqueId().toString());
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
teamWinner.addPlayer(eloPlayer);
eloPlayer.Rating += 25;
Manager.getEloManager().addToPlayerElos(eloPlayer, this.GetName());
Bukkit.broadcastMessage(player.getName() + " GetTeamList Elo: " + eloPlayer.Rating);
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), eloPlayer.Rating);
Bukkit.broadcastMessage(player.getName() + " Post-Save Elo: " + eloPlayer.Rating);
}
}
else
{
for (Player player : team.GetPlayers(false))
{
Bukkit.broadcastMessage("Game Class LosingTeam For Loop Reached");
EloPlayer eloPlayer = new EloPlayer();
eloPlayer.setUniqueId(player.getUniqueId().toString());
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
teamLoser.addPlayer(eloPlayer);
eloPlayer.Rating -= 15;
Bukkit.broadcastMessage(player.getName() + " GetTeamList Elo: " + eloPlayer.Rating);
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), eloPlayer.Rating);
Bukkit.broadcastMessage(player.getName() + " Post-Save Elo: " + eloPlayer.Rating);
}
}
}
}
}
@EventHandler
public void handleInteractEntityPacket(GameStateChangeEvent event)
{

View File

@ -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;
}
}

View File

@ -564,7 +564,7 @@ public class CaptureTheFlag extends TeamGame
for (Player player : WinnerTeam.GetPlayers(false))
{
EloPlayer eloPlayer = new EloPlayer();
eloPlayer.UniqueId = player.getUniqueId().toString();
eloPlayer.setUniqueId(player.getUniqueId().toString());
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
teamWinner.addPlayer(eloPlayer);
@ -575,7 +575,7 @@ public class CaptureTheFlag extends TeamGame
for (Player player : team.GetPlayers(false))
{
EloPlayer eloPlayer = new EloPlayer();
eloPlayer.UniqueId = player.getUniqueId().toString();
eloPlayer.setUniqueId(player.getUniqueId().toString());
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
teamLoser.addPlayer(eloPlayer);
@ -585,12 +585,12 @@ public class CaptureTheFlag extends TeamGame
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamWinner, teamLoser, GameResult.Win).getPlayers())
{
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
Manager.getEloManager().saveElo(eloPlayer.getUniqueId(), GetName(), eloPlayer.Rating);
}
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamLoser, teamWinner, GameResult.Loss).getPlayers())
{
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
Manager.getEloManager().saveElo(eloPlayer.getUniqueId(), GetName(), eloPlayer.Rating);
}
}

View File

@ -86,6 +86,8 @@ public class Domination extends TeamGame
this.WorldTimeSet = 2000;
this.DeathSpectateSecs = 10;
this.EloRanking = true;
this.EloSetting.setEloSetting(2);
//this.QuitOut = false;
}
@ -327,9 +329,12 @@ public class Domination extends TeamGame
for (Player player : WinnerTeam.GetPlayers(false))
{
EloPlayer eloPlayer = new EloPlayer();
eloPlayer.UniqueId = player.getUniqueId().toString();
eloPlayer.setUniqueId(player.getUniqueId().toString());
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
//Increment Elo (in case it isn't being incremented already)
eloPlayer.Rating += 20;
teamWinner.addPlayer(eloPlayer);
}
}
@ -338,9 +343,12 @@ public class Domination extends TeamGame
for (Player player : team.GetPlayers(false))
{
EloPlayer eloPlayer = new EloPlayer();
eloPlayer.UniqueId = player.getUniqueId().toString();
eloPlayer.setUniqueId(player.getUniqueId().toString());
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
//Decrement Elo (in case it isn't being decremented already)
eloPlayer.Rating -= 10;
teamLoser.addPlayer(eloPlayer);
}
}
@ -348,12 +356,15 @@ public class Domination extends TeamGame
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamWinner, teamLoser, GameResult.Win).getPlayers())
{
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
eloPlayer.Rating += 20;
Manager.getEloManager().saveElo(eloPlayer.getUniqueId(), GetName(), eloPlayer.Rating);
}
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamLoser, teamWinner, GameResult.Loss).getPlayers())
{
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
eloPlayer.Rating -= 10;
Manager.getEloManager().saveElo(eloPlayer.getUniqueId(), GetName(), eloPlayer.Rating);
}
}

View File

@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.common;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
@ -79,6 +80,10 @@ public class TeamDeathmatch extends TeamGame
this.WorldTimeSet = 2000;
this.CompassEnabled = true;
this.EloRanking = true;
this.EloSetting.setEloSetting(2);
this.Manager.getEloManager().generatePlayerElos(this.GetPlayers(false), this.GetName());
this.Manager.GetDamage().UseSimpleWeaponDamage = false;
//_healthObj = GetScoreboard().registerNewObjective("HP", "dummy");
@ -350,8 +355,12 @@ public class TeamDeathmatch extends TeamGame
AddGems(player, 10, "Participation", false, false);
}
Bukkit.broadcastMessage("TDM AnnounceEnd Called");
if (EloRanking)
{
Bukkit.broadcastMessage("TDM EloRanking = True");
EloTeam teamWinner = new EloTeam();
EloTeam teamLoser = new EloTeam();
@ -361,11 +370,23 @@ public class TeamDeathmatch extends TeamGame
{
for (Player player : WinnerTeam.GetPlayers(false))
{
Bukkit.broadcastMessage("TDM WinnerTeam For Loop Reached");
EloPlayer eloPlayer = new EloPlayer();
eloPlayer.UniqueId = player.getUniqueId().toString();
eloPlayer.setUniqueId(player.getUniqueId().toString());
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
teamWinner.addPlayer(eloPlayer);
eloPlayer.Rating += 25;
Manager.getEloManager().addToPlayerElos(eloPlayer, this.GetName());
Bukkit.broadcastMessage(player.getName() + " GetTeamList Elo: " + eloPlayer.Rating);
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), eloPlayer.Rating);
Bukkit.broadcastMessage(player.getName() + " Post-Save Elo: " + eloPlayer.Rating);
}
}
else
@ -373,23 +394,35 @@ public class TeamDeathmatch extends TeamGame
for (Player player : team.GetPlayers(false))
{
EloPlayer eloPlayer = new EloPlayer();
eloPlayer.UniqueId = player.getUniqueId().toString();
eloPlayer.setUniqueId(player.getUniqueId().toString());
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
teamLoser.addPlayer(eloPlayer);
eloPlayer.Rating -= 15;
Bukkit.broadcastMessage(player.getName() + " GetTeamList Elo: " + eloPlayer.Rating);
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), eloPlayer.Rating);
Bukkit.broadcastMessage(player.getName() + " Post-Save Elo: " + eloPlayer.Rating);
}
}
}
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamWinner, teamLoser, GameResult.Win).getPlayers())
{
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
eloPlayer.Rating += 25;
Manager.getEloManager().saveElo(eloPlayer.getUniqueId(), GetName(), eloPlayer.Rating);
Bukkit.broadcastMessage(eloPlayer.getUniqueId() + "Post-Save Elo: " + eloPlayer.Rating);
}
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamLoser, teamWinner, GameResult.Loss).getPlayers())
{
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
eloPlayer.Rating -= 15;
Manager.getEloManager().saveElo(eloPlayer.getUniqueId(), GetName(), eloPlayer.Rating);
Bukkit.broadcastMessage(eloPlayer.getUniqueId() + "Post-Save Elo: " + eloPlayer.Rating);
}
}
//End

View File

@ -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;
@ -150,6 +153,8 @@ public class TurfForts extends TeamGame
this.ItemPickup = false;
this.DamageSelf = false;
this.DeathSpectateSecs = 4;
this.EloRanking = true;
this.EloSetting.setEloSetting(2);
_breakStatTracker = new BlockBreakStatTracker(this, false);
@ -851,10 +856,56 @@ public class TurfForts 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.setUniqueId(player.getUniqueId().toString());
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
teamWinner.addPlayer(eloPlayer);
Bukkit.broadcastMessage(player.getName() + "'s old Elo: " + eloPlayer.Rating);
}
}
else
{
for (Player player : team.GetPlayers(false))
{
EloPlayer eloPlayer = new EloPlayer();
eloPlayer.setUniqueId(player.getUniqueId().toString());
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
teamLoser.addPlayer(eloPlayer);
Bukkit.broadcastMessage(player.getName() + "'s old Elo: " + eloPlayer.Rating);
}
}
}
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamWinner, teamLoser, GameResult.Win).getPlayers())
{
Manager.getEloManager().saveElo(eloPlayer.getUniqueId(), GetName(), eloPlayer.Rating);
Bukkit.broadcastMessage(eloPlayer.getUniqueId() + "'s new Elo: " + eloPlayer.Rating);
}
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamLoser, teamWinner, GameResult.Loss).getPlayers())
{
Manager.getEloManager().saveElo(eloPlayer.getUniqueId(), GetName(), eloPlayer.Rating);
}
}
//End
SetState(GameState.End);
}
public Long getEnemyTurfEntranceTime(Player player)
{
return _enemyTurf.get(player);