War Invasion, GUI Improvements, New ClanRelation for Winning/Losing War, Update Clan Map for new relation, Show invasions in scoreboard
This commit is contained in:
parent
6187b5e680
commit
f6cfc36e9f
@ -99,13 +99,15 @@ public class C
|
||||
public static ChatColor xSelf = ChatColor.AQUA;
|
||||
public static ChatColor xAlly = ChatColor.GREEN;
|
||||
public static ChatColor xEnemy = ChatColor.RED;
|
||||
public static ChatColor xWar = ChatColor.RED;
|
||||
public static ChatColor xWarWinning = ChatColor.LIGHT_PURPLE;
|
||||
public static ChatColor xWarLosing = ChatColor.RED;
|
||||
public static ChatColor xPillage = ChatColor.LIGHT_PURPLE;
|
||||
|
||||
public static ChatColor xdNeutral = ChatColor.GOLD;
|
||||
public static ChatColor xdSelf = ChatColor.DARK_AQUA;
|
||||
public static ChatColor xdAlly = ChatColor.DARK_GREEN;
|
||||
public static ChatColor xdEnemy = ChatColor.DARK_RED;
|
||||
public static ChatColor xdWar = ChatColor.DARK_RED;
|
||||
public static ChatColor xdWarWinning = ChatColor.DARK_PURPLE;
|
||||
public static ChatColor xdWarLosing = ChatColor.DARK_RED;
|
||||
public static ChatColor xdPillage = ChatColor.DARK_PURPLE;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class ClanRepository extends RepositoryBase
|
||||
private static String ADD_CLAN = "INSERT INTO clans (serverId, name, description, home, admin, dateCreated, energy, lastOnline) VALUES (?, ?, ?, ?, ?, now(), ?, now());";
|
||||
private static String ADD_CLAN_MEMBER = "INSERT INTO accountClan (accountId, clanId, clanRole) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.name = ?;";
|
||||
private static String ADD_CLAN_ALLIANCE = "INSERT INTO clanAlliances (clanId, otherClanId, trusted) VALUES (?, ?, ?);";
|
||||
private static String ADD_CLAN_WAR = "INSERT INTO clanWar (initiatorId, clanId, score) VALUES (?, ?, ?)";
|
||||
private static String ADD_CLAN_WAR = "INSERT INTO clanWar (initiatorId, clanId, score, created, lastUpdated) VALUES (?, ?, ?, ?, ?)";
|
||||
private static String ADD_CLAN_TERRITORY = "INSERT INTO clanTerritory (clanId, chunk, safe) VALUES (?, ?, ?);";
|
||||
|
||||
private static String UPDATE_CLAN = "UPDATE clans SET name = ?, description = ?, home = ?, admin = ?, energy = ?, kills = ?, murder = ?, deaths = ?, warWins = ?, warLosses = ?, lastOnline = ? WHERE id = ?;";
|
||||
@ -515,9 +515,10 @@ public class ClanRepository extends RepositoryBase
|
||||
return affectedRows == size;
|
||||
}
|
||||
|
||||
public void addWar(int initiatorId, int clanId, int score)
|
||||
public void addWar(int initiatorId, int clanId, int score, Timestamp currentTime)
|
||||
{
|
||||
executeUpdate(ADD_CLAN_WAR, new ColumnInt("initiatorId", initiatorId), new ColumnInt("clanId", clanId), new ColumnInt("score", score));
|
||||
executeUpdate(ADD_CLAN_WAR, new ColumnInt("initiatorId", initiatorId), new ColumnInt("clanId", clanId), new ColumnInt("score", score),
|
||||
new ColumnTimestamp("created", currentTime), new ColumnTimestamp("lastUpdated", currentTime));
|
||||
}
|
||||
|
||||
public boolean updateWar(int initiatorId, int clanId, int score, Timestamp lastUpdated)
|
||||
|
@ -31,20 +31,28 @@ public class ClanWarData
|
||||
return _clanB;
|
||||
}
|
||||
|
||||
public int getClanAPoints()
|
||||
{
|
||||
return _clanAPoints;
|
||||
}
|
||||
|
||||
public int getClanBPoints()
|
||||
{
|
||||
return -_clanAPoints;
|
||||
}
|
||||
|
||||
public int getPoints(String clan)
|
||||
{
|
||||
if (_clanA.equals(clan))
|
||||
return getPoints();
|
||||
return getClanAPoints();
|
||||
else if (_clanB.equals(clan))
|
||||
return -getPoints();
|
||||
return getClanBPoints();
|
||||
|
||||
throw new RuntimeException("ClanWarData::getPoints Invalid Clan for War. ClanA: " + _clanA + ", ClanB: " + _clanB + ", Lookup Clan: " + clan);
|
||||
}
|
||||
|
||||
public int getPoints()
|
||||
{
|
||||
System.out.println("ClanWarData::getPoints Value: " + _clanAPoints + " Hash: " + hashCode());
|
||||
|
||||
return _clanAPoints;
|
||||
}
|
||||
|
||||
@ -70,7 +78,7 @@ public class ClanWarData
|
||||
|
||||
public void setCooldown(long cooldown)
|
||||
{
|
||||
_cooldown = cooldown;
|
||||
_cooldown = System.currentTimeMillis() + cooldown;
|
||||
}
|
||||
|
||||
public boolean isOnCooldown()
|
||||
@ -78,12 +86,26 @@ public class ClanWarData
|
||||
return _cooldown >= System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void resetPoints()
|
||||
{
|
||||
update();
|
||||
|
||||
_clanAPoints = 0;
|
||||
}
|
||||
|
||||
public void increment(String clan)
|
||||
{
|
||||
update();
|
||||
|
||||
if (_clanA.equals(clan))
|
||||
_clanAPoints++;
|
||||
else if (_clanB.equals(clan))
|
||||
_clanAPoints--;
|
||||
else throw new RuntimeException("ClanWarData::increment Invalid Clan for War. ClanA: " + _clanA + ", ClanB: " + _clanB + ", Lookup Clan: " + clan);
|
||||
}
|
||||
|
||||
private void update()
|
||||
{
|
||||
setLastUpdated(new Timestamp(System.currentTimeMillis()));
|
||||
}
|
||||
}
|
||||
|
@ -555,10 +555,14 @@ public class ClanInfo
|
||||
{
|
||||
int warPoints = 0;
|
||||
|
||||
ClanWarData data = getWarData(against);
|
||||
ClanWarData data = _warIn.get(against);
|
||||
if (data != null)
|
||||
{
|
||||
warPoints = data.getPoints(getName());
|
||||
warPoints = data.getClanBPoints();
|
||||
}
|
||||
else if ((data = _warOut.get(against)) != null)
|
||||
{
|
||||
warPoints = data.getClanAPoints();
|
||||
}
|
||||
|
||||
return warPoints;
|
||||
@ -590,6 +594,20 @@ public class ClanInfo
|
||||
else throw new RuntimeException("Failed to add war to clan `" + getName() + "` ClanA: " + war.getClanA() + ", ClanB: " + war.getClanB());
|
||||
}
|
||||
|
||||
public List<ClanWarData> getWars()
|
||||
{
|
||||
List<ClanWarData> wars = new LinkedList<ClanWarData>();
|
||||
wars.addAll(_warIn.values());
|
||||
wars.addAll(_warOut.values());
|
||||
|
||||
System.out.println("Get All Wars");
|
||||
for (ClanWarData data : wars)
|
||||
{
|
||||
System.out.println("clanA: " + data.getClanA() + " clanB: " + data.getClanB());
|
||||
}
|
||||
return wars;
|
||||
}
|
||||
|
||||
public void clearWar(String againstClan)
|
||||
{
|
||||
_warIn.remove(againstClan);
|
||||
@ -656,6 +674,11 @@ public class ClanInfo
|
||||
return players;
|
||||
}
|
||||
|
||||
public int getOnlinePlayerCount()
|
||||
{
|
||||
return _onlinePlayers.size();
|
||||
}
|
||||
|
||||
public void playerOnline(Player player)
|
||||
{
|
||||
ClansPlayer clansPlayer = _memberMap.get(player.getUniqueId());
|
||||
|
@ -2,13 +2,15 @@ package mineplex.game.clans.clans;
|
||||
|
||||
public enum ClanRole
|
||||
{
|
||||
NONE(0), RECRUIT(100), MEMBER(500), ADMIN(1000), LEADER(Integer.MAX_VALUE);
|
||||
NONE(0, "None"), RECRUIT(100, "Recruit"), MEMBER(500, "Member"), ADMIN(1000, "Admin"), LEADER(Integer.MAX_VALUE, "Leader");
|
||||
|
||||
private int _powerValue;
|
||||
private String _friendlyName;
|
||||
|
||||
ClanRole(int powerValue)
|
||||
ClanRole(int powerValue, String friendlyName)
|
||||
{
|
||||
_powerValue = powerValue;
|
||||
_friendlyName = friendlyName;
|
||||
}
|
||||
|
||||
public boolean has(ClanRole role)
|
||||
@ -16,6 +18,11 @@ public enum ClanRole
|
||||
return getPowerValue() >= role.getPowerValue();
|
||||
}
|
||||
|
||||
public String getFriendlyName()
|
||||
{
|
||||
return _friendlyName;
|
||||
}
|
||||
|
||||
public int getPowerValue()
|
||||
{
|
||||
return _powerValue;
|
||||
|
@ -74,8 +74,6 @@ public class ClansDataAccessLayer
|
||||
|
||||
_manager.getClanMap().remove(clan.getName());
|
||||
|
||||
_manager.getWarManager().clearInvasions(clan.getName());
|
||||
|
||||
for (ClansPlayer player : clan.getMembers().values())
|
||||
{
|
||||
_manager.getClanMemberUuidMap().remove(player.getUuid());
|
||||
@ -620,14 +618,15 @@ public class ClansDataAccessLayer
|
||||
|
||||
public void war(final ClanInfo clanA, final ClanInfo clanB, final int score, final Callback<ClanWarData> warCallback)
|
||||
{
|
||||
final ClanWarData war = new ClanWarData(clanA.getName(), clanB.getName(), score, new Timestamp(System.currentTimeMillis()), new Timestamp(System.currentTimeMillis()), 0);
|
||||
final Timestamp currentTime = new Timestamp(System.currentTimeMillis());
|
||||
final ClanWarData war = new ClanWarData(clanA.getName(), clanB.getName(), score, currentTime, currentTime, 0);
|
||||
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_repository.addWar(clanA.getId(), clanB.getId(), score);
|
||||
_repository.addWar(clanA.getId(), clanB.getId(), score, currentTime);
|
||||
|
||||
runSync(new Runnable()
|
||||
{
|
||||
|
@ -44,7 +44,8 @@ public class ClansUtility
|
||||
SELF(C.xSelf, C.xdSelf),
|
||||
ALLY(C.xAlly, C.xdAlly),
|
||||
ALLY_TRUST(C.xAlly, C.xdAlly),
|
||||
WAR(C.xWar, C.xdWar),
|
||||
WAR_WINNING(C.xWarWinning, C.xdWarWinning),
|
||||
WAR_LOSING(C.xWarLosing, C.xdWarLosing),
|
||||
NEUTRAL(C.xNeutral, C.xdNeutral),
|
||||
ADMIN(C.xAdmin, C.xAdmin),
|
||||
SAFE(C.xSafe, C.xSafe);
|
||||
@ -522,10 +523,13 @@ public class ClansUtility
|
||||
if (cA.isAlly(cB.getName()))
|
||||
return ClanRelation.ALLY;
|
||||
|
||||
if (cA.isEnemy(cB))
|
||||
return ClanRelation.WAR;
|
||||
// War
|
||||
int warPoints = cA.getWarPoints(cB);
|
||||
if (warPoints >= 10)
|
||||
return ClanRelation.WAR_WINNING;
|
||||
else if (warPoints <= -10)
|
||||
return ClanRelation.WAR_LOSING;
|
||||
|
||||
//Enemy
|
||||
return ClanRelation.NEUTRAL;
|
||||
}
|
||||
|
||||
@ -915,4 +919,161 @@ public class ClansUtility
|
||||
return true;
|
||||
}
|
||||
|
||||
public void promote(Player caller, String other)
|
||||
{
|
||||
ClanInfo clan = getClanByPlayer(caller);
|
||||
|
||||
if (clan == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
|
||||
return;
|
||||
}
|
||||
|
||||
ClansPlayer self = clan.getMembers().get(caller.getUniqueId());
|
||||
ClansPlayer target = clan.getClansPlayerFromName(other);
|
||||
|
||||
if (target == null) return;
|
||||
|
||||
if (target.equals(caller.getName()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You cannot promote yourself."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.getRole().ordinal() <= target.getRole().ordinal())
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(other) + "."));
|
||||
return;
|
||||
}
|
||||
|
||||
// Task
|
||||
String newRank = "?";
|
||||
if (target.getRole() == ClanRole.RECRUIT)
|
||||
{
|
||||
Clans.getClanDataAccess().role(clan, target.getUuid(), ClanRole.MEMBER);
|
||||
newRank = "Member";
|
||||
}
|
||||
else if (target.getRole() == ClanRole.MEMBER)
|
||||
{
|
||||
Clans.getClanDataAccess().role(clan, target.getUuid(), ClanRole.ADMIN);
|
||||
newRank = "Admin";
|
||||
}
|
||||
else if (target.getRole() == ClanRole.ADMIN)
|
||||
{
|
||||
Clans.getClanDataAccess().role(clan, target.getUuid(), ClanRole.LEADER);
|
||||
newRank = "Leader";
|
||||
|
||||
// Give Leader
|
||||
Clans.getClanDataAccess().role(clan, caller.getUniqueId(), ClanRole.ADMIN);
|
||||
}
|
||||
|
||||
// Inform
|
||||
clan.inform(F.name(caller.getName()) + " promoted " + F.name(other) + " to " + F.elem(newRank) + ".", null);
|
||||
}
|
||||
|
||||
public void demote(Player caller, String other)
|
||||
{
|
||||
ClanInfo clan = getClanByPlayer(caller);
|
||||
|
||||
if (clan == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
|
||||
return;
|
||||
}
|
||||
|
||||
ClansPlayer self = clan.getMembers().get(caller.getUniqueId());
|
||||
ClansPlayer target = clan.getClansPlayerFromName(other);
|
||||
|
||||
if (target == null) return;
|
||||
|
||||
if (target.equals(caller.getName()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You cannot demote yourself."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.getRole().ordinal() <= target.getRole().ordinal())
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(other) + "."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.getRole() == ClanRole.RECRUIT)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You cannot demote " + F.name(other) + " any further."));
|
||||
return;
|
||||
}
|
||||
|
||||
// Task
|
||||
String newRank = "?";
|
||||
if (target.getRole() == ClanRole.MEMBER)
|
||||
{
|
||||
Clans.getClanDataAccess().role(clan, target.getUuid(), ClanRole.RECRUIT);
|
||||
newRank = "Recruit";
|
||||
}
|
||||
else if (target.getRole() == ClanRole.ADMIN)
|
||||
{
|
||||
Clans.getClanDataAccess().role(clan, target.getUuid(), ClanRole.MEMBER);
|
||||
newRank = "Member";
|
||||
}
|
||||
|
||||
// Inform
|
||||
clan.inform(F.main("Clans", F.name(caller.getName()) + " demoted " + F.name(other) + " to " + F.elem(newRank) + "."), null);
|
||||
}
|
||||
|
||||
public void kick(final Player caller, final String other)
|
||||
{
|
||||
final ClanInfo clan = getClanByPlayer(caller);
|
||||
|
||||
if (clan == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
|
||||
return;
|
||||
}
|
||||
|
||||
ClansPlayer self = clan.getMembers().get(caller.getUniqueId());
|
||||
ClansPlayer clansPlayer = clan.getClansPlayerFromName(other);
|
||||
|
||||
if (self == null || clansPlayer == null) return;
|
||||
|
||||
if (self.getRole() != ClanRole.LEADER && self.getRole() != ClanRole.ADMIN)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can kick members."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (clansPlayer.getRole() == ClanRole.LEADER)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "Clan leaders cannot be kicked."));
|
||||
UtilPlayer.message(caller, F.main("Clans", "To disband a clan, use /c disband"));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((clansPlayer.getRole() == ClanRole.LEADER && self.getRole() == ClanRole.ADMIN) || (clansPlayer.getRole() == ClanRole.ADMIN && self.getRole() == ClanRole.ADMIN))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(other) + "."));
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = UtilPlayer.searchOnline(null, other, false);
|
||||
|
||||
Callback<Boolean> callback = new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
// Inform
|
||||
if (player != null) UtilPlayer.message(player, F.main("Clans", F.name(caller.getName()) + " kicked you from " + F.elem("Clan " + clan.getName()) + "."));
|
||||
UtilPlayer.message(caller, F.main("Clans", "You kicked " + F.name(other) + " from your Clan."));
|
||||
clan.inform(F.main("Clans", F.name(caller.getName()) + " kicked " + F.name(other) + " from your Clan."), caller.getName());
|
||||
}
|
||||
};
|
||||
|
||||
// Task
|
||||
if (player != null)
|
||||
Clans.getClanDataAccess().leave(clan, player, callback);
|
||||
else
|
||||
Clans.getClanDataAccess().leave(clan, clansPlayer, callback);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -298,46 +298,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
public void delete(final Player caller, String[] args)
|
||||
{
|
||||
final ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
|
||||
|
||||
if (clan == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Plugin.getClanUtility().getRole(caller) != ClanRole.LEADER)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader can disband the Clan."));
|
||||
return;
|
||||
}
|
||||
|
||||
// Event
|
||||
ClanDisbandedEvent event = new ClanDisbandedEvent(clan, caller);
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Task
|
||||
Plugin.getClanDataAccess().delete(clan, new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
// Inform
|
||||
UtilServer.broadcast(F.main("Clans", F.name(caller.getName()) + " disbanded " + F.elem("Clan " + clan.getName()) + "."));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "There was an error processing your request. Try again later"));
|
||||
}
|
||||
}
|
||||
});
|
||||
Plugin.getClanUtility().delete(caller);
|
||||
}
|
||||
|
||||
public void invite(Player caller, String[] args)
|
||||
@ -497,101 +458,29 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
}
|
||||
|
||||
final String target = UtilPlayer.searchCollection(caller, args[1], clan.getMemberNameSet(), "Clan Member", true);
|
||||
ClansPlayer self = clan.getMembers().get(caller.getUniqueId());
|
||||
ClansPlayer clansPlayer = clan.getClansPlayerFromName(target);
|
||||
|
||||
if (target == null || clansPlayer == null) return;
|
||||
|
||||
if (self.getRole() != ClanRole.LEADER && self.getRole() != ClanRole.ADMIN)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can kick members."));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((clansPlayer.getRole() == ClanRole.LEADER && self.getRole() == ClanRole.ADMIN) || (clansPlayer.getRole() == ClanRole.ADMIN && self.getRole() == ClanRole.ADMIN))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(target) + "."));
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = UtilPlayer.searchOnline(null, target, false);
|
||||
|
||||
Callback<Boolean> callback = new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
// Inform
|
||||
if (player != null) UtilPlayer.message(player, F.main("Clans", F.name(caller.getName()) + " kicked you from " + F.elem("Clan " + clan.getName()) + "."));
|
||||
UtilPlayer.message(caller, F.main("Clans", "You kicked " + F.name(target) + " from your Clan."));
|
||||
clan.inform(F.main("Clans", F.name(caller.getName()) + " kicked " + F.name(target) + " from your Clan."), caller.getName());
|
||||
}
|
||||
};
|
||||
|
||||
// Task
|
||||
if (player != null)
|
||||
Plugin.getClanDataAccess().leave(clan, player, callback);
|
||||
else
|
||||
Plugin.getClanDataAccess().leave(clan, clansPlayer, callback);
|
||||
|
||||
_manager.getClanUtility().kick(caller, target);
|
||||
}
|
||||
|
||||
public void promote(Player caller, String[] args)
|
||||
{
|
||||
ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
|
||||
|
||||
|
||||
if (clan == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You did not input player to promote."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final String targetName = UtilPlayer.searchCollection(caller, args[1], clan.getMemberNameSet(), "Clan Member", true);
|
||||
ClansPlayer self = clan.getMembers().get(caller.getUniqueId());
|
||||
ClansPlayer target = clan.getClansPlayerFromName(targetName);
|
||||
|
||||
if (target == null) return;
|
||||
|
||||
if (target.equals(caller.getName()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You cannot promote yourself."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.getRole().ordinal() <= target.getRole().ordinal())
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(targetName) + "."));
|
||||
return;
|
||||
}
|
||||
|
||||
// Task
|
||||
String newRank = "?";
|
||||
if (target.getRole() == ClanRole.RECRUIT)
|
||||
{
|
||||
Plugin.getClanDataAccess().role(clan, target.getUuid(), ClanRole.MEMBER);
|
||||
newRank = "Member";
|
||||
}
|
||||
else if (target.getRole() == ClanRole.MEMBER)
|
||||
{
|
||||
Plugin.getClanDataAccess().role(clan, target.getUuid(), ClanRole.ADMIN);
|
||||
newRank = "Admin";
|
||||
}
|
||||
else if (target.getRole() == ClanRole.ADMIN)
|
||||
{
|
||||
Plugin.getClanDataAccess().role(clan, target.getUuid(), ClanRole.LEADER);
|
||||
newRank = "Leader";
|
||||
|
||||
// Give Leader
|
||||
Plugin.getClanDataAccess().role(clan, caller.getUniqueId(), ClanRole.ADMIN);
|
||||
}
|
||||
|
||||
// Inform
|
||||
clan.inform(F.name(caller.getName()) + " promoted " + F.name(targetName) + " to " + F.elem(newRank) + ".", null);
|
||||
|
||||
_manager.getClanUtility().promote(caller, targetName);
|
||||
}
|
||||
|
||||
public void demote(Player caller, String[] args)
|
||||
@ -611,44 +500,8 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
}
|
||||
|
||||
final String targetName = UtilPlayer.searchCollection(caller, args[1], clan.getMemberNameSet(), "Clan Member", true);
|
||||
ClansPlayer self = clan.getMembers().get(caller.getUniqueId());
|
||||
ClansPlayer target = clan.getClansPlayerFromName(targetName);
|
||||
|
||||
if (target == null) return;
|
||||
|
||||
if (target.equals(caller.getName()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You cannot demote yourself."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.getRole().ordinal() <= target.getRole().ordinal())
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(targetName) + "."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.getRole() == ClanRole.RECRUIT)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You cannot demote " + F.name(targetName) + " any further."));
|
||||
return;
|
||||
}
|
||||
|
||||
// Task
|
||||
String newRank = "?";
|
||||
if (target.getRole() == ClanRole.MEMBER)
|
||||
{
|
||||
Plugin.getClanDataAccess().role(clan, target.getUuid(), ClanRole.RECRUIT);
|
||||
newRank = "Recruit";
|
||||
}
|
||||
else if (target.getRole() == ClanRole.ADMIN)
|
||||
{
|
||||
Plugin.getClanDataAccess().role(clan, target.getUuid(), ClanRole.MEMBER);
|
||||
newRank = "Member";
|
||||
}
|
||||
|
||||
// Inform
|
||||
clan.inform(F.main("Clans", F.name(caller.getName()) + " demoted " + F.name(targetName) + " to " + F.elem(newRank) + "."), null);
|
||||
|
||||
_manager.getClanUtility().demote(caller, targetName);
|
||||
}
|
||||
|
||||
public void ally(Player caller, String[] args)
|
||||
|
@ -0,0 +1,46 @@
|
||||
package mineplex.game.clans.clans.gui.button;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClanRole;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.gui.ClanShop;
|
||||
import mineplex.game.clans.clans.gui.page.ClanMainPage;
|
||||
|
||||
public class ClanMemeberButton extends ClanButton
|
||||
{
|
||||
private ClanMainPage _page;
|
||||
private String _other;
|
||||
|
||||
public ClanMemeberButton(ClanShop shop, ClansManager clansManager, Player player, ClanInfo clanInfo, ClanRole clanRole, ClanMainPage page, String other)
|
||||
{
|
||||
super(shop, clansManager, player, clanInfo, clanRole);
|
||||
_other = other;
|
||||
_page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
if (clickType == ClickType.LEFT)
|
||||
{
|
||||
// Promote
|
||||
getClansManager().getClanUtility().promote(getPlayer(), _other);
|
||||
_page.refresh();
|
||||
}
|
||||
else if (clickType == ClickType.RIGHT)
|
||||
{
|
||||
// Demote
|
||||
getClansManager().getClanUtility().demote(getPlayer(), _other);
|
||||
_page.refresh();
|
||||
}
|
||||
else if (clickType == ClickType.SHIFT_RIGHT)
|
||||
{
|
||||
// Kick
|
||||
getClansManager().getClanUtility().kick(getPlayer(), _other);
|
||||
_page.refresh();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package mineplex.game.clans.clans.gui.button;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.core.shop.item.IButton;
|
||||
|
||||
public class MemberButton implements IButton
|
||||
{
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
Bukkit.broadcastMessage("Member button click");
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package mineplex.game.clans.clans.gui.page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
@ -13,7 +14,10 @@ import org.bukkit.inventory.ItemStack;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilSkull;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
@ -28,8 +32,10 @@ import mineplex.game.clans.clans.gui.button.ClanCreateButton;
|
||||
import mineplex.game.clans.clans.gui.button.ClanEnergyButton;
|
||||
import mineplex.game.clans.clans.gui.button.ClanInviteButton;
|
||||
import mineplex.game.clans.clans.gui.button.ClanLeaveButton;
|
||||
import mineplex.game.clans.clans.gui.button.ClanMemeberButton;
|
||||
import mineplex.game.clans.clans.gui.button.ClanTerritoryButton;
|
||||
import mineplex.game.clans.clans.gui.button.ClanWhoButton;
|
||||
import mineplex.game.clans.core.war.ClanWarData;
|
||||
|
||||
public class ClanMainPage extends ClanPageBase
|
||||
{
|
||||
@ -62,7 +68,7 @@ public class ClanMainPage extends ClanPageBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildClan(ClanInfo clanInfo, ClanRole clanRole)
|
||||
public void buildClan(final ClanInfo clanInfo, ClanRole clanRole)
|
||||
{
|
||||
// Invites
|
||||
{
|
||||
@ -72,15 +78,16 @@ public class ClanMainPage extends ClanPageBase
|
||||
int size = clanInfo.getSize();
|
||||
int maxSize = clanInfo.getMaxSize();
|
||||
ArrayList<String> inviteLore = new ArrayList<String>();
|
||||
inviteLore.add(C.Reset + "Clans can have a max size of " + C.cYellow + maxSize + C.Reset + " members");
|
||||
inviteLore.add(C.Reset + "You currently have " + C.cYellow + size + C.Reset + " members");
|
||||
inviteLore.add(C.Reset + "More members in your clan will allow you to");
|
||||
inviteLore.add(C.Reset + "claim more land, but it will also increase");
|
||||
inviteLore.add(C.Reset + "your Energy drain per minute.");
|
||||
inviteLore.add(" ");
|
||||
inviteLore.add(C.Reset + C.cGray + "Clans can have a max size of " + C.cYellow + maxSize + C.cGray + " members");
|
||||
inviteLore.add(C.Reset + C.cGray + "You currently have " + C.cYellow + size + C.cGray + " members");
|
||||
inviteLore.add(C.Reset + C.cGray + "More members in your clan will allow you to");
|
||||
inviteLore.add(C.Reset + C.cGray + "claim more land, but it will also increase");
|
||||
inviteLore.add(C.Reset + C.cGray + "your Energy drain per minute.");
|
||||
if (clanRole.has(ClanRole.ADMIN))
|
||||
{
|
||||
inviteLore.add(" ");
|
||||
inviteLore.add(C.Reset + C.cGray + "Left Click " + C.cWhite + "Invite Player");
|
||||
inviteLore.add(C.Reset + C.cYellow + "Left Click " + C.cWhite + "Invite Player");
|
||||
}
|
||||
|
||||
ShopItem inviteItem = new ShopItem(inviteMaterial, inviteDate, inviteName, inviteLore.toArray(new String[0]), 1, false, false);
|
||||
@ -96,19 +103,20 @@ public class ClanMainPage extends ClanPageBase
|
||||
ArrayList<String> territoryLore = new ArrayList<String>();
|
||||
int claims = clanInfo.getClaims();
|
||||
int maxClaims = clanInfo.getClaimsMax();
|
||||
territoryLore.add(C.Reset + "Every land claim represents a 16x16 chunk of the map");
|
||||
territoryLore.add(C.Reset + "Your clan can claim a maximum of " + C.cYellow + maxClaims + C.Reset + " chunks");
|
||||
territoryLore.add(C.Reset + "You currently have " + C.cYellow + claims + C.Reset + " chunk(s) claimed");
|
||||
territoryLore.add(C.Reset + "You can increase your max claims with more clan members");
|
||||
territoryLore.add(C.Reset + "Your Energy drain will increase with every new land claim");
|
||||
territoryLore.add(" ");
|
||||
territoryLore.add(C.Reset + C.cGray + "Every land claim represents a 16x16 chunk");
|
||||
territoryLore.add(C.Reset + C.cGray + "Your clan can claim a maximum of " + C.cYellow + maxClaims + C.cGray + " chunks");
|
||||
territoryLore.add(C.Reset + C.cGray + "You currently have " + C.cYellow + claims + C.cGray + " chunk(s) claimed");
|
||||
territoryLore.add(C.Reset + C.cGray + "Increase max claims with more clan members");
|
||||
territoryLore.add(C.Reset + C.cGray + "Energy cost will increase with more land claimed");
|
||||
if (clanRole.has(ClanRole.ADMIN))
|
||||
{
|
||||
territoryLore.add(" ");
|
||||
territoryLore.add(ChatColor.RESET + C.cGray + "Left Click " + C.cWhite + "Claim Land");
|
||||
territoryLore.add(ChatColor.RESET + C.cGray + "Shift-Left Click " + C.cWhite + "Unclaim Land");
|
||||
territoryLore.add(ChatColor.RESET + C.cYellow + "Left Click " + C.cWhite + "Claim Land");
|
||||
territoryLore.add(ChatColor.RESET + C.cYellow + "Shift-Left Click " + C.cWhite + "Unclaim Land");
|
||||
if (clanRole.has(ClanRole.LEADER))
|
||||
{
|
||||
territoryLore.add(ChatColor.RESET + C.cGray + "Shift-Right Click " + C.cWhite + "Unclaim All Land");
|
||||
territoryLore.add(ChatColor.RESET + C.cYellow + "Shift-Right Click " + C.cWhite + "Unclaim All Land");
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,15 +131,16 @@ public class ClanMainPage extends ClanPageBase
|
||||
Material energyMaterial = USE_RESOURCE_ICONS ? ClanIcon.ENERGY.getMaterial() : Material.GOLD_BLOCK;
|
||||
byte energyData = USE_RESOURCE_ICONS ? ClanIcon.ENERGY.getData() : 0;
|
||||
ArrayList<String> energyLore = new ArrayList<String>();
|
||||
energyLore.add(C.Reset + "Energy is the currency used to upkeep");
|
||||
energyLore.add(C.Reset + "your clan. Energy drains over time and");
|
||||
energyLore.add(C.Reset + "you will need to refill it at the NPC in");
|
||||
energyLore.add(C.Reset + "the shops. More clan members and more land");
|
||||
energyLore.add(C.Reset + "increases the rate energy drains at.");
|
||||
energyLore.add(" ");
|
||||
energyLore.add(C.Reset + C.cGray + "Energy is the currency used to upkeep");
|
||||
energyLore.add(C.Reset + C.cGray + "your clan. Energy drains over time and");
|
||||
energyLore.add(C.Reset + C.cGray + "you will need to refill it at the NPC in");
|
||||
energyLore.add(C.Reset + C.cGray + "the shops. More clan members and more land");
|
||||
energyLore.add(C.Reset + C.cGray + "increases the rate energy drains at.");
|
||||
energyLore.add(" ");
|
||||
energyLore.add(C.Reset + C.cYellow + "Energy " + C.cWhite + clanInfo.getEnergy() + "/" + clanInfo.getEnergyMax());
|
||||
if (clanInfo.getEnergyCostPerMinute() > 0)
|
||||
energyLore.add(C.Reset + "Time Left " + C.cYellow + clanInfo.getEnergyLeftString());
|
||||
energyLore.add(C.Reset + "Energy " + C.cYellow + clanInfo.getEnergy());
|
||||
energyLore.add(C.Reset + "Max Energy " + C.cYellow + clanInfo.getEnergyMax());
|
||||
energyLore.add(C.Reset + C.cYellow + "Energy Depletes " + C.cWhite + clanInfo.getEnergyLeftString());
|
||||
|
||||
ShopItem energyItem = new ShopItem(energyMaterial, energyData, energyName, energyLore.toArray(new String[0]), 1, false, false);
|
||||
ClanEnergyButton energyButton = new ClanEnergyButton(getShop(), getPlugin(), getPlayer(), clanInfo, clanRole);
|
||||
@ -148,11 +157,11 @@ public class ClanMainPage extends ClanPageBase
|
||||
leaveLore.add(" ");
|
||||
if (clanRole.has(ClanRole.MEMBER))
|
||||
{
|
||||
leaveLore.add(ChatColor.RESET + C.cGray + "Shift-Left Click " + C.cWhite + "Leave Clan");
|
||||
leaveLore.add(ChatColor.RESET + C.cYellow + "Shift-Left Click " + C.cWhite + "Leave Clan");
|
||||
}
|
||||
if (clanRole.has(ClanRole.LEADER))
|
||||
{
|
||||
leaveLore.add(ChatColor.RESET + C.cGray + "Shift-Right Click " + C.cWhite + "Disband Clan");
|
||||
leaveLore.add(ChatColor.RESET + C.cYellow + "Shift-Right Click " + C.cWhite + "Disband Clan");
|
||||
}
|
||||
|
||||
ShopItem leaveItem = new ShopItem(leaveMaterial, leaveData, leaveName, leaveLore.toArray(new String[0]), 1, false, false);
|
||||
@ -166,6 +175,10 @@ public class ClanMainPage extends ClanPageBase
|
||||
Material commandsMaterial = USE_RESOURCE_ICONS ? ClanIcon.COMMANDS.getMaterial() : Material.PAPER;
|
||||
byte commandsData = USE_RESOURCE_ICONS ? ClanIcon.COMMANDS.getData() : 0;
|
||||
ArrayList<String> commandsLore = new ArrayList<String>();
|
||||
commandsLore.add(" ");
|
||||
commandsLore.add(ChatColor.RESET + C.cYellow + "/c ally <clan> " + C.cWhite + "Request Ally");
|
||||
commandsLore.add(ChatColor.RESET + C.cYellow + "/c neutral <clan> " + C.cWhite + "Revoke Ally");
|
||||
commandsLore.add(ChatColor.RESET + C.cYellow + "/c sethome " + C.cWhite + "Set Home");
|
||||
|
||||
ShopItem commandsItem = new ShopItem(commandsMaterial, commandsData, commandsName, commandsLore.toArray(new String[0]), 1, false, false);
|
||||
setItem(8, commandsItem);
|
||||
@ -176,7 +189,7 @@ public class ClanMainPage extends ClanPageBase
|
||||
int slot = 18;
|
||||
for (ClansPlayer clansPlayer : UtilAlg.sortSet(clanInfo.getMembers().values(), new ClansPlayerComparator()))
|
||||
{
|
||||
addPlayerButton(slot, clansPlayer);
|
||||
addPlayerButton(slot, clansPlayer, clanInfo, clanRole);
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
@ -212,11 +225,63 @@ public class ClanMainPage extends ClanPageBase
|
||||
|
||||
// Wars
|
||||
{
|
||||
TreeSet<ClanWarData> warSet = new TreeSet<ClanWarData>(new Comparator<ClanWarData>()
|
||||
{
|
||||
@Override
|
||||
public int compare(ClanWarData o1, ClanWarData o2)
|
||||
{
|
||||
return o1.getPoints(clanInfo.getName()) - o2.getPoints(clanInfo.getName());
|
||||
}
|
||||
});
|
||||
|
||||
warSet.addAll(clanInfo.getWars());
|
||||
|
||||
Iterator<ClanWarData> descIterator = warSet.descendingIterator();
|
||||
Iterator<ClanWarData> ascIterator = warSet.iterator();
|
||||
|
||||
for (int i = 0; i < 4 && descIterator.hasNext(); i++)
|
||||
{
|
||||
ClanWarData data = descIterator.next();
|
||||
int slot = 45 + i;
|
||||
addWarButton(slot, clanInfo, data);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4 && ascIterator.hasNext(); i++)
|
||||
{
|
||||
ClanWarData data = ascIterator.next();
|
||||
int slot = 53 - i;
|
||||
addWarButton(slot, clanInfo, data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void addWarButton(int slot, ClanInfo clan, final ClanWarData clanWar)
|
||||
{
|
||||
String enemyName = clanWar.getClanA().equals(clan.getName()) ? clanWar.getClanB() : clanWar.getClanA();
|
||||
final ClanInfo enemy = getPlugin().getClan(enemyName);
|
||||
String itemName = enemyName;
|
||||
Material material = USE_RESOURCE_ICONS ? ClanIcon.WAR.getMaterial() : Material.DIAMOND_SWORD;
|
||||
byte data = USE_RESOURCE_ICONS ? ClanIcon.WAR.getData() : 0;
|
||||
int warPoints = clanWar.getPoints(clan.getName());
|
||||
|
||||
ArrayList<String> lore = new ArrayList<String>(5);
|
||||
lore.add(" ");
|
||||
lore.add(C.Reset + C.cYellow + "War Points " + clan.getFormattedWarPoints(enemy));
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + C.cGray + "Left Click " + C.cWhite + "Clan Info");
|
||||
|
||||
ShopItem shopItem = new ShopItem(material, data, itemName, lore.toArray(new String[0]), 0, false, false);
|
||||
addButtonFakeCount(slot, shopItem, new IButton()
|
||||
{
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
getShop().openPageForPlayer(player, new ClanWhoPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), player, enemy, true));
|
||||
}
|
||||
}, warPoints);
|
||||
}
|
||||
|
||||
private void addAllyButton(int slot, final ClanInfo ally)
|
||||
{
|
||||
String itemName = ally.getName();
|
||||
@ -237,46 +302,34 @@ public class ClanMainPage extends ClanPageBase
|
||||
}, ally.getOnlinePlayers().size());
|
||||
}
|
||||
|
||||
private void addWarButton(int slot, ClanInfo war)
|
||||
private void addPlayerButton(int slot, ClansPlayer clansPlayer, ClanInfo guiInfo, ClanRole guiRole)
|
||||
{
|
||||
String itemName = war.getName();
|
||||
Material material = USE_RESOURCE_ICONS ? ClanIcon.ALLIANCE.getMaterial() : Material.EMERALD_BLOCK;
|
||||
byte data = USE_RESOURCE_ICONS ? ClanIcon.ALLIANCE.getData() : 0;
|
||||
String itemName = (clansPlayer.isOnline() ? C.cGreenB : C.cRedB) + clansPlayer.getPlayerName();
|
||||
ArrayList<String> lore = new ArrayList<String>(5);
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + C.cGray + "Left Click " + C.cWhite + "Clan Info");
|
||||
|
||||
ShopItem shopItem = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false);
|
||||
addButton(slot, shopItem, new IButton()
|
||||
lore.add(C.Reset + C.cYellow + "Role " + C.cWhite + clansPlayer.getRole().getFriendlyName());
|
||||
if (clansPlayer.isOnline())
|
||||
{
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
Player player = UtilPlayer.searchExact(clansPlayer.getUuid());
|
||||
if (player != null)
|
||||
{
|
||||
|
||||
String loc = UtilWorld.locToStrClean(player.getLocation());
|
||||
lore.add(C.Reset + C.cYellow + "Location " + C.cWhite + loc);
|
||||
// TODO Save join date?
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// TODO Save last join date
|
||||
|
||||
private void addPlayerButton(int slot, ClansPlayer clansPlayer)
|
||||
{
|
||||
String itemName = C.cGreenB + clansPlayer.getPlayerName();
|
||||
ArrayList<String> lore = new ArrayList<String>(5);
|
||||
lore.add(clansPlayer.isOnline() ? C.cGreen + "Online!" : C.cRed + "Offline");
|
||||
lore.add(C.Reset + clansPlayer.getRole().name());
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + C.cGray + "Left Click " + C.cWhite + "Promote");
|
||||
lore.add(ChatColor.RESET + C.cGray + "Right Click " + C.cWhite + "Demote");
|
||||
lore.add(ChatColor.RESET + C.cGray + "Shift-Right Click " + C.cWhite + "Kick");
|
||||
if (guiRole.has(ClanRole.ADMIN))
|
||||
{
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + C.cYellow + "Left Click " + C.cWhite + "Promote");
|
||||
lore.add(ChatColor.RESET + C.cYellow + "Right Click " + C.cWhite + "Demote");
|
||||
lore.add(ChatColor.RESET + C.cYellow + "Shift-Right Click " + C.cWhite + "Kick");
|
||||
}
|
||||
|
||||
ItemStack item = UtilSkull.getPlayerHead(clansPlayer.isOnline() ? clansPlayer.getPlayerName() : "", itemName, lore);
|
||||
|
||||
addButton(slot, item, new IButton()
|
||||
{
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
addButton(slot, item, new ClanMemeberButton(getShop(), getPlugin(), getPlayer(), guiInfo, guiRole, this, clansPlayer.getPlayerName()));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.game.clans.clans.gui.page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -8,8 +9,10 @@ import org.bukkit.inventory.ItemStack;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilSkull;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
@ -52,14 +55,51 @@ public class ClanWhoPage extends ClanPageBase
|
||||
{
|
||||
int slot = 4;
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
lore.add(C.Reset + C.cYellow + "Description");
|
||||
lore.add(C.Reset + " " + _lookupClan.getDesc());
|
||||
lore.add(C.Reset + C.cYellow + "Formed");
|
||||
lore.add(C.Reset + " " + UtilTime.convertString(System.currentTimeMillis() - _lookupClan.getDateCreated().getTime(), 1, UtilTime.TimeUnit.FIT));
|
||||
lore.add(" ");
|
||||
|
||||
// Basic Clan Info
|
||||
lore.add(C.Reset + C.cYellow + "Description " + C.cWhite + _lookupClan.getDesc());
|
||||
lore.add(C.Reset + C.cYellow + "Formed " + C.cWhite + UtilTime.convertString(System.currentTimeMillis() - _lookupClan.getDateCreated().getTime(), 1, UtilTime.TimeUnit.FIT));
|
||||
lore.add(C.Reset + C.cYellow + "Members " + C.cWhite + _lookupClan.getOnlinePlayerCount() + "/" + _lookupClan.getMembers().size());
|
||||
lore.add(C.Reset + C.cYellow + "Territory " + C.cWhite + _lookupClan.getClaims() + "/" + _lookupClan.getClaimsMax());
|
||||
lore.add(C.Reset + C.cYellow + "TNT Protection " + C.cWhite + _lookupClan.getProtected());
|
||||
if (clanInfo != null)
|
||||
{
|
||||
lore.add(C.Reset + C.cYellow + "Your War Points");
|
||||
lore.add(C.Reset + " " + clanInfo.getFormattedWarPoints(_lookupClan));
|
||||
lore.add(C.Reset + C.cYellow + "Your War Points " + C.cWhite + clanInfo.getFormattedWarPoints(_lookupClan));
|
||||
}
|
||||
lore.add(" ");
|
||||
|
||||
// Energy
|
||||
lore.add(C.Reset + C.cYellow + "Energy " + C.cWhite + _lookupClan.getEnergy() + "/" + _lookupClan.getEnergyMax());
|
||||
if (_lookupClan.getEnergyCostPerMinute() > 0)
|
||||
lore.add(C.Reset + C.cYellow + "Energy Depletes " + C.cWhite + _lookupClan.getEnergyLeftString());
|
||||
|
||||
lore.add(" ");
|
||||
|
||||
// Allies
|
||||
if (_lookupClan.getAllyMap().size() > 0)
|
||||
{
|
||||
String allySorted = "";
|
||||
HashSet<String> allyUnsorted = new HashSet<String>();
|
||||
|
||||
for (String allyName : _lookupClan.getAllyMap().keySet())
|
||||
allyUnsorted.add(allyName);
|
||||
|
||||
for (String cur : UtilAlg.sortKey(allyUnsorted))
|
||||
allySorted += getPlugin().getClanUtility().mRel(getPlugin().getClanUtility().relPC(getPlayer(), getPlugin().getClanMap().get(cur)), cur, false)
|
||||
+ ", ";
|
||||
lore.add(C.Reset + C.cYellow + "Allies");
|
||||
lore.add(" " + allySorted);
|
||||
}
|
||||
|
||||
// Self Clan Info
|
||||
if (_lookupClan.equals(clanInfo))
|
||||
{
|
||||
String clanHome = _lookupClan.getHome() == null ? "None" : UtilWorld.locToStrClean(_lookupClan.getHome());
|
||||
String generator = _lookupClan.getGenerator() == null ? "None" : UtilWorld.blockToStrClean(_lookupClan.getGenerator().getBlock());
|
||||
|
||||
lore.add(C.Reset + C.cYellow + "Clan Home " + C.cWhite + clanHome);
|
||||
lore.add(C.Reset + C.cYellow + "TNT Generator " + C.cWhite + generator);
|
||||
}
|
||||
|
||||
ShopItem shopItem = new ShopItem(ClanIcon.ALLIANCE.getMaterial(), ClanIcon.ALLIANCE.getData(), _lookupClan.getName(), lore.toArray(new String[0]), 1, false, false);
|
||||
@ -85,10 +125,19 @@ public class ClanWhoPage extends ClanPageBase
|
||||
|
||||
private void addPlayer(int slot, ClansPlayer clansPlayer)
|
||||
{
|
||||
String itemName = C.cGreenB + clansPlayer.getPlayerName();
|
||||
String itemName = (clansPlayer.isOnline() ? C.cGreenB : C.cRedB) + clansPlayer.getPlayerName();
|
||||
ArrayList<String> lore = new ArrayList<String>(5);
|
||||
lore.add(clansPlayer.isOnline() ? C.cGreen + "Online!" : C.cRed + "Offline");
|
||||
lore.add(C.Reset + clansPlayer.getRole().name());
|
||||
lore.add(" ");
|
||||
lore.add(C.Reset + C.cYellow + "Role " + C.cWhite + clansPlayer.getRole().getFriendlyName());
|
||||
if (clansPlayer.isOnline())
|
||||
{
|
||||
Player player = UtilPlayer.searchExact(clansPlayer.getUuid());
|
||||
if (player != null)
|
||||
{
|
||||
String loc = UtilWorld.locToStrClean(player.getLocation());
|
||||
lore.add(C.Reset + C.cYellow + "Location " + C.cWhite + loc);
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack item = UtilSkull.getPlayerHead(clansPlayer.isOnline() ? clansPlayer.getPlayerName() : "", itemName, lore);
|
||||
setItem(slot, item);
|
||||
|
@ -4,6 +4,7 @@ import java.awt.Color;
|
||||
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansUtility;
|
||||
import mineplex.game.clans.clans.worldevent.WorldEventManager;
|
||||
import mineplex.minecraft.game.core.boss.EventState;
|
||||
import mineplex.minecraft.game.core.boss.WorldEvent;
|
||||
@ -92,7 +93,9 @@ public class ItemMapRenderer extends MapRenderer
|
||||
}
|
||||
else
|
||||
{
|
||||
if (owningClan.isAdmin())
|
||||
ClansUtility.ClanRelation relation = _manager.getClansUtility().rel(clan, owningClan);
|
||||
|
||||
if (relation == ClansUtility.ClanRelation.ADMIN)
|
||||
{
|
||||
colorAll = false;
|
||||
|
||||
@ -105,20 +108,25 @@ public class ItemMapRenderer extends MapRenderer
|
||||
clanColor = Color.GRAY;
|
||||
}
|
||||
}
|
||||
else if (clan == null)
|
||||
{
|
||||
clanColor = Color.YELLOW;
|
||||
}
|
||||
else if (clan.isEnemy(owningClan))
|
||||
else if (relation == ClansUtility.ClanRelation.WAR_LOSING)
|
||||
{
|
||||
clanColor = Color.RED;
|
||||
}
|
||||
else if (clan.isAlly(owningClan.getName()))
|
||||
else if (relation == ClansUtility.ClanRelation.WAR_WINNING)
|
||||
{
|
||||
clanColor = Color.MAGENTA;
|
||||
}
|
||||
else if (relation == ClansUtility.ClanRelation.ALLY || relation == ClansUtility.ClanRelation.ALLY_TRUST)
|
||||
{
|
||||
clanColor = Color.GREEN;
|
||||
}
|
||||
else if (clan.isNeutral(owningClan.getName()))
|
||||
else if (relation == ClansUtility.ClanRelation.SELF)
|
||||
{
|
||||
clanColor = Color.CYAN;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Neutral
|
||||
clanColor = Color.YELLOW;
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class ClansPlayerScoreboard extends PlayerScoreboard
|
||||
if ((domObjective = scoreboard.getObjective(DisplaySlot.BELOW_NAME)) == null)
|
||||
{
|
||||
domObjective = scoreboard.registerNewObjective("war", "dummy");
|
||||
domObjective.setDisplayName("War");
|
||||
domObjective.setDisplayName("War Points");
|
||||
domObjective.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public class ClansScoreboardManager extends ScoreboardManager
|
||||
private ClansManager _clansManager;
|
||||
private WarManager _warManager;
|
||||
private WorldEventManager _worldEvent;
|
||||
|
||||
|
||||
public ClansScoreboardManager(JavaPlugin plugin, TutorialManager tutorialManager, ClansManager clansManager, WarManager warManager, WorldEventManager worldEvent, CoreClientManager clientManager, DonationManager donationManager)
|
||||
{
|
||||
super(plugin, clientManager, donationManager);
|
||||
@ -50,6 +50,8 @@ public class ClansScoreboardManager extends ScoreboardManager
|
||||
data.writeElement(new ScoreboardElementPlayer(_clansManager));
|
||||
|
||||
data.writeElement(_worldEvent);
|
||||
|
||||
data.writeElement(_warManager);
|
||||
|
||||
for (Tutorial tutorial : tutorialManager.getTutorials().values())
|
||||
{
|
||||
|
@ -1,41 +1,23 @@
|
||||
package mineplex.game.clans.clans.war;
|
||||
|
||||
import mineplex.game.clans.core.war.ClanWarData;
|
||||
|
||||
public class WarInvasion
|
||||
{
|
||||
private static final long INVADE_LENGTH = 60000L * 30; // 30 Minutes
|
||||
|
||||
private String _invadedClan;
|
||||
private String _invaderClan;
|
||||
private long _startTime;
|
||||
private long _endTime;
|
||||
|
||||
public WarInvasion(ClanWarData clanWar)
|
||||
{
|
||||
if (clanWar.getPoints() > WarManager.WAR_FINISH_POINTS)
|
||||
{
|
||||
// Initiator Won
|
||||
_invaderClan = clanWar.getClanA();
|
||||
_invadedClan = clanWar.getClanB();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Initiated On Won
|
||||
_invaderClan = clanWar.getClanB();
|
||||
_invadedClan = clanWar.getClanA();
|
||||
}
|
||||
|
||||
_startTime = System.currentTimeMillis();
|
||||
_endTime = _startTime + INVADE_LENGTH;
|
||||
}
|
||||
|
||||
public WarInvasion(String invadedClan, String invaderClan)
|
||||
{
|
||||
_invadedClan = invadedClan;
|
||||
_invaderClan = invaderClan;
|
||||
_startTime = System.currentTimeMillis();
|
||||
_endTime = _startTime + INVADE_LENGTH;
|
||||
_endTime = _startTime + WarManager.INVADE_LENGTH;
|
||||
}
|
||||
|
||||
public long getTimeLeft()
|
||||
{
|
||||
return _endTime - System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public String getInvadedClan()
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.game.clans.clans.war;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
@ -16,22 +17,30 @@ import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.scoreboard.ScoreboardManager;
|
||||
import mineplex.core.scoreboard.elements.ScoreboardElement;
|
||||
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.ClansUtility;
|
||||
import mineplex.game.clans.clans.event.ClanDisbandedEvent;
|
||||
import mineplex.game.clans.clans.event.ClansPlayerDeathEvent;
|
||||
import mineplex.game.clans.clans.war.command.WarPointsCommand;
|
||||
import mineplex.game.clans.clans.war.event.WarInvasionEndEvent;
|
||||
import mineplex.game.clans.clans.war.event.WarInvasionStartEvent;
|
||||
import mineplex.game.clans.core.war.ClanWarData;
|
||||
import org.omg.CORBA.DynAnyPackage.InvalidSeq;
|
||||
|
||||
public class WarManager extends MiniPlugin
|
||||
public class WarManager extends MiniPlugin implements ScoreboardElement
|
||||
{
|
||||
public static final int WAR_START_POINTS = 0;
|
||||
public static final int WAR_FINISH_POINTS = 20;
|
||||
public static final long WAR_COOLDOWN = 60000L * 60; // 60 Minutes
|
||||
public static final long INVADE_LENGTH = 60000L * 30; // 30 Minutes
|
||||
public static final long WAR_COOLDOWN = 60000L * 30; // 30 Minutes
|
||||
|
||||
private final ClansManager _clansManager;
|
||||
|
||||
@ -39,13 +48,15 @@ public class WarManager extends MiniPlugin
|
||||
* Map of the active war invasions. This is indexed by the clan that is being invaded on
|
||||
* We will need to access this when blocks are broken in the invaded on clan's land!
|
||||
*/
|
||||
private Map<String, List<WarInvasion>> _activeInvasions;
|
||||
private Map<String, List<WarInvasion>> _invadedMap;
|
||||
private Map<String, List<WarInvasion>> _invaderMap;
|
||||
|
||||
public WarManager(JavaPlugin plugin, ClansManager clansManager)
|
||||
{
|
||||
super("ClanWar Manager", plugin);
|
||||
_clansManager = clansManager;
|
||||
_activeInvasions = new HashMap<String, List<WarInvasion>>();
|
||||
_invadedMap = new HashMap<String, List<WarInvasion>>();
|
||||
_invaderMap = new HashMap<String, List<WarInvasion>>();
|
||||
}
|
||||
|
||||
public ClansManager getClansManager()
|
||||
@ -53,29 +64,25 @@ public class WarManager extends MiniPlugin
|
||||
return _clansManager;
|
||||
}
|
||||
|
||||
public List<WarInvasion> getWarInvasions(ClanInfo invadedOn)
|
||||
public List<WarInvasion> getInvasionsOn(ClanInfo invaded)
|
||||
{
|
||||
return _activeInvasions.get(invadedOn.getName());
|
||||
return _invadedMap.get(invaded.getName());
|
||||
}
|
||||
|
||||
private void addInvasion(WarInvasion invasion)
|
||||
public List<WarInvasion> getInvasionsFor(ClanInfo invader)
|
||||
{
|
||||
String invaded = invasion.getInvadedClan();
|
||||
if (_activeInvasions.containsKey(invaded))
|
||||
{
|
||||
_activeInvasions.get(invaded).add(invasion);
|
||||
}
|
||||
else
|
||||
{
|
||||
LinkedList<WarInvasion> invasions = new LinkedList<WarInvasion>();
|
||||
invasions.add(invasion);
|
||||
_activeInvasions.put(invaded, invasions);
|
||||
}
|
||||
return _invaderMap.get(invader.getName());
|
||||
}
|
||||
|
||||
public boolean isBeingInvaded(ClanInfo clanInfo)
|
||||
{
|
||||
List<WarInvasion> invasions = _activeInvasions.get(clanInfo.getName());
|
||||
List<WarInvasion> invasions = _invadedMap.get(clanInfo.getName());
|
||||
return invasions != null && !invasions.isEmpty();
|
||||
}
|
||||
|
||||
public boolean isInvading(ClanInfo clanInfo)
|
||||
{
|
||||
List<WarInvasion> invasions = _invaderMap.get(clanInfo.getName());
|
||||
return invasions != null && !invasions.isEmpty();
|
||||
}
|
||||
|
||||
@ -85,7 +92,7 @@ public class WarManager extends MiniPlugin
|
||||
ClanInfo playerClan = _clansManager.getClan(player);
|
||||
if (clanInfo != null)
|
||||
{
|
||||
List<WarInvasion> invasions = _activeInvasions.get(clanInfo.getName());
|
||||
List<WarInvasion> invasions = _invadedMap.get(clanInfo.getName());
|
||||
if (invasions != null)
|
||||
{
|
||||
for (WarInvasion invasion : invasions)
|
||||
@ -102,10 +109,10 @@ public class WarManager extends MiniPlugin
|
||||
/**
|
||||
* Clear all invasions against clan. This is typically used for when a clan is deleted
|
||||
*/
|
||||
public void clearInvasions(String clan)
|
||||
{
|
||||
_activeInvasions.remove(clan);
|
||||
}
|
||||
// public void clearInvasions(String clan)
|
||||
// {
|
||||
// List<WarInvasion> invasions =
|
||||
// }
|
||||
|
||||
@EventHandler
|
||||
public void handleDeath(ClansPlayerDeathEvent event)
|
||||
@ -118,14 +125,20 @@ public class WarManager extends MiniPlugin
|
||||
final ClanInfo killerClan = event.getKiller().getClan();
|
||||
|
||||
ClanWarData war = clan.getWarData(killerClan);
|
||||
if (war != null)
|
||||
if (war != null && !war.isOnCooldown())
|
||||
{
|
||||
// War already exists
|
||||
ClansUtility.ClanRelation rel = _clansManager.getClanUtility().rel(clan, killerClan);
|
||||
_clansManager.middleTextClan(killerClan, "", C.cGreen + "+1 WP against " + rel.getColor(false) + clan.getName());
|
||||
_clansManager.middleTextClan(clan, "", C.cGreen + "-1 WP against " + rel.getColor(false) + killerClan.getName());
|
||||
_clansManager.messageClan(killerClan, F.main("Clans", "Your clan gained 1 War Point against " + rel.getColor(false) +
|
||||
clan.getName() + " " + C.Reset + "(" + killerClan.getFormattedWarPoints(clan) + C.Reset + ")"));
|
||||
_clansManager.messageClan(clan, F.main("Clans", "Your clan lost 1 War Point against " + rel.getColor(false) +
|
||||
killerClan.getName() + " " + C.Reset + "(" + clan.getFormattedWarPoints(killerClan) + C.Reset + ")"));
|
||||
war.increment(killerClan.getName());
|
||||
// todo: check war complete
|
||||
checkWarComplete(war);
|
||||
|
||||
ClanInfo clanA = clan.getName().equals(war.getClanA()) ? clan : killerClan;
|
||||
ClanInfo clanB = clan.equals(clanA) ? killerClan : clan;
|
||||
_clansManager.getClanDataAccess().updateWar(clanA, clanB, war, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -136,8 +149,8 @@ public class WarManager extends MiniPlugin
|
||||
public void run(ClanWarData data)
|
||||
{
|
||||
ClansUtility.ClanRelation rel = _clansManager.getClanUtility().rel(clan, killerClan);
|
||||
_clansManager.middleTextClan(killerClan, "", C.cGreen + "+1 WP against " + rel.getColor(false) + clan.getName());
|
||||
_clansManager.middleTextClan(clan, "", C.cGreen + "-1 WP against " + rel.getColor(false) + killerClan.getName());
|
||||
_clansManager.messageClan(killerClan, F.main("Clans", "Your clan gained 1 War Point against " + rel.getColor(false) + clan.getName()));
|
||||
_clansManager.messageClan(clan, F.main("Clans", "Your clan lost 1 War Point against " + rel.getColor(false) + killerClan.getName()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -145,6 +158,61 @@ public class WarManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
private void checkWarComplete(ClanWarData war)
|
||||
{
|
||||
String invaderClan = null;
|
||||
String invadedClan = null;
|
||||
|
||||
if (war.getClanAPoints() >= WAR_FINISH_POINTS)
|
||||
{
|
||||
// Clan A invades Clan B
|
||||
invaderClan = war.getClanA();
|
||||
invadedClan = war.getClanB();
|
||||
}
|
||||
else if (war.getClanBPoints() >= WAR_FINISH_POINTS)
|
||||
{
|
||||
// Clan B invades Clan A
|
||||
invaderClan = war.getClanB();
|
||||
invadedClan = war.getClanA();
|
||||
}
|
||||
|
||||
if (invadedClan != null && invaderClan != null)
|
||||
{
|
||||
// Reset War to 0:0
|
||||
war.resetPoints();
|
||||
war.setCooldown(WAR_COOLDOWN);
|
||||
|
||||
WarInvasion invasion = new WarInvasion(invadedClan, invaderClan);
|
||||
startInvasion(invasion);
|
||||
}
|
||||
}
|
||||
|
||||
private void startInvasion(WarInvasion invasion)
|
||||
{
|
||||
String invaded = invasion.getInvadedClan();
|
||||
String invader = invasion.getInvaderClan();
|
||||
|
||||
addInvasion(invaded, invasion, _invadedMap);
|
||||
addInvasion(invader, invasion, _invaderMap);
|
||||
|
||||
WarInvasionStartEvent event = new WarInvasionStartEvent(invasion);
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
private void addInvasion(String name, WarInvasion invasion, Map<String, List<WarInvasion>> invasionMap)
|
||||
{
|
||||
if (invasionMap.containsKey(name))
|
||||
{
|
||||
invasionMap.get(name).add(invasion);
|
||||
}
|
||||
else
|
||||
{
|
||||
LinkedList<WarInvasion> invasions = new LinkedList<WarInvasion>();
|
||||
invasions.add(invasion);
|
||||
invasionMap.put(name, invasions);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void clearInvasions(UpdateEvent event)
|
||||
{
|
||||
@ -153,7 +221,7 @@ public class WarManager extends MiniPlugin
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
Iterator<Map.Entry<String, List<WarInvasion>>> iterator = _activeInvasions.entrySet().iterator();
|
||||
Iterator<Map.Entry<String, List<WarInvasion>>> iterator = _invadedMap.entrySet().iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
List<WarInvasion> invasions = iterator.next().getValue();
|
||||
@ -166,6 +234,13 @@ public class WarManager extends MiniPlugin
|
||||
WarInvasionEndEvent endEvent = new WarInvasionEndEvent(invasion);
|
||||
Bukkit.getServer().getPluginManager().callEvent(endEvent);
|
||||
|
||||
List<WarInvasion> invaderList = _invaderMap.get(invasion.getInvaderClan());
|
||||
if (invaderList != null)
|
||||
{
|
||||
invaderList.remove(invasion);
|
||||
if (invaderList.isEmpty()) _invaderMap.remove(invasion.getInvaderClan());
|
||||
}
|
||||
|
||||
invasionIterator.remove();
|
||||
}
|
||||
}
|
||||
@ -193,4 +268,51 @@ public class WarManager extends MiniPlugin
|
||||
{
|
||||
addCommand(new WarPointsCommand(this));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void cancelDisband(ClanDisbandedEvent event)
|
||||
{
|
||||
ClanInfo clan = event.getClan();
|
||||
if (isBeingInvaded(clan) || isInvading(clan))
|
||||
{
|
||||
UtilPlayer.message(event.getDisbander(), F.main("Clans", "Clans cannot be disbanded in the middle of an invasion"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLines(ScoreboardManager manager, Player player, List<String> out)
|
||||
{
|
||||
List<String> element = new ArrayList<String>();
|
||||
|
||||
ClanInfo clan = _clansManager.getClan(player);
|
||||
|
||||
if (clan != null)
|
||||
{
|
||||
List<WarInvasion> invadedList = _invadedMap.get(clan);
|
||||
List<WarInvasion> invaderList = _invaderMap.get(clan);
|
||||
|
||||
if (invaderList != null && !invaderList.isEmpty())
|
||||
{
|
||||
for (WarInvasion invasion : invaderList)
|
||||
{
|
||||
element.add(C.cPurpleB + "Invading");
|
||||
element.add(" " + invasion.getInvadedClan());
|
||||
element.add(" " + UtilTime.convertString(invasion.getTimeLeft(), 1, UtilTime.TimeUnit.FIT));
|
||||
}
|
||||
}
|
||||
|
||||
if (invadedList != null && !invadedList.isEmpty())
|
||||
{
|
||||
for (WarInvasion invasion : invadedList)
|
||||
{
|
||||
element.add(C.cRedB + "Invaded");
|
||||
element.add(" " + invasion.getInvaderClan());
|
||||
element.add(" " + UtilTime.convertString(invasion.getTimeLeft(), 1, UtilTime.TimeUnit.FIT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user