Merge branch 'develop' of github.com:Mineplex-LLC/Minecraft-PC into alex-compvanilla

This commit is contained in:
AlexTheCoder 2016-04-22 05:41:24 -04:00
commit 70541fd6f2
74 changed files with 1514 additions and 1086 deletions

View File

@ -0,0 +1,31 @@
package mineplex.core.common.util;
import com.google.common.base.Optional;
import net.minecraft.server.v1_8_R3.EntityTameableAnimal;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftTameableAnimal;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Tameable;
public class SpigotUtil
{
// Explanation:
// - Tameable animals (wolves, ocelots) keep track of their most
// recent owner.
// - When an animal is assigned a new owner, its data watcher is
// updated with the new owner's UUID
// - During this process, the old owner's UUID is checked against
// the new one
// - If the animal didn't have a previous owner, the old owner's
// UUID is the empty string.
// - UUID.fromString() is called on the empty string, and throws
// an exception.
//
// We can mitigate this issue by manually setting a previous owner
// UUID before we call Tameable#setOwner(AnimalTamer)
//
// (note: this does not apply to horses)
public static void setOldOwner_RemoveMeWhenSpigotFixesThis(Tameable tameable, AnimalTamer tamer)
{
((CraftTameableAnimal)tameable).getHandle().getDataWatcher().watch(17, tamer.getUniqueId().toString(), EntityTameableAnimal.META_OWNER, Optional.absent());
}
}

View File

@ -216,6 +216,24 @@ public class UtilAlg
return true; return true;
} }
public static boolean inBoundingBox(Location loc, Vector cornerA, Vector cornerB)
{
if (loc.getX() <= Math.min(cornerA.getX(), cornerB.getX())) return false;
if (loc.getX() >= Math.max(cornerA.getX(), cornerB.getX())) return false;
if (cornerA.getY() != cornerB.getY())
{
if (loc.getY() <= Math.min(cornerA.getY(), cornerB.getY())) return false;
if (loc.getY() >= Math.max(cornerA.getY(), cornerB.getY())) return false;
}
if (loc.getZ() <= Math.min(cornerA.getZ(), cornerB.getZ())) return false;
if (loc.getZ() >= Math.max(cornerA.getZ(), cornerB.getZ())) return false;
return true;
}
public static Vector cross(Vector a, Vector b) public static Vector cross(Vector a, Vector b)
{ {
double x = a.getY()*b.getZ() - a.getZ()*b.getY(); double x = a.getY()*b.getZ() - a.getZ()*b.getY();

View File

@ -1480,4 +1480,28 @@ public class UtilBlock
IBlockData ibd = net.minecraft.server.v1_8_R3.Block.getById(type).fromLegacyData(data); IBlockData ibd = net.minecraft.server.v1_8_R3.Block.getById(type).fromLegacyData(data);
chunk.a(pos, ibd); chunk.a(pos, ibd);
} }
/**
* @return true if all of the blocks within the specified radius of the specified origin block are boundless ({@link UtilItem#isBoundless}.)
*/
public static boolean boundless(Location origin, double radius)
{
for (Block block : getInRadius(origin, radius).keySet())
{
if (!UtilItem.isBoundless(block.getType()))
{
return false;
}
}
return true;
}
/**
* @return true if there are any non-boundless ({@link UtilItem#isBoundless}) blocks within the specified radius of the specified origin block.
*/
public static boolean boundless(Block origin, double radius)
{
return boundless(origin.getLocation(), radius);
}
} }

View File

@ -2,18 +2,20 @@ package mineplex.core.common.util;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.function.Predicate;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.WorldBorder;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
public class UtilWorld public class UtilWorld
{ {
public static World getWorld(String world) public static World getWorld(String world)
@ -210,4 +212,81 @@ public class UtilWorld
origin.getBlock().getRelative(BlockFace.WEST)); origin.getBlock().getRelative(BlockFace.WEST));
} }
/**
* This method will use the World provided by the given Location.<p>
* @return <b>true</b> if the specified location is within the bounds of the
* world's set border, or <b>false</b> if {@link World#getWorldBorder()} returns null.
*/
public static boolean inWorldBorder(Location location)
{
WorldBorder border = location.getWorld().getWorldBorder();
if (border == null)
{
return false;
}
double size = border.getSize() / 2;
double maxX = size;
double maxZ = size;
double minX = -size;
double minZ = -size;
return location.getX() >= minX && location.getX() <= maxX && location.getZ() >= minZ && location.getZ() <= maxZ;
}
/**
* This method will use the World specified by the second argument, and the
* x, y, and z provided by the given Location.<p>
* @return <b>true</b> if the specified location is within the bounds of the
* world's set border, or <b>false</b> if {@link World#getWorldBorder()} returns null.
*/
public static boolean inWorldBorder(World world, Location location)
{
WorldBorder border = world.getWorldBorder();
if (border == null)
{
return false;
}
double size = border.getSize() / 2;
double maxX = size;
double maxZ = size;
double minX = -size;
double minZ = -size;
return location.getX() >= minX && location.getX() <= maxX && location.getZ() >= minZ && location.getZ() <= maxZ;
}
/**
* @return <b>true</b> if the specified bounding box is within the bounds of the
* world's set border, or <b>false</b> if {@link World#getWorldBorder()} returns null.
*/
public static boolean isBoxInWorldBorder(World world, Location min, Location max)
{
WorldBorder border = world.getWorldBorder();
if (border == null)
{
return false;
}
double size = border.getSize() / 2;
double maxX = size;
double maxZ = size;
double minX = -size;
double minZ = -size;
double startX = Math.min(min.getX(), max.getX());
double startZ = Math.min(min.getZ(), max.getZ());
double endX = Math.max(min.getX(), max.getX());
double endZ = Math.max(min.getZ(), max.getZ());
return startX >= minX && startZ <= maxX && endX >= minZ && endZ <= maxZ;
}
} }

View File

@ -1,5 +1,6 @@
package mineplex.core.account; package mineplex.core.account;
import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -378,7 +379,12 @@ public class CoreClientManager extends MiniPlugin
@Override @Override
public void run() 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()); _clientLoginLock.remove(client.GetPlayerName());
} }
}); });

View File

@ -57,7 +57,7 @@ public class AccountRepository extends MinecraftRepository
//executeUpdate(CREATE_ACCOUNT_TABLE); //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 // First we try to grab the account id from cache - this saves an extra trip to database
int accountId = PlayerCache.getInstance().getAccountId(uuid); int accountId = PlayerCache.getInstance().getAccountId(uuid);
@ -117,10 +117,7 @@ public class AccountRepository extends MinecraftRepository
statement.getMoreResults(); statement.getMoreResults();
} }
} }
catch (Exception exception)
{
exception.printStackTrace();
}
return accountId; return accountId;
} }

View File

@ -4,5 +4,5 @@ import mineplex.core.common.util.NautHashMap;
public class EloClientData public class EloClientData
{ {
public NautHashMap<String, Integer> Elos = new NautHashMap<String, Integer>(); public NautHashMap<Integer, Integer> Elos = new NautHashMap<Integer, Integer>();
} }

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,71 +2,61 @@ package mineplex.core.elo;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.UUID; import java.util.HashSet;
import mineplex.core.MiniDbClientPlugin; import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import org.bukkit.Bukkit; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
public class EloManager extends MiniDbClientPlugin<EloClientData> public class EloManager extends MiniDbClientPlugin<EloClientData>
{ {
private static Object _playerEloLock = new Object();
private EloRepository _repository; private EloRepository _repository;
private EloRatingSystem _ratingSystem; private EloRatingSystem _ratingSystem;
private NautHashMap<String, NautHashMap<String, Integer>> _playerElos; private NautHashMap<String, EloTeam> _eloTeams = new NautHashMap<>();
public EloManager(JavaPlugin plugin, CoreClientManager clientManager) public EloManager(JavaPlugin plugin, CoreClientManager clientManager)
{ {
super("Elo Rating", plugin, clientManager); super("Elo Rating", plugin, clientManager);
_repository = new EloRepository(plugin); _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)); _ratingSystem = new EloRatingSystem
_playerElos = new NautHashMap<String, NautHashMap<String, Integer>>(); (
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) return Get(player).Elos.get(gameType);
{
if (_playerElos.containsKey(uuid.toString()))
{
if (_playerElos.get(uuid.toString()).containsKey(gameType))
{
elo = _playerElos.get(uuid.toString()).get(gameType);
}
}
}
return elo;
} }
public EloTeam getNewRatings(EloTeam teamA, EloTeam teamB, GameResult result) public EloTeam getNewRatings(EloTeam teamA, EloTeam teamB, GameResult result)
{ {
EloTeam newTeam = new EloTeam(); 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(); int newTotal = _ratingSystem.getNewRating(teamA.TotalElo / teamA.getPlayers().size(), teamB.TotalElo / teamB.getPlayers().size(), result) * teamA.getPlayers().size();
int kTotal = 0;
System.out.println("New " + result + " Team Rating:" + newTotal);
for (EloPlayer player : teamA.getPlayers()) for (EloPlayer player : teamA.getPlayers())
{ {
EloPlayer newPlayer = new EloPlayer(); kTotal += _ratingSystem.getKFactor(player.getRating());
newPlayer.UniqueId = player.UniqueId; }
newPlayer.Rating = (int)(player.Rating + ((double)player.Rating / (double)teamA.TotalElo) * (newTotal - teamA.TotalElo));
System.out.println("Old:"); for (EloPlayer player : teamA.getPlayers())
player.printInfo(); {
int newRating = (int)(player.getRating() + ((double)_ratingSystem.getKFactor(player.getRating()) / (double)kTotal) * (newTotal - teamA.TotalElo));
System.out.println("New:"); EloPlayer newPlayer = new EloPlayer(player.getPlayer(), player.getAccountId(), newRating);
newPlayer.printInfo();
newTeam.addPlayer(newPlayer); newTeam.addPlayer(newPlayer);
} }
@ -74,33 +64,85 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
return newTeam; 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); runAsync(new Runnable()
}
public void saveElo(final String uuid, final String gameType, final int elo)
{
Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
{ {
public void run() 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 @Override
protected EloClientData AddPlayer(String player) protected EloClientData AddPlayer(String player)
{ {
@ -116,6 +158,46 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
@Override @Override
public String getQuery(int accountId, String uuid, String name) 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();
} }
} }

View File

@ -1,12 +1,37 @@
package mineplex.core.elo; package mineplex.core.elo;
import org.bukkit.entity.Player;
public class EloPlayer public class EloPlayer
{ {
public String UniqueId; private Player _player;
public int Rating; 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() public void printInfo()
{ {
System.out.println(UniqueId + "'s elo is " + Rating); System.out.println(_player.getName() + "'s elo is " + _rating);
} }
} }

View File

@ -57,7 +57,7 @@ public class EloRatingSystem
return oldRating + (int) (kFactor * (score - expectedScore)); return oldRating + (int) (kFactor * (score - expectedScore));
} }
private double getKFactor(int rating) double getKFactor(int rating)
{ {
for (int i = 0; i < _kFactors.length; i++) for (int i = 0; i < _kFactors.length; i++)
{ {

View File

@ -4,17 +4,16 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import mineplex.core.database.MinecraftRepository; import mineplex.core.database.MinecraftRepository;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.RepositoryBase;
import mineplex.serverdata.database.column.ColumnInt; import mineplex.serverdata.database.column.ColumnInt;
import mineplex.serverdata.database.column.ColumnVarChar;
import org.bukkit.plugin.java.JavaPlugin;
public class EloRepository extends MinecraftRepository 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 (accountId, gameType, elo) VALUES (?, ?, ?);";
private static String INSERT_ELO = "INSERT INTO eloRating (uuid, gameType, elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE elo=VALUES(elo);"; 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) public EloRepository(JavaPlugin plugin)
{ {
@ -23,14 +22,26 @@ public class EloRepository extends MinecraftRepository
initialize(); initialize();
} }
public void initialize() public void initialize() { }
{
//executeUpdate(CREATE_ELO_TABLE);
}
public void saveElo(String uuid, String gameType, int elo) public boolean saveElo(int accountId, int gameType, int oldElo, int elo) throws SQLException
{ {
executeUpdate(INSERT_ELO, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("gameType", 100, gameType), new ColumnInt("elo", elo)); 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;
}
return updateSucceeded;
} }
public EloClientData loadClientInformation(ResultSet resultSet) throws SQLException public EloClientData loadClientInformation(ResultSet resultSet) throws SQLException
@ -39,7 +50,7 @@ public class EloRepository extends MinecraftRepository
while (resultSet.next()) while (resultSet.next())
{ {
clientData.Elos.put(resultSet.getString(1), resultSet.getInt(2)); clientData.Elos.put(resultSet.getInt(1), resultSet.getInt(2));
} }
return clientData; return clientData;

View File

@ -1,23 +1,29 @@
package mineplex.core.elo; package mineplex.core.elo;
import java.util.ArrayList; import java.util.Collection;
import java.util.List;
import mineplex.core.common.util.NautHashMap;
public class EloTeam public class EloTeam
{ {
private List<EloPlayer> _players = new ArrayList<EloPlayer>(); private NautHashMap<String, EloPlayer> _players = new NautHashMap<>();
public int TotalElo = 0; public int TotalElo = 0;
public boolean Winner = false;
public void addPlayer(EloPlayer player) 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();
} }
} }

View File

@ -2,8 +2,6 @@ package mineplex.core.incognito;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -13,8 +11,6 @@ import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.base.Function;
import mineplex.core.MiniDbClientPlugin; import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
@ -27,6 +23,7 @@ import mineplex.core.incognito.events.IncognitoStatusChangeEvent;
import mineplex.core.incognito.repository.IncognitoClient; import mineplex.core.incognito.repository.IncognitoClient;
import mineplex.core.incognito.repository.IncognitoRepository; import mineplex.core.incognito.repository.IncognitoRepository;
import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketHandler;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -34,6 +31,7 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
{ {
private CoreClientManager _clientManager; private CoreClientManager _clientManager;
private IncognitoRepository _repository; private IncognitoRepository _repository;
private PreferencesManager _preferencesManager;
public IncognitoManager(JavaPlugin plugin, CoreClientManager clientManager, PacketHandler packetHandler) public IncognitoManager(JavaPlugin plugin, CoreClientManager clientManager, PacketHandler packetHandler)
{ {
@ -132,6 +130,41 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
} }
} }
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
return;
}
for (Player player : UtilServer.getPlayers())
{
for (Player other : UtilServer.getPlayers())
{
if (Get(player).Status)
{
IncognitoHidePlayerEvent customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(player));
if (!customEvent.isCancelled() && !_clientManager.hasRank(other, _clientManager.Get(player).GetRank()))
{
other.hidePlayer(player);
}
}
if (Get(other).Status)
{
IncognitoHidePlayerEvent customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(other));
if (!customEvent.isCancelled() && !_clientManager.hasRank(player, _clientManager.Get(other).GetRank()))
{
player.hidePlayer(other);
}
}
}
}
}
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void Quit(PlayerQuitEvent event) public void Quit(PlayerQuitEvent event)
{ {
@ -182,4 +215,14 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
Get(playerName).Status = resultSet.getInt("status") == 1; Get(playerName).Status = resultSet.getInt("status") == 1;
} }
} }
public PreferencesManager getPreferences()
{
return _preferencesManager;
}
public void setPreferencesManager(PreferencesManager preferencesManager)
{
_preferencesManager = preferencesManager;
}
} }

View File

@ -18,6 +18,12 @@ public class IncognitoToggleCommand extends CommandBase<IncognitoManager>
@Override @Override
public void Execute(Player caller, String[] args) public void Execute(Player caller, String[] args)
{ {
if (Plugin.getPreferences().Get(caller).Invisibility)
{
UtilPlayer.message(caller, F.main("Incognito", "You are not allowed to toggle incognito on while Hub Invisibility is enabled."));
return;
}
if (Plugin.toggle(caller)) if (Plugin.toggle(caller))
{ {
UtilPlayer.message(caller, F.main("Incognito", "You are now incognito. Your status will only change when you run " + F.elem(AliasUsed) + " again.")); UtilPlayer.message(caller, F.main("Incognito", "You are now incognito. Your status will only change when you run " + F.elem(AliasUsed) + " again."));

View File

@ -94,7 +94,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
addCommand(new AnnounceCommand(this)); addCommand(new AnnounceCommand(this));
//addCommand(new GlobalCommand(this)); //addCommand(new GlobalCommand(this));
addCommand(new AdminCommand(this, _incognitoManager)); addCommand(new AdminCommand(this));
} }
@Override @Override
@ -616,4 +616,9 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
} }
} }
} }
public IncognitoManager getIncognitoManager()
{
return _incognitoManager;
}
} }

View File

@ -14,13 +14,9 @@ import mineplex.core.message.MessageManager;
public class AdminCommand extends CommandBase<MessageManager> public class AdminCommand extends CommandBase<MessageManager>
{ {
private IncognitoManager _incognitoManager; public AdminCommand(MessageManager plugin)
public AdminCommand(MessageManager plugin, IncognitoManager incognitoManager)
{ {
super(plugin, Rank.ALL, "a","admin"); super(plugin, Rank.ALL, "a","admin");
_incognitoManager = incognitoManager;
} }
@Override @Override
@ -55,7 +51,7 @@ public class AdminCommand extends CommandBase<MessageManager>
{ {
if (Plugin.GetClientManager().Get(to).GetRank().has(Rank.HELPER)) if (Plugin.GetClientManager().Get(to).GetRank().has(Rank.HELPER))
{ {
if (_incognitoManager.Get(to).Status) if (Plugin.getIncognitoManager().Get(to).Status)
{ {
continue; continue;
} }

View File

@ -4,20 +4,6 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Map.Entry; import java.util.Map.Entry;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.preferences.command.PreferencesCommand;
import mineplex.core.preferences.ui.ExclusivePreferencesShop;
import mineplex.core.preferences.ui.PreferencesShop;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -29,17 +15,35 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.donation.DonationManager;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.preferences.command.PreferencesCommand;
import mineplex.core.preferences.ui.ExclusivePreferencesShop;
import mineplex.core.preferences.ui.PreferencesShop;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class PreferencesManager extends MiniDbClientPlugin<UserPreferences> public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
{ {
private PreferencesRepository _repository; private PreferencesRepository _repository;
private PreferencesShop _shop; private PreferencesShop _shop;
private ExclusivePreferencesShop _exclusiveShop; private ExclusivePreferencesShop _exclusiveShop;
private IncognitoManager _incognitoManager;
private NautHashMap<String, UserPreferences> _saveBuffer = new NautHashMap<String, UserPreferences>(); private NautHashMap<String, UserPreferences> _saveBuffer = new NautHashMap<String, UserPreferences>();
public boolean GiveItem; public boolean GiveItem;
public PreferencesManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) public PreferencesManager(JavaPlugin plugin, IncognitoManager incognito, CoreClientManager clientManager, DonationManager donationManager)
{ {
super("Preferences", plugin, clientManager); super("Preferences", plugin, clientManager);
@ -47,6 +51,8 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
_exclusiveShop = new ExclusivePreferencesShop(this, clientManager, donationManager); _exclusiveShop = new ExclusivePreferencesShop(this, clientManager, donationManager);
_shop = new PreferencesShop(this, clientManager, donationManager, _exclusiveShop); _shop = new PreferencesShop(this, clientManager, donationManager, _exclusiveShop);
_incognitoManager = incognito;
_exclusiveShop.setPreferencesShop(_shop); _exclusiveShop.setPreferencesShop(_shop);
addCommand(new PreferencesCommand(this)); addCommand(new PreferencesCommand(this));
@ -138,4 +144,9 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
{ {
return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI, clanTips, hubMusic, disableAds FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;"; return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI, clanTips, hubMusic, disableAds FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;";
} }
public IncognitoManager getIncognitoManager()
{
return _incognitoManager;
}
} }

View File

@ -8,6 +8,8 @@ import org.bukkit.event.inventory.ClickType;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilUI; import mineplex.core.common.util.UtilUI;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.preferences.PreferencesManager; import mineplex.core.preferences.PreferencesManager;
@ -149,6 +151,12 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
private void toggleHubInvisibility(org.bukkit.entity.Player player) private void toggleHubInvisibility(org.bukkit.entity.Player player)
{ {
if (getPlugin().getIncognitoManager() != null && getPlugin().getIncognitoManager().Get(player).Status)
{
UtilPlayer.message(player, F.main("Incognito", "You are not allowed to use Hub Visibility whilst in incognito mode."));
return;
}
getPlugin().Get(player).Invisibility = !getPlugin().Get(player).Invisibility; getPlugin().Get(player).Invisibility = !getPlugin().Get(player).Invisibility;
// Dont save for Mod/SnrMod - prevents them just being invis 24/7 // Dont save for Mod/SnrMod - prevents them just being invis 24/7

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

@ -97,7 +97,11 @@ public class Clans extends JavaPlugin
new ServerConfiguration(this, _clientManager); new ServerConfiguration(this, _clientManager);
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager); PacketHandler packetHandler = new PacketHandler(this);
IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler);
PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager, _donationManager);
incognito.setPreferencesManager(preferenceManager);
ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager)); ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager));
@ -111,7 +115,6 @@ public class Clans extends JavaPlugin
// ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager); // ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager);
PacketHandler packetHandler = new PacketHandler(this);
Punish punish = new Punish(this, webServerAddress, _clientManager); Punish punish = new Punish(this, webServerAddress, _clientManager);
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
AntiHack.Instance.setKick(false); AntiHack.Instance.setKick(false);
@ -120,8 +123,6 @@ public class Clans extends JavaPlugin
IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal);
IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler);
StatsManager statsManager = new StatsManager(this, _clientManager); StatsManager statsManager = new StatsManager(this, _clientManager);
AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager); AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager);
Chat chat = new Chat(this, incognito, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); Chat chat = new Chat(this, incognito, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
@ -143,7 +144,7 @@ public class Clans extends JavaPlugin
GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager); GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager);
HologramManager hologram = new HologramManager(this, packetHandler); HologramManager hologram = new HologramManager(this, packetHandler);
_clansManager = new ClansManager(this, /*clansBans,*/ serverStatusManager.getCurrentServerName(), packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress); _clansManager = new ClansManager(this, /*clansBans,*/ serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress);
new Recipes(this); new Recipes(this);
new Farming(this); new Farming(this);
new BuildingShop(_clansManager, _clientManager, _donationManager); new BuildingShop(_clansManager, _clientManager, _donationManager);

View File

@ -806,7 +806,7 @@ public class ClansDataAccessLayer
public void run() public void run()
{ {
ClanToken clan = _repository.retrieveClan(clanName); ClanToken clan = _repository.retrieveClan(clanName);
callback.run(clan); runSync(() -> callback.run(clan));
} }
}); });
} }

View File

@ -522,8 +522,7 @@ public class ClansGame extends MiniPlugin
ClanInfo clan = _clans.getClanUtility().getClanByPlayer(event.getPlayer()); ClanInfo clan = _clans.getClanUtility().getClanByPlayer(event.getPlayer());
if (clan == null) return; if (clan == null) return;
if(!clan.isOnline()) clan.setLastOnline(new Timestamp(System.currentTimeMillis())); //Noone else on clan.setLastOnline(new Timestamp(System.currentTimeMillis()));
else clan.setLastOnline(new Timestamp(0));
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)

View File

@ -9,15 +9,19 @@ import java.util.Set;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.UUID; import java.util.UUID;
import mineplex.core.recharge.Recharge;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
@ -28,6 +32,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -57,7 +62,6 @@ import mineplex.core.explosion.Explosion;
import mineplex.core.hologram.Hologram; import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager; import mineplex.core.hologram.HologramManager;
import mineplex.core.incognito.IncognitoManager; import mineplex.core.incognito.IncognitoManager;
import mineplex.core.incognito.events.IncognitoHidePlayerEvent;
import mineplex.core.incognito.events.IncognitoStatusChangeEvent; import mineplex.core.incognito.events.IncognitoStatusChangeEvent;
import mineplex.core.movement.Movement; import mineplex.core.movement.Movement;
import mineplex.core.npc.NpcManager; import mineplex.core.npc.NpcManager;
@ -99,7 +103,6 @@ import mineplex.game.clans.clans.redis.ClanLoadCommandHandler;
import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.regions.ClansRegions;
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.clans.siege.SiegeManager;
import mineplex.game.clans.clans.staff.SilentChestOpen;
import mineplex.game.clans.clans.supplyDrop.SupplyDropManager; import mineplex.game.clans.clans.supplyDrop.SupplyDropManager;
import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager; import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager;
import mineplex.game.clans.clans.war.WarManager; import mineplex.game.clans.clans.war.WarManager;
@ -227,7 +230,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
// Spawn area // Spawn area
public ClansManager(JavaPlugin plugin/*, ClansBanManager clansBans*/, String serverName, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress) public ClansManager(JavaPlugin plugin/*, ClansBanManager clansBans*/, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress)
{ {
super("Clans Manager", plugin); super("Clans Manager", plugin);
@ -236,7 +239,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
/*_clansBans = clansBans;*/ /*_clansBans = clansBans;*/
_punish = punish; _punish = punish;
_incognitoManager = new IncognitoManager(plugin, clientManager, packetHandler); _incognitoManager = incognitoManager;
_serverName = serverName; _serverName = serverName;
_clientManager = clientManager; _clientManager = clientManager;
_combatManager = new CombatManager(plugin); _combatManager = new CombatManager(plugin);
@ -296,8 +299,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
new Field(plugin, creature, _condition, this, energy, serverName); new Field(plugin, creature, _condition, this, energy, serverName);
new SilentChestOpen(this);
// Required managers to be initialized // Required managers to be initialized
new Spawn(plugin, this); new Spawn(plugin, this);
new NPCManager(this, _hologramManager); new NPCManager(this, _hologramManager);
@ -1339,6 +1340,41 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
} }
@EventHandler
public void disableHorses(VehicleEnterEvent event)
{
if (event.getEntered() instanceof Player && event.getVehicle() instanceof Horse)
{
if(!Recharge.Instance.use((Player) event.getEntered(), "Ride Horse", 2 * 20L, true, false))
{
event.setCancelled(true);
}
}
}
@EventHandler
public void damageHorse(EntityDamageEvent event)
{
if (event.getEntity() instanceof Horse)
{
if (event.getEntity().getPassenger() != null && event.getEntity().getPassenger() instanceof Player)
{
event.getEntity().getPassenger().eject();
Recharge.Instance.use((Player) event.getEntity().getPassenger(), "Ride Horse", 2 * 20L, false, false);
}
event.getEntity().eject();
}
else if(event.getEntity() instanceof Player)
{
if(event.getEntity().getVehicle() != null && event.getEntity().getVehicle() instanceof Horse)
{
Recharge.Instance.use((Player) event.getEntity(), "Ride Horse", 2 * 20L, false, false);
event.getEntity().getVehicle().eject();
}
}
}
public Pair<ClanInfo, Long> leftRecently(UUID uniqueId, long time) public Pair<ClanInfo, Long> leftRecently(UUID uniqueId, long time)
{ {
if (_clanMemberLeftMap.containsKey(uniqueId) && (System.currentTimeMillis() - _clanMemberLeftMap.get(uniqueId).getRight()) <= time) if (_clanMemberLeftMap.containsKey(uniqueId) && (System.currentTimeMillis() - _clanMemberLeftMap.get(uniqueId).getRight()) <= time)

View File

@ -1,5 +1,6 @@
package mineplex.game.clans.clans.commands; package mineplex.game.clans.clans.commands;
import mineplex.game.clans.clans.ClansManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
@ -23,6 +24,11 @@ public class KillCommand extends CommandBase<DamageManager>
UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in combat.")); UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in combat."));
return; return;
} }
if(ClansManager.getInstance().getTutorial().inTutorial(caller))
{
UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in the tutorial."));
return;
}
UtilPlayer.message(caller, F.main("Clans", "You have imploded.")); UtilPlayer.message(caller, F.main("Clans", "You have imploded."));

View File

@ -112,6 +112,7 @@ public class SiegeManager extends MiniPlugin
if (!part) if (!part)
{ {
System.out.println("Removing slime...");
slime.remove(); slime.remove();
} }
else else
@ -162,11 +163,13 @@ public class SiegeManager extends MiniPlugin
{ {
if (((ArmorStand) entity).getHelmet() != null && ((ArmorStand) entity).getHelmet().getType().equals(Material.SPONGE)) if (((ArmorStand) entity).getHelmet() != null && ((ArmorStand) entity).getHelmet().getType().equals(Material.SPONGE))
{ {
System.out.println("Removing armor stand");
entity.remove(); entity.remove();
} }
if (entity.getPassenger() != null && entity.getPassenger() instanceof Slime && entity.getPassenger().getPassenger() instanceof Slime) if (entity.getPassenger() != null && entity.getPassenger() instanceof Slime && entity.getPassenger().getPassenger() instanceof Slime)
{ {
System.out.println("Removing armostand + children");
entity.getPassenger().getPassenger().remove(); entity.getPassenger().getPassenger().remove();
entity.getPassenger().remove(); entity.getPassenger().remove();
entity.remove(); entity.remove();

View File

@ -24,185 +24,151 @@ import mineplex.serverdata.database.column.ColumnVarChar;
public class SiegeWeaponRepository extends MinecraftRepository public class SiegeWeaponRepository extends MinecraftRepository
{ {
private static final String CREATE = "CREATE TABLE IF NOT EXISTS clansSiegeWeapons (uniqueId INT NOT NULL," private static final String CREATE = "CREATE TABLE IF NOT EXISTS clansSiegeWeapons (uniqueId INT NOT NULL,"
+ "serverId INT NOT NULL," + "serverId INT NOT NULL,"
+ "location VARCHAR(30)," + "location VARCHAR(30),"
+ "ownerClan INT NOT NULL," + "ownerClan INT NOT NULL,"
+ "weaponType TINYINT NOT NULL," + "weaponType TINYINT NOT NULL,"
+ "health INT NOT NULL," + "health INT NOT NULL,"
+ "yaw INT NOT NULL," + "yaw INT NOT NULL,"
+ "lastFired LONG," + "lastFired LONG,"
+ "entities VARCHAR(200)," + "entities VARCHAR(200),"
+ "PRIMARY KEY (uniqueId));"; + "PRIMARY KEY (uniqueId));";
private static final String GET_WEAPON_BY_ID = "SELECT * FROM clansSiegeWeapons WHERE uniqueId=?;"; private static final String GET_WEAPON_BY_ID = "SELECT * FROM clansSiegeWeapons WHERE uniqueId=?;";
private static final String GET_WEAPONS_BY_CLAN = "SELECT * FROM clansSiegeWeapons WHERE ownerClan=?;"; private static final String GET_WEAPONS_BY_CLAN = "SELECT * FROM clansSiegeWeapons WHERE ownerClan=?;";
private static final String GET_WEAPONS_BY_SERVER = "SELECT * FROM clansSiegeWeapons WHERE serverId=?;"; private static final String GET_WEAPONS_BY_SERVER = "SELECT * FROM clansSiegeWeapons WHERE serverId=?;";
private static final String UPDATE_WEAPON = "UPDATE clansSiegeWeapons SET health=?,yaw=?,lastFired=? WHERE uniqueId=?;"; private static final String UPDATE_WEAPON = "UPDATE clansSiegeWeapons SET health=?,yaw=?,lastFired=? WHERE uniqueId=?;";
private static final String INSERT_WEAPON = "INSERT INTO clansSiegeWeapons VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);"; private static final String INSERT_WEAPON = "INSERT INTO clansSiegeWeapons VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);";
private static final String DELETE_WEAPON = "DELETE FROM clansSiegeWeapons WHERE uniqueId=?;"; private static final String DELETE_WEAPON = "DELETE FROM clansSiegeWeapons WHERE uniqueId=?;";
private SiegeManager _siegeManager; private SiegeManager _siegeManager;
public SiegeWeaponRepository(JavaPlugin plugin, SiegeManager siegeManager) public SiegeWeaponRepository(JavaPlugin plugin, SiegeManager siegeManager)
{ {
super(plugin, DBPool.getAccount()); super(plugin, DBPool.getAccount());
_siegeManager = siegeManager; _siegeManager = siegeManager;
} }
public void deleteWeapon(final int uniqueId) public void deleteWeapon(final int uniqueId)
{ {
System.out.println("Siege Repo> Deleting weapon " + uniqueId); System.out.println("Siege Repo> Deleting weapon " + uniqueId);
_siegeManager.runAsync(() -> _siegeManager.runAsync(() ->
executeUpdate(DELETE_WEAPON, new ColumnInt("uniqueId", uniqueId)) executeUpdate(DELETE_WEAPON, new ColumnInt("uniqueId", uniqueId))
); );
} }
public void getWeaponById(final int uniqueId, final Callback<SiegeWeaponToken> callback) public void getWeaponById(final int uniqueId, final Callback<SiegeWeaponToken> callback)
{ {
_siegeManager.runAsync(() -> _siegeManager.runAsync(() ->
executeQuery(GET_WEAPON_BY_ID, resultSet -> { executeQuery(GET_WEAPON_BY_ID, resultSet -> {
SiegeWeaponToken token = new SiegeWeaponToken(); SiegeWeaponToken token = new SiegeWeaponToken();
resultSet.next(); resultSet.next();
load(token, resultSet); load(token, resultSet);
callback.run(token); callback.run(token);
}, new ColumnInt("uniqueId", uniqueId)) }, new ColumnInt("uniqueId", uniqueId))
); );
} }
public void getWeaponsByServer(final int serverId, final Callback<List<SiegeWeaponToken>> callback) public void getWeaponsByServer(final int serverId, final Callback<List<SiegeWeaponToken>> callback)
{ {
_siegeManager.runAsync(() -> _siegeManager.runAsync(() ->
executeQuery(GET_WEAPONS_BY_SERVER, resultSet -> { executeQuery(GET_WEAPONS_BY_SERVER, resultSet -> {
List<SiegeWeaponToken> tokens = Lists.newArrayList(); List<SiegeWeaponToken> tokens = Lists.newArrayList();
while (resultSet.next()) while (resultSet.next())
{ {
SiegeWeaponToken token = new SiegeWeaponToken(); SiegeWeaponToken token = new SiegeWeaponToken();
load(token, resultSet); load(token, resultSet);
tokens.add(token); tokens.add(token);
} }
callback.run(tokens); callback.run(tokens);
}, new ColumnInt("serverId", serverId)) }, new ColumnInt("serverId", serverId))
); );
} }
public void getWeaponsByClan(final ClanInfo clan, final Callback<List<SiegeWeaponToken>> callback) public void getWeaponsByClan(final ClanInfo clan, final Callback<List<SiegeWeaponToken>> callback)
{ {
_siegeManager.runAsync(() -> _siegeManager.runAsync(() ->
executeQuery(GET_WEAPONS_BY_CLAN, resultSet -> { executeQuery(GET_WEAPONS_BY_CLAN, resultSet -> {
List<SiegeWeaponToken> tokens = Lists.newArrayList(); List<SiegeWeaponToken> tokens = Lists.newArrayList();
while (resultSet.next()) while (resultSet.next())
{ {
SiegeWeaponToken token = new SiegeWeaponToken(); SiegeWeaponToken token = new SiegeWeaponToken();
load(token, resultSet); load(token, resultSet);
tokens.add(token); tokens.add(token);
} }
callback.run(tokens); callback.run(tokens);
}, new ColumnInt("ownerClan", clan.getId())) }, new ColumnInt("ownerClan", clan.getId()))
); );
} }
private void load(SiegeWeaponToken token, ResultSet columns) throws SQLException private void load(SiegeWeaponToken token, ResultSet columns) throws SQLException
{ {
token.UniqueId = columns.getInt("uniqueId"); token.UniqueId = columns.getInt("uniqueId");
token.Location = UtilWorld.strToLoc(columns.getString("location")); token.Location = UtilWorld.strToLoc(columns.getString("location"));
token.OwnerClan = _siegeManager.getClansManager().getClanUtility().getClanById(columns.getInt("ownerClan")); token.OwnerClan = _siegeManager.getClansManager().getClanUtility().getClanById(columns.getInt("ownerClan"));
token.WeaponType = columns.getByte("weaponType"); token.WeaponType = columns.getByte("weaponType");
token.Health = columns.getShort("health"); token.Health = columns.getShort("health");
token.Yaw = columns.getShort("yaw"); token.Yaw = columns.getShort("yaw");
token.LastFired = columns.getTimestamp("lastFired").getTime(); token.LastFired = columns.getTimestamp("lastFired").getTime();
token.Entities = decodeEntities(columns.getString("entities"));
System.out.println("Siege Repo> Loaded weapon " + token.UniqueId); System.out.println("Siege Repo> Loaded weapon " + token.UniqueId);
} }
public void updateWeapon(SiegeWeaponToken token) public void updateWeapon(SiegeWeaponToken token)
{ {
System.out.println("Siege Repo> Updating weapon " + token.UniqueId); System.out.println("Siege Repo> Updating weapon " + token.UniqueId);
_siegeManager.runAsync(() -> _siegeManager.runAsync(() ->
executeUpdate(UPDATE_WEAPON, executeUpdate(UPDATE_WEAPON,
new ColumnInt("health", token.Health), new ColumnInt("health", token.Health),
new ColumnInt("yaw", token.Yaw), new ColumnInt("yaw", token.Yaw),
new ColumnTimestamp("lastFired", new Timestamp(token.LastFired)), new ColumnTimestamp("lastFired", new Timestamp(token.LastFired)),
new ColumnInt("uniqueId", token.UniqueId)) new ColumnInt("uniqueId", token.UniqueId))
); );
} }
public void insertWeapon(SiegeWeaponToken token) public void insertWeapon(SiegeWeaponToken token)
{ {
System.out.println("Siege Repo> Inserting new weapon " + token.UniqueId); System.out.println("Siege Repo> Inserting new weapon " + token.UniqueId);
_siegeManager.runAsync(() -> _siegeManager.runAsync(() ->
executeUpdate(INSERT_WEAPON, executeUpdate(INSERT_WEAPON,
new ColumnInt("uniqueId", token.UniqueId), new ColumnInt("uniqueId", token.UniqueId),
new ColumnInt("serverId", _siegeManager.getClansManager().getServerId()), new ColumnInt("serverId", _siegeManager.getClansManager().getServerId()),
new ColumnVarChar("location", 30, UtilWorld.locToStr(token.Location)), new ColumnVarChar("location", 30, UtilWorld.locToStr(token.Location)),
new ColumnInt("ownerClan", token.OwnerClan.getId()), new ColumnInt("ownerClan", token.OwnerClan.getId()),
new ColumnInt("weaponType", token.WeaponType), new ColumnInt("weaponType", token.WeaponType),
new ColumnInt("health", token.Health), new ColumnInt("health", token.Health),
new ColumnInt("yaw", token.Yaw), new ColumnInt("yaw", token.Yaw),
new ColumnTimestamp("lastFired", new Timestamp(token.LastFired)), new ColumnTimestamp("lastFired", new Timestamp(token.LastFired)),
new ColumnVarChar("entities", 100, encodeEntities(token.Entities))) new ColumnVarChar("entities", 100, ""))
); );
} }
private String encodeEntities(Map<String, String> entities) @Override
{ protected void initialize()
StringBuilder builder = new StringBuilder(); {
executeUpdate(CREATE);
}
int l = 0; @Override
for (String name : entities.keySet()) protected void update()
{ {
if (l != 0) }
{
builder.append(",");
}
builder.append(name + ":" + entities.get(name));
l++;
}
return builder.toString();
}
private Map<String, String> decodeEntities(String data)
{
Map<String, String> map = new HashMap<>();
for (String entries : data.split(","))
{
map.put(entries.split(":")[0], entries.split(":")[1]);
}
return map;
}
@Override
protected void initialize()
{
_siegeManager.runAsync(() ->
executeUpdate(CREATE)
);
}
@Override
protected void update()
{
}
} }

View File

@ -16,6 +16,5 @@ public class SiegeWeaponToken
public int Health; public int Health;
public int Yaw; public int Yaw;
public long LastFired; public long LastFired;
public Map<String, String> Entities;
} }

View File

@ -1,8 +1,6 @@
package mineplex.game.clans.clans.siege.weapon; package mineplex.game.clans.clans.siege.weapon;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Map.Entry;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -39,7 +37,6 @@ import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.clans.siege.SiegeManager;
import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent; import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent;
import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken; import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken;
import mineplex.game.clans.clans.siege.weapon.projectile.ProjectileAttributes;
import mineplex.game.clans.clans.siege.weapon.projectile.WeaponProjectile; import mineplex.game.clans.clans.siege.weapon.projectile.WeaponProjectile;
import mineplex.game.clans.clans.siege.weapon.util.AccessRule; import mineplex.game.clans.clans.siege.weapon.util.AccessRule;
import mineplex.game.clans.clans.siege.weapon.util.AccessType; import mineplex.game.clans.clans.siege.weapon.util.AccessType;
@ -55,6 +52,13 @@ public class Cannon extends SiegeWeapon
{ {
super(300, "Cannon", token, siegeManager.getClansManager(), siegeManager); super(300, "Cannon", token, siegeManager.getClansManager(), siegeManager);
if (_ownerClan == null)
{
System.out.println("[cannon] owner clan null, killing");
kill();
return;
}
System.out.println("Siege> Loading Cannon from token " + token.UniqueId); System.out.println("Siege> Loading Cannon from token " + token.UniqueId);
setBoundingBox(1); setBoundingBox(1);
@ -69,8 +73,6 @@ public class Cannon extends SiegeWeapon
_baseDamage = 650; _baseDamage = 650;
setProjectileAttributes(new ProjectileAttributes().setPrimedTnt().setDoCrater().craterSize(3).craterChanceOfAir(2.d));
setFireRule(new AccessRule(AccessType.LCLICK_BB, player -> { setFireRule(new AccessRule(AccessType.LCLICK_BB, player -> {
if (!isRiding(player)) if (!isRiding(player))
{ {
@ -107,11 +109,11 @@ public class Cannon extends SiegeWeapon
enableInventory(UtilServer.getServer().createInventory(null, InventoryType.DISPENSER, C.cDAquaB + _name), new AccessRule(AccessType.RCLICK_BB, player -> player.equals(getRider()))); enableInventory(UtilServer.getServer().createInventory(null, InventoryType.DISPENSER, C.cDAquaB + _name), new AccessRule(AccessType.RCLICK_BB, player -> player.equals(getRider())));
setRideable(new AccessRule(AccessType.RCLICK_BB, player -> { setRideable(new AccessRule(AccessType.RCLICK_BB, player -> {
// if (!_ownerClan.isMember(player)) if (!_ownerClan.isMember(player))
// { {
// UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan.")); UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan."));
// return false; return false;
// } }
if (getRider() != null && !getRider().equals(player)) if (getRider() != null && !getRider().equals(player))
{ {
@ -140,7 +142,7 @@ public class Cannon extends SiegeWeapon
setStateInfo("Unloaded", new WeaponStateInfo(Material.SPONGE, (byte) 1)); setStateInfo("Unloaded", new WeaponStateInfo(Material.SPONGE, (byte) 1));
setStateInfo("Loaded", new WeaponStateInfo(Material.SPONGE, (byte) 0)); setStateInfo("Loaded", new WeaponStateInfo(Material.SPONGE, (byte) 0));
loadEntities(); loadEntities(true);
setFirepowerType(Material.SULPHUR); setFirepowerType(Material.SULPHUR);
setAmmunitionType(Material.TNT); setAmmunitionType(Material.TNT);
@ -153,8 +155,6 @@ public class Cannon extends SiegeWeapon
_baseDamage = 650; _baseDamage = 650;
setProjectileAttributes(new ProjectileAttributes().setPrimedTnt().setDoCrater().craterSize(3).craterChanceOfAir(2.d));
setFireRule(new AccessRule(AccessType.LCLICK_BB, player -> { setFireRule(new AccessRule(AccessType.LCLICK_BB, player -> {
if (!isRiding(player)) if (!isRiding(player))
{ {
@ -179,9 +179,9 @@ public class Cannon extends SiegeWeapon
return false; return false;
} }
if (System.currentTimeMillis() - _lastFired < 20000) if (System.currentTimeMillis() - _lastFired < 30000)
{ {
UtilPlayer.message(player, F.main("Clans", "Cannon is cooling down (" + F.time(UtilTime.MakeStr(20000 - (System.currentTimeMillis() - _lastFired))) + ")")); UtilPlayer.message(player, F.main("Clans", "Cannon is cooling down (" + F.time(UtilTime.MakeStr(30000 - (System.currentTimeMillis() - _lastFired))) + ")"));
return false; return false;
} }
@ -191,11 +191,11 @@ public class Cannon extends SiegeWeapon
enableInventory(UtilServer.getServer().createInventory(null, InventoryType.DISPENSER, C.cDAquaB + _name), new AccessRule(AccessType.RCLICK_BB, player -> player.equals(getRider()))); enableInventory(UtilServer.getServer().createInventory(null, InventoryType.DISPENSER, C.cDAquaB + _name), new AccessRule(AccessType.RCLICK_BB, player -> player.equals(getRider())));
setRideable(new AccessRule(AccessType.RCLICK_BB, player -> { setRideable(new AccessRule(AccessType.RCLICK_BB, player -> {
// if (!_ownerClan.isMember(player)) if (!_ownerClan.isMember(player))
// { {
// UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan.")); UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan."));
// return false; return false;
// } }
if (getRider() != null && !getRider().equals(player)) if (getRider() != null && !getRider().equals(player))
{ {
@ -298,7 +298,7 @@ public class Cannon extends SiegeWeapon
return true; // all slots are now filled; slot == 0 || slot == 1 || slot == 2; return true; // all slots are now filled; slot == 0 || slot == 1 || slot == 2;
} }
private void loadEntities() private void loadEntities(boolean insert)
{ {
Slime filler = _location.getWorld().spawn(_location.clone(), Slime.class); Slime filler = _location.getWorld().spawn(_location.clone(), Slime.class);
@ -332,8 +332,10 @@ public class Cannon extends SiegeWeapon
addEntity(weapon, "WEAPON"); addEntity(weapon, "WEAPON");
if (insert)
insert(); {
insert();
}
} }
@Override @Override
@ -341,29 +343,24 @@ public class Cannon extends SiegeWeapon
{ {
Lists.newArrayList(_location.getWorld().getEntities()) Lists.newArrayList(_location.getWorld().getEntities())
.forEach(entity -> { .forEach(entity -> {
for (Entry<String, String> entry : _loadedToken.Entities.entrySet()) if (Integer.toString(_uniqueId).equals(entity.getCustomName()))
{ {
if (entity.getUniqueId().toString().equals(entry.getValue())) entity.remove();
{
addEntity(entity, entry.getKey());
}
} }
}); });
if (getEntity("WEAPON") == null || getEntity("Filler_1") == null || getEntity("PLAYERMOUNT") == null) loadEntities(false);
{
System.out.println("[Cannon] Could not find all entities, killing.");
kill();
}
} }
@Override @Override
public void CustomFire(WeaponProjectile projectile) protected WeaponProjectile CustomFire(double yawRot, double verticalVel, double horizontalVel)
{ {
projectile.setLocation(projectile.getLocation().add(.0, .2, .0)); Location location = UtilAlg.moveForward(new Location(_location.getWorld(), _location.getX(), _location.getY() + .2, _location.getZ(), (float) yawRot, (float) 0), 0.35, (float) yawRot, false);
UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, projectile.getLocation(), new Vector(0, 0, 0), .1f, 2, ViewDist.MAX); UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, location, new Vector(0, 0, 0), .1f, 2, ViewDist.MAX);
UtilServer.getServer().getOnlinePlayers().forEach(player -> player.playSound(projectile.getLocation(), Sound.EXPLODE, 1.f, 1.f)); UtilServer.getServer().getOnlinePlayers().forEach(player -> player.playSound(location, Sound.EXPLODE, 1.f, 1.f));
return new TntProjectile(this, location, yawRot, verticalVel, horizontalVel);
} }
@Override @Override
@ -428,12 +425,12 @@ public class Cannon extends SiegeWeapon
@EventHandler @EventHandler
public void explosionEffects(SiegeWeaponExplodeEvent event) public void explosionEffects(SiegeWeaponExplodeEvent event)
{ {
for (int i = 0; i < 8; i++) // for (int i = 0; i < 8; i++)
{ // {
// Explosion particle effects. // // Explosion particle effects.
Location point = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), 5); // Location point = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), 5);
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, point, 0, 0, 0, 1, 2, ViewDist.MAX); // UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, point, 0, 0, 0, 1, 2, ViewDist.MAX);
} // }
// Block explosion. // Block explosion.
ArrayList<Block> blocks = new ArrayList<>(); ArrayList<Block> blocks = new ArrayList<>();
@ -441,6 +438,12 @@ public class Cannon extends SiegeWeapon
while (blocks.size() < 10 && (attempts < 30)) while (blocks.size() < 10 && (attempts < 30))
{ {
Block block = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), (4 * getPowerLevel())).getBlock(); Block block = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), (4 * getPowerLevel())).getBlock();
if (_siegeManager.getClansManager().getClanUtility().getClaim(block.getLocation()) != null && !_siegeManager.getClansManager().getBlacklist().allowed(_siegeManager.getClansManager().getClanUtility().getClaim(block.getLocation()).Owner))
{
continue;
}
if ((block.getType() != Material.AIR) && (!blocks.contains(block))) if ((block.getType() != Material.AIR) && (!blocks.contains(block)))
{ {
blocks.add(block); blocks.add(block);
@ -449,9 +452,10 @@ public class Cannon extends SiegeWeapon
attempts++; attempts++;
} }
_siegeManager.getClansManager().getExplosion().BlockExplosion( _clans.getExplosion().BlockExplosion(
blocks, blocks,
event.getProjectile().getLocation(), event.getProjectile().getLocation(),
false,
false false
); );
} }

View File

@ -1,6 +1,5 @@
package mineplex.game.clans.clans.siege.weapon; package mineplex.game.clans.clans.siege.weapon;
import java.util.HashMap;
import java.util.UUID; import java.util.UUID;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
@ -49,12 +48,12 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClanDeleteEvent;
import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.clans.siege.SiegeManager;
import mineplex.game.clans.clans.siege.events.LoadSiegeWeaponEvent; import mineplex.game.clans.clans.siege.events.LoadSiegeWeaponEvent;
import mineplex.game.clans.clans.siege.events.MountSiegeWeaponEvent; import mineplex.game.clans.clans.siege.events.MountSiegeWeaponEvent;
import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent; import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent;
import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken; import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken;
import mineplex.game.clans.clans.siege.weapon.projectile.ProjectileAttributes;
import mineplex.game.clans.clans.siege.weapon.projectile.WeaponProjectile; import mineplex.game.clans.clans.siege.weapon.projectile.WeaponProjectile;
import mineplex.game.clans.clans.siege.weapon.util.AccessRule; import mineplex.game.clans.clans.siege.weapon.util.AccessRule;
import mineplex.game.clans.clans.siege.weapon.util.AccessType; import mineplex.game.clans.clans.siege.weapon.util.AccessType;
@ -138,7 +137,6 @@ public abstract class SiegeWeapon implements Listener
protected int _baseDamage; protected int _baseDamage;
protected ProjectileAttributes _projectileAttributes;
protected WeaponProjectile _projectile; protected WeaponProjectile _projectile;
public SiegeWeapon(int maxHealth, String name, SiegeWeaponToken token, ClansManager clansManager, SiegeManager siegeManager) public SiegeWeapon(int maxHealth, String name, SiegeWeaponToken token, ClansManager clansManager, SiegeManager siegeManager)
@ -328,7 +326,7 @@ public abstract class SiegeWeapon implements Listener
_inventory.clear(); _inventory.clear();
CustomFire(_projectile = new WeaponProjectile(this, _location.clone().add(.5, 0, .5), _projectileAttributes, ((ArmorStand) getEntity("WEAPON")).getHeadPose().getY(), vel[0], vel[1])); _projectile = CustomFire(((ArmorStand) getEntity("WEAPON")).getHeadPose().getY(), vel[0], vel[1]);
} }
protected void setFireRule(AccessRule rule) protected void setFireRule(AccessRule rule)
@ -366,11 +364,6 @@ public abstract class SiegeWeapon implements Listener
_maxAmmunition = maxAmmunition; _maxAmmunition = maxAmmunition;
} }
protected void setProjectileAttributes(ProjectileAttributes projectileAttributes)
{
_projectileAttributes = projectileAttributes;
}
protected boolean isRiding(Player player) protected boolean isRiding(Player player)
{ {
return player.equals(getRider()); return player.equals(getRider());
@ -523,19 +516,22 @@ public abstract class SiegeWeapon implements Listener
protected abstract double[] GetProjectileVelocity(); protected abstract double[] GetProjectileVelocity();
protected abstract String GetNextState(); protected abstract String GetNextState();
protected abstract void FindEntities(); protected abstract void FindEntities();
protected abstract WeaponProjectile CustomFire(double yawRot, double verticalVel, double horizontalVel);
protected void CustomTick() { return; } protected void CustomTick() { return; }
protected void CustomOnMount(Player player) { return; } protected void CustomOnMount(Player player) { return; }
protected void CustomLeftClick(Player player) { return; } protected void CustomLeftClick(Player player) { return; }
protected void CustomRightClick(Player player) { return; } protected void CustomRightClick(Player player) { return; }
protected void CustomCleanup() { return; } protected void CustomCleanup() { return; }
protected void CustomUpdateState(String state) { return; } protected void CustomUpdateState(String state) { return; }
protected void CustomFire(WeaponProjectile projectile) { return; }
protected double CustomRotate(double yaw) { return yaw; } protected double CustomRotate(double yaw) { return yaw; }
protected boolean CustomDismount(Player player, Entity entity) { return false; } protected boolean CustomDismount(Player player, Entity entity) { return false; }
protected boolean CustomMount(Player player) { return false; } protected boolean CustomMount(Player player) { return false; }
protected final void addEntity(Entity entity, String uniqueName) protected final void addEntity(Entity entity, String uniqueName)
{ {
entity.setCustomName(Integer.toString(_uniqueId));
entity.setCustomNameVisible(false);
_comprisedOf.add(entity); _comprisedOf.add(entity);
_entityMapping.put(uniqueName, entity); _entityMapping.put(uniqueName, entity);
@ -691,6 +687,16 @@ public abstract class SiegeWeapon implements Listener
} }
} }
@EventHandler
public void clanDelete(ClanDeleteEvent event)
{
if (event.getClanInfo().getName().equals(_ownerClan.getName()))
{
System.out.println("Killing Siege weapon " + _uniqueId + " because owner clan has been deleted.");
kill();
}
}
@EventHandler @EventHandler
public void onSiegeWeaponExplode(SiegeWeaponExplodeEvent event) public void onSiegeWeaponExplode(SiegeWeaponExplodeEvent event)
{ {
@ -942,29 +948,19 @@ public abstract class SiegeWeapon implements Listener
token.Location = _location; token.Location = _location;
token.Health = _health; token.Health = _health;
token.Yaw = (int) _yaw; token.Yaw = (int) _yaw;
token.Entities = new HashMap<>();
_entityMapping.entrySet().forEach(entry ->
token.Entities.put(entry.getKey(), entry.getValue().getUniqueId().toString())
);
return token; return token;
} }
public boolean isPartOf(UUID uniqueId) public boolean isPartOf(UUID uniqueId)
{ {
if (_loadedToken == null) for (Entity entity : _comprisedOf)
{ {
for (Entity entity : _comprisedOf) if (entity.getUniqueId().equals(uniqueId))
{ return true;
if (entity.getUniqueId().equals(uniqueId))
return true;
}
return false;
} }
return _loadedToken.Entities.values().contains(uniqueId.toString()); return false;
} }
public void setInvincible(boolean invincible) public void setInvincible(boolean invincible)

View File

@ -0,0 +1,63 @@
package mineplex.game.clans.clans.siege.weapon;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.siege.weapon.projectile.WeaponProjectile;
public class TntProjectile extends WeaponProjectile
{
public TntProjectile(SiegeWeapon weapon, Location origin, double yawRot, double yVel, double xMulti)
{
super(weapon, origin, yawRot, yVel, xMulti);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onTntExplode(EntityExplodeEvent event)
{
if (event.getEntity().equals(_projectileEntity))
{
((TNTPrimed) event.getEntity()).setFuseTicks(60);
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onTntExplode(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
((TNTPrimed) _projectileEntity).setFuseTicks(60);
}
@Override
public Entity spawn()
{
TNTPrimed tnt = _origin.getWorld().spawn(_origin, TNTPrimed.class);
Vector velocity = UtilAlg.getTrajectory(
_origin,
UtilAlg.moveForward(
_origin,
2.,
(float) Math.toDegrees(_yawRot), false))
.multiply(_xMulti)
.setY(_yVel);
tnt.setVelocity(velocity);
return tnt;
}
}

View File

@ -26,9 +26,9 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.nameblacklist.ClansBlacklist;
import mineplex.game.clans.clans.siege.weapon.SiegeWeapon; import mineplex.game.clans.clans.siege.weapon.SiegeWeapon;
import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.ClanTerritory;
import net.minecraft.server.v1_8_R3.Explosion;
public class Crater implements Listener public class Crater implements Listener
{ {
@ -39,14 +39,9 @@ public class Crater implements Listener
private final long _birthTime; private final long _birthTime;
private final int _size;
private final double _airChance;
private final boolean _fire;
private final List<CraterBlock> _blocks; private final List<CraterBlock> _blocks;
public Crater(SiegeWeapon weapon, WeaponProjectile projectile, Location origin, int size, double airChance, boolean doFire) public Crater(SiegeWeapon weapon, WeaponProjectile projectile, Location origin)
{ {
_weapon = weapon; _weapon = weapon;
_origin = origin; _origin = origin;
@ -54,10 +49,6 @@ public class Crater implements Listener
_birthTime = System.currentTimeMillis(); _birthTime = System.currentTimeMillis();
_blocks = new ArrayList<>(); _blocks = new ArrayList<>();
_size = size;
_airChance = airChance;
_fire = doFire;
UtilServer.getPluginManager().registerEvents(this, _weapon.getClans().getPlugin()); UtilServer.getPluginManager().registerEvents(this, _weapon.getClans().getPlugin());
createExplosion(); createExplosion();
@ -108,124 +99,57 @@ public class Crater implements Listener
return; return;
} }
_blocks.add(new CraterBlock(_origin, 0, Material.AIR)); boolean explosion = _origin.getWorld().createExplosion(_origin, 2.6f);
HashMap<Block, Double> blockList = new HashMap<Block, Double>(); boolean floating = _origin.distance(UtilBlock.nearestFloor(_origin)) > 0.6;
int iR = (int) _size + 1;
for (int x = -iR; x <= iR; x++) if (explosion)
{ {
for (int z = -iR; z <= iR; z++) for (Block block : UtilBlock.getInRadius(_origin.getBlock(), 2.6f).keySet())
{ {
for (int y = -iR; y <= iR; y++) boolean charred = false;
double dist = block.getLocation().distance(_origin);
if (floating)
{ {
Block curBlock = _origin.getBlock().getRelative(x, y, z); if (!block.getRelative(BlockFace.DOWN).getType().equals(CHARRED_TYPE)
&& !block.getRelative(BlockFace.DOWN).getType().equals(Material.AIR)
double offset = UtilMath.offset(_origin, curBlock.getLocation()); && Math.random() > 0.79)
if (offset <= _size)
{ {
blockList.put(curBlock, Double.valueOf(offset)); charred = true;
} }
} }
else
{
if (block.getRelative(BlockFace.UP).getType().equals(Material.AIR)
&& !block.getRelative(BlockFace.DOWN).getType().equals(CHARRED_TYPE)
&& !block.getRelative(BlockFace.DOWN).getType().equals(Material.AIR)
&& Math.random() > 0.79)
{
charred = true;
}
}
if (block.getType().equals(Material.SMOOTH_BRICK))
{
charred = false;
}
if (block.getType().equals(Material.BEDROCK))
{
charred = false;
}
if (charred)
{
CraterBlock charredBlock = new CraterBlock(block.getLocation(), dist, CHARRED_TYPE, (byte) 0);
charredBlock.set();
_blocks.add(charredBlock);
}
} }
} }
for (Entry<Block, Double> entry : blockList.entrySet())
{
Block block = entry.getKey();
ClanTerritory territory = _weapon.getClans().getClanUtility().getClaim(block.getLocation());
if (territory != null && !ClansManager.getInstance().getBlacklist().allowed(territory.Owner))
{
continue;
}
double distance = entry.getValue().doubleValue();
boolean air = distance <= _airChance || (Math.random() > (distance) / 3.65d);
if (block.getState() instanceof Chest) continue;
if (block.getType() == Material.AIR) continue;
if (air)
{
_blocks.add(new CraterBlock(block.getLocation(), distance, Material.AIR));
Block above = block;
while (!UtilItem.isBoundless((above = above.getRelative(BlockFace.UP)).getType()))
{
_blocks.add(new CraterBlock(above.getLocation(), distance, Material.AIR));
}
if (!UtilItem.isBoundless(block.getRelative(BlockFace.DOWN).getType()))
{
if (_fire && Math.random() >= .5)
{
_blocks.add(new CraterBlock(block.getLocation(), distance, Material.FIRE));
}
}
}
}
_blocks.forEach(CraterBlock::set);
for (Entry<Block, Double> entry : blockList.entrySet())
{
Block block = entry.getKey();
ClanTerritory territory = _weapon.getClans().getClanUtility().getClaim(block.getLocation());
if (territory != null && !ClansManager.getInstance().getBlacklist().allowed(territory.Owner))
{
continue;
}
double distance = entry.getValue().doubleValue();
if (block.getType() == Material.AIR) continue;
if (block.getState() instanceof Chest)
{
Chest chest = (Chest) block.getState();
for (ItemStack item : chest.getBlockInventory().getContents())
{
if (item == null)
{
continue;
}
if (item.getType() == Material.AIR)
{
continue;
}
_origin.getWorld().dropItemNaturally(_origin, item);
}
}
if (
distance > _airChance &&
Math.random() > .75 &&
UtilItem.isBoundless(block.getRelative(BlockFace.UP).getType()) &&
!UtilItem.isBoundless(block.getRelative(BlockFace.DOWN).getType()) &&
!block.getRelative(BlockFace.UP).getType().equals(CHARRED_TYPE) &&
!block.getRelative(BlockFace.DOWN).getType().equals(CHARRED_TYPE))
{
_blocks.add(new CraterBlock(block.getLocation(), distance, CHARRED_TYPE));
if (_fire)
{
_blocks.add(new CraterBlock(block.getRelative(BlockFace.UP).getLocation(), distance, Material.FIRE));
}
}
}
_blocks.forEach(CraterBlock::set);
} }
} }

View File

@ -1,75 +0,0 @@
package mineplex.game.clans.clans.siege.weapon.projectile;
import org.bukkit.Material;
public class ProjectileAttributes
{
protected boolean _isFallingBlock;
protected Material _fallingBlockType;
protected byte _fallingBlockData;
protected boolean _isPrimedTnt;
protected boolean _doCrater;
protected int _craterSize;
protected double _craterChanceOfAir;
protected boolean _craterDoFire;
public ProjectileAttributes setFallingBlock()
{
_isFallingBlock = true;
return this;
}
public ProjectileAttributes setFallingBlockType(Material type)
{
_fallingBlockType = type;
return this;
}
public ProjectileAttributes setFallingBlockData(byte data)
{
_fallingBlockData = data;
return this;
}
public ProjectileAttributes setPrimedTnt()
{
_isPrimedTnt = true;
return this;
}
public ProjectileAttributes setDoCrater()
{
_doCrater = true;
return this;
}
public ProjectileAttributes craterSize(int size)
{
_craterSize = size;
return this;
}
public ProjectileAttributes craterDoFire(boolean doFire)
{
_craterDoFire = doFire;
return this;
}
public ProjectileAttributes craterChanceOfAir(double chance)
{
_craterChanceOfAir = chance;
return this;
}
}

View File

@ -23,55 +23,33 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent; import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent;
import mineplex.game.clans.clans.siege.weapon.SiegeWeapon; import mineplex.game.clans.clans.siege.weapon.SiegeWeapon;
public class WeaponProjectile implements Listener public abstract class WeaponProjectile implements Listener
{ {
private ProjectileAttributes _attributes; protected Location _origin;
private Location _origin; protected Entity _projectileEntity;
private Entity _projectileEntity;
private SiegeWeapon _weapon; protected SiegeWeapon _weapon;
private double _yRot; protected double _yawRot;
private double _xMulti; protected double _xMulti;
private double _yVel; protected double _yVel;
private boolean _dead; protected boolean _dead;
private Player _shooter; protected Player _shooter;
public WeaponProjectile(SiegeWeapon weapon, Location origin, ProjectileAttributes attributes, double yRot, double yVel, double xMulti) public WeaponProjectile(SiegeWeapon weapon, Location origin, double yawRot, double yVel, double xMulti)
{ {
_shooter = weapon.getRider(); _shooter = weapon.getRider();
_weapon = weapon; _weapon = weapon;
_origin = origin; _origin = origin;
_attributes = attributes; _yawRot = yawRot;
_yRot = yRot;
_yVel = yVel; _yVel = yVel;
_xMulti = xMulti; _xMulti = xMulti;
UtilServer.getPluginManager().registerEvents(this, weapon.getClans().getPlugin()); UtilServer.getPluginManager().registerEvents(this, weapon.getClans().getPlugin());
spawn(); _projectileEntity = spawn();
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onTntExplode(EntityExplodeEvent event)
{
if (event.getEntity().equals(_projectileEntity))
{
((TNTPrimed) event.getEntity()).setFuseTicks(60);
event.setCancelled(true);
}
}
@EventHandler
public void onBlockFall(EntityChangeBlockEvent event)
{
if (!_dead && event.getEntity().equals(_projectileEntity))
{
die();
event.setCancelled(true);
}
} }
@EventHandler @EventHandler
@ -82,39 +60,30 @@ public class WeaponProjectile implements Listener
return; return;
} }
if (_projectileEntity.isDead()) if (_projectileEntity == null || _projectileEntity.isDead())
{ {
die(); die();
return; return;
} }
if (_dead || _projectileEntity == null) if (_projectileEntity.getTicksLived() <= 10)
{ {
die();
return; return;
} }
((TNTPrimed) _projectileEntity).setFuseTicks(60); boolean moving = Math.abs(_projectileEntity.getVelocity().getX()) > 0.01 || Math.abs(_projectileEntity.getVelocity().getZ()) > 0.01;
if ((Math.abs(_projectileEntity.getVelocity().getX()) < 0.01 // Some rough collision detection. Not perfect, but the best I could conjure up myself.
|| Math.abs(_projectileEntity.getVelocity().getZ()) < 0.01) if (!moving && !UtilBlock.boundless(_projectileEntity.getLocation(), 2))
&& UtilBlock.getInRadius(_projectileEntity.getLocation(), 2)
.keySet()
.stream()
.filter(block -> !UtilItem.isBoundless(block.getType()))
.iterator().hasNext() && _projectileEntity.getTicksLived() >= 10)
{ {
SiegeWeaponExplodeEvent newEvent = new SiegeWeaponExplodeEvent(_weapon, this); SiegeWeaponExplodeEvent newEvent = UtilServer.CallEvent(new SiegeWeaponExplodeEvent(_weapon, this));
UtilServer.CallEvent(newEvent);
if (!newEvent.isCancelled()) if (!newEvent.isCancelled())
{ {
new Crater(_weapon, this, _projectileEntity.getLocation(), _attributes._craterSize, _attributes._craterChanceOfAir, _attributes._craterDoFire); new Crater(_weapon, this, _projectileEntity.getLocation());
UtilServer.getServer().getOnlinePlayers().forEach(player -> player.playSound(_projectileEntity.getLocation(), Sound.EXPLODE, 1.f, 1.f));
} }
UtilServer.getServer().getOnlinePlayers().forEach(player -> player.playSound(_projectileEntity.getLocation(), Sound.EXPLODE, 1.f, 1.f));
die(); die();
} }
} }
@ -147,48 +116,7 @@ public class WeaponProjectile implements Listener
_dead = true; _dead = true;
} }
private void spawn() public abstract Entity spawn();
{
if (_attributes._isFallingBlock)
{
FallingBlock fallingBlock = _origin.getWorld().spawnFallingBlock(_origin, _attributes._fallingBlockType, _attributes._fallingBlockData);
_projectileEntity = fallingBlock;
Vector velocity = UtilAlg.getTrajectory(
_origin,
UtilAlg.moveForward(
_origin,
2.,
(float) Math.toDegrees(_yRot), false))
.multiply(_xMulti)
.setY(_yVel);
fallingBlock.setVelocity(velocity);
}
else if (_attributes._isPrimedTnt)
{
TNTPrimed tnt = _origin.getWorld().spawn(_origin, TNTPrimed.class);
_projectileEntity = tnt;
Vector velocity = UtilAlg.getTrajectory(
_origin,
UtilAlg.moveForward(
_origin,
2.,
(float) Math.toDegrees(_yRot), false))
.multiply(_xMulti)
.setY(_yVel);
tnt.setVelocity(velocity);
}
}
public int getCraterSize()
{
return _attributes._craterSize;
}
public Player getShooter() public Player getShooter()
{ {

View File

@ -1,37 +0,0 @@
package mineplex.game.clans.clans.staff;
import org.bukkit.block.Chest;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import mineplex.core.common.util.UtilServer;
public class SilentChestInventory implements Listener
{
private Chest _chest;
private Inventory _inventory;
private Player _viewer;
public SilentChestInventory(Chest chest, Player viewer)
{
_chest = chest;
viewer.openInventory(_chest.getBlockInventory());
UtilServer.RegisterEvents(this);
}
@EventHandler
public void closeInventory(InventoryCloseEvent event)
{
if (event.getInventory().equals(_inventory) && event.getPlayer().equals(_viewer))
{
UtilServer.Unregister(this);
}
}
}

View File

@ -1,49 +0,0 @@
package mineplex.game.clans.clans.staff;
import org.bukkit.block.BlockState;
import org.bukkit.block.Chest;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilServer;
import mineplex.core.incognito.IncognitoManager;
import mineplex.game.clans.clans.ClansManager;
public class SilentChestOpen extends MiniPlugin
{
private ClansManager _clansManager;
public SilentChestOpen(ClansManager clansManager)
{
super("Silent Chest", clansManager.getPlugin());
_clansManager = clansManager;
}
@EventHandler
public void onInteract(PlayerInteractEvent event)
{
if (!_clansManager.getIncognitoManager().Get(event.getPlayer()).Status)
return;
if (!ClansManager.getInstance().getClientManager().hasRank(event.getPlayer(), Rank.CMOD))
return;
if (event.getClickedBlock() == null)
return;
BlockState block = event.getClickedBlock().getState();
if (!(block instanceof Chest))
return;
Chest chest = (Chest) block;
UtilServer.RegisterEvents(new SilentChestInventory(chest, event.getPlayer()));
event.setCancelled(true);
}
}

View File

@ -52,9 +52,15 @@ public class EventTerrainFinder
loc.Set(UtilBlock.getHighest(chunk.getWorld(), chunk.getBlock(0, 0, 0)).getLocation()); loc.Set(UtilBlock.getHighest(chunk.getWorld(), chunk.getBlock(0, 0, 0)).getLocation());
}); });
if (!UtilWorld.isBoxInWorldBorder(world, loc.Get().clone().subtract(size * 2, vert, size * 2), loc.Get().clone().add(size * 2, vert, size * 2)))
{
continue;
}
if (loc.Get() == null) if (loc.Get() == null)
{
continue; continue;
}
System.out.println("Done finding area... [success]"); System.out.println("Done finding area... [success]");
@ -62,7 +68,7 @@ public class EventTerrainFinder
return loc.Get(); return loc.Get();
} }
System.out.println("Done finding area..."); System.out.println("Failed to find area...");
return null; return null;
} }

View File

@ -77,6 +77,19 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
} }
} }
public boolean isInEvent(Location location)
{
for (WorldEvent event : _runningEvents)
{
if (event.isInBounds(location))
{
return true;
}
}
return false;
}
@EventHandler @EventHandler
public void update(UpdateEvent event) public void update(UpdateEvent event)
{ {
@ -124,6 +137,17 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
} }
} }
public void randomEvent()
{
if (_runningEvents.size() == 0)
{
if (UtilServer.getPlayers().length > 0)
{
tryStartEvent();
}
}
}
private void tryStartEvent() private void tryStartEvent()
{ {
WorldEventType[] types = WorldEventType.values(); WorldEventType[] types = WorldEventType.values();

View File

@ -0,0 +1,28 @@
package mineplex.game.clans.clans.worldevent.command;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.clans.worldevent.WorldEventManager;
import mineplex.game.clans.clans.worldevent.WorldEventType;
import mineplex.minecraft.game.core.boss.WorldEvent;
/**
* Command for spawning a random world event in the world.
*/
public class RandomCommand extends CommandBase<WorldEventManager>
{
public RandomCommand(WorldEventManager plugin)
{
super(plugin, Rank.JNR_DEV, "random", "rand");
}
@Override
public void Execute(Player caller, String[] args)
{
Plugin.randomEvent();
}
}

View File

@ -14,6 +14,7 @@ public class WorldEventCommand extends MultiCommandBase<WorldEventManager>
AddCommand(new StartCommand(Plugin)); AddCommand(new StartCommand(Plugin));
AddCommand(new ClearCommand(Plugin)); AddCommand(new ClearCommand(Plugin));
AddCommand(new RandomCommand(Plugin));
} }
@Override @Override

View File

@ -41,7 +41,7 @@ import mineplex.game.clans.shop.bank.BankShop;
public class GoldManager extends MiniPlugin public class GoldManager extends MiniPlugin
{ {
public static final double GEM_CONVERSION_RATE = 32; // The number of gold coins when converted from a single gem public static final double GEM_CONVERSION_RATE = 16; // The number of gold coins when converted from a single gem
public static final double DEATH_TAX = 0.04d; // Percentage of gold lost on death public static final double DEATH_TAX = 0.04d; // Percentage of gold lost on death
public static final String META_STRING = "clans.goldAmount"; public static final String META_STRING = "clans.goldAmount";

View File

@ -59,6 +59,7 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.weight.Weight; import mineplex.core.common.weight.Weight;
import mineplex.core.common.weight.WeightSet; import mineplex.core.common.weight.WeightSet;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
@ -304,6 +305,61 @@ public class Gameplay extends MiniPlugin
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void disableEnderChest(PlayerInteractEvent event)
{
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
{
return;
}
if (event.getClickedBlock() == null)
{
return;
}
if (_clansManager.getWorldEvent().isInEvent(event.getClickedBlock().getLocation()))
{
return;
}
if (event.getClickedBlock().getType().equals(Material.ENDER_CHEST))
{
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You are not permitted to use Ender Chests."));
event.setCancelled(true);
return;
}
}
@EventHandler
public void onInteract(PlayerInteractEvent event)
{
if (!_clansManager.getIncognitoManager().Get(event.getPlayer()).Status)
{
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
{
return;
}
if (event.getClickedBlock() == null)
{
return;
}
if (!event.getClickedBlock().getType().equals(Material.CHEST)
&& !event.getClickedBlock().getType().equals(Material.TRAPPED_CHEST))
{
return;
}
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You are not allowed to use this whilst incognito."));
event.setCancelled(true);
}
/** /**
* Disable all Piston related events in Clans * Disable all Piston related events in Clans
* *
@ -818,12 +874,18 @@ public class Gameplay extends MiniPlugin
UtilInv.Update(player); UtilInv.Update(player);
// Break // Break
if (Math.random() > 0.85) event.getClickedBlock().setData((byte) (event.getClickedBlock().getData() + 4)); if (Math.random() > 0.85)
if (event.getClickedBlock().getData() >= 12)
{ {
player.getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, 145); byte data = event.getClickedBlock().getData();
event.getClickedBlock().setTypeIdAndData(0, (byte) 0, true); if (data >= 8) // Anvil has already been damaged twice
{
player.getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, 145);
event.getClickedBlock().setType(Material.AIR);
}
else
{
event.getClickedBlock().setData((byte)(data + 4));
}
} }
// Record // Record

View File

@ -1,11 +1,10 @@
package mineplex.game.clans.items.attributes.armor; package mineplex.game.clans.items.attributes.armor;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.AttributeType;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.generation.ValueDistribution; import mineplex.game.clans.items.generation.ValueDistribution;
// A.K.A Conquering for Armor // A.K.A Conquering for Armor
@ -34,6 +33,6 @@ public class ConqueringArmorAttribute extends FlatReductionAttribute
@Override @Override
public boolean reducesDamage(DamageCause cause, Entity attacker) public boolean reducesDamage(DamageCause cause, Entity attacker)
{ {
return attacker != null; // Reduces damage from all entities return !(attacker instanceof Player); // Reduces damage from all entities
} }
} }

View File

@ -60,6 +60,6 @@ public class GiantsBroadsword extends LegendaryItem
private void buffPlayer(Player player) private void buffPlayer(Player player)
{ {
grantPotionEffect(player, PotionEffectType.SLOW, 40, SLOW_AMPLIFIER); grantPotionEffect(player, PotionEffectType.SLOW, 40, SLOW_AMPLIFIER);
grantPotionEffect(player, PotionEffectType.REGENERATION, 40, REGEN_AMPLIFIER); //Regen grantPotionEffect(player, PotionEffectType.REGENERATION, 2, REGEN_AMPLIFIER); //Regen
} }
} }

View File

@ -20,6 +20,7 @@ import mineplex.core.common.util.RGBData;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilCollections; import mineplex.core.common.util.UtilCollections;
import mineplex.core.common.util.UtilColor; import mineplex.core.common.util.UtilColor;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilParticle.ViewDist;
@ -38,6 +39,8 @@ public class MeridianScepter extends LegendaryItem
private RGBData[] colors = { UtilColor.RgbPurple, UtilColor.RgbPurple.Lighten(), UtilColor.RgbPurple.Darken() }; private RGBData[] colors = { UtilColor.RgbPurple, UtilColor.RgbPurple.Lighten(), UtilColor.RgbPurple.Darken() };
private int _witherDamageTimes = 5;
public MeridianScepter() public MeridianScepter()
{ {
super("Meridian Scepter", UtilText.splitLinesToArray(new String[] { super("Meridian Scepter", UtilText.splitLinesToArray(new String[] {
@ -80,7 +83,6 @@ public class MeridianScepter extends LegendaryItem
final Vector direction = shooter.getEyeLocation().getDirection().normalize().multiply(0.25); final Vector direction = shooter.getEyeLocation().getDirection().normalize().multiply(0.25);
final int maxRange = 50; final int maxRange = 50;
final int maxDings = maxRange * 4; final int maxDings = maxRange * 4;
final int damage = 6;
UtilServer.repeat(new BukkitRunnable() UtilServer.repeat(new BukkitRunnable()
{ {
@ -96,16 +98,21 @@ public class MeridianScepter extends LegendaryItem
Player player = (Player) cur; Player player = (Player) cur;
Location eLoc = player.getLocation();
// If they are less than 0.5 blocks away // If they are less than 0.5 blocks away
if (eLoc.clone().add(0, player.getEyeHeight() / 2, 0).distance(projectile) <= 0.7) if (player.getEyeLocation().subtract(0, .3, 0).distance(projectile) <= 2)
{ {
ClansManager.getInstance().getDamageManager().NewDamageEvent(player, player, null, player.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 20 * _witherDamageTimes, 0));
DamageCause.CUSTOM, damage, true, true, false,
player.getName(), "Meridian Scepter");
player.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 20 * 4, 0)); int time = 0;
for (int i = 0; i < _witherDamageTimes; i++)
{
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(UtilServer.getPlugin(), () -> {
ClansManager.getInstance().getDamageManager().NewDamageEvent(player, shooter, null,
DamageCause.CUSTOM, 1.75, false, true, true,
shooter.getName(), "Meridian Scepter");
}, ++time * 20);
}
UtilPlayer.message(player, F.main("Clans", F.elem(player.getName()) + " hit you with a " + F.elem("Meridian Scepter") + C.mBody + ".")); UtilPlayer.message(player, F.main("Clans", F.elem(player.getName()) + " hit you with a " + F.elem("Meridian Scepter") + C.mBody + "."));
UtilPlayer.message(shooter, F.main("Clans", "You hit " + F.elem(player.getName()) + " with your " + F.elem("Meridian Scepter") + C.mBody + ".")); UtilPlayer.message(shooter, F.main("Clans", "You hit " + F.elem(player.getName()) + " with your " + F.elem("Meridian Scepter") + C.mBody + "."));
@ -142,7 +149,7 @@ public class MeridianScepter extends LegendaryItem
continue; continue;
} }
if (ClansManager.getInstance().getClan(shooter) == ClansManager.getInstance().getClan(closest)) if (ClansManager.getInstance().isInClan(shooter) && ClansManager.getInstance().getClan(shooter).isMember(closest))
{ {
continue; continue;
} }
@ -152,12 +159,17 @@ public class MeridianScepter extends LegendaryItem
continue; continue;
} }
if (closest.getGameMode().equals(GameMode.CREATIVE) || closest.getGameMode().equals(GameMode.SPECTATOR))
{
continue;
}
if (ClansManager.getInstance().getIncognitoManager().Get(closest).Status) if (ClansManager.getInstance().getIncognitoManager().Get(closest).Status)
{ {
continue; continue;
} }
if (ClansManager.getInstance().getClan(shooter) != null && ClansManager.getInstance().getClan(shooter).isAlly(ClansManager.getInstance().getClan(closest))) if (ClansManager.getInstance().isInClan(shooter) && ClansManager.getInstance().getClan(shooter).isAlly(ClansManager.getInstance().getClan(closest)))
{ {
continue; continue;
} }

View File

@ -5,10 +5,6 @@ import java.util.EnumMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; 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.MiniPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.chat.Chat; import mineplex.core.chat.Chat;
@ -24,12 +20,15 @@ import mineplex.core.scoreboard.ScoreboardManager;
import mineplex.core.scoreboard.elements.ScoreboardElement; import mineplex.core.scoreboard.elements.ScoreboardElement;
import mineplex.core.task.TaskManager; import mineplex.core.task.TaskManager;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.siege.SiegeManager;
import mineplex.game.clans.message.ClansMessageManager; import mineplex.game.clans.message.ClansMessageManager;
import mineplex.game.clans.tutorial.command.TutorialCommand; import mineplex.game.clans.tutorial.command.TutorialCommand;
import mineplex.game.clans.tutorial.gui.TutorialShop; import mineplex.game.clans.tutorial.gui.TutorialShop;
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial; 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 public class TutorialManager extends MiniPlugin implements ScoreboardElement
{ {
private CoreClientManager _clientManager; private CoreClientManager _clientManager;

View File

@ -277,6 +277,11 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
public void displayChatMessages(Player player) public void displayChatMessages(Player player)
{ {
if (getPlugin().getTutorialSession(player) == null)
{
return;
}
for (int i = 0; i < 1; i++) for (int i = 0; i < 1; i++)
{ {
UtilPlayer.message(player, ""); UtilPlayer.message(player, "");

View File

@ -4,6 +4,44 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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.Bukkit;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Effect; import org.bukkit.Effect;
@ -26,45 +64,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
//import mineplex.game.clans.tutorial.tutorials.clans.repository.TutorialRepository;
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;
public class ClansMainTutorial extends Tutorial public class ClansMainTutorial extends Tutorial
{ {

View File

@ -5,19 +5,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; 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.DefaultHashMap;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.EnclosedObject; import mineplex.core.common.util.EnclosedObject;
@ -31,7 +18,6 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager; 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.clans.siege.weapon.Cannon;
import mineplex.game.clans.tutorial.TutorialRegion; import mineplex.game.clans.tutorial.TutorialRegion;
import mineplex.game.clans.tutorial.TutorialSession; 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.ClansMainTutorial;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.HoldItemGoal; 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.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.GetMapGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.LoadCannonGoal; 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.MountCannonGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.StealEnemyPotatoesGoal; 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> public class AttackEnemyObjective extends OrderedObjective<ClansMainTutorial>
{ {

View File

@ -1,16 +1,6 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy; 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.ClansManager;
import mineplex.game.clans.clans.siege.SiegeManager;
import mineplex.game.clans.clans.siege.events.MountSiegeWeaponEvent; import mineplex.game.clans.clans.siege.events.MountSiegeWeaponEvent;
import mineplex.game.clans.clans.siege.weapon.Cannon; import mineplex.game.clans.clans.siege.weapon.Cannon;
import mineplex.game.clans.tutorial.TutorialRegion; 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.ClansMainTutorial.Point;
import mineplex.game.clans.tutorial.tutorials.clans.objective.AttackEnemyObjective; 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> public class MountCannonGoal extends ObjectiveGoal<AttackEnemyObjective>
{ {
private ClansManager _clansManager; private ClansManager _clansManager;

View File

@ -107,7 +107,11 @@ public class Hub extends JavaPlugin implements IRelation
//Other Modules //Other Modules
PacketHandler packetHandler = new PacketHandler(this); PacketHandler packetHandler = new PacketHandler(this);
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager); IncognitoManager incognito = new IncognitoManager(this, clientManager, packetHandler);
PreferencesManager preferenceManager = new PreferencesManager(this, incognito, clientManager, donationManager);
incognito.setPreferencesManager(preferenceManager);
preferenceManager.GiveItem = true; preferenceManager.GiveItem = true;
Creature creature = new Creature(this); Creature creature = new Creature(this);
NpcManager npcManager = new NpcManager(this, creature); NpcManager npcManager = new NpcManager(this, creature);
@ -142,7 +146,6 @@ public class Hub extends JavaPlugin implements IRelation
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager); QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager);
IncognitoManager incognito = new IncognitoManager(this, clientManager, packetHandler);
new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager); new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager);
Chat chat = new Chat(this, incognito, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); Chat chat = new Chat(this, incognito, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());

View File

@ -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(); StringBuilder stringBuilder = new StringBuilder();
@ -103,7 +103,7 @@ public class QueueManager extends MiniPlugin
for (Player player : players) for (Player player : players)
{ {
eloCumulative = _eloManager.getElo(player.getUniqueId(), gameType); eloCumulative = _eloManager.getElo(player, gameType);
} }
final int elo = eloCumulative / players.length; final int elo = eloCumulative / players.length;

View File

@ -12,7 +12,7 @@ public class QueueRepository
{ {
private boolean _us = true; 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 SAVE_STATE_VALUE = "UPDATE playerQueue SET state = ? WHERE id = ?;";
private static String DELETE_QUEUE_RECORD = "DELETE FROM playerQueue 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);"; 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; ResultSet resultSet = null;
PreparedStatement preparedStatement = null; PreparedStatement preparedStatement = null;
@ -110,7 +110,7 @@ public class QueueRepository
{ {
preparedStatement = connection.prepareStatement(INSERT_ACCOUNT, Statement.RETURN_GENERATED_KEYS); preparedStatement = connection.prepareStatement(INSERT_ACCOUNT, Statement.RETURN_GENERATED_KEYS);
preparedStatement.setString(1, playerList); preparedStatement.setString(1, playerList);
preparedStatement.setString(2, gameType); preparedStatement.setInt(2, gameType);
preparedStatement.setInt(3, elo); preparedStatement.setInt(3, elo);
//preparedStatement.setBoolean(4, _us); //preparedStatement.setBoolean(4, _us);
preparedStatement.setInt(4, playerCount); preparedStatement.setInt(4, playerCount);

View File

@ -105,7 +105,8 @@ public class QueuePage extends ShopPageBase<QueueManager, QueueShop>
@Override @Override
public void onClick(Player player, ClickType clickType) 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(); buildPage();
} }
private void queuePlayer(String gameType, Player player) private void queuePlayer(int gameType, Player player)
{ {
Party party = getPlugin().getPartyManager().GetParty(player); Party party = getPlugin().getPartyManager().GetParty(player);

View File

@ -6,6 +6,7 @@ import java.util.LinkedList;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryCrafting;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryCloseEvent;
@ -27,6 +28,7 @@ import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.Skill;
import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
import net.minecraft.server.v1_8_R3.Material;
public class Recall extends Skill public class Recall extends Skill
{ {
@ -58,6 +60,11 @@ public class Recall extends Skill
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!(player.getOpenInventory().getTopInventory() instanceof CraftInventoryCrafting))
{
return;
}
int level = getLevel(player); int level = getLevel(player);
if (level == 0) if (level == 0)
return; return;

View File

@ -2,6 +2,7 @@ package mineplex.minecraft.game.classcombat.Skill.Assassin;
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import net.minecraft.server.v1_8_R3.Material;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -21,9 +22,11 @@ import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryCrafting;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
@ -56,6 +59,11 @@ public class SmokeBomb extends Skill
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!(player.getOpenInventory().getTopInventory() instanceof CraftInventoryCrafting))
{
return;
}
int level = getLevel(player); int level = getLevel(player);
if (level == 0) return; if (level == 0) return;
@ -141,6 +149,18 @@ public class SmokeBomb extends Skill
Factory.Condition().EndCondition(event.getPlayer(), null, GetName()); Factory.Condition().EndCondition(event.getPlayer(), null, GetName());
} }
@EventHandler
public void closeInv(InventoryCloseEvent event)
{
if (getLevel(event.getPlayer()) == 0)
{
return;
}
event.getPlayer().getInventory().addItem(event.getPlayer().getItemOnCursor());
event.getPlayer().setItemOnCursor(null);
}
@EventHandler @EventHandler
public void Smoke(UpdateEvent event) public void Smoke(UpdateEvent event)
{ {

View File

@ -126,6 +126,6 @@ public class HoldPosition extends SkillActive
@Override @Override
public void Reset(Player player) public void Reset(Player player)
{ {
player.setFoodLevel(20);
} }
} }

View File

@ -5,8 +5,8 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -15,6 +15,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.blockrestore.BlockRestoreMap; import mineplex.core.blockrestore.BlockRestoreMap;
@ -25,7 +26,7 @@ import mineplex.core.common.block.schematic.UtilSchematic;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTextMiddle;
@ -65,6 +66,14 @@ public abstract class WorldEvent implements Listener, ScoreboardElement
private boolean _isArcade; private boolean _isArcade;
private double _difficulty = 1; private double _difficulty = 1;
private double _minX;
private double _minY;
private double _minZ;
private double _maxX;
private double _maxY;
private double _maxZ;
public WorldEvent(DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name, Location cornerLocation) public WorldEvent(DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name, Location cornerLocation)
{ {
this(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, name, cornerLocation, null); this(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, name, cornerLocation, null);
@ -328,7 +337,6 @@ public abstract class WorldEvent implements Listener, ScoreboardElement
{ {
onComplete.run(); onComplete.run();
} }
} }
}); });
@ -407,4 +415,50 @@ public abstract class WorldEvent implements Listener, ScoreboardElement
} }
} }
public boolean isInBounds(Location location)
{
if (_minX == 0)
{
// Calculate bounds
Set<Block> blocks = _blocks.getChangedBlocks();
for (Block block : blocks)
{
if (_minX > block.getX())
{
_minX = block.getX();
}
if (_minY > block.getY())
{
_minY = block.getY();
}
if (_minZ > block.getZ())
{
_minZ = block.getZ();
}
if (_maxX < block.getX())
{
_maxX = block.getX();
}
if (_maxY < block.getY())
{
_maxY = block.getY();
}
if (_maxZ < block.getZ())
{
_maxZ = block.getZ();
}
}
_maxY++;
}
return UtilAlg.inBoundingBox(location, new Vector(_minX, _minY, _minZ), new Vector(_maxX, _maxY, _maxZ));
}
} }

View File

@ -377,9 +377,22 @@ public class ConditionEffect implements Listener
if (condition == null || condition.GetSource() == null) if (condition == null || condition.GetSource() == null)
continue; continue;
Manager.getDamagerManager().NewDamageEvent(ent, condition.GetSource(), null, try
DamageCause.CUSTOM, 0.1, false, true, false, {
condition.GetSource() != null ? condition.GetSource().getName() : "The Mighty Defek7", "Poison"); Manager.getDamagerManager().NewDamageEvent(ent, condition.GetSource(), null,
DamageCause.CUSTOM, 0.1, false, true, false,
condition.GetSource() != null ? condition.GetSource().getName() : "The Mighty Defek7", "Poison");
}
catch (Exception exception)
{
System.out.println("__+Poison error+__");
System.out.println("Manager null? : " + Manager == null);
System.out.println("Manager.getDamagerManager null? : " + Manager.getDamagerManager() == null);
System.out.println("condition.GetSource() null? : " + condition.GetSource() == null);
System.out.println("condition.GetSource().getName() null? : " + condition.GetSource().getName() == null);
throw exception;
}
} }
} }

View File

@ -53,7 +53,7 @@ public class CustomExplosion extends Explosion
private mineplex.core.explosion.Explosion _explosion; private mineplex.core.explosion.Explosion _explosion;
private float _damage; private float _damage;
private boolean _useCustomDamage; private boolean _useCustomDamage;
private int _maxFallingBlocks = -1; private int _maxFallingBlocks = 0;
private float _maxDamage = 1000; private float _maxDamage = 1000;
private float _size; private float _size;
private boolean _damageBlocks = true; private boolean _damageBlocks = true;

View File

@ -57,7 +57,7 @@ public class StaffServer extends JavaPlugin
Punish punish = new Punish(this, webServerAddress, clientManager); Punish punish = new Punish(this, webServerAddress, clientManager);
new NpcManager(this, new Creature(this)); new NpcManager(this, new Creature(this));
ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager)); ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager));
PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager); PreferencesManager preferenceManager = new PreferencesManager(this, null, clientManager, donationManager);
preferenceManager.GiveItem = false; preferenceManager.GiveItem = false;
Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName()); Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName());

View File

@ -110,7 +110,12 @@ public class Arcade extends JavaPlugin
_serverConfiguration = new ServerConfiguration(this, _clientManager); _serverConfiguration = new ServerConfiguration(this, _clientManager);
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager); PacketHandler packetHandler = new PacketHandler(this);
IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler);
PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager, _donationManager);
incognito.setPreferencesManager(preferenceManager);
Creature creature = new Creature(this); Creature creature = new Creature(this);
ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager)); ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager));
@ -118,7 +123,6 @@ public class Arcade extends JavaPlugin
Teleport teleport = new Teleport(this, _clientManager); Teleport teleport = new Teleport(this, _clientManager);
Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName()); Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName());
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
PacketHandler packetHandler = new PacketHandler(this);
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
@ -129,8 +133,6 @@ public class Arcade extends JavaPlugin
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
AntiHack.Instance.setKick(false); AntiHack.Instance.setKick(false);
IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler);
IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal);
StatsManager statsManager = new StatsManager(this, _clientManager); StatsManager statsManager = new StatsManager(this, _clientManager);
AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager); AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager);

View File

@ -1,5 +1,6 @@
package nautilus.game.arcade.game; package nautilus.game.arcade.game;
import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; 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.UtilTextMiddle;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.disguises.DisguisePlayer; 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.itemstack.ItemBuilder;
import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketInfo; import mineplex.core.packethandler.PacketInfo;
@ -310,6 +314,7 @@ public abstract class Game implements Listener
public String Winner = "Nobody"; public String Winner = "Nobody";
public GameTeam WinnerTeam = null; public GameTeam WinnerTeam = null;
//ELO
public boolean EloRanking = false; public boolean EloRanking = false;
public int EloStart = 1000; public int EloStart = 1000;
@ -1037,18 +1042,6 @@ public abstract class Game implements Listener
return SpectatorSpawn; 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 @EventHandler
public abstract void ScoreboardUpdate(UpdateEvent event); public abstract void ScoreboardUpdate(UpdateEvent event);
@ -1214,6 +1207,8 @@ public abstract class Game implements Listener
if (AnnounceSilence) if (AnnounceSilence)
Manager.GetChat().Silence(5000, false); Manager.GetChat().Silence(5000, false);
endElo();
} }
public void AnnounceEnd(List<Player> places) public void AnnounceEnd(List<Player> places)
@ -1271,6 +1266,8 @@ public abstract class Game implements Listener
if (AnnounceSilence) if (AnnounceSilence)
Manager.GetChat().Silence(5000, false); Manager.GetChat().Silence(5000, false);
endElo();
} }
public void Announce(String message) public void Announce(String message)
@ -1570,10 +1567,48 @@ public abstract class Game implements Listener
AddGems(player, 10, "Participation", false, false); AddGems(player, 10, "Participation", false, false);
} }
endElo();
// End // End
SetState(GameState.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 @EventHandler
public void handleInteractEntityPacket(GameStateChangeEvent event) 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

@ -71,7 +71,6 @@ public class ChampionsCTF extends CaptureTheFlag
InventoryOpenChest = true; InventoryOpenChest = true;
EloRanking = false;
EloStart = 1000; EloStart = 1000;
this.DontAllowOverfill = true; this.DontAllowOverfill = true;

View File

@ -66,7 +66,6 @@ public class ChampionsDominate extends Domination
InventoryOpenChest = true; InventoryOpenChest = true;
EloRanking = false;
EloStart = 1000; EloStart = 1000;
this.DontAllowOverfill = true; this.DontAllowOverfill = true;

View File

@ -66,7 +66,6 @@ public class ChampionsTDM extends TeamDeathmatch
this.StrictAntiHack = true; this.StrictAntiHack = true;
InventoryOpenChest = true; InventoryOpenChest = true;
this.DisableKillCommand = false; this.DisableKillCommand = false;
this.DontAllowOverfill = true; this.DontAllowOverfill = true;

View File

@ -551,48 +551,7 @@ public class CaptureTheFlag extends TeamGame
if (player.isOnline()) if (player.isOnline())
AddGems(player, 10, "Participation", false, false); AddGems(player, 10, "Participation", false, false);
} }
endElo();
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);
}
}
//End //End
SetState(GameState.End); SetState(GameState.End);

View File

@ -315,47 +315,7 @@ public class Domination extends TeamGame
AddGems(player, 10, "Participation", false, false); AddGems(player, 10, "Participation", false, false);
} }
if (EloRanking) endElo();
{
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);
}
}
//End //End
SetState(GameState.End); SetState(GameState.End);

View File

@ -3,11 +3,30 @@ package nautilus.game.arcade.game.games.common;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; 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.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -18,38 +37,6 @@ import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.scoreboard.Objective; 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 public class TeamDeathmatch extends TeamGame
{ {
private ArrayList<CapturePointTDM> _points = new ArrayList<CapturePointTDM>(); private ArrayList<CapturePointTDM> _points = new ArrayList<CapturePointTDM>();
@ -79,6 +66,21 @@ public class TeamDeathmatch extends TeamGame
this.WorldTimeSet = 2000; this.WorldTimeSet = 2000;
this.CompassEnabled = true; 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; this.Manager.GetDamage().UseSimpleWeaponDamage = false;
//_healthObj = GetScoreboard().registerNewObjective("HP", "dummy"); //_healthObj = GetScoreboard().registerNewObjective("HP", "dummy");
@ -334,9 +336,6 @@ public class TeamDeathmatch extends TeamGame
ScoreboardWrite(); ScoreboardWrite();
//Announce
AnnounceEnd(winner);
for (GameTeam team : GetTeamList()) for (GameTeam team : GetTeamList())
{ {
if (WinnerTeam != null && team.equals(WinnerTeam)) if (WinnerTeam != null && team.equals(WinnerTeam))
@ -350,52 +349,27 @@ public class TeamDeathmatch extends TeamGame
AddGems(player, 10, "Participation", false, false); AddGems(player, 10, "Participation", false, false);
} }
if (EloRanking) //Announce End
{ AnnounceEnd(winner);
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);
}
}
//End //End
SetState(GameState.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) @EventHandler(priority = EventPriority.HIGHEST)
public void UsableInteract(PlayerInteractEvent event) public void UsableInteract(PlayerInteractEvent event)
{ {

View File

@ -44,6 +44,9 @@ import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime; 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.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
@ -851,10 +854,13 @@ public class TurfForts extends TeamGame
AddGems(player, 10, "Participation", false, false); AddGems(player, 10, "Participation", false, false);
} }
endElo();
//End //End
SetState(GameState.End); SetState(GameState.End);
} }
public Long getEnemyTurfEntranceTime(Player player) public Long getEnemyTurfEntranceTime(Player player)
{ {
return _enemyTurf.get(player); return _enemyTurf.get(player);

View File

@ -4,6 +4,8 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Random; import java.util.Random;
import com.google.common.base.Optional;
import mineplex.core.common.util.SpigotUtil;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
@ -16,17 +18,15 @@ import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickBlock; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickBlock;
import net.minecraft.server.v1_8_R3.EntityWolf;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.AnimalTamer; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftWolf;
import org.bukkit.entity.Entity; import org.bukkit.entity.*;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
public class SpellSummonWolves extends Spell implements SpellClick, SpellClickBlock public class SpellSummonWolves extends Spell implements SpellClick, SpellClickBlock
@ -57,6 +57,7 @@ public class SpellSummonWolves extends Spell implements SpellClick, SpellClickBl
wolf.setCollarColor(DyeColor.YELLOW); wolf.setCollarColor(DyeColor.YELLOW);
wolf.setTamed(true); wolf.setTamed(true);
SpigotUtil.setOldOwner_RemoveMeWhenSpigotFixesThis(wolf, player);
wolf.setOwner(player); wolf.setOwner(player);
wolf.setBreed(false); wolf.setBreed(false);
wolf.setCustomName(player.getDisplayName() + "'s Wolf"); wolf.setCustomName(player.getDisplayName() + "'s Wolf");

View File

@ -23,15 +23,7 @@ import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.common.util.C; import mineplex.core.common.util.*;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
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.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
@ -99,6 +91,7 @@ public class PerkWolfPet extends Perk
Wolf wolf = cur.getWorld().spawn(cur.getLocation(), Wolf.class); Wolf wolf = cur.getWorld().spawn(cur.getLocation(), Wolf.class);
Manager.GetGame().CreatureAllowOverride = false; Manager.GetGame().CreatureAllowOverride = false;
SpigotUtil.setOldOwner_RemoveMeWhenSpigotFixesThis(wolf, cur);
wolf.setOwner(cur); wolf.setOwner(cur);
wolf.setCollarColor(DyeColor.GREEN); wolf.setCollarColor(DyeColor.GREEN);
wolf.playEffect(EntityEffect.WOLF_HEARTS); wolf.playEffect(EntityEffect.WOLF_HEARTS);

View File

@ -19,17 +19,13 @@ import mineplex.core.common.util.UtilBlockText.TextAlign;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilWorld;
import mineplex.core.cosmetic.event.ActivateGemBoosterEvent; import mineplex.core.cosmetic.event.ActivateGemBoosterEvent;
import mineplex.core.donation.Donor; import mineplex.core.donation.Donor;
import mineplex.core.event.CustomTagEvent; import mineplex.core.event.CustomTagEvent;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; 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.Kit;
import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.KitSorter; 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.Bukkit;
import org.bukkit.ChatColor; 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, Scoreboard> _scoreboardMap = new NautHashMap<Player, Scoreboard>();
private NautHashMap<Player, Integer> _gemMap = new NautHashMap<Player, Integer>(); private NautHashMap<Player, Integer> _gemMap = new NautHashMap<Player, Integer>();
private NautHashMap<Player, Integer> _eloMap = 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 NautHashMap<Player, String> _kitMap = new NautHashMap<Player, String>();
private int _oldPlayerCount = 0; private int _oldPlayerCount = 0;
@ -1119,14 +1113,14 @@ public class GameLobbyManager implements Listener
entry.getValue().resetScores(_kitMap.get(entry.getKey()) + ""); entry.getValue().resetScores(_kitMap.get(entry.getKey()) + "");
// Set new // Set new
objective.getScore(" ").setScore(line--); objective.getScore(" ").setScore(line--);
objective.getScore(teamColor + C.Bold + "Kit").setScore(line--); objective.getScore(teamColor + C.Bold + "Kit").setScore(line--);
objective.getScore(kitName + "").setScore(line--); objective.getScore(kitName + "").setScore(line--);
_kitMap.put(entry.getKey(), kitName + ""); _kitMap.put(entry.getKey(), kitName + "");
} }
objective.getScore(" ").setScore(line--); objective.getScore(" ").setScore(line--);
objective.getScore(C.cGreen + C.Bold + "Gems").setScore(line--); objective.getScore(C.cGreen + C.Bold + "Gems").setScore(line--);
// Remove old // Remove old
@ -1137,21 +1131,21 @@ public class GameLobbyManager implements Listener
_gemMap.put(entry.getKey(), Manager.GetDonation().Get(entry.getKey().getName()).GetGems()); _gemMap.put(entry.getKey(), Manager.GetDonation().Get(entry.getKey().getName()).GetGems());
//Server //Server
objective.getScore(" ").setScore(line--); objective.getScore(" ").setScore(line--);
objective.getScore(C.cAqua + C.Bold + "Server").setScore(line--); objective.getScore(C.cAqua + C.Bold + "Server").setScore(line--);
objective.getScore(_serverName).setScore(line--); objective.getScore(_serverName).setScore(line--);
//ELO // ELO DIVISION
if (Manager.GetGame() != null && Manager.GetGame().EloRanking) if (Manager.GetGame() != null && Manager.GetGame().EloRanking)
{ {
objective.getScore(" ").setScore(line--); objective.getScore(" ").setScore(line--);
objective.getScore(C.cPurple + C.Bold + "Elo").setScore(line--); objective.getScore(C.cPurpleB + C.Bold + "Division").setScore(line--);
// Remove old // Remove old
entry.getValue().resetScores(_eloMap.get(entry.getKey()) + " "); entry.getValue().resetScores(_divisionMap.get(entry.getKey()) + " ");
// Set new // 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--);
} }
} }