Fix bug with converting gems to coins not properly displaying gem amounts converted. Fix bug with shop item data values not properly being used. Globalize clans to work cross-server and implement GUI to allow players to join clans servers, view clan info from hub, and transfer their clan from server to server.
This commit is contained in:
parent
35c79804ac
commit
aad5942242
@ -146,6 +146,9 @@
|
||||
<fileset dir="../Mineplex.Minecraft.Game.Core/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.Game.Clans.Core/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.Hub">
|
||||
<include name="*.yml"/>
|
||||
</fileset>
|
||||
|
@ -517,6 +517,14 @@ public class UtilPlayer
|
||||
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)
|
||||
{
|
||||
HashMap<Player, Double> players = new HashMap<Player, Double>();
|
||||
|
@ -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
|
||||
{
|
@ -229,7 +229,7 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
|
||||
return _player;
|
||||
}
|
||||
|
||||
protected CoreClient getClient()
|
||||
public CoreClient getClient()
|
||||
{
|
||||
return _client;
|
||||
}
|
||||
|
12
Plugins/Mineplex.Game.Clans.Core/.classpath
Normal file
12
Plugins/Mineplex.Game.Clans.Core/.classpath
Normal 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.8"/>
|
||||
<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>
|
17
Plugins/Mineplex.Game.Clans.Core/.project
Normal file
17
Plugins/Mineplex.Game.Clans.Core/.project
Normal 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>
|
@ -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
|
||||
}
|
||||
}
|
@ -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,12 +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.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.*;
|
||||
@ -40,7 +41,9 @@ 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_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 = ? OR c.admin = 1;";
|
||||
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_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 = ?;";
|
||||
@ -52,7 +55,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());";
|
||||
@ -66,6 +69,7 @@ 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_SERVER_ID = "UPDATE clans SET serverId = ?, home = '' 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 (?);";
|
||||
@ -124,6 +128,105 @@ public class ClanRepository extends RepositoryBase
|
||||
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(int clanId, String serverName, 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()
|
||||
{
|
||||
System.out.println("Beginning to load clans from database...");
|
@ -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
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package mineplex.game.clans.clans.repository.tokens;
|
||||
package mineplex.game.clans.core.repository.tokens;
|
||||
|
||||
public class ClanAllianceToken
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package mineplex.game.clans.clans.repository.tokens;
|
||||
package mineplex.game.clans.core.repository.tokens;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package mineplex.game.clans.clans.repository.tokens;
|
||||
package mineplex.game.clans.core.repository.tokens;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package mineplex.game.clans.clans.repository.tokens;
|
||||
package mineplex.game.clans.core.repository.tokens;
|
||||
|
||||
public class ClanTerritoryToken
|
||||
{
|
@ -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;
|
@ -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;
|
||||
}
|
||||
}
|
@ -11,5 +11,6 @@
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/gson-2.2.1.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Database"/>
|
||||
<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"/>
|
||||
</classpath>
|
||||
|
@ -21,11 +21,11 @@ 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;
|
||||
|
||||
public class ClanInfo
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -10,14 +10,15 @@ import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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.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.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;
|
||||
|
||||
public class ClansDataAccessLayer
|
||||
{
|
||||
@ -42,10 +43,22 @@ public class ClansDataAccessLayer
|
||||
boolean out = _repository.deleteClan(clan.getId());
|
||||
|
||||
if (out)
|
||||
{
|
||||
deleteLocally(clan);
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
@ -68,11 +81,6 @@ public class ClansDataAccessLayer
|
||||
_manager.log("Deleted [" + clan.getName() + "].");
|
||||
}
|
||||
|
||||
if (callback != null) callback.run(out);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void createAndJoin(final Player player, final String name, final Callback<ClanInfo> callback)
|
||||
{
|
||||
create(player.getName(), name, false, new Callback<ClanInfo>()
|
||||
@ -621,6 +629,16 @@ public class ClansDataAccessLayer
|
||||
_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()
|
||||
{
|
||||
return _repository;
|
||||
|
@ -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;
|
||||
|
@ -26,7 +26,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;
|
||||
@ -62,15 +61,17 @@ 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.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;
|
||||
@ -92,12 +93,21 @@ 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.data.DataRepository;
|
||||
import mineplex.serverdata.data.PlayerServerInfo;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ConnectionData;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
|
||||
public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelation
|
||||
{
|
||||
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;
|
||||
|
||||
@ -115,6 +125,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
private Teleport _teleport;
|
||||
private ConditionManager _condition;
|
||||
private ClassCombatShop _classShop;
|
||||
private DataRepository<PlayerServerInfo> _playerRepository; //
|
||||
|
||||
private ClassManager _classManager;
|
||||
public ClassManager getClassManager() { return _classManager; }
|
||||
@ -150,6 +161,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
{
|
||||
super("Clans Manager", plugin);
|
||||
|
||||
_instance = this;
|
||||
_serverName = serverName;
|
||||
_clientManager = clientManager;
|
||||
_combatManager = new CombatManager(plugin);
|
||||
@ -209,6 +221,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan> 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);
|
||||
@ -228,6 +243,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
_claimMap.put(territoryToken.Chunk, new ClanTerritory(territoryToken));
|
||||
}
|
||||
|
||||
_playerRepository = new RedisDataRepository<PlayerServerInfo>(Region.ALL, PlayerServerInfo.class, "ClansServerCache");
|
||||
//RedisDataRepository(ConnectionData writeConn, ConnectionData readConn, Region region, Class<T> elementType, String elementLabel)
|
||||
// Initialize default region factions and territory (spawn/fields/borderlands)
|
||||
_clanRegions = new ClansRegions(plugin, this);
|
||||
_clanRegions.initializeRegions();
|
||||
|
@ -17,7 +17,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
|
||||
{
|
||||
|
@ -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<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."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Plugin.getClanDataAccess().createAndJoin(caller, args[1], new Callback<ClanInfo>()
|
||||
{
|
||||
@Override
|
||||
@ -315,6 +318,8 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
}
|
||||
});
|
||||
}
|
||||
}});
|
||||
}
|
||||
|
||||
public void delete(final Player caller, String[] args)
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
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)
|
||||
|
@ -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;
|
||||
|
@ -12,5 +12,6 @@
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.ServerData"/>
|
||||
<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.Game.Clans.Core"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
@ -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)
|
||||
|
@ -77,7 +77,7 @@ public class LobbyMenu extends ShopPageBase<ServerManager, LobbyShop> 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));
|
||||
}
|
||||
|
@ -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<ServerManager, ServerNpcShop> implements IServerPage
|
||||
public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop>
|
||||
{
|
||||
// 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<ServerManager, ServerNpcShop> 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<ServerManager, ServerNpcShop> 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<ServerManager, ServerNpcShop> 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<ServerManager, ServerNpcShop> 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<ServerManager, ServerNpcShop> 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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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!");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
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 ClansServerShop extends ShopBase<ServerManager>
|
||||
{
|
||||
|
||||
private ClanRepository _repository;
|
||||
|
||||
public ClansServerShop(ServerManager plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||
{
|
||||
super(plugin, clientManager, donationManager, "Clans");
|
||||
|
||||
_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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user