Merge branch 'clans-beta' of ssh://184.154.0.242:7999/min/mineplex into clans-beta

This commit is contained in:
Mini-Chiss 2015-08-29 16:02:21 -07:00
commit 110222e5f3
52 changed files with 931 additions and 165 deletions

View File

@ -146,6 +146,9 @@
<fileset dir="../Mineplex.Minecraft.Game.Core/bin"> <fileset dir="../Mineplex.Minecraft.Game.Core/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
</fileset> </fileset>
<fileset dir="../Mineplex.Game.Clans.Core/bin">
<include name="**/*.class"/>
</fileset>
<fileset dir="../Mineplex.Hub"> <fileset dir="../Mineplex.Hub">
<include name="*.yml"/> <include name="*.yml"/>
</fileset> </fileset>

View File

@ -208,6 +208,12 @@ public class UtilParticle
return packet; 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, public static void PlayParticle(ParticleType type,Location location, float offsetX, float offsetY, float offsetZ,
float speed, int count, ViewDist dist, Player... players) float speed, int count, ViewDist dist, Player... players)
{ {

View File

@ -517,6 +517,14 @@ public class UtilPlayer
System.out.println("Kicked Client [" + player.getName() + "] for [" + module + " - " + message + "]"); System.out.println("Kicked Client [" + player.getName() + "] for [" + module + " - " + message + "]");
} }
public static void kick(Collection<Player> players, String module, String message, boolean log)
{
for (Player player : players)
{
kick(player, module, message, log);
}
}
public static HashMap<Player, Double> getInRadius(Location loc, double dR) public static HashMap<Player, Double> getInRadius(Location loc, double dR)
{ {
HashMap<Player, Double> players = new HashMap<Player, Double>(); HashMap<Player, Double> players = new HashMap<Player, Double>();

View File

@ -82,9 +82,9 @@ public class UtilWorld
if (cur.getName().equalsIgnoreCase(parts[0])) if (cur.getName().equalsIgnoreCase(parts[0]))
{ {
int x = Integer.parseInt(parts[1]); int x = Integer.parseInt(parts[1]);
int y = Integer.parseInt(parts[1]); int y = Integer.parseInt(parts[2]);
int z = Integer.parseInt(parts[1]); int z = Integer.parseInt(parts[3]);
cur.getBlockAt(x, y, z); return cur.getBlockAt(x, y, z);
} }
} }
} }

View File

@ -1,11 +1,10 @@
package mineplex.game.clans.shop.bank; package mineplex.core.shop.item;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.IButton;
import mineplex.game.clans.economy.GoldManager;
public class DisplayButton implements IButton public class DisplayButton implements IButton
{ {

View File

@ -229,7 +229,7 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
return _player; return _player;
} }
protected CoreClient getClient() public CoreClient getClient()
{ {
return _client; return _client;
} }

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Database"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-3.5.2.jar"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.ServerData"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Mineplex.Game.Clans.Core</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

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

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.clans.repository; package mineplex.game.clans.core.repository;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -9,9 +9,7 @@ import java.sql.Timestamp;
import java.util.Collection; import java.util.Collection;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit; import mineplex.core.common.util.Callback;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.database.DBPool; import mineplex.core.database.DBPool;
import mineplex.core.database.RepositoryBase; 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.ColumnTimestamp;
import mineplex.core.database.column.ColumnVarChar; import mineplex.core.database.column.ColumnVarChar;
import mineplex.database.tables.records.ClansRecord; import mineplex.database.tables.records.ClansRecord;
import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.core.repository.tokens.ClanAllianceToken;
import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken; import mineplex.game.clans.core.repository.tokens.ClanEnemyToken;
import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken; import mineplex.game.clans.core.repository.tokens.ClanMemberToken;
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken; import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken;
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken; import mineplex.game.clans.core.repository.tokens.ClanToken;
import mineplex.game.clans.clans.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 org.jooq.DSLContext;
import static mineplex.database.Tables.*; 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_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 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_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_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 = ?;"; 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_TERRITORIES = "DELETE FROM clanTerritory WHERE clanId = ?;";
private static String DELETE_CLAN_ALLIANCE = "DELETE FROM clanAlliances WHERE clanId = ? AND otherClanId = ?;"; 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_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 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());"; 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_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_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_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 GET_CLAN_SERVER = "SELECT id FROM clanServer WHERE clanServer.serverName = ?";
private static String ADD_CLAN_SERVER = "INSERT INTO clanServer (serverName) VALUES (?);"; private static String ADD_CLAN_SERVER = "INSERT INTO clanServer (serverName) VALUES (?);";
@ -126,6 +130,105 @@ public class ClanRepository extends RepositoryBase
executeUpdate(CREATE_CLAN_ALLIANCE_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<Boolean> 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<ClanToken> 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<Boolean> 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<SimpleClanToken> 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<ClanToken> retrieveClans() public Collection<ClanToken> retrieveClans()
{ {
System.out.println("Beginning to load clans from database..."); System.out.println("Beginning to load clans from database...");
@ -150,13 +253,15 @@ public class ClanRepository extends RepositoryBase
token.Deaths = resultSet.getInt(9); token.Deaths = resultSet.getInt(9);
token.WarWins = resultSet.getInt(10); token.WarWins = resultSet.getInt(10);
token.WarLosses = resultSet.getInt(11); token.WarLosses = resultSet.getInt(11);
token.DateCreated = resultSet.getTimestamp(12); token.Generator = resultSet.getString(12);
token.LastOnline = resultSet.getTimestamp(13); token.GeneratorStock = resultSet.getInt(13);
token.DateCreated = resultSet.getTimestamp(14);
token.LastOnline = resultSet.getTimestamp(15);
ClanTerritoryToken territoryToken = new ClanTerritoryToken(); ClanTerritoryToken territoryToken = new ClanTerritoryToken();
territoryToken.ClanName = token.Name; territoryToken.ClanName = token.Name;
territoryToken.Chunk = resultSet.getString(14); territoryToken.Chunk = resultSet.getString(16);
territoryToken.Safe = resultSet.getBoolean(15); territoryToken.Safe = resultSet.getBoolean(17);
if (!clans.containsKey(token.Name)) if (!clans.containsKey(token.Name))
{ {

View File

@ -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 public class ClanTerritory
{ {

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.clans.repository.tokens; package mineplex.game.clans.core.repository.tokens;
public class ClanAllianceToken public class ClanAllianceToken
{ {

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.clans.repository.tokens; package mineplex.game.clans.core.repository.tokens;
import java.sql.Timestamp; import java.sql.Timestamp;

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.clans.repository.tokens; package mineplex.game.clans.core.repository.tokens;
import java.util.UUID; import java.util.UUID;

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.clans.repository.tokens; package mineplex.game.clans.core.repository.tokens;
public class ClanTerritoryToken public class ClanTerritoryToken
{ {

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.clans.repository.tokens; package mineplex.game.clans.core.repository.tokens;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
@ -17,6 +17,8 @@ public class ClanToken
public int Deaths; public int Deaths;
public int WarWins; public int WarWins;
public int WarLosses; public int WarLosses;
public String Generator;
public int GeneratorStock;
public Timestamp DateCreated; public Timestamp DateCreated;
public Timestamp LastOnline; public Timestamp LastOnline;

View File

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

View File

@ -11,5 +11,6 @@
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/gson-2.2.1.jar"/> <classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/gson-2.2.1.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Database"/> <classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Database"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-3.5.2.jar"/> <classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-3.5.2.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Game.Clans.Core"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -9,6 +9,7 @@ import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.common.util.C; 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.UtilTime.TimeUnit;
import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken; import mineplex.game.clans.core.repository.tokens.ClanAllianceToken;
import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken; import mineplex.game.clans.core.repository.tokens.ClanEnemyToken;
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken; import mineplex.game.clans.core.repository.tokens.ClanMemberToken;
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken; import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken;
import mineplex.game.clans.clans.repository.tokens.ClanToken; import mineplex.game.clans.core.repository.tokens.ClanToken;
import mineplex.game.clans.clans.tntGenerator.TntGenerator; import mineplex.game.clans.clans.tntGenerator.TntGenerator;
public class ClanInfo public class ClanInfo
@ -82,6 +84,23 @@ public class ClanInfo
} }
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; _energy = token.Energy;
_admin = token.Admin; _admin = token.Admin;

View File

@ -9,7 +9,7 @@ import mineplex.core.common.util.UtilInput;
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.UtilWorld; 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.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -12,14 +12,16 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.sun.org.apache.xpath.internal.operations.Bool; import com.sun.org.apache.xpath.internal.operations.Bool;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilWorld; 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.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.scoreboard.ClansScoreboardManager;
import mineplex.game.clans.clans.tntGenerator.TntGenerator; import mineplex.game.clans.clans.tntGenerator.TntGenerator;
@ -45,16 +47,31 @@ public class ClansDataAccessLayer
{ {
final boolean out = _repository.deleteClan(clan.getId()); final boolean out = _repository.deleteClan(clan.getId());
if (out)
{
runSync(new Runnable() runSync(new Runnable()
{ {
@Override @Override
public void run() public void run()
{ {
if (out) deleteLocally(clan);
if (callback != null) callback.run(out);
}
});
}
}
});
}
public void deleteLocally(ClanInfo clan)
{ {
//Territory Unclaim //Territory Unclaim
for (String cur : clan.getClaimSet()) for (String cur : clan.getClaimSet())
{
_manager.getClaimMap().remove(cur); _manager.getClaimMap().remove(cur);
}
_manager.getClanMap().remove(clan.getName()); _manager.getClanMap().remove(clan.getName());
@ -80,13 +97,6 @@ public class ClansDataAccessLayer
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
} }
if (callback != null) callback.run(out);
}
});
}
});
}
public void createAndJoin(final Player player, final String name, final Callback<ClanInfo> callback) public void createAndJoin(final Player player, final String name, final Callback<ClanInfo> callback)
{ {
create(player.getName(), name, false, new Callback<ClanInfo>() create(player.getName(), name, false, new Callback<ClanInfo>()
@ -674,6 +684,16 @@ public class ClansDataAccessLayer
_manager.log("Safe Zone at [" + claim.Chunk + "] set to [" + claim.Safe + "] by [" + player + "]."); _manager.log("Safe Zone at [" + claim.Chunk + "] set to [" + claim.Safe + "] by [" + player + "].");
} }
public void retrieveClan(String clanName, Callback<ClanToken> callback)
{
_repository.retrieveClan(clanName, callback);
}
public void clanExists(String clanName, Callback<Boolean> callback)
{
_repository.clanExists(clanName, callback);
}
public ClanRepository getRepository() public ClanRepository getRepository()
{ {
return _repository; return _repository;

View File

@ -13,7 +13,7 @@ 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.ClansUtility.ClanRelation; 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.Chunk;
import org.bukkit.Material; import org.bukkit.Material;

View File

@ -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 ((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) 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; return;
String mimic = Clans.Get(event.getPlayer()).getMimic(); String mimic = Clans.Get(event.getPlayer()).getMimic();

View File

@ -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.EnumToolMaterial;
import net.minecraft.server.v1_7_R4.Item; import net.minecraft.server.v1_7_R4.Item;
import net.minecraft.server.v1_7_R4.ItemSword; import net.minecraft.server.v1_7_R4.ItemSword;
import mineplex.core.MiniClientPlugin; import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager; 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.loot.LootManager;
import mineplex.game.clans.clans.map.ItemMapManager; import mineplex.game.clans.clans.map.ItemMapManager;
import mineplex.game.clans.clans.murder.MurderManager; 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.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.scoreboard.ClansScoreboardManager;
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;
import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.clans.worldevent.WorldEventManager; 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.fields.Field;
import mineplex.game.clans.gameplay.Gameplay; import mineplex.game.clans.gameplay.Gameplay;
import mineplex.game.clans.gameplay.safelog.LoggingManager; 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.damage.DamageManager;
import mineplex.minecraft.game.core.fire.Fire; import mineplex.minecraft.game.core.fire.Fire;
import mineplex.minecraft.game.core.mechanics.Weapon; 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<ClientClan> implements IRelation public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelation
{ {
public static final int FIELD_RADIUS = 128;
public static final int CLAIMABLE_RADIUS = 800; public static final int CLAIMABLE_RADIUS = 800;
public static final int WORLD_RADIUS = 1200; public static final int WORLD_RADIUS = 1200;
private static final TimeZone TIME_ZONE = TimeZone.getDefault(); private static final TimeZone TIME_ZONE = TimeZone.getDefault();
private static ClansManager _instance;
public static ClansManager getInstance() { return _instance; }
private String _serverName; private String _serverName;
@ -155,6 +162,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
{ {
super("Clans Manager", plugin); super("Clans Manager", plugin);
_instance = this;
_serverName = serverName; _serverName = serverName;
_clientManager = clientManager; _clientManager = clientManager;
_combatManager = new CombatManager(plugin); _combatManager = new CombatManager(plugin);
@ -194,7 +202,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
// TODO: Re-enable customtagfix with NCP update? // TODO: Re-enable customtagfix with NCP update?
//new CustomTagFix(plugin, packetHandler); //new CustomTagFix(plugin, packetHandler);
new Field(plugin, creature, _condition, energy, serverName); new Field(plugin, creature, _condition, this, energy, serverName);
// Required managers to be initialized // Required managers to be initialized
new Spawn(plugin, this); new Spawn(plugin, this);
@ -217,6 +225,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
skillManager.removeSkill("Shield Smash"); skillManager.removeSkill("Shield Smash");
_classManager = new ClassManager(plugin, _clientManager, donationManager, skillManager, itemFactory, webServerAddress); _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); StatsManager statsManager = new StatsManager(plugin, _clientManager);
AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, donationManager); AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, donationManager);
ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager); ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager);
@ -236,6 +247,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
_claimMap.put(territoryToken.Chunk, new ClanTerritory(territoryToken)); _claimMap.put(territoryToken.Chunk, new ClanTerritory(territoryToken));
} }
//RedisDataRepository(ConnectionData writeConn, ConnectionData readConn, Region region, Class<T> elementType, String elementLabel)
// Initialize default region factions and territory (spawn/fields/borderlands) // Initialize default region factions and territory (spawn/fields/borderlands)
_clanRegions = new ClansRegions(plugin, this); _clanRegions = new ClansRegions(plugin, this);
_clanRegions.initializeRegions(); _clanRegions.initializeRegions();
@ -298,17 +310,13 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
int x = Math.abs(location.getBlockX()); int x = Math.abs(location.getBlockX());
int z = Math.abs(location.getBlockZ()); int z = Math.abs(location.getBlockZ());
return (x > FIELD_RADIUS || z > FIELD_RADIUS) return (x <= CLAIMABLE_RADIUS && z <= CLAIMABLE_RADIUS)
&& (x <= CLAIMABLE_RADIUS && z <= CLAIMABLE_RADIUS)
&& !Spawn.getInstance().isInSpawn(location); && !Spawn.getInstance().isInSpawn(location);
} }
public static boolean isFields(Location location) public boolean isFields(Location location)
{ {
int x = Math.abs(location.getBlockX()); return getClanUtility().isSpecial(location, "Fields");
int z = Math.abs(location.getBlockZ());
return x <= FIELD_RADIUS && z <= FIELD_RADIUS;
} }
public boolean canUnclaimChunk(ClanInfo stealer, ClanInfo owner) public boolean canUnclaimChunk(ClanInfo stealer, ClanInfo owner)

View File

@ -18,7 +18,7 @@ import mineplex.core.common.util.F;
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.common.util.UtilWorld; import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.repository.ClanTerritory; import mineplex.game.clans.core.repository.ClanTerritory;
public class ClansUtility public class ClansUtility
{ {
@ -430,9 +430,10 @@ public class ClansUtility
public ClanRelation relPT(String pA, String tB) public ClanRelation relPT(String pA, String tB)
{ {
ClanTerritory claim = getClaim(tB); ClanTerritory claim = getClaim(tB);
if (claim != null) if (claim != null && claim.Safe)
if (claim.Safe) {
return ClanRelation.SAFE; return ClanRelation.SAFE;
}
return rel(getClanByPlayer(pA), getOwner(tB)); return rel(getClanByPlayer(pA), getOwner(tB));
} }

View File

@ -24,6 +24,7 @@ import mineplex.game.clans.clans.ClansBlacklist;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.ClientClan; import mineplex.game.clans.clans.ClientClan;
import mineplex.game.clans.core.repository.tokens.ClanToken;
public class ClansCommand extends CommandBase<ClansManager> public class ClansCommand extends CommandBase<ClansManager>
{ {
@ -288,15 +289,17 @@ public class ClansCommand extends CommandBase<ClansManager>
} }
} }
for (String cur : Plugin.getClanMap().keySet()) Plugin.getClanDataAccess().clanExists(args[1], new Callback<Boolean>()
{ {
if (cur.equalsIgnoreCase(args[1])) @Override
public void run(Boolean clanExists)
{
if (clanExists)
{ {
UtilPlayer.message(caller, F.main("Clans", "Clan name is already in use by another Clan.")); UtilPlayer.message(caller, F.main("Clans", "Clan name is already in use by another Clan."));
return;
} }
} else
{
Plugin.getClanDataAccess().createAndJoin(caller, args[1], new Callback<ClanInfo>() Plugin.getClanDataAccess().createAndJoin(caller, args[1], new Callback<ClanInfo>()
{ {
@Override @Override
@ -315,6 +318,8 @@ public class ClansCommand extends CommandBase<ClansManager>
} }
}); });
} }
}});
}
public void delete(final Player caller, String[] args) public void delete(final Player caller, String[] args)
{ {

View File

@ -23,7 +23,7 @@ public class ClansLoginManager extends MiniPlugin implements ILoginProcessor
super("Clans Login Manager", plugin); super("Clans Login Manager", plugin);
_serverName = serverName; _serverName = serverName;
_enabled = false; _enabled = true;
clientManager.addStoredProcedureLoginProcessor(this); clientManager.addStoredProcedureLoginProcessor(this);
} }

View File

@ -21,7 +21,7 @@ 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.repository.ClanTerritory; import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.minecraft.game.core.combat.CombatComponent; import mineplex.minecraft.game.core.combat.CombatComponent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;

View File

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

View File

@ -62,7 +62,9 @@ public class ClansRegions extends MiniPlugin
Location worldCenter = new Location(_world, 0, 0, 0); Location worldCenter = new Location(_world, 0, 0, 0);
// Initialize Spawn faction and claims // 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()}); claimArea("Shops", SHOP_RADIUS, 0, true, new Location[]{Spawn.getEastShop(), Spawn.getWestShop()});
// Initialize Fields and Borderlands factions and claims // 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) private void claimArea(ClanInfo clan, Location location, int chunkRadius, int claimOffset, boolean safe)
{ {
int chunkX = location.getChunk().getX(); int chunkX = location.getChunk().getX();

View File

@ -8,7 +8,7 @@ import mineplex.core.scoreboard.ScoreboardManager;
import mineplex.core.scoreboard.elements.ScoreboardElement; import mineplex.core.scoreboard.elements.ScoreboardElement;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClansUtility; 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; import org.bukkit.entity.Player;

View File

@ -248,11 +248,14 @@ public class TntGeneratorManager extends MiniPlugin
private void clearStand(Block block) private void clearStand(Block block)
{ {
TileEntityBrewingStand tileEntity = (TileEntityBrewingStand)((CraftWorld)block.getWorld()).getTileEntityAt(block.getX(), block.getY(), block.getZ()); TileEntityBrewingStand tileEntity = (TileEntityBrewingStand)((CraftWorld)block.getWorld()).getTileEntityAt(block.getX(), block.getY(), block.getZ());
if (tileEntity != null)
{
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
tileEntity.items[i] = null; tileEntity.items[i] = null;
} }
} }
}
private void updateBrewingStand(TntGenerator generator) private void updateBrewingStand(TntGenerator generator)
{ {

View File

@ -192,7 +192,7 @@ public class GoldManager extends MiniPlugin
{ {
deductGems(player, gemAmount); deductGems(player, gemAmount);
addGold(player, goldCount); 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); _transferTracker.insertTransfer(player);
} }
} }

View File

@ -5,6 +5,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.creature.Creature; import mineplex.core.creature.Creature;
import mineplex.core.energy.Energy; import mineplex.core.energy.Energy;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.fields.repository.FieldRepository; import mineplex.game.clans.fields.repository.FieldRepository;
import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.condition.ConditionManager;
@ -14,12 +15,13 @@ public class Field extends MiniPlugin
private FieldOre _ore; private FieldOre _ore;
private FieldMonster _mob; 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); super("Field Factory", plugin);
FieldRepository repository = new FieldRepository(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); _ore = new FieldOre(plugin, repository, serverName);
_mob = new FieldMonster(plugin, repository, creature, serverName); _mob = new FieldMonster(plugin, repository, creature, serverName);
} }

View File

@ -39,6 +39,7 @@ public class FieldBlock extends MiniPlugin
private Energy _energy; private Energy _energy;
private FieldRepository _repository; private FieldRepository _repository;
private HashMap<String, FieldBlockData> _blocks; private HashMap<String, FieldBlockData> _blocks;
private ClansManager _clansManager;
private HashSet<String> _active = new HashSet<String>(); private HashSet<String> _active = new HashSet<String>();
@ -52,13 +53,15 @@ public class FieldBlock extends MiniPlugin
private String _serverName; 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); super("Field Block", plugin);
_conditionFactory = condition.Factory(); _conditionFactory = condition.Factory();
_energy = energy; _energy = energy;
_repository = repository; _repository = repository;
_clansManager = clansManager;
_blocks = new HashMap<String, FieldBlockData>(); _blocks = new HashMap<String, FieldBlockData>();
_serverName = serverName; _serverName = serverName;
@ -214,7 +217,7 @@ public class FieldBlock extends MiniPlugin
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void BlockBreak(BlockBreakEvent event) 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. event.setCancelled(true); // Cancel all block breaks in fields. Handle custom breaking for FieldBlocks and Ores.

View File

@ -199,12 +199,9 @@ public class FieldOre extends MiniPlugin
return null; return null;
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void Break(BlockBreakEvent event) public void Break(BlockBreakEvent event)
{ {
if (event.isCancelled())
return;
if (!_oreLocations.containsKey(event.getBlock().getLocation())) if (!_oreLocations.containsKey(event.getBlock().getLocation()))
return; return;

View File

@ -51,7 +51,7 @@ public abstract class ClansShopPage<T extends ShopBase<ClansManager>> extends Sh
public void addShopItem(int slot, Material material, int buyPrice, int sellPrice, byte data) 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) public void addShopItem(int slot, Material material, int buyPrice, int sellPrice, String displayName)

View File

@ -10,6 +10,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.shop.item.DisplayButton;
import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase; import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClanInfo;

View File

@ -29,6 +29,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilParticle;
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.UtilTextMiddle; import mineplex.core.common.util.UtilTextMiddle;
@ -103,7 +104,7 @@ public class Spawn extends MiniPlugin
for (Player cur : UtilServer.getPlayers()) for (Player cur : UtilServer.getPlayers())
{ {
if (_clansManager.getClanUtility().isSafe(cur.getLocation())) if (isInSpawn(cur.getLocation()))
{ {
long lastDamager = _clansManager.getCombatManager().Get(cur).GetLastCombat(); long lastDamager = _clansManager.getCombatManager().Get(cur).GetLastCombat();
long duration = System.currentTimeMillis() - lastDamager; long duration = System.currentTimeMillis() - lastDamager;
@ -115,6 +116,7 @@ public class Spawn extends MiniPlugin
UtilTextMiddle.display(null, message, 0, 20, 0, cur); 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); _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)) 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 @EventHandler
public void onSkillTriggered(SkillTriggerEvent event) public void onSkillTriggered(SkillTriggerEvent event)
{ {

View File

@ -12,5 +12,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.ServerData"/> <classpathentry combineaccessrules="false" kind="src" path="/Mineplex.ServerData"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-3.5.2.jar"/> <classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-3.5.2.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Database"/> <classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Database"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Game.Clans.Core"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -62,6 +62,7 @@ import mineplex.hub.server.ui.LobbyShop;
import mineplex.hub.server.ui.QuickShop; import mineplex.hub.server.ui.QuickShop;
import mineplex.hub.server.ui.ServerCountSorter; import mineplex.hub.server.ui.ServerCountSorter;
import mineplex.hub.server.ui.ServerNpcShop; import mineplex.hub.server.ui.ServerNpcShop;
import mineplex.hub.server.ui.clans.ClansServerShop;
import mineplex.serverdata.Region; import mineplex.serverdata.Region;
import mineplex.serverdata.data.MinecraftServer; import mineplex.serverdata.data.MinecraftServer;
import mineplex.serverdata.data.ServerGroup; import mineplex.serverdata.data.ServerGroup;
@ -124,6 +125,9 @@ public class ServerManager extends MiniPlugin
_quickShop = new QuickShop(this, clientManager, donationManager, "Quick Menu"); _quickShop = new QuickShop(this, clientManager, donationManager, "Quick Menu");
_lobbyShop = new LobbyShop(this, clientManager, donationManager, "Lobby Menu"); _lobbyShop = new LobbyShop(this, clientManager, donationManager, "Lobby Menu");
//_domShop = new new QueueShop(_queueManager, clientManager, donationManager, "Dominate"); //_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) @EventHandler(priority = EventPriority.LOW)

View File

@ -77,7 +77,7 @@ public class LobbyMenu extends ShopPageBase<ServerManager, LobbyShop> implements
lore.add(ChatColor.RESET + C.Line + "Click to join!"); lore.add(ChatColor.RESET + C.Line + "Click to join!");
if (status != Material.EMERALD_BLOCK) 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 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)); 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));
} }

View File

@ -26,7 +26,7 @@ import mineplex.hub.server.ServerManager;
import mineplex.hub.server.ServerSorter; import mineplex.hub.server.ServerSorter;
import mineplex.hub.server.ui.button.JoinServerButton; import mineplex.hub.server.ui.button.JoinServerButton;
public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> implements IServerPage public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop>
{ {
// Shop Item Messages // Shop Item Messages
private static final String MESSAGE_BETA_GET_ULTRA = ChatColor.RESET + C.Line + "Get Ultra to join Tournament servers!"; 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<ServerManager, ServerNpcShop> im
if (serverInfo.HostedByStaff && staffSlot < 9) if (serverInfo.HostedByStaff && staffSlot < 9)
{ {
addButton(staffSlot, getPrivateItem(serverInfo), new JoinServerButton(this, serverInfo)); addButton(staffSlot, getPrivateItem(serverInfo), new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
staffSlot++; staffSlot++;
} }
else else
@ -246,7 +246,7 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
if (slot >= 54) if (slot >= 54)
continue; continue;
addButton(slot, getPrivateItem(serverInfo), new JoinServerButton(this, serverInfo)); addButton(slot, getPrivateItem(serverInfo), new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
slot++; slot++;
} }
} }
@ -276,7 +276,7 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
setItem(slot, shopItem); setItem(slot, shopItem);
else else
{ {
addButton(slot, shopItem, new JoinServerButton(this, serverInfo)); addButton(slot, shopItem, new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
} }
if (full) if (full)
@ -378,7 +378,7 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
{ {
ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded); ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded);
addButton(slot, shopItem, new JoinServerButton(this, serverInfo)); addButton(slot, shopItem, new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
slot++; slot++;
} }
@ -409,17 +409,4 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
buildPage(); 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);
}
} }

View File

@ -3,24 +3,54 @@ package mineplex.hub.server.ui.button;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import mineplex.core.common.Rank;
import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.IButton;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.hub.server.ServerInfo; import mineplex.hub.server.ServerInfo;
import mineplex.hub.server.ServerManager;
import mineplex.hub.server.ui.IServerPage; import mineplex.hub.server.ui.IServerPage;
public class JoinServerButton implements IButton public class JoinServerButton implements IButton
{ {
private IServerPage _page; private ShopPageBase<?, ?> _page;
private ServerManager _serverManager;
private ServerInfo _serverInfo; private ServerInfo _serverInfo;
private Player _player;
public JoinServerButton(IServerPage page, ServerInfo serverInfo) public JoinServerButton(ShopPageBase<?, ?> page, ServerManager serverManager, ServerInfo serverInfo, Player player)
{ {
_page = page; _page = page;
_serverManager = serverManager;
_serverInfo = serverInfo; _serverInfo = serverInfo;
_player = player;
} }
@Override @Override
public void onClick(Player player, ClickType clickType) 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);
}
} }
} }

View File

@ -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<Boolean>()
{
@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!");
}
}
});
}
}

View File

@ -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<ServerManager, ClanMoveServerShop>
{
//private DataRepository<PlayerServerInfo> _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<ServerInfo> 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);
}
}

View File

@ -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<ServerManager>
{
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<ServerManager, ? extends ShopBase<ServerManager>> 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);
}
}

View File

@ -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<ServerManager, ClansServerShop>
{
//private DataRepository<PlayerServerInfo> _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<SimpleClanToken>()
{
@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<ServerInfo> 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);
}
}

View File

@ -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<ServerManager>
{
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<ServerManager, ? extends ShopBase<ServerManager>> 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());
}
}
}
}

View File

@ -157,6 +157,11 @@ public class ServerCommandManager
System.out.println("Registered : " + commandName); 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) public void registerCommandType(String commandName, Class<? extends ServerCommand> commandType)
{ {
registerCommandType(commandName, commandType, null); registerCommandType(commandName, commandType, null);

View File

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