diff --git a/Plugins/BuildFiles/common.xml b/Plugins/BuildFiles/common.xml
index 4c3d6b432..103162fb8 100644
--- a/Plugins/BuildFiles/common.xml
+++ b/Plugins/BuildFiles/common.xml
@@ -146,6 +146,9 @@
+
+
+
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java
index 0c1cb1b21..010f18448 100644
--- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java
@@ -207,6 +207,12 @@ public class UtilParticle
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleName, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count, displayFar);
return packet;
}
+
+ public static void PlayParticle(ParticleType type,Location location, float offsetX, float offsetY,
+ float offsetZ, float speed, int count, ViewDist dist)
+ {
+ PlayParticle(type, location, offsetX, offsetY, offsetZ, speed, count, dist, UtilServer.getPlayers());
+ }
public static void PlayParticle(ParticleType type,Location location, float offsetX, float offsetY, float offsetZ,
float speed, int count, ViewDist dist, Player... players)
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java
index b8ccbce3b..a2a6c4fd1 100644
--- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java
@@ -516,6 +516,14 @@ public class UtilPlayer
if (log)
System.out.println("Kicked Client [" + player.getName() + "] for [" + module + " - " + message + "]");
}
+
+ public static void kick(Collection players, String module, String message, boolean log)
+ {
+ for (Player player : players)
+ {
+ kick(player, module, message, log);
+ }
+ }
public static HashMap getInRadius(Location loc, double dR)
{
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java
index 62448d59b..c2a3c40ab 100644
--- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java
@@ -82,9 +82,9 @@ public class UtilWorld
if (cur.getName().equalsIgnoreCase(parts[0]))
{
int x = Integer.parseInt(parts[1]);
- int y = Integer.parseInt(parts[1]);
- int z = Integer.parseInt(parts[1]);
- cur.getBlockAt(x, y, z);
+ int y = Integer.parseInt(parts[2]);
+ int z = Integer.parseInt(parts[3]);
+ return cur.getBlockAt(x, y, z);
}
}
}
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/DisplayButton.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/DisplayButton.java
similarity index 80%
rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/DisplayButton.java
rename to Plugins/Mineplex.Core/src/mineplex/core/shop/item/DisplayButton.java
index f2e04bb5e..9697e4934 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/DisplayButton.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/DisplayButton.java
@@ -1,11 +1,10 @@
-package mineplex.game.clans.shop.bank;
+package mineplex.core.shop.item;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.shop.item.IButton;
-import mineplex.game.clans.economy.GoldManager;
public class DisplayButton implements IButton
{
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java
index bb41d48a5..4b01a608a 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java
@@ -229,7 +229,7 @@ public abstract class ShopPageBase
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Plugins/Mineplex.Game.Clans.Core/.project b/Plugins/Mineplex.Game.Clans.Core/.project
new file mode 100644
index 000000000..fb0cce853
--- /dev/null
+++ b/Plugins/Mineplex.Game.Clans.Core/.project
@@ -0,0 +1,17 @@
+
+
+ Mineplex.Game.Clans.Core
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClanServerChangeCommand.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClanServerChangeCommand.java
new file mode 100644
index 000000000..6a4422bd5
--- /dev/null
+++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClanServerChangeCommand.java
@@ -0,0 +1,29 @@
+package mineplex.game.clans.core;
+
+import mineplex.game.clans.core.repository.tokens.SimpleClanToken;
+import mineplex.serverdata.commands.ServerCommand;
+
+
+public class ClanServerChangeCommand extends ServerCommand
+{
+ private String _clanName;
+ public String getClanName() { return _clanName; }
+
+ public ClanServerChangeCommand(String serverName, String clanName)
+ {
+ super(serverName);
+
+ _clanName = clanName;
+ }
+
+ public ClanServerChangeCommand(SimpleClanToken clan)
+ {
+ this(clan.getHomeServer(), clan.getClanName());
+ }
+
+ @Override
+ public void run()
+ {
+ // Utilitizes a callback functionality to seperate dependencies
+ }
+}
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/ClanRepository.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java
similarity index 77%
rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/ClanRepository.java
rename to Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java
index 2696addd0..2c757ecfa 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/ClanRepository.java
+++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java
@@ -1,4 +1,4 @@
-package mineplex.game.clans.clans.repository;
+package mineplex.game.clans.core.repository;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -9,9 +9,7 @@ import java.sql.Timestamp;
import java.util.Collection;
import java.util.UUID;
-import org.bukkit.Bukkit;
-import org.bukkit.plugin.java.JavaPlugin;
-
+import mineplex.core.common.util.Callback;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.database.DBPool;
import mineplex.core.database.RepositoryBase;
@@ -22,13 +20,15 @@ import mineplex.core.database.column.ColumnInt;
import mineplex.core.database.column.ColumnTimestamp;
import mineplex.core.database.column.ColumnVarChar;
import mineplex.database.tables.records.ClansRecord;
-import mineplex.game.clans.clans.ClanInfo;
-import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken;
-import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken;
-import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
-import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
-import mineplex.game.clans.clans.repository.tokens.ClanToken;
-
+import mineplex.game.clans.core.repository.tokens.ClanAllianceToken;
+import mineplex.game.clans.core.repository.tokens.ClanEnemyToken;
+import mineplex.game.clans.core.repository.tokens.ClanMemberToken;
+import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken;
+import mineplex.game.clans.core.repository.tokens.ClanToken;
+import mineplex.game.clans.core.repository.tokens.SimpleClanToken;
+
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.java.JavaPlugin;
import org.jooq.DSLContext;
import static mineplex.database.Tables.*;
@@ -41,7 +41,10 @@ public class ClanRepository extends RepositoryBase
private static String CREATE_CLAN_TERRITORY_TABLE = "CREATE TABLE IF NOT EXISTS clanTerritory (id INT NOT NULL AUTO_INCREMENT, clanId INT, serverId INT NOT NULL, chunk VARCHAR(100), safe BIT(1), PRIMARY KEY (id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId, serverId));";
private static String CREATE_CLAN_ALLIANCE_TABLE = "CREATE TABLE IF NOT EXISTS clanAlliances (id INT NOT NULL AUTO_INCREMENT, clanId INT, otherClanId INT, trusted BIT(1), PRIMARY KEY (id), FOREIGN KEY (otherClanId) REFERENCES clans(id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId));";
- private static String RETRIEVE_START_CLAN_INFO = "SELECT c.id, c.name, c.description, c.home, c.admin, c.energy, c.kills, c.murder, c.deaths, c.warWins, c.warLosses, c.dateCreated, c.lastOnline, ct.chunk, ct.safe FROM clans AS c LEFT JOIN clanTerritory AS ct ON ct.clanId = c.id WHERE c.serverId = ?;";
+ private static String RETRIEVE_CLAN_INFO = "SELECT c.id, c.name, c.description, c.home, c.admin, c.energy, c.kills, c.murder, c.deaths, c.warWins, c.warLosses, c.dateCreated, c.lastOnline FROM clans AS c WHERE lower(c.name) = ?;";
+ private static String RETRIEVE_PLAYER_CLAN_INFO = "SELECT clans.name, accountClan.clanRole, clanServer.serverName, clans.id FROM accountClan INNER JOIN clans ON clans.id = accountClan.clanId INNER JOIN clanServer ON clans.serverId = clanServer.id WHERE accountClan.accountId = ?;";
+ private static String RETRIEVE_START_CLAN_INFO = "SELECT c.id, c.name, c.description, c.home, c.admin, c.energy, c.kills, c.murder, c.deaths, c.warWins, c.warLosses, c.generator, c.generatorStock, c.dateCreated, c.lastOnline, ct.chunk, ct.safe FROM clans AS c LEFT JOIN clanTerritory AS ct ON ct.clanId = c.id WHERE c.serverId = ?;";
+
private static String RETRIEVE_CLAN_MEMBER_INFO = "SELECT c.name, a.name, a.uuid, clanRole FROM accountClan AS ac INNER JOIN accounts AS a ON a.id = ac.accountId INNER JOIN clans AS c on c.id = ac.clanId WHERE c.serverId = ?;";
private static String RETRIEVE_CLAN_ALLIANCE_INFO = "SELECT c.name, cOther.name, ca.trusted FROM clanAlliances AS ca INNER JOIN clans AS c ON c.id = ca.clanId INNER JOIN clans as cOther ON cOther.id = ca.otherClanId WHERE c.serverId = ?;";
private static String RETRIEVE_CLAN_ENEMY_INFO = "SELECT c.name, cOther.name, clanScore, otherClanScore, clanKills, otherClanKills, timeFormed FROM clanEnemies AS ce INNER JOIN clans AS c ON c.id = ce.clanId INNER JOIN clans as cOther ON cOther.id = ce.otherClanId WHERE c.serverId = ?;";
@@ -53,7 +56,7 @@ public class ClanRepository extends RepositoryBase
private static String DELETE_CLAN_TERRITORIES = "DELETE FROM clanTerritory WHERE clanId = ?;";
private static String DELETE_CLAN_ALLIANCE = "DELETE FROM clanAlliances WHERE clanId = ? AND otherClanId = ?;";
private static String DELETE_CLAN_ALLIANCES = "DELETE FROM clanAlliances WHERE clanId = ? OR otherClanId = ?;";
- private static String DELETE_CLAN_ENEMY = "DELETE FROM clanEnemies WHERE clanId = ? OR otherClanId = ?;";
+ private static String DELETE_CLAN_ENEMIES = "DELETE FROM clanEnemies WHERE clanId = ? OR otherClanId = ?;";
private static String DELETE_CLAN = "DELETE FROM clans WHERE id = ?;";
private static String ADD_CLAN = "INSERT INTO clans (serverId, name, description, home, admin, dateCreated, energy, lastOnline) VALUES (?, ?, ?, ?, ?, now(), ?, now());";
@@ -67,7 +70,8 @@ public class ClanRepository extends RepositoryBase
private static String UPDATE_CLAN_ALLIANCE = "UPDATE clanAlliances SET trusted = ? WHERE clanId = ? AND otherClanId = ?;";
private static String UPDATE_CLAN_ENEMY = "UPDATE clanEnemies SET clanScore = ?, otherClanScore = ?, clanKills = ?, otherClanKills = ? WHERE clanId = ? AND otherClanId = ?;";
private static String UPDATE_CLAN_TERRITORY = "UPDATE clanTerritory SET safe = ? WHERE serverId = ? AND chunk = ?;";
- private static String UPDATE_CLAN_GENERATOR = "UPDATE clans SET generator = ?, generatorCount = ? WHERE id = ?;";
+ private static String UPDATE_CLAN_SERVER_ID = "UPDATE clans SET serverId = ?, home = '' WHERE id = ?;";
+ private static String UPDATE_CLAN_GENERATOR = "UPDATE clans SET generator = ?, generatorStock = ? WHERE id = ?;";
private static String GET_CLAN_SERVER = "SELECT id FROM clanServer WHERE clanServer.serverName = ?";
private static String ADD_CLAN_SERVER = "INSERT INTO clanServer (serverName) VALUES (?);";
@@ -80,7 +84,7 @@ public class ClanRepository extends RepositoryBase
super(plugin, DBPool.ACCOUNT);
_serverName = serverName;
- _serverId = -1;
+ _serverId = -1;
loadServerId();
}
@@ -125,7 +129,106 @@ public class ClanRepository extends RepositoryBase
executeUpdate(CREATE_CLAN_TERRITORY_TABLE);
executeUpdate(CREATE_CLAN_ALLIANCE_TABLE);
}
+
+ /**
+ * Updates a clan's home server while removing all
+ * alliances, enemies, teritory claims and homes set on
+ * originating server.
+ * @param clanId - the id of the clan to move
+ * @param serverId - the id of the destination server being moved to
+ */
+ public void moveClanServer(final int clanId, String serverName, final Callback callback)
+ {
+ executeQuery(GET_CLAN_SERVER, new ResultSetCallable()
+ {
+ @Override
+ public void processResultSet(ResultSet resultSet) throws SQLException
+ {
+ boolean success = resultSet.next();
+
+ if (success)
+ {
+ int serverId = resultSet.getInt(1);
+ ColumnInt clanIdCol = new ColumnInt("clanId", clanId);
+ ColumnInt serverIdCol = new ColumnInt("serverId", serverId);
+
+ executeUpdate(DELETE_CLAN_ALLIANCES, clanIdCol, clanIdCol);
+ executeUpdate(DELETE_CLAN_ENEMIES, clanIdCol, clanIdCol);
+ executeUpdate(DELETE_CLAN_TERRITORIES, clanIdCol);
+ executeUpdate(UPDATE_CLAN_SERVER_ID, serverIdCol, clanIdCol);
+ }
+
+ callback.run(success);
+ }
+ }, new ColumnVarChar("serverName", 100, serverName));
+
+ }
+
+ public void retrieveClan(String clanName, final Callback callback)
+ {
+ executeQuery(RETRIEVE_CLAN_INFO, new ResultSetCallable()
+ {
+ @Override
+ public void processResultSet(ResultSet resultSet) throws SQLException
+ {
+ if (resultSet.next())
+ {
+ ClanToken token = new ClanToken();
+ token.Id = resultSet.getInt(1);
+ token.Name = resultSet.getString(2);
+ token.Description = resultSet.getString(3);
+ token.Home = resultSet.getString(4);
+ token.Admin = resultSet.getBoolean(5);
+ token.Energy = resultSet.getInt(6);
+ token.Kills = resultSet.getInt(7);
+ token.Murder = resultSet.getInt(8);
+ token.Deaths = resultSet.getInt(9);
+ token.WarWins = resultSet.getInt(10);
+ token.WarLosses = resultSet.getInt(11);
+ token.DateCreated = resultSet.getTimestamp(12);
+ token.LastOnline = resultSet.getTimestamp(13);
+
+ callback.run(token);
+ }
+ }
+ }, new ColumnVarChar("name", 100, clanName.toLowerCase()));
+ }
+
+ public void clanExists(String clanName, final Callback callback)
+ {
+ executeQuery(RETRIEVE_CLAN_INFO, new ResultSetCallable()
+ {
+ @Override
+ public void processResultSet(ResultSet resultSet) throws SQLException
+ {
+ boolean clanExists = resultSet.next();
+ callback.run(clanExists);
+ }
+ }, new ColumnVarChar("name", 100, clanName.toLowerCase()));
+ }
+ public void retrievePlayersClan(int accountId, final Callback callback)
+ {
+ executeQuery(RETRIEVE_PLAYER_CLAN_INFO, new ResultSetCallable()
+ {
+ @Override
+ public void processResultSet(ResultSet resultSet) throws SQLException
+ {
+ SimpleClanToken clanToken = null;
+ if (resultSet.next())
+ {
+ String clanName = resultSet.getString(1);
+ String clanRole = resultSet.getString(2);
+ String homeServer = resultSet.getString(3);
+ int clanId = resultSet.getInt(4);
+ clanToken = new SimpleClanToken(clanName, clanRole, homeServer, clanId);
+ }
+
+ callback.run(clanToken);
+ }
+ }, new ColumnInt("accountId", accountId));
+ }
+
public Collection retrieveClans()
{
System.out.println("Beginning to load clans from database...");
@@ -150,13 +253,15 @@ public class ClanRepository extends RepositoryBase
token.Deaths = resultSet.getInt(9);
token.WarWins = resultSet.getInt(10);
token.WarLosses = resultSet.getInt(11);
- token.DateCreated = resultSet.getTimestamp(12);
- token.LastOnline = resultSet.getTimestamp(13);
+ token.Generator = resultSet.getString(12);
+ token.GeneratorStock = resultSet.getInt(13);
+ token.DateCreated = resultSet.getTimestamp(14);
+ token.LastOnline = resultSet.getTimestamp(15);
ClanTerritoryToken territoryToken = new ClanTerritoryToken();
territoryToken.ClanName = token.Name;
- territoryToken.Chunk = resultSet.getString(14);
- territoryToken.Safe = resultSet.getBoolean(15);
+ territoryToken.Chunk = resultSet.getString(16);
+ territoryToken.Safe = resultSet.getBoolean(17);
if (!clans.containsKey(token.Name))
{
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/ClanTerritory.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanTerritory.java
similarity index 72%
rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/ClanTerritory.java
rename to Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanTerritory.java
index c13d2a36c..1ee9303a1 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/ClanTerritory.java
+++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanTerritory.java
@@ -1,6 +1,6 @@
-package mineplex.game.clans.clans.repository;
+package mineplex.game.clans.core.repository;
-import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
+import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken;
public class ClanTerritory
{
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanAllianceToken.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/tokens/ClanAllianceToken.java
similarity index 61%
rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanAllianceToken.java
rename to Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/tokens/ClanAllianceToken.java
index fe4520969..c749feec1 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanAllianceToken.java
+++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/tokens/ClanAllianceToken.java
@@ -1,4 +1,4 @@
-package mineplex.game.clans.clans.repository.tokens;
+package mineplex.game.clans.core.repository.tokens;
public class ClanAllianceToken
{
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanEnemyToken.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/tokens/ClanEnemyToken.java
similarity index 77%
rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanEnemyToken.java
rename to Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/tokens/ClanEnemyToken.java
index 3aa201763..8fb9e1ed1 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanEnemyToken.java
+++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/tokens/ClanEnemyToken.java
@@ -1,4 +1,4 @@
-package mineplex.game.clans.clans.repository.tokens;
+package mineplex.game.clans.core.repository.tokens;
import java.sql.Timestamp;
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanMemberToken.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/tokens/ClanMemberToken.java
similarity index 70%
rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanMemberToken.java
rename to Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/tokens/ClanMemberToken.java
index 4af96feb0..9fab8c68a 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanMemberToken.java
+++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/tokens/ClanMemberToken.java
@@ -1,4 +1,4 @@
-package mineplex.game.clans.clans.repository.tokens;
+package mineplex.game.clans.core.repository.tokens;
import java.util.UUID;
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanTerritoryToken.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/tokens/ClanTerritoryToken.java
similarity index 74%
rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanTerritoryToken.java
rename to Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/tokens/ClanTerritoryToken.java
index 5b7ca2108..d7c6cbfde 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanTerritoryToken.java
+++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/tokens/ClanTerritoryToken.java
@@ -1,4 +1,4 @@
-package mineplex.game.clans.clans.repository.tokens;
+package mineplex.game.clans.core.repository.tokens;
public class ClanTerritoryToken
{
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanToken.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/tokens/ClanToken.java
similarity index 86%
rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanToken.java
rename to Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/tokens/ClanToken.java
index d739ceb69..0dfbba08d 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/repository/tokens/ClanToken.java
+++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/tokens/ClanToken.java
@@ -1,4 +1,4 @@
-package mineplex.game.clans.clans.repository.tokens;
+package mineplex.game.clans.core.repository.tokens;
import java.sql.Timestamp;
import java.util.ArrayList;
@@ -17,6 +17,8 @@ public class ClanToken
public int Deaths;
public int WarWins;
public int WarLosses;
+ public String Generator;
+ public int GeneratorStock;
public Timestamp DateCreated;
public Timestamp LastOnline;
diff --git a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/tokens/SimpleClanToken.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/tokens/SimpleClanToken.java
new file mode 100644
index 000000000..70757bd98
--- /dev/null
+++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/tokens/SimpleClanToken.java
@@ -0,0 +1,25 @@
+package mineplex.game.clans.core.repository.tokens;
+
+public class SimpleClanToken
+{
+
+ private String _clanName;
+ public String getClanName() { return _clanName; }
+
+ private String _clanRole;
+ public String getClanRole() { return _clanRole; }
+
+ private String _homeServer;
+ public String getHomeServer() { return _homeServer; }
+
+ private int _clanId;
+ public int getClanId() { return _clanId; }
+
+ public SimpleClanToken(String clanName, String clanRole, String homeServer, int clanId)
+ {
+ _clanName = clanName;
+ _clanRole = clanRole;
+ _homeServer = homeServer;
+ _clanId = clanId;
+ }
+}
diff --git a/Plugins/Mineplex.Game.Clans/.classpath b/Plugins/Mineplex.Game.Clans/.classpath
index 33cd9fb00..4a7e01944 100644
--- a/Plugins/Mineplex.Game.Clans/.classpath
+++ b/Plugins/Mineplex.Game.Clans/.classpath
@@ -11,5 +11,6 @@
+
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java
index 2c042ed8b..f3b93409e 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java
@@ -9,6 +9,7 @@ import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.Sound;
+import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
@@ -21,11 +22,12 @@ import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
-import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken;
-import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken;
-import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
-import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
-import mineplex.game.clans.clans.repository.tokens.ClanToken;
+import mineplex.game.clans.core.repository.tokens.ClanAllianceToken;
+import mineplex.game.clans.core.repository.tokens.ClanEnemyToken;
+import mineplex.game.clans.core.repository.tokens.ClanMemberToken;
+import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken;
+import mineplex.game.clans.core.repository.tokens.ClanToken;
+
import mineplex.game.clans.clans.tntGenerator.TntGenerator;
public class ClanInfo
@@ -80,6 +82,23 @@ public class ClanInfo
catch (Exception e)
{
+ }
+
+ try
+ {
+ if (token.Generator != null && token.Generator.length() > 0)
+ {
+ Block block = UtilWorld.strToBlock(token.Generator);
+ if (block != null)
+ {
+ _generator = new TntGenerator(block);
+ _generator.setStock(token.GeneratorStock);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+
}
_energy = token.Energy;
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java
index 67273393c..9b4e17bdc 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java
@@ -9,7 +9,7 @@ import mineplex.core.common.util.UtilInput;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilWorld;
-import mineplex.game.clans.clans.repository.ClanTerritory;
+import mineplex.game.clans.core.repository.ClanTerritory;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java
index ebfb9ed7a..94304525a 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java
@@ -12,14 +12,16 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.sun.org.apache.xpath.internal.operations.Bool;
+
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilWorld;
+import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
+import mineplex.game.clans.core.repository.ClanRepository;
+import mineplex.game.clans.core.repository.ClanTerritory;
+import mineplex.game.clans.core.repository.tokens.ClanEnemyToken;
+import mineplex.game.clans.core.repository.tokens.ClanToken;
import mineplex.game.clans.clans.event.ClanDeleteEvent;
-import mineplex.game.clans.clans.repository.ClanRepository;
-import mineplex.game.clans.clans.repository.ClanTerritory;
-import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken;
-import mineplex.game.clans.clans.repository.tokens.ClanToken;
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
import mineplex.game.clans.clans.tntGenerator.TntGenerator;
@@ -45,47 +47,55 @@ public class ClansDataAccessLayer
{
final boolean out = _repository.deleteClan(clan.getId());
- runSync(new Runnable()
+ if (out)
{
- @Override
- public void run()
+ runSync(new Runnable()
{
- if (out)
+ @Override
+ public void run()
{
- //Territory Unclaim
- for (String cur : clan.getClaimSet())
- _manager.getClaimMap().remove(cur);
-
- _manager.getClanMap().remove(clan.getName());
-
- for (String cur : clan.getMembers().keySet())
- {
- _manager.getClanMemberMap().remove(cur);
- }
-
- //Clean from Others
- for (ClanInfo cur : _manager.getClanMap().values())
- {
- cur.getAllyMap().remove(clan.getName());
- cur.getRequestMap().remove(clan.getName());
- }
-
- //Scoreboard
- _scoreboard.refresh(clan);
-
- //Log
- _manager.log("Deleted [" + clan.getName() + "].");
-
- ClanDeleteEvent event = new ClanDeleteEvent(clan);
- Bukkit.getServer().getPluginManager().callEvent(event);
+ deleteLocally(clan);
+
+ if (callback != null) callback.run(out);
}
+ });
+ }
- if (callback != null) callback.run(out);
- }
- });
}
});
}
+
+ public void deleteLocally(ClanInfo clan)
+ {
+ //Territory Unclaim
+ for (String cur : clan.getClaimSet())
+ {
+ _manager.getClaimMap().remove(cur);
+ }
+
+ _manager.getClanMap().remove(clan.getName());
+
+ for (String cur : clan.getMembers().keySet())
+ {
+ _manager.getClanMemberMap().remove(cur);
+ }
+
+ //Clean from Others
+ for (ClanInfo cur : _manager.getClanMap().values())
+ {
+ cur.getAllyMap().remove(clan.getName());
+ cur.getRequestMap().remove(clan.getName());
+ }
+
+ //Scoreboard
+ _scoreboard.refresh(clan);
+
+ //Log
+ _manager.log("Deleted [" + clan.getName() + "].");
+
+ ClanDeleteEvent event = new ClanDeleteEvent(clan);
+ Bukkit.getServer().getPluginManager().callEvent(event);
+ }
public void createAndJoin(final Player player, final String name, final Callback callback)
{
@@ -674,6 +684,16 @@ public class ClansDataAccessLayer
_manager.log("Safe Zone at [" + claim.Chunk + "] set to [" + claim.Safe + "] by [" + player + "].");
}
+ public void retrieveClan(String clanName, Callback callback)
+ {
+ _repository.retrieveClan(clanName, callback);
+ }
+
+ public void clanExists(String clanName, Callback callback)
+ {
+ _repository.clanExists(clanName, callback);
+ }
+
public ClanRepository getRepository()
{
return _repository;
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java
index 438bcf71e..f16010650 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java
@@ -13,7 +13,7 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
-import mineplex.game.clans.clans.repository.ClanTerritory;
+import mineplex.game.clans.core.repository.ClanTerritory;
import org.bukkit.Chunk;
import org.bukkit.Material;
@@ -33,7 +33,7 @@ public class ClansDisplay extends MiniPlugin
Clans = clans;
}
-
+
@EventHandler
public void Update(UpdateEvent event)
{
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java
index 1619e4b75..b566859da 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java
@@ -199,10 +199,10 @@ public class ClansGame extends MiniPlugin
((Player) event.getEntity()).setSaturation(3.8F); // While not entirely accurate, this is a pretty good guess at original food level changes
}
- @EventHandler(priority = EventPriority.LOW)
+ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void BlockBreak(BlockBreakEvent event)
{
- if (event.isCancelled() || event.getPlayer().getWorld().getEnvironment() != Environment.NORMAL || event.getPlayer().getGameMode() == GameMode.CREATIVE)
+ if (event.getPlayer().getWorld().getEnvironment() != Environment.NORMAL || event.getPlayer().getGameMode() == GameMode.CREATIVE)
return;
String mimic = Clans.Get(event.getPlayer()).getMimic();
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java
index dd4dfc1b1..9928c0433 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java
@@ -27,7 +27,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_7_R4.EnumToolMaterial;
import net.minecraft.server.v1_7_R4.Item;
import net.minecraft.server.v1_7_R4.ItemSword;
-
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
@@ -65,16 +64,18 @@ import mineplex.game.clans.clans.commands.ServerTimeCommand;
import mineplex.game.clans.clans.loot.LootManager;
import mineplex.game.clans.clans.map.ItemMapManager;
import mineplex.game.clans.clans.murder.MurderManager;
+import mineplex.game.clans.clans.redis.ClanServerChangeHandler;
import mineplex.game.clans.clans.regions.ClansRegions;
-import mineplex.game.clans.clans.repository.ClanTerritory;
-import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
-import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
-import mineplex.game.clans.clans.repository.tokens.ClanToken;
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager;
import mineplex.game.clans.clans.war.WarManager;
import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.clans.worldevent.WorldEventManager;
+import mineplex.game.clans.core.ClanServerChangeCommand;
+import mineplex.game.clans.core.repository.ClanTerritory;
+import mineplex.game.clans.core.repository.tokens.ClanMemberToken;
+import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken;
+import mineplex.game.clans.core.repository.tokens.ClanToken;
import mineplex.game.clans.fields.Field;
import mineplex.game.clans.gameplay.Gameplay;
import mineplex.game.clans.gameplay.safelog.LoggingManager;
@@ -96,13 +97,19 @@ import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import mineplex.minecraft.game.core.fire.Fire;
import mineplex.minecraft.game.core.mechanics.Weapon;
+import mineplex.serverdata.Region;
+import mineplex.serverdata.commands.ServerCommandManager;
+import mineplex.serverdata.redis.RedisDataRepository;
+import mineplex.serverdata.servers.ConnectionData;
+import mineplex.serverdata.servers.ServerManager;
public class ClansManager extends MiniClientPlugin implements IRelation
{
- public static final int FIELD_RADIUS = 128;
public static final int CLAIMABLE_RADIUS = 800;
public static final int WORLD_RADIUS = 1200;
private static final TimeZone TIME_ZONE = TimeZone.getDefault();
+ private static ClansManager _instance;
+ public static ClansManager getInstance() { return _instance; }
private String _serverName;
@@ -155,6 +162,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat
{
super("Clans Manager", plugin);
+ _instance = this;
_serverName = serverName;
_clientManager = clientManager;
_combatManager = new CombatManager(plugin);
@@ -194,7 +202,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat
// TODO: Re-enable customtagfix with NCP update?
//new CustomTagFix(plugin, packetHandler);
- new Field(plugin, creature, _condition, energy, serverName);
+ new Field(plugin, creature, _condition, this, energy, serverName);
// Required managers to be initialized
new Spawn(plugin, this);
@@ -217,6 +225,9 @@ public class ClansManager extends MiniClientPlugin implements IRelat
skillManager.removeSkill("Shield Smash");
_classManager = new ClassManager(plugin, _clientManager, donationManager, skillManager, itemFactory, webServerAddress);
+ // Register redis based server commands
+ ServerCommandManager.getInstance().registerCommandType(ClanServerChangeCommand.class, new ClanServerChangeHandler());
+
StatsManager statsManager = new StatsManager(plugin, _clientManager);
AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, donationManager);
ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager);
@@ -236,6 +247,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat
_claimMap.put(territoryToken.Chunk, new ClanTerritory(territoryToken));
}
+ //RedisDataRepository(ConnectionData writeConn, ConnectionData readConn, Region region, Class elementType, String elementLabel)
// Initialize default region factions and territory (spawn/fields/borderlands)
_clanRegions = new ClansRegions(plugin, this);
_clanRegions.initializeRegions();
@@ -298,17 +310,13 @@ public class ClansManager extends MiniClientPlugin implements IRelat
int x = Math.abs(location.getBlockX());
int z = Math.abs(location.getBlockZ());
- return (x > FIELD_RADIUS || z > FIELD_RADIUS)
- && (x <= CLAIMABLE_RADIUS && z <= CLAIMABLE_RADIUS)
+ return (x <= CLAIMABLE_RADIUS && z <= CLAIMABLE_RADIUS)
&& !Spawn.getInstance().isInSpawn(location);
}
- public static boolean isFields(Location location)
+ public boolean isFields(Location location)
{
- int x = Math.abs(location.getBlockX());
- int z = Math.abs(location.getBlockZ());
-
- return x <= FIELD_RADIUS && z <= FIELD_RADIUS;
+ return getClanUtility().isSpecial(location, "Fields");
}
public boolean canUnclaimChunk(ClanInfo stealer, ClanInfo owner)
@@ -750,7 +758,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat
e.printStackTrace();
}
catch (IllegalAccessException e)
- {
+ {
e.printStackTrace();
}
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java
index 61b6ce377..7b74ca122 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java
@@ -18,7 +18,7 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
-import mineplex.game.clans.clans.repository.ClanTerritory;
+import mineplex.game.clans.core.repository.ClanTerritory;
public class ClansUtility
{
@@ -430,9 +430,10 @@ public class ClansUtility
public ClanRelation relPT(String pA, String tB)
{
ClanTerritory claim = getClaim(tB);
- if (claim != null)
- if (claim.Safe)
- return ClanRelation.SAFE;
+ if (claim != null && claim.Safe)
+ {
+ return ClanRelation.SAFE;
+ }
return rel(getClanByPlayer(pA), getOwner(tB));
}
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java
index 93c7d9324..6dd3aa8ec 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java
@@ -24,6 +24,7 @@ import mineplex.game.clans.clans.ClansBlacklist;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.ClientClan;
+import mineplex.game.clans.core.repository.tokens.ClanToken;
public class ClansCommand extends CommandBase
{
@@ -69,7 +70,7 @@ public class ClansCommand extends CommandBase
else if (args[0].equalsIgnoreCase("demote") || args[0].equalsIgnoreCase("-"))
demote(caller, args);
-
+
else if (args[0].equalsIgnoreCase("join") || args[0].equalsIgnoreCase("j"))
join(caller, args);
@@ -285,35 +286,39 @@ public class ClansCommand extends CommandBase
{
UtilPlayer.message(caller, F.main("Clans", "Clan name cannot be a Clan command."));
return;
- }
+ }
}
- for (String cur : Plugin.getClanMap().keySet())
- {
- if (cur.equalsIgnoreCase(args[1]))
- {
- UtilPlayer.message(caller, F.main("Clans", "Clan name is already in use by another Clan."));
- return;
- }
- }
-
- Plugin.getClanDataAccess().createAndJoin(caller, args[1], new Callback()
- {
- @Override
- public void run(ClanInfo data)
- {
- if (data != null)
+ Plugin.getClanDataAccess().clanExists(args[1], new Callback()
{
- //Inform
- UtilServer.broadcast(F.main("Clans", F.name(caller.getName()) + " formed " + F.elem("Clan " + args[1]) + "."));
- }
- else
- {
- // Hopefully shouldn't happen!
- UtilPlayer.message(caller, F.main("Clans", "There was an error creating the clan. Please try again"));
- }
- }
- });
+ @Override
+ public void run(Boolean clanExists)
+ {
+ if (clanExists)
+ {
+ UtilPlayer.message(caller, F.main("Clans", "Clan name is already in use by another Clan."));
+ }
+ else
+ {
+ Plugin.getClanDataAccess().createAndJoin(caller, args[1], new Callback()
+ {
+ @Override
+ public void run(ClanInfo data)
+ {
+ if (data != null)
+ {
+ //Inform
+ UtilServer.broadcast(F.main("Clans", F.name(caller.getName()) + " formed " + F.elem("Clan " + args[1]) + "."));
+ }
+ else
+ {
+ // Hopefully shouldn't happen!
+ UtilPlayer.message(caller, F.main("Clans", "There was an error creating the clan. Please try again"));
+ }
+ }
+ });
+ }
+ }});
}
public void delete(final Player caller, String[] args)
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java
index 9c6561ab2..9fd73a193 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java
@@ -23,7 +23,7 @@ public class ClansLoginManager extends MiniPlugin implements ILoginProcessor
super("Clans Login Manager", plugin);
_serverName = serverName;
- _enabled = false;
+ _enabled = true;
clientManager.addStoredProcedureLoginProcessor(this);
}
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/murder/MurderManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/murder/MurderManager.java
index 985095a88..64637f164 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/murder/MurderManager.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/murder/MurderManager.java
@@ -21,7 +21,7 @@ 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.repository.ClanTerritory;
+import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.minecraft.game.core.combat.CombatComponent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/redis/ClanServerChangeHandler.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/redis/ClanServerChangeHandler.java
new file mode 100644
index 000000000..6e794960c
--- /dev/null
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/redis/ClanServerChangeHandler.java
@@ -0,0 +1,29 @@
+package mineplex.game.clans.clans.redis;
+
+import mineplex.core.common.util.UtilPlayer;
+import mineplex.game.clans.clans.ClanInfo;
+import mineplex.game.clans.clans.ClansManager;
+import mineplex.game.clans.core.ClanServerChangeCommand;
+import mineplex.serverdata.commands.CommandCallback;
+import mineplex.serverdata.commands.ServerCommand;
+
+public class ClanServerChangeHandler implements CommandCallback
+{
+
+ public void run(ServerCommand command)
+ {
+ if (command instanceof ClanServerChangeCommand)
+ {
+ ClanServerChangeCommand serverCommand = (ClanServerChangeCommand) command;
+ String clanName = serverCommand.getClanName();
+ ClanInfo clanInfo = ClansManager.getInstance().getClan(clanName);
+
+ if (clanInfo != null)
+ {
+ // Kick all online players from clan and delete clan info locally
+ UtilPlayer.kick(clanInfo.getOnlinePlayers(), "Clans", "Your clan leader has moved your clan to another server!", true);
+ ClansManager.getInstance().getClanDataAccess().deleteLocally(clanInfo);
+ }
+ }
+ }
+}
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java
index 2db1d2926..30634c061 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java
@@ -62,7 +62,9 @@ public class ClansRegions extends MiniPlugin
Location worldCenter = new Location(_world, 0, 0, 0);
// Initialize Spawn faction and claims
- claimArea("Spawn", SPAWN_RADIUS, 0, true, new Location[]{Spawn.getNorthSpawn(), Spawn.getSouthSpawn()});
+ claimArea("Spawn", SPAWN_RADIUS, 1, false, new Location[]{Spawn.getNorthSpawn(), Spawn.getSouthSpawn()}); // Claim unsafe area around
+ claimArea("Spawn", SPAWN_RADIUS, 0, true, new Location[]{Spawn.getNorthSpawn(), Spawn.getSouthSpawn()}); // Claim the centre safe chunk
+
claimArea("Shops", SHOP_RADIUS, 0, true, new Location[]{Spawn.getEastShop(), Spawn.getWestShop()});
// Initialize Fields and Borderlands factions and claims
@@ -162,6 +164,11 @@ public class ClansRegions extends MiniPlugin
}
}
+ /*private void claimArea(String clanName, int chunkRadius, int claimOffset, boolean safe, Location... locations)
+ {
+ claimArea(clanName, chunkRadius, claimOffset, 0, safe, locations);
+ }*/
+
private void claimArea(ClanInfo clan, Location location, int chunkRadius, int claimOffset, boolean safe)
{
int chunkX = location.getChunk().getX();
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java
index 33a30c870..011d3b91d 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementPlayer.java
@@ -8,7 +8,7 @@ import mineplex.core.scoreboard.ScoreboardManager;
import mineplex.core.scoreboard.elements.ScoreboardElement;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClansUtility;
-import mineplex.game.clans.clans.repository.ClanTerritory;
+import mineplex.game.clans.core.repository.ClanTerritory;
import org.bukkit.entity.Player;
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/tntGenerator/TntGeneratorManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/tntGenerator/TntGeneratorManager.java
index b5ef3b8f6..b71dec391 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/tntGenerator/TntGeneratorManager.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/tntGenerator/TntGeneratorManager.java
@@ -248,9 +248,12 @@ public class TntGeneratorManager extends MiniPlugin
private void clearStand(Block block)
{
TileEntityBrewingStand tileEntity = (TileEntityBrewingStand)((CraftWorld)block.getWorld()).getTileEntityAt(block.getX(), block.getY(), block.getZ());
- for (int i = 0; i < 4; i++)
+ if (tileEntity != null)
{
- tileEntity.items[i] = null;
+ for (int i = 0; i < 4; i++)
+ {
+ tileEntity.items[i] = null;
+ }
}
}
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java
index 5f45ffe02..0e7929e36 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java
@@ -192,7 +192,7 @@ public class GoldManager extends MiniPlugin
{
deductGems(player, gemAmount);
addGold(player, goldCount);
- notify(player, String.format("You have transferred %d gems into %d gold coins!", gemCount, goldCount));
+ notify(player, String.format("You have transferred %d gems into %d gold coins!", gemAmount, goldCount));
_transferTracker.insertTransfer(player);
}
}
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/Field.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/Field.java
index e10405fa2..f02c1e6e7 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/Field.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/Field.java
@@ -5,6 +5,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.creature.Creature;
import mineplex.core.energy.Energy;
+import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.fields.repository.FieldRepository;
import mineplex.minecraft.game.core.condition.ConditionManager;
@@ -14,12 +15,13 @@ public class Field extends MiniPlugin
private FieldOre _ore;
private FieldMonster _mob;
- public Field(JavaPlugin plugin, Creature creature, ConditionManager condition, Energy energy, String serverName)
+ public Field(JavaPlugin plugin, Creature creature, ConditionManager condition,
+ ClansManager clansManager, Energy energy, String serverName)
{
super("Field Factory", plugin);
FieldRepository repository = new FieldRepository(plugin);
- _block = new FieldBlock(plugin, condition, energy, repository, serverName);
+ _block = new FieldBlock(plugin, condition, clansManager, energy, repository, serverName);
_ore = new FieldOre(plugin, repository, serverName);
_mob = new FieldMonster(plugin, repository, creature, serverName);
}
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldBlock.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldBlock.java
index 682bd4b9c..cceb3d6d0 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldBlock.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldBlock.java
@@ -39,6 +39,7 @@ public class FieldBlock extends MiniPlugin
private Energy _energy;
private FieldRepository _repository;
private HashMap _blocks;
+ private ClansManager _clansManager;
private HashSet _active = new HashSet();
@@ -52,13 +53,15 @@ public class FieldBlock extends MiniPlugin
private String _serverName;
- public FieldBlock(JavaPlugin plugin, ConditionManager condition, Energy energy, FieldRepository repository, String serverName)
+ public FieldBlock(JavaPlugin plugin, ConditionManager condition, ClansManager clansManager,
+ Energy energy, FieldRepository repository, String serverName)
{
super("Field Block", plugin);
_conditionFactory = condition.Factory();
_energy = energy;
_repository = repository;
+ _clansManager = clansManager;
_blocks = new HashMap();
_serverName = serverName;
@@ -214,7 +217,7 @@ public class FieldBlock extends MiniPlugin
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void BlockBreak(BlockBreakEvent event)
{
- if (ClansManager.isFields(event.getBlock().getLocation()))
+ if (_clansManager.isFields(event.getBlock().getLocation()))
{
event.setCancelled(true); // Cancel all block breaks in fields. Handle custom breaking for FieldBlocks and Ores.
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldOre.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldOre.java
index 6cef5491c..1e9b23e73 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldOre.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldOre.java
@@ -199,12 +199,9 @@ public class FieldOre extends MiniPlugin
return null;
}
- @EventHandler(priority = EventPriority.LOWEST)
+ @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void Break(BlockBreakEvent event)
{
- if (event.isCancelled())
- return;
-
if (!_oreLocations.containsKey(event.getBlock().getLocation()))
return;
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java
index b93f992fa..92fa19555 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java
@@ -51,7 +51,7 @@ public abstract class ClansShopPage> extends Sh
public void addShopItem(int slot, Material material, int buyPrice, int sellPrice, byte data)
{
- addShopItem(slot, material, buyPrice, sellPrice, Clans.prettifyName(material));
+ addShopItem(slot, material, buyPrice, sellPrice, data, Clans.prettifyName(material), 1);
}
public void addShopItem(int slot, Material material, int buyPrice, int sellPrice, String displayName)
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/BankPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/BankPage.java
index a97b503de..ad48389a7 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/BankPage.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/BankPage.java
@@ -10,6 +10,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory;
+import mineplex.core.shop.item.DisplayButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.clans.ClanInfo;
diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java
index 559cde77f..ae35f42f1 100644
--- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java
+++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java
@@ -29,6 +29,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
+import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
@@ -103,7 +104,7 @@ public class Spawn extends MiniPlugin
for (Player cur : UtilServer.getPlayers())
{
- if (_clansManager.getClanUtility().isSafe(cur.getLocation()))
+ if (isInSpawn(cur.getLocation()))
{
long lastDamager = _clansManager.getCombatManager().Get(cur).GetLastCombat();
long duration = System.currentTimeMillis() - lastDamager;
@@ -115,6 +116,7 @@ public class Spawn extends MiniPlugin
UtilTextMiddle.display(null, message, 0, 20, 0, cur);
_clansManager.getCondition().Factory().Custom(COMBAT_TAG_NAME, cur, cur, ConditionType.CUSTOM, 1, 0, false, Material.FIRE, (byte)0, true);
+ playUnsafeParticles(cur);
}
else if (!UtilTime.elapsed(lastDamager, COMBAT_TAG_DURATION + 600))
{
@@ -124,6 +126,11 @@ public class Spawn extends MiniPlugin
}
}
+ private void playUnsafeParticles(Player player)
+ {
+ UtilParticle.PlayParticle(UtilParticle.ParticleType.CRIT, player.getEyeLocation().add(0, 0.75d, 0), 0, 0, 0, 0.2f, 35, UtilParticle.ViewDist.NORMAL);
+ }
+
@EventHandler
public void onSkillTriggered(SkillTriggerEvent event)
{
diff --git a/Plugins/Mineplex.Hub/.classpath b/Plugins/Mineplex.Hub/.classpath
index 866da57e1..baebf1394 100644
--- a/Plugins/Mineplex.Hub/.classpath
+++ b/Plugins/Mineplex.Hub/.classpath
@@ -12,5 +12,6 @@
+
diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubType.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubType.java
index 961a5bfee..4b058b45f 100644
--- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubType.java
+++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubType.java
@@ -2,7 +2,7 @@ package mineplex.hub;
public enum HubType
{
- Normal,
+ Normal,
Halloween,
Christmas
}
diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java
index 9cfa24d21..7da629370 100644
--- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java
+++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java
@@ -62,6 +62,7 @@ import mineplex.hub.server.ui.LobbyShop;
import mineplex.hub.server.ui.QuickShop;
import mineplex.hub.server.ui.ServerCountSorter;
import mineplex.hub.server.ui.ServerNpcShop;
+import mineplex.hub.server.ui.clans.ClansServerShop;
import mineplex.serverdata.Region;
import mineplex.serverdata.data.MinecraftServer;
import mineplex.serverdata.data.ServerGroup;
@@ -124,6 +125,9 @@ public class ServerManager extends MiniPlugin
_quickShop = new QuickShop(this, clientManager, donationManager, "Quick Menu");
_lobbyShop = new LobbyShop(this, clientManager, donationManager, "Lobby Menu");
//_domShop = new new QueueShop(_queueManager, clientManager, donationManager, "Dominate");
+
+ // TODO: Find more appropriate place to initialize Clans server shop?
+ new ClansServerShop(this, _clientManager, _donationManager);
}
@EventHandler(priority = EventPriority.LOW)
diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java
index f084c2ded..2e743365c 100644
--- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java
+++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java
@@ -77,7 +77,7 @@ public class LobbyMenu extends ShopPageBase implements
lore.add(ChatColor.RESET + C.Line + "Click to join!");
if (status != Material.EMERALD_BLOCK)
- addButton(slot, new ShopItem(status, ChatColor.UNDERLINE + "" + ChatColor.BOLD + "" + ChatColor.WHITE + "Server " + serverInfo.Name.substring(serverInfo.Name.indexOf('-') + 1), lore.toArray(new String[lore.size()]), Integer.parseInt(serverInfo.Name.substring(serverInfo.Name.indexOf('-') + 1)), false), new JoinServerButton(this, serverInfo));
+ addButton(slot, new ShopItem(status, ChatColor.UNDERLINE + "" + ChatColor.BOLD + "" + ChatColor.WHITE + "Server " + serverInfo.Name.substring(serverInfo.Name.indexOf('-') + 1), lore.toArray(new String[lore.size()]), Integer.parseInt(serverInfo.Name.substring(serverInfo.Name.indexOf('-') + 1)), false), new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
else
addItem(slot, new ShopItem(status, ChatColor.UNDERLINE + "" + ChatColor.BOLD + "" + ChatColor.WHITE + "Server " + serverInfo.Name.substring(serverInfo.Name.indexOf('-') + 1), lore.toArray(new String[lore.size()]), Integer.parseInt(serverInfo.Name.substring(serverInfo.Name.indexOf('-') + 1)), false));
}
diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java
index 64993b32e..6f383a8b9 100644
--- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java
+++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java
@@ -26,7 +26,7 @@ import mineplex.hub.server.ServerManager;
import mineplex.hub.server.ServerSorter;
import mineplex.hub.server.ui.button.JoinServerButton;
-public class ServerNpcPage extends ShopPageBase implements IServerPage
+public class ServerNpcPage extends ShopPageBase
{
// Shop Item Messages
private static final String MESSAGE_BETA_GET_ULTRA = ChatColor.RESET + C.Line + "Get Ultra to join Tournament servers!";
@@ -238,7 +238,7 @@ public class ServerNpcPage extends ShopPageBase im
if (serverInfo.HostedByStaff && staffSlot < 9)
{
- addButton(staffSlot, getPrivateItem(serverInfo), new JoinServerButton(this, serverInfo));
+ addButton(staffSlot, getPrivateItem(serverInfo), new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
staffSlot++;
}
else
@@ -246,7 +246,7 @@ public class ServerNpcPage extends ShopPageBase im
if (slot >= 54)
continue;
- addButton(slot, getPrivateItem(serverInfo), new JoinServerButton(this, serverInfo));
+ addButton(slot, getPrivateItem(serverInfo), new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
slot++;
}
}
@@ -276,7 +276,7 @@ public class ServerNpcPage extends ShopPageBase im
setItem(slot, shopItem);
else
{
- addButton(slot, shopItem, new JoinServerButton(this, serverInfo));
+ addButton(slot, shopItem, new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
}
if (full)
@@ -378,7 +378,7 @@ public class ServerNpcPage extends ShopPageBase im
{
ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded);
- addButton(slot, shopItem, new JoinServerButton(this, serverInfo));
+ addButton(slot, shopItem, new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
slot++;
}
@@ -409,17 +409,4 @@ public class ServerNpcPage extends ShopPageBase im
buildPage();
}
- public void SelectServer(Player player, ServerInfo serverInfo)
- {
- System.out.println("Selecting server :" + serverInfo.Name);
- int slots = getPlugin().getRequiredSlots(player, serverInfo.ServerType);
-
- if (serverInfo.getAvailableSlots() < slots && !(getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA") || getClient().GetRank().Has(Rank.ULTRA)))
- {
- playDenySound(player);
- return;
- }
-
- getPlugin().selectServer(player, serverInfo);
- }
}
diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/JoinServerButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/JoinServerButton.java
index d0a57ec41..872b0f430 100644
--- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/JoinServerButton.java
+++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/JoinServerButton.java
@@ -3,24 +3,54 @@ package mineplex.hub.server.ui.button;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
+import mineplex.core.common.Rank;
import mineplex.core.shop.item.IButton;
+import mineplex.core.shop.page.ShopPageBase;
import mineplex.hub.server.ServerInfo;
+import mineplex.hub.server.ServerManager;
import mineplex.hub.server.ui.IServerPage;
public class JoinServerButton implements IButton
{
- private IServerPage _page;
+ private ShopPageBase, ?> _page;
+ private ServerManager _serverManager;
private ServerInfo _serverInfo;
+ private Player _player;
- public JoinServerButton(IServerPage page, ServerInfo serverInfo)
+ public JoinServerButton(ShopPageBase, ?> page, ServerManager serverManager, ServerInfo serverInfo, Player player)
{
_page = page;
+ _serverManager = serverManager;
_serverInfo = serverInfo;
+ _player = player;
}
@Override
public void onClick(Player player, ClickType clickType)
{
- _page.SelectServer(player, _serverInfo);
+ selectServer(player, _serverInfo);
+ }
+
+ public void selectServer(Player player, ServerInfo serverInfo)
+ {
+ if (serverInfo != null)
+ {
+ System.out.println("Selecting server :" + serverInfo.Name);
+ int slots = _serverManager.getRequiredSlots(player, serverInfo.ServerType);
+
+ if (serverInfo.getAvailableSlots() < slots && !(_page.getDonationManager().Get(_player.getName()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA") || _page.getClient().GetRank().Has(Rank.ULTRA)))
+ {
+ _page.playDenySound(player);
+
+ }
+ else
+ {
+ _serverManager.selectServer(player, serverInfo);
+ }
+ }
+ else
+ {
+ _page.playDenySound(player);
+ }
}
}
diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClanMoveServerButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClanMoveServerButton.java
new file mode 100644
index 000000000..72908145b
--- /dev/null
+++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClanMoveServerButton.java
@@ -0,0 +1,48 @@
+package mineplex.hub.server.ui.clans;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.inventory.ClickType;
+
+import mineplex.core.common.util.Callback;
+import mineplex.core.shop.item.IButton;
+import mineplex.game.clans.core.ClanServerChangeCommand;
+import mineplex.game.clans.core.repository.ClanRepository;
+import mineplex.game.clans.core.repository.tokens.SimpleClanToken;
+
+public class ClanMoveServerButton implements IButton
+{
+
+ private ClanRepository _repository;
+ private SimpleClanToken _clan;
+ private String _serverName;
+
+ public ClanMoveServerButton(ClanRepository repository, SimpleClanToken clan, String serverName)
+ {
+ _repository = repository;
+ _clan = clan;
+ _serverName = serverName;
+ }
+
+ @Override
+ public void onClick(Player player, ClickType clickType)
+ {
+ _repository.moveClanServer(_clan.getClanId(), _serverName, new Callback()
+ {
+ @Override
+ public void run(Boolean success)
+ {
+ if (success)
+ {
+ ClanServerChangeCommand changeCommand = new ClanServerChangeCommand(_clan);
+ changeCommand.publish();
+ System.out.println("Successfully finished moving clan to new home server!");
+ }
+ else
+ {
+ System.out.println("ERROR: Unable to successfully move clan to new home server!");
+ }
+ }
+ });
+ }
+
+}
diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClanMoveServerPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClanMoveServerPage.java
new file mode 100644
index 000000000..c74be3a16
--- /dev/null
+++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClanMoveServerPage.java
@@ -0,0 +1,68 @@
+package mineplex.hub.server.ui.clans;
+
+import java.util.Collection;
+import java.util.List;
+
+import mineplex.core.account.CoreClientManager;
+import mineplex.core.common.util.C;
+import mineplex.core.common.util.Callback;
+import mineplex.core.donation.DonationManager;
+import mineplex.core.shop.item.DisplayButton;
+import mineplex.core.shop.item.ShopItem;
+import mineplex.core.shop.page.ShopPageBase;
+import mineplex.game.clans.core.repository.ClanRepository;
+import mineplex.game.clans.core.repository.tokens.SimpleClanToken;
+import mineplex.hub.server.ServerInfo;
+import mineplex.hub.server.ServerManager;
+
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+
+public class ClanMoveServerPage extends ShopPageBase
+{
+
+ //private DataRepository _repository; // Stores the name of the last Clans server a player was on
+ private ClanRepository _repository;
+ private SimpleClanToken _clan;
+ private int _accountId;
+
+ public ClanMoveServerPage(ServerManager plugin, ClanMoveServerShop shop, CoreClientManager clientManager,
+ DonationManager donationManager, Player player, ClanRepository repository, SimpleClanToken clan)
+ {
+ super(plugin, shop, clientManager, donationManager, "Clans Server Change", player, 27);
+
+ _repository = repository;
+ _clan = clan;
+ _accountId = clientManager.getAccountId(player);
+
+ buildPage();
+ }
+
+ @Override
+ protected void buildPage()
+ {
+ Collection servers = getPlugin().getServerList("Clans");
+
+ int currentSlot = 9;
+ for (ServerInfo server : servers)
+ {
+ if (!server.Name.equalsIgnoreCase(_clan.getHomeServer()))
+ {
+ buildServerButton(currentSlot, server);
+ currentSlot++;
+ }
+ }
+ // TODO: Build a button for each available clans server to move clan to
+ // clicking the button should move the clan to the new server
+ }
+
+ private void buildServerButton(int slot, ServerInfo server)
+ {
+ ClanMoveServerButton button = new ClanMoveServerButton(_repository, _clan, server.Name);
+ String title = C.Bold + C.cGold + "Move Clan To Server!";
+ String desc1 = C.cGold + "Server: " + C.cAqua + server.Name;
+ String desc2 = C.cGold + "Players: " + C.cAqua + server.CurrentPlayers + "/" + server.MaxPlayers;
+ ShopItem shopItem = new ShopItem(Material.DIAMOND_BLOCK, title, new String[] {" ", desc1, desc2, " "}, 0, true, true);
+ addButton(slot, shopItem, button);
+ }
+}
diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClanMoveServerShop.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClanMoveServerShop.java
new file mode 100644
index 000000000..6336115e2
--- /dev/null
+++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClanMoveServerShop.java
@@ -0,0 +1,62 @@
+package mineplex.hub.server.ui.clans;
+
+import org.bukkit.Sound;
+import org.bukkit.entity.Player;
+
+import mineplex.core.account.CoreClientManager;
+import mineplex.core.common.util.C;
+import mineplex.core.common.util.F;
+import mineplex.core.donation.DonationManager;
+import mineplex.core.party.Party;
+import mineplex.core.shop.ShopBase;
+import mineplex.core.shop.page.ShopPageBase;
+import mineplex.game.clans.core.repository.ClanRepository;
+import mineplex.game.clans.core.repository.tokens.SimpleClanToken;
+import mineplex.hub.server.ServerManager;
+
+public class ClanMoveServerShop extends ShopBase
+{
+
+ private ClanRepository _repository;
+ private SimpleClanToken _clan;
+
+ public ClanMoveServerShop(ServerManager plugin, CoreClientManager clientManager, DonationManager donationManager,
+ SimpleClanToken clan)
+ {
+ super(plugin, clientManager, donationManager, "Move Clans Server");
+
+ _repository = new ClanRepository(plugin.getPlugin(), plugin.getStatusManager().getCurrentServerName());
+ _clan = clan;
+ }
+
+ @Override
+ protected ShopPageBase> buildPagesFor(Player player)
+ {
+ return new ClanMoveServerPage(getPlugin(), this, getClientManager(), getDonationManager(), player, _repository, _clan);
+ }
+
+ @Override
+ protected boolean canOpenShop(Player player)
+ {
+ Party party = getPlugin().getPartyManager().GetParty(player);
+
+ if (party != null)
+ {
+ player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f);
+ player.sendMessage(F.main("Party", "You cannot join Clans while in a party."));
+ return false;
+ }
+
+ return true;
+ }
+
+ protected void openShopForPlayer(Player player)
+ {
+ getPlugin().getHubManager().GetVisibility().addHiddenPlayer(player);
+ }
+
+ protected void closeShopForPlayer(Player player)
+ {
+ getPlugin().getHubManager().GetVisibility().removeHiddenPlayer(player);
+ }
+}
diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClansServerPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClansServerPage.java
new file mode 100644
index 000000000..d5c16fdfd
--- /dev/null
+++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClansServerPage.java
@@ -0,0 +1,147 @@
+package mineplex.hub.server.ui.clans;
+
+import java.util.Collection;
+
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.event.inventory.ClickType;
+
+import mineplex.core.account.CoreClientManager;
+import mineplex.core.common.util.C;
+import mineplex.core.common.util.Callback;
+import mineplex.core.donation.DonationManager;
+import mineplex.core.shop.item.DisplayButton;
+import mineplex.core.shop.item.IButton;
+import mineplex.core.shop.item.ShopItem;
+import mineplex.core.shop.page.ShopPageBase;
+import mineplex.game.clans.core.repository.ClanRepository;
+import mineplex.game.clans.core.repository.tokens.SimpleClanToken;
+import mineplex.hub.server.ServerInfo;
+import mineplex.hub.server.ServerManager;
+import mineplex.hub.server.ui.button.JoinServerButton;
+import mineplex.serverdata.data.DataRepository;
+
+public class ClansServerPage extends ShopPageBase
+{
+
+ //private DataRepository _repository; // Stores the name of the last Clans server a player was on
+ private ClanRepository _repository;
+ private int _accountId;
+
+ public ClansServerPage(ServerManager plugin, ClansServerShop shop, CoreClientManager clientManager,
+ DonationManager donationManager, Player player, ClanRepository repository)
+ {
+ super(plugin, shop, clientManager, donationManager, "Clans", player, 27);
+
+ _repository = repository;
+ _accountId = clientManager.getAccountId(player);
+
+ buildPage();
+ }
+
+ @Override
+ protected void buildPage()
+ {
+ _repository.retrievePlayersClan(_accountId, new Callback()
+ {
+ @Override
+ public void run(SimpleClanToken data)
+ {
+ if (data != null)
+ {
+ System.out.println("Found clan: " + data.getClanName() + " - " + data.getHomeServer());
+ buildClanPage(data);
+ }
+ else
+ {
+ System.out.println("NO CLAN FOUND!");
+ buildNoClanPage();
+ }
+ }
+ });
+ }
+
+ private void buildClanPage(SimpleClanToken clan)
+ {
+ buildJoinHomeServer(clan);
+
+ if (isLeader(clan))
+ {
+ buildMoveClan(clan);
+ }
+ }
+
+ private void buildNoClanPage()
+ {
+ Collection servers = getPlugin().getServerList("Clans");
+
+ int currentSlot = 9;
+ for (ServerInfo server : servers)
+ {
+ buildJoinServer(currentSlot, server);
+ currentSlot++;
+ }
+ }
+
+ private boolean isLeader(SimpleClanToken clan)
+ {
+ return clan.getClanRole().equalsIgnoreCase("Leader");
+ }
+
+ private void buildJoinHomeServer(SimpleClanToken clan)
+ {
+ ServerInfo serverInfo = getServerInfo(clan.getHomeServer());
+ boolean serverOnline = (serverInfo != null);
+ String serverStatus = serverOnline ? C.cGreen + "Online" : C.cRed + "Offline";
+
+ String title = C.cRed + C.Bold + "Join Home Server!";
+ String description = C.cGold + "Join your home server, " + C.cAqua + clan.getHomeServer() + C.cGold + "!";
+ String serverDesc = C.cGold + "Server Status: " + serverStatus + C.cGold + "!";
+ ShopItem shopItem = new ShopItem(Material.GOLD_BLOCK, title, new String[] {" ", description, serverDesc, " "}, 0, true, true);
+ addButton(4, shopItem, new JoinServerButton(this, getPlugin(), getServerInfo(clan.getHomeServer()), getPlayer()));
+ }
+
+ private void buildJoinServer(int slot, ServerInfo server)
+ {
+ String title = C.cRed + C.Bold + "Join Clans Server!";
+ String desc1 = C.cGold + "Name: " + C.cAqua + server.Name;
+ String desc2 = C.cGold + "Players: " + C.cAqua + server.CurrentPlayers + "/" + server.MaxPlayers;
+
+ ShopItem shopItem = new ShopItem(Material.GOLD_BLOCK, title, new String[] {" ", desc1, desc2, " "}, 0, true, true);
+ addButton(slot, shopItem, new JoinServerButton(this, getPlugin(), server, getPlayer()));
+ }
+
+ private void buildMoveClan(final SimpleClanToken clan)
+ {
+ // Build button for moving clan to another server
+ String title = C.cRed + C.Bold + "Change Clan's Home Server!";
+ String description = C.cGold + "Move your clan to another server!";
+ String desc2 = C.Bold + C.cRed + "Warning: " + ChatColor.RESET + C.cGold + "Changing your clan's";
+ String desc3 = C.cGold + "home server will permanently unclaim";
+ String desc4 = C.cGold + "your land and prevent you from";
+ String desc5 = C.cGold + "joining the original server.";
+ ShopItem shopItem = new ShopItem(Material.BOOK_AND_QUILL, title, new String[] {" ", description, desc2, desc3, desc4, desc5, " "}, 0, true, true);
+
+ IButton button = new IButton()
+ {
+ @Override
+ public void onClick(Player player, ClickType clickType)
+ {
+ ClanMoveServerShop shop = new ClanMoveServerShop(getPlugin(), getClientManager(), getDonationManager(), clan);
+
+ if (!shop.attemptShopOpen(player))
+ {
+ playDenySound(player);
+ }
+ }
+ };
+
+ addButton(13, shopItem, button);
+ }
+
+ private ServerInfo getServerInfo(String serverName)
+ {
+ return getPlugin().getServerInfo(serverName);
+ }
+}
diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClansServerShop.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClansServerShop.java
new file mode 100644
index 000000000..9987f36de
--- /dev/null
+++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClansServerShop.java
@@ -0,0 +1,80 @@
+package mineplex.hub.server.ui.clans;
+
+import org.bukkit.Sound;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.block.Action;
+import org.bukkit.event.player.PlayerInteractEvent;
+
+import mineplex.core.account.CoreClientManager;
+import mineplex.core.common.util.C;
+import mineplex.core.common.util.F;
+import mineplex.core.donation.DonationManager;
+import mineplex.core.party.Party;
+import mineplex.core.shop.ShopBase;
+import mineplex.core.shop.page.ShopPageBase;
+import mineplex.game.clans.core.repository.ClanRepository;
+import mineplex.game.clans.core.repository.tokens.SimpleClanToken;
+import mineplex.hub.server.ServerManager;
+
+public class ClansServerShop extends ShopBase
+{
+
+ private ClanRepository _repository;
+
+ public ClansServerShop(ServerManager plugin, CoreClientManager clientManager, DonationManager donationManager)
+ {
+ super(plugin, clientManager, donationManager, "Clans");
+ System.out.println("initiateddd-----------------------------------");
+ _repository = new ClanRepository(plugin.getPlugin(), plugin.getStatusManager().getCurrentServerName());
+ }
+
+ @Override
+ protected ShopPageBase> buildPagesFor(Player player)
+ {
+ return new ClansServerPage(getPlugin(), this, getClientManager(), getDonationManager(), player, _repository);
+ }
+
+ @Override
+ protected boolean canOpenShop(Player player)
+ {
+ Party party = getPlugin().getPartyManager().GetParty(player);
+
+ if (party != null)
+ {
+ player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f);
+ player.sendMessage(F.main("Party", "You cannot join Clans while in a party."));
+ return false;
+ }
+
+ return true;
+ }
+
+ protected void openShopForPlayer(Player player)
+ {
+ getPlugin().getHubManager().GetVisibility().addHiddenPlayer(player);
+ }
+
+ protected void closeShopForPlayer(Player player)
+ {
+ getPlugin().getHubManager().GetVisibility().removeHiddenPlayer(player);
+ }
+
+ // TODO: REMOVE THIS, JUST FOR DEBUGGING
+ @EventHandler
+ public void onPlayerInteract(PlayerInteractEvent event)
+ {
+ System.out.println("CALLED");
+ if (event.getPlayer().getName().equalsIgnoreCase("Elinoo")
+ || event.getPlayer().getName().equalsIgnoreCase("MrTwiggy")
+ || event.getPlayer().getName().equalsIgnoreCase("GetGrimyWits"))
+ {
+ System.out.println("CALLED2");
+ if (event.getPlayer().isSneaking() && event.getAction() == Action.RIGHT_CLICK_AIR)
+ {
+ System.out.println("CALLED3");
+ this.attemptShopOpen(event.getPlayer());
+ }
+ }
+ }
+}
diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java
index 31341ae10..5cc588d2b 100644
--- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java
+++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java
@@ -157,6 +157,11 @@ public class ServerCommandManager
System.out.println("Registered : " + commandName);
}
+ public void registerCommandType(Class extends ServerCommand> commandType, CommandCallback callback)
+ {
+ registerCommandType(commandType.getSimpleName(), commandType, callback);
+ }
+
public void registerCommandType(String commandName, Class extends ServerCommand> commandType)
{
registerCommandType(commandName, commandType, null);
diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/PlayerServerInfo.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/PlayerServerInfo.java
new file mode 100644
index 000000000..f4a0be4f4
--- /dev/null
+++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/PlayerServerInfo.java
@@ -0,0 +1,25 @@
+package mineplex.serverdata.data;
+
+public class PlayerServerInfo implements Data
+{
+
+ private String _playerName;
+ public String getPlayerName() { return _playerName; }
+
+ private String _lastServer;
+ public String getLastServer() { return _lastServer; }
+ public void setLastServer(String lastServer) { _lastServer = lastServer; }
+
+ public PlayerServerInfo(String playerName, String lastServer)
+ {
+ _playerName = playerName;
+ _lastServer = lastServer;
+ }
+
+ @Override
+ public String getDataId()
+ {
+ return _playerName;
+ }
+
+}