Clan name->uuid changes
This commit is contained in:
parent
6a4c9061fa
commit
86420132ce
@ -1,6 +1,8 @@
|
|||||||
package mineplex.core.common.util;
|
package mineplex.core.common.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
@ -24,6 +26,15 @@ public class UtilAlg
|
|||||||
|
|
||||||
return sortedSet;
|
return sortedSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> TreeSet<T> sortSet(Collection<T> toSort, Comparator<T> comparator)
|
||||||
|
{
|
||||||
|
TreeSet<T> sortedSet = new TreeSet<T>(comparator);
|
||||||
|
for (T cur : toSort)
|
||||||
|
sortedSet.add(cur);
|
||||||
|
|
||||||
|
return sortedSet;
|
||||||
|
}
|
||||||
|
|
||||||
public static Location getMidpoint(Location a, Location b)
|
public static Location getMidpoint(Location a, Location b)
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -53,7 +54,7 @@ public class ClanInfo
|
|||||||
private TntGenerator _generator;
|
private TntGenerator _generator;
|
||||||
|
|
||||||
// Loaded from Client
|
// Loaded from Client
|
||||||
private NautHashMap<String, ClanRole> _memberMap = new NautHashMap<String, ClanRole>();
|
private NautHashMap<UUID, ClansPlayer> _memberMap = new NautHashMap<UUID, ClansPlayer>();
|
||||||
private NautHashMap<String, Boolean> _allyMap = new NautHashMap<String, Boolean>();
|
private NautHashMap<String, Boolean> _allyMap = new NautHashMap<String, Boolean>();
|
||||||
private HashSet<String> _claimSet = new HashSet<String>();
|
private HashSet<String> _claimSet = new HashSet<String>();
|
||||||
private EnemyData _enemyData;
|
private EnemyData _enemyData;
|
||||||
@ -109,7 +110,8 @@ public class ClanInfo
|
|||||||
|
|
||||||
for (ClanMemberToken memberToken : token.Members)
|
for (ClanMemberToken memberToken : token.Members)
|
||||||
{
|
{
|
||||||
_memberMap.put(memberToken.Name, ClanRole.valueOf(memberToken.ClanRole));
|
ClanRole role = ClanRole.valueOf(memberToken.ClanRole);
|
||||||
|
_memberMap.put(memberToken.PlayerUUID, new ClansPlayer(memberToken.Name, memberToken.PlayerUUID, role));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ClanTerritoryToken territoryToken : token.Territories)
|
for (ClanTerritoryToken territoryToken : token.Territories)
|
||||||
@ -181,9 +183,9 @@ public class ClanInfo
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMember(String other)
|
public boolean isMember(Player player)
|
||||||
{
|
{
|
||||||
return getMembers().containsKey(other);
|
return getMembers().containsKey(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAlly(String other)
|
public boolean isAlly(String other)
|
||||||
@ -220,7 +222,7 @@ public class ClanInfo
|
|||||||
return getAllyMap().get(clan);
|
return getAllyMap().get(clan);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkedList<String> mDetails(String caller)
|
public LinkedList<String> mDetails(Player caller)
|
||||||
{
|
{
|
||||||
LinkedList<String> stringList = new LinkedList<String>();
|
LinkedList<String> stringList = new LinkedList<String>();
|
||||||
|
|
||||||
@ -264,22 +266,22 @@ public class ClanInfo
|
|||||||
|
|
||||||
// Members
|
// Members
|
||||||
String members = "";
|
String members = "";
|
||||||
for (String cur : UtilAlg.sortKey(getMembers().keySet()))
|
for (ClansPlayer cur : UtilAlg.sortSet(getMembers().values(), new ClansPlayerComparator()))
|
||||||
{
|
{
|
||||||
String name = C.listValueOff + cur;
|
String name = C.listValueOff + cur.getPlayerName();
|
||||||
if (UtilPlayer.isOnline(cur))
|
if (cur.isOnline())
|
||||||
name = C.listValueOn + cur;
|
name = C.listValueOn + cur.getPlayerName();
|
||||||
|
|
||||||
if (getMembers().get(cur) == ClanRole.LEADER)
|
if (cur.getRole() == ClanRole.LEADER)
|
||||||
members += C.listValue + "L." + name + C.mBody + ", ";
|
members += C.listValue + "L." + name + C.mBody + ", ";
|
||||||
|
|
||||||
if (getMembers().get(cur) == ClanRole.ADMIN)
|
if (cur.getRole() == ClanRole.ADMIN)
|
||||||
members += C.listValue + "A." + name + C.mBody + ", ";
|
members += C.listValue + "A." + name + C.mBody + ", ";
|
||||||
|
|
||||||
if (getMembers().get(cur) == ClanRole.MEMBER)
|
if (cur.getRole() == ClanRole.MEMBER)
|
||||||
members += C.listValue + "M." + name + C.mBody + ", ";
|
members += C.listValue + "M." + name + C.mBody + ", ";
|
||||||
|
|
||||||
if (getMembers().get(cur) == ClanRole.RECRUIT)
|
if (cur.getRole() == ClanRole.RECRUIT)
|
||||||
members += C.listValue + "R." + name + C.mBody + ", ";
|
members += C.listValue + "R." + name + C.mBody + ", ";
|
||||||
}
|
}
|
||||||
stringList.add(F.value("Members", members));
|
stringList.add(F.value("Members", members));
|
||||||
@ -327,16 +329,16 @@ public class ClanInfo
|
|||||||
|
|
||||||
public void inform(String message, String ignore)
|
public void inform(String message, String ignore)
|
||||||
{
|
{
|
||||||
for (String cur : getMembers().keySet())
|
for (UUID cur : getMembers().keySet())
|
||||||
{
|
{
|
||||||
if (ignore != null && cur.equals(ignore))
|
Player player = UtilPlayer.searchExact(cur);
|
||||||
continue;
|
|
||||||
|
|
||||||
Player player = UtilPlayer.searchOnline(null, cur, false);
|
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (player.getName().equals(ignore))
|
||||||
|
continue;
|
||||||
|
|
||||||
UtilPlayer.message(player, F.main("Clans", message));
|
UtilPlayer.message(player, F.main("Clans", message));
|
||||||
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 2f);
|
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 2f);
|
||||||
}
|
}
|
||||||
@ -357,7 +359,7 @@ public class ClanInfo
|
|||||||
_desc = desc;
|
_desc = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NautHashMap<String, ClanRole> getMembers()
|
public NautHashMap<UUID, ClansPlayer> getMembers()
|
||||||
{
|
{
|
||||||
return _memberMap;
|
return _memberMap;
|
||||||
}
|
}
|
||||||
@ -424,8 +426,8 @@ public class ClanInfo
|
|||||||
|
|
||||||
public boolean isOnlineNow()
|
public boolean isOnlineNow()
|
||||||
{
|
{
|
||||||
for (String cur : getMembers().keySet())
|
for (ClansPlayer cur : getMembers().values())
|
||||||
if (UtilPlayer.isOnline(cur))
|
if (cur.isOnline())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -433,8 +435,8 @@ public class ClanInfo
|
|||||||
|
|
||||||
public boolean isOnline()
|
public boolean isOnline()
|
||||||
{
|
{
|
||||||
for (String cur : getMembers().keySet())
|
for (ClansPlayer cur : getMembers().values())
|
||||||
if (UtilPlayer.isOnline(cur))
|
if (cur.isOnline())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return System.currentTimeMillis() - _lastOnline.getTime() < Clans.getOnlineTime();
|
return System.currentTimeMillis() - _lastOnline.getTime() < Clans.getOnlineTime();
|
||||||
@ -442,8 +444,8 @@ public class ClanInfo
|
|||||||
|
|
||||||
public String getProtected()
|
public String getProtected()
|
||||||
{
|
{
|
||||||
for (String cur : getMembers().keySet())
|
for (ClansPlayer cur : getMembers().values())
|
||||||
if (UtilPlayer.isOnline(cur))
|
if (cur.isOnline())
|
||||||
return C.cRed + "No - Clan Members are Online";
|
return C.cRed + "No - Clan Members are Online";
|
||||||
|
|
||||||
if (System.currentTimeMillis() - _lastOnline.getTime() > Clans.getOnlineTime())
|
if (System.currentTimeMillis() - _lastOnline.getTime() > Clans.getOnlineTime())
|
||||||
@ -598,7 +600,11 @@ public class ClanInfo
|
|||||||
|
|
||||||
public void playerOnline(Player player)
|
public void playerOnline(Player player)
|
||||||
{
|
{
|
||||||
|
ClansPlayer clansPlayer = _memberMap.get(player.getUniqueId());
|
||||||
|
|
||||||
_onlinePlayers.add(player.getUniqueId());
|
_onlinePlayers.add(player.getUniqueId());
|
||||||
|
clansPlayer.setPlayerName(player.getName());
|
||||||
|
clansPlayer.setOnline(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playerOnline(String player)
|
public void playerOnline(String player)
|
||||||
@ -621,6 +627,36 @@ public class ClanInfo
|
|||||||
|
|
||||||
public void playerOffline(Player player)
|
public void playerOffline(Player player)
|
||||||
{
|
{
|
||||||
|
ClansPlayer clansPlayer = _memberMap.get(player.getUniqueId());
|
||||||
|
|
||||||
|
if (clansPlayer != null)
|
||||||
|
{
|
||||||
|
clansPlayer.setOnline(false);
|
||||||
|
}
|
||||||
|
|
||||||
_onlinePlayers.remove(player.getUniqueId());
|
_onlinePlayers.remove(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<String> getMemberNameSet()
|
||||||
|
{
|
||||||
|
HashSet<String> set = new HashSet<String>();
|
||||||
|
|
||||||
|
for (ClansPlayer cp : _memberMap.values())
|
||||||
|
{
|
||||||
|
set.add(cp.getPlayerName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClansPlayer getClansPlayerFromName(String playerName)
|
||||||
|
{
|
||||||
|
for (ClansPlayer cp : _memberMap.values())
|
||||||
|
{
|
||||||
|
if (cp.getPlayerName().equals(playerName))
|
||||||
|
return cp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -319,12 +319,13 @@ public class ClansAdmin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String target = UtilPlayer.searchCollection(caller, args[2], clan.getMembers().keySet(), "Clan Member", true);
|
String target = UtilPlayer.searchCollection(caller, args[2], clan.getMemberNameSet(), "Clan Member", true);
|
||||||
|
ClansPlayer clansPlayer = clan.getClansPlayerFromName(target);
|
||||||
|
|
||||||
if (target == null)
|
if (target == null || clansPlayer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (clan.getMembers().get(target) == ClanRole.LEADER)
|
if (clansPlayer.getRole() == ClanRole.LEADER)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans Admin", "You cannot promote " + F.name(target) + " any further."));
|
UtilPlayer.message(caller, F.main("Clans Admin", "You cannot promote " + F.name(target) + " any further."));
|
||||||
return;
|
return;
|
||||||
@ -332,19 +333,19 @@ public class ClansAdmin
|
|||||||
|
|
||||||
//Task
|
//Task
|
||||||
String newRank = "?";
|
String newRank = "?";
|
||||||
if (clan.getMembers().get(target) == ClanRole.RECRUIT)
|
if (clansPlayer.getRole() == ClanRole.RECRUIT)
|
||||||
{
|
{
|
||||||
Clans.getClanDataAccess().role(clan, target, ClanRole.MEMBER);
|
Clans.getClanDataAccess().role(clan, clansPlayer.getUuid(), ClanRole.MEMBER);
|
||||||
newRank = "Member";
|
newRank = "Member";
|
||||||
}
|
}
|
||||||
else if (clan.getMembers().get(target) == ClanRole.MEMBER)
|
else if (clansPlayer.getRole() == ClanRole.MEMBER)
|
||||||
{
|
{
|
||||||
Clans.getClanDataAccess().role(clan, target, ClanRole.ADMIN);
|
Clans.getClanDataAccess().role(clan, clansPlayer.getUuid(), ClanRole.ADMIN);
|
||||||
newRank = "Admin";
|
newRank = "Admin";
|
||||||
}
|
}
|
||||||
else if (clan.getMembers().get(target) == ClanRole.ADMIN)
|
else if (clansPlayer.getRole() == ClanRole.ADMIN)
|
||||||
{
|
{
|
||||||
Clans.getClanDataAccess().role(clan, target, ClanRole.LEADER);
|
Clans.getClanDataAccess().role(clan, clansPlayer.getUuid(), ClanRole.LEADER);
|
||||||
newRank = "Leader";
|
newRank = "Leader";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,11 +367,12 @@ public class ClansAdmin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String target = UtilPlayer.searchCollection(caller, args[2], clan.getMembers().keySet(), "Clan Member", true);
|
String target = UtilPlayer.searchCollection(caller, args[2], clan.getMemberNameSet(), "Clan Member", true);
|
||||||
if (target == null)
|
ClansPlayer clansPlayer = clan.getClansPlayerFromName(target);
|
||||||
|
if (target == null || clansPlayer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (clan.getMembers().get(target) == ClanRole.RECRUIT)
|
if (clansPlayer.getRole() == ClanRole.RECRUIT)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans Admin", "You cannot demote " + F.name(target) + " any further."));
|
UtilPlayer.message(caller, F.main("Clans Admin", "You cannot demote " + F.name(target) + " any further."));
|
||||||
return;
|
return;
|
||||||
@ -378,19 +380,19 @@ public class ClansAdmin
|
|||||||
|
|
||||||
//Task
|
//Task
|
||||||
String newRank = "?";
|
String newRank = "?";
|
||||||
if (clan.getMembers().get(target) == ClanRole.MEMBER)
|
if (clansPlayer.getRole() == ClanRole.MEMBER)
|
||||||
{
|
{
|
||||||
Clans.getClanDataAccess().role(clan, target, ClanRole.RECRUIT);
|
Clans.getClanDataAccess().role(clan, clansPlayer.getUuid(), ClanRole.RECRUIT);
|
||||||
newRank = "Recruit";
|
newRank = "Recruit";
|
||||||
}
|
}
|
||||||
else if (clan.getMembers().get(target) == ClanRole.ADMIN)
|
else if (clansPlayer.getRole() == ClanRole.ADMIN)
|
||||||
{
|
{
|
||||||
Clans.getClanDataAccess().role(clan, target, ClanRole.MEMBER);
|
Clans.getClanDataAccess().role(clan, clansPlayer.getUuid(), ClanRole.MEMBER);
|
||||||
newRank = "Member";
|
newRank = "Member";
|
||||||
}
|
}
|
||||||
else if (clan.getMembers().get(target) == ClanRole.LEADER)
|
else if (clansPlayer.getRole() == ClanRole.LEADER)
|
||||||
{
|
{
|
||||||
Clans.getClanDataAccess().role(clan, target, ClanRole.ADMIN);
|
Clans.getClanDataAccess().role(clan, clansPlayer.getUuid(), ClanRole.ADMIN);
|
||||||
newRank = "Admin";
|
newRank = "Admin";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,12 +414,13 @@ public class ClansAdmin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String targetName = UtilPlayer.searchCollection(caller, args[2], clan.getMembers().keySet(), "Clan Member", true);
|
final String target = UtilPlayer.searchCollection(caller, args[2], clan.getMemberNameSet(), "Clan Member", true);
|
||||||
|
ClansPlayer clansPlayer = clan.getClansPlayerFromName(target);
|
||||||
|
|
||||||
if (targetName == null)
|
if (target == null || clansPlayer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
final Player player = UtilPlayer.searchOnline(null, targetName, false);
|
final Player player = UtilPlayer.searchExact(clansPlayer.getUuid());
|
||||||
|
|
||||||
Callback<Boolean> callback = new Callback<Boolean>()
|
Callback<Boolean> callback = new Callback<Boolean>()
|
||||||
{
|
{
|
||||||
@ -429,8 +432,8 @@ public class ClansAdmin
|
|||||||
//Inform
|
//Inform
|
||||||
if (player != null)
|
if (player != null)
|
||||||
UtilPlayer.message(player, F.main("Clans Admin", caller.getName() + " kicked you from " + F.elem("Clan " + clan.getName()) + "."));
|
UtilPlayer.message(player, F.main("Clans Admin", caller.getName() + " kicked you from " + F.elem("Clan " + clan.getName()) + "."));
|
||||||
UtilPlayer.message(caller, F.main("Clans Admin", "You kicked " + targetName + " from your Clan."));
|
UtilPlayer.message(caller, F.main("Clans Admin", "You kicked " + target + " from your Clan."));
|
||||||
clan.inform(F.main("Clans Admin", caller.getName() + " kicked " + targetName + " from your Clan."), caller.getName());
|
clan.inform(F.main("Clans Admin", caller.getName() + " kicked " + target + " from your Clan."), caller.getName());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -440,7 +443,7 @@ public class ClansAdmin
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (player != null) Clans.getClanDataAccess().leave(clan, player, callback);
|
if (player != null) Clans.getClanDataAccess().leave(clan, player, callback);
|
||||||
else Clans.getClanDataAccess().leave(clan, targetName, callback);
|
else Clans.getClanDataAccess().leave(clan, clansPlayer, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ally(Player caller, String[] args)
|
public void ally(Player caller, String[] args)
|
||||||
@ -600,7 +603,7 @@ public class ClansAdmin
|
|||||||
if (ownerClan != null)
|
if (ownerClan != null)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans Admin", "This Territory is claimed by " +
|
UtilPlayer.message(caller, F.main("Clans Admin", "This Territory is claimed by " +
|
||||||
Clans.getClanUtility().mRel(Clans.getClanUtility().relPC(caller.getName(), ownerClan), ownerClan.getName(), true) + "."));
|
Clans.getClanUtility().mRel(Clans.getClanUtility().relPC(caller, ownerClan), ownerClan.getName(), true) + "."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package mineplex.game.clans.clans;
|
package mineplex.game.clans.clans;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
@ -14,6 +15,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import com.sun.org.apache.xpath.internal.operations.Bool;
|
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||||
|
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
|
import mineplex.core.common.util.UtilAlg;
|
||||||
import mineplex.core.common.util.UtilBlock;
|
import mineplex.core.common.util.UtilBlock;
|
||||||
import mineplex.core.common.util.UtilWorld;
|
import mineplex.core.common.util.UtilWorld;
|
||||||
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
|
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
|
||||||
@ -75,9 +77,9 @@ public class ClansDataAccessLayer
|
|||||||
|
|
||||||
_manager.getClanMap().remove(clan.getName());
|
_manager.getClanMap().remove(clan.getName());
|
||||||
|
|
||||||
for (String cur : clan.getMembers().keySet())
|
for (ClansPlayer player : clan.getMembers().values())
|
||||||
{
|
{
|
||||||
_manager.getClanMemberMap().remove(cur);
|
_manager.getClanMemberUuidMap().remove(player.getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Clean from Others
|
//Clean from Others
|
||||||
@ -208,15 +210,15 @@ public class ClansDataAccessLayer
|
|||||||
|
|
||||||
private void updateJoinCache(ClanInfo clan, Player player, ClanRole role)
|
private void updateJoinCache(ClanInfo clan, Player player, ClanRole role)
|
||||||
{
|
{
|
||||||
String playerName = player.getName();
|
if (_manager.getClanMemberUuidMap().containsKey(player.getUniqueId()))
|
||||||
if (_manager.getClanMemberMap().containsKey(playerName))
|
|
||||||
leave(_manager.getClanUtility().getClanByPlayer(player), player, null);
|
leave(_manager.getClanUtility().getClanByPlayer(player), player, null);
|
||||||
|
|
||||||
//Update Clan
|
//Update Clan
|
||||||
clan.getMembers().put(playerName, role);
|
ClansPlayer cp = new ClansPlayer(player.getName(), player.getUniqueId(), role);
|
||||||
_manager.getClanMemberMap().put(playerName, clan);
|
clan.getMembers().put(player.getUniqueId(), cp);
|
||||||
clan.getInviteeMap().remove(playerName);
|
_manager.getClanMemberUuidMap().put(player.getUniqueId(), clan);
|
||||||
clan.getInviterMap().remove(playerName);
|
clan.getInviteeMap().remove(player.getName());
|
||||||
|
clan.getInviterMap().remove(player.getName());
|
||||||
clan.playerOnline(player);
|
clan.playerOnline(player);
|
||||||
|
|
||||||
//Scoreboard
|
//Scoreboard
|
||||||
@ -225,11 +227,15 @@ public class ClansDataAccessLayer
|
|||||||
|
|
||||||
public void leave(ClanInfo clan, Player player, Callback<Boolean> callback)
|
public void leave(ClanInfo clan, Player player, Callback<Boolean> callback)
|
||||||
{
|
{
|
||||||
leave(clan, player.getName(), callback);
|
ClansPlayer clansPlayer = clan.getMembers().get(player.getUniqueId());
|
||||||
_scoreboard.refresh(player);
|
if (clansPlayer != null)
|
||||||
|
{
|
||||||
|
leave(clan, clansPlayer, callback);
|
||||||
|
_scoreboard.refresh(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void leave(final ClanInfo clan, final String player, final Callback<Boolean> callback)
|
public void leave(final ClanInfo clan, final ClansPlayer clansPlayer, final Callback<Boolean> callback)
|
||||||
{
|
{
|
||||||
if (clan == null)
|
if (clan == null)
|
||||||
return;
|
return;
|
||||||
@ -239,7 +245,7 @@ public class ClansDataAccessLayer
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
final boolean success = _repository.removeMember(clan.getId(), player);
|
final boolean success = _repository.removeMember(clan.getId(), clansPlayer.getPlayerName());
|
||||||
|
|
||||||
runSync(new Runnable()
|
runSync(new Runnable()
|
||||||
{
|
{
|
||||||
@ -249,11 +255,11 @@ public class ClansDataAccessLayer
|
|||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
//Update Clan
|
//Update Clan
|
||||||
clan.getMembers().remove(player);
|
clan.getMembers().remove(clansPlayer.getUuid());
|
||||||
_manager.getClanMemberMap().remove(player);
|
_manager.getClanMemberUuidMap().remove(clansPlayer.getUuid());
|
||||||
clan.playerOffline(player);
|
clan.playerOffline(clansPlayer.getPlayerName());
|
||||||
//Log
|
//Log
|
||||||
_manager.log("Removed [" + player + "] from [" + clan.getName() + "].");
|
_manager.log("Removed [" + clansPlayer.getPlayerName() + "] from [" + clan.getName() + "].");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callback != null) callback.run(success);
|
if (callback != null) callback.run(success);
|
||||||
@ -263,23 +269,28 @@ public class ClansDataAccessLayer
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void role(final ClanInfo clan, final String player, final ClanRole role)
|
public void role(final ClanInfo clan, final UUID uuid, final ClanRole role)
|
||||||
{
|
{
|
||||||
//Update Clan
|
final ClansPlayer clansPlayer = clan.getMembers().get(uuid);
|
||||||
clan.getMembers().put(player, role);
|
|
||||||
|
|
||||||
//Save
|
if (clansPlayer != null)
|
||||||
runAsync(new Runnable()
|
|
||||||
{
|
{
|
||||||
@Override
|
// Update Clan
|
||||||
public void run()
|
clansPlayer.setRole(role);
|
||||||
{
|
|
||||||
_repository.updateMember(clan.getId(), player, role.toString());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//Log
|
//Save
|
||||||
_manager.log("Removed [" + player + "] from [" + clan.getName() + "].");
|
runAsync(new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
_repository.updateMember(clan.getId(), clansPlayer.getPlayerName(), role.toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Log
|
||||||
|
_manager.log("Removed [" + clansPlayer.getPlayerName() + "] from [" + clan.getName() + "].");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void invite(ClanInfo clan, String player, String inviter)
|
public void invite(ClanInfo clan, String player, String inviter)
|
||||||
|
@ -108,7 +108,7 @@ public class ClansDisplay extends MiniPlugin
|
|||||||
if (claim != null)
|
if (claim != null)
|
||||||
{
|
{
|
||||||
//Relation
|
//Relation
|
||||||
ClanRelation relation = Clans.getClanUtility().relPT(player.getName(), claim.Chunk);
|
ClanRelation relation = Clans.getClanUtility().relPT(player, claim.Chunk);
|
||||||
|
|
||||||
//Name
|
//Name
|
||||||
ownerString = Clans.getClanUtility().mRel(relation, claim.Owner, false);
|
ownerString = Clans.getClanUtility().mRel(relation, claim.Owner, false);
|
||||||
@ -187,9 +187,9 @@ public class ClansDisplay extends MiniPlugin
|
|||||||
|
|
||||||
//Add Icon
|
//Add Icon
|
||||||
if (i == chunk.getX() && j == chunk.getZ())
|
if (i == chunk.getX() && j == chunk.getZ())
|
||||||
output += getMapIcon(Clans.getClanUtility().relPC(player.getName(), curOwner), curClaim, curOwner, curChunk, pCount, true, local);
|
output += getMapIcon(Clans.getClanUtility().relPC(player, curOwner), curClaim, curOwner, curChunk, pCount, true, local);
|
||||||
else
|
else
|
||||||
output += getMapIcon(Clans.getClanUtility().relPC(player.getName(), curOwner), curClaim, curOwner, curChunk, pCount, false, local);
|
output += getMapIcon(Clans.getClanUtility().relPC(player, curOwner), curClaim, curOwner, curChunk, pCount, false, local);
|
||||||
}
|
}
|
||||||
|
|
||||||
output += ">";
|
output += ">";
|
||||||
|
@ -153,7 +153,7 @@ public class ClansGame extends MiniPlugin
|
|||||||
if (!Clans.getClanUtility().canHurt(defender, attacker))
|
if (!Clans.getClanUtility().canHurt(defender, attacker))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
ClanRelation rel = Clans.getRelation(defender.getName(), attacker.getName());
|
ClanRelation rel = Clans.getRelation(defender, attacker);
|
||||||
UtilPlayer.message(attacker, F.main("Clans", "You cannot harm " + Clans.getClanUtility().mRel(rel, defender.getName(), false) + "."));
|
UtilPlayer.message(attacker, F.main("Clans", "You cannot harm " + Clans.getClanUtility().mRel(rel, defender.getName(), false) + "."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -235,7 +235,7 @@ public class ClansGame extends MiniPlugin
|
|||||||
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can not break " +
|
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can not break " +
|
||||||
F.elem(ItemStackFactory.Instance.GetName(event.getBlock(), true)) +
|
F.elem(ItemStackFactory.Instance.GetName(event.getBlock(), true)) +
|
||||||
" in " +
|
" in " +
|
||||||
Clans.getClanUtility().getOwnerStringRel(event.getBlock().getLocation(), event.getPlayer().getName()) +
|
Clans.getClanUtility().getOwnerStringRel(event.getBlock().getLocation(), event.getPlayer()) +
|
||||||
"."));
|
"."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ public class ClansGame extends MiniPlugin
|
|||||||
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can not break " +
|
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can not break " +
|
||||||
F.elem(ItemStackFactory.Instance.GetName(event.getBlock(), true)) +
|
F.elem(ItemStackFactory.Instance.GetName(event.getBlock(), true)) +
|
||||||
" in " +
|
" in " +
|
||||||
Clans.getClanUtility().getOwnerStringRel(event.getBlock().getLocation(), event.getPlayer().getName()) +
|
Clans.getClanUtility().getOwnerStringRel(event.getBlock().getLocation(), event.getPlayer()) +
|
||||||
"." +
|
"." +
|
||||||
mimic));
|
mimic));
|
||||||
}
|
}
|
||||||
@ -290,7 +290,7 @@ public class ClansGame extends MiniPlugin
|
|||||||
//Inform
|
//Inform
|
||||||
if (damager != null)
|
if (damager != null)
|
||||||
{
|
{
|
||||||
ClanRelation rel = Clans.getRelation(damagee.getName(), damager.getName());
|
ClanRelation rel = Clans.getRelation(damagee, damager);
|
||||||
UtilPlayer.message(damager, F.main("Clans",
|
UtilPlayer.message(damager, F.main("Clans",
|
||||||
"You cannot harm " + Clans.getClanUtility().mRel(rel, damagee.getName(), false) + "."));
|
"You cannot harm " + Clans.getClanUtility().mRel(rel, damagee.getName(), false) + "."));
|
||||||
}
|
}
|
||||||
@ -382,7 +382,7 @@ public class ClansGame extends MiniPlugin
|
|||||||
|
|
||||||
Location sideLoc = new Location(loc.getWorld(), loc.getX()+x, loc.getY(), loc.getZ()+z);
|
Location sideLoc = new Location(loc.getWorld(), loc.getX()+x, loc.getY(), loc.getZ()+z);
|
||||||
|
|
||||||
if (Clans.getClanUtility().isSelf(player.getName(), sideLoc))
|
if (Clans.getClanUtility().isSelf(player, sideLoc))
|
||||||
self = true;
|
self = true;
|
||||||
|
|
||||||
if (enemy != null)
|
if (enemy != null)
|
||||||
@ -391,7 +391,7 @@ public class ClansGame extends MiniPlugin
|
|||||||
if (Clans.getClanUtility().getAccess(player, sideLoc) != ClanRelation.SELF)
|
if (Clans.getClanUtility().getAccess(player, sideLoc) != ClanRelation.SELF)
|
||||||
enemy = Clans.getClanUtility().getOwnerStringRel(
|
enemy = Clans.getClanUtility().getOwnerStringRel(
|
||||||
new Location(loc.getWorld(), loc.getX()+x, loc.getY(), loc.getZ()+z),
|
new Location(loc.getWorld(), loc.getX()+x, loc.getY(), loc.getZ()+z),
|
||||||
player.getName());
|
player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enemy != null && !self)
|
if (enemy != null && !self)
|
||||||
@ -442,7 +442,7 @@ public class ClansGame extends MiniPlugin
|
|||||||
F.elem(ItemStackFactory.Instance.GetName(event.getClickedBlock(), true)) +
|
F.elem(ItemStackFactory.Instance.GetName(event.getClickedBlock(), true)) +
|
||||||
" in " +
|
" in " +
|
||||||
Clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getLocation(),
|
Clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getLocation(),
|
||||||
player.getName()) +
|
player) +
|
||||||
"." +
|
"." +
|
||||||
mimic));
|
mimic));
|
||||||
|
|
||||||
@ -459,7 +459,7 @@ public class ClansGame extends MiniPlugin
|
|||||||
F.elem(ItemStackFactory.Instance.GetName(event.getClickedBlock(), true)) +
|
F.elem(ItemStackFactory.Instance.GetName(event.getClickedBlock(), true)) +
|
||||||
" in " +
|
" in " +
|
||||||
Clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getLocation(),
|
Clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getLocation(),
|
||||||
player.getName()) +
|
player) +
|
||||||
"." +
|
"." +
|
||||||
mimic));
|
mimic));
|
||||||
|
|
||||||
@ -480,7 +480,7 @@ public class ClansGame extends MiniPlugin
|
|||||||
F.elem(ItemStackFactory.Instance.GetName(player.getItemInHand(), true)) +
|
F.elem(ItemStackFactory.Instance.GetName(player.getItemInHand(), true)) +
|
||||||
" in " +
|
" in " +
|
||||||
Clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getRelative(event.getBlockFace()).getLocation(),
|
Clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getRelative(event.getBlockFace()).getLocation(),
|
||||||
player.getName()) +
|
player) +
|
||||||
"." +
|
"." +
|
||||||
mimic));
|
mimic));
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package mineplex.game.clans.clans;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -154,7 +155,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
|||||||
|
|
||||||
//Clans
|
//Clans
|
||||||
private NautHashMap<String, ClanInfo> _clanMap = new NautHashMap<String, ClanInfo>();
|
private NautHashMap<String, ClanInfo> _clanMap = new NautHashMap<String, ClanInfo>();
|
||||||
private NautHashMap<String, ClanInfo> _clanMemberMap = new NautHashMap<String, ClanInfo>();
|
// private NautHashMap<String, ClanInfo> _clanMemberNameMap = new NautHashMap<String, ClanInfo>();
|
||||||
|
private NautHashMap<UUID, ClanInfo> _clanMemberUuidMap = new NautHashMap<UUID, ClanInfo>();
|
||||||
private NautHashMap<String, ClanTerritory> _claimMap = new NautHashMap<String, ClanTerritory>();
|
private NautHashMap<String, ClanTerritory> _claimMap = new NautHashMap<String, ClanTerritory>();
|
||||||
private NautHashMap<String, Long> _unclaimMap = new NautHashMap<String, Long>();
|
private NautHashMap<String, Long> _unclaimMap = new NautHashMap<String, Long>();
|
||||||
|
|
||||||
@ -273,7 +275,10 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
|||||||
_clanMap.put(clanToken.Name, clan);
|
_clanMap.put(clanToken.Name, clan);
|
||||||
|
|
||||||
for (ClanMemberToken memberToken : clanToken.Members)
|
for (ClanMemberToken memberToken : clanToken.Members)
|
||||||
_clanMemberMap.put(memberToken.Name, clan);
|
{
|
||||||
|
_clanMemberUuidMap.put(memberToken.PlayerUUID, clan);
|
||||||
|
// _clanMemberMap.put(memberToken.Name, clan);
|
||||||
|
}
|
||||||
|
|
||||||
for (ClanTerritoryToken territoryToken : clanToken.Territories)
|
for (ClanTerritoryToken territoryToken : clanToken.Territories)
|
||||||
_claimMap.put(territoryToken.Chunk, new ClanTerritory(territoryToken));
|
_claimMap.put(territoryToken.Chunk, new ClanTerritory(territoryToken));
|
||||||
@ -314,9 +319,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
|||||||
return _clanMap;
|
return _clanMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NautHashMap<String, ClanInfo> getClanMemberMap()
|
public NautHashMap<UUID, ClanInfo> getClanMemberUuidMap()
|
||||||
{
|
{
|
||||||
return _clanMemberMap;
|
return _clanMemberUuidMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isClaimable(Location location)
|
public static boolean isClaimable(Location location)
|
||||||
@ -341,7 +346,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
|||||||
|
|
||||||
public ClanInfo getClan(Player player)
|
public ClanInfo getClan(Player player)
|
||||||
{
|
{
|
||||||
return _clanMemberMap.get(player.getName());
|
return _clanMemberUuidMap.get(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClanInfo getEnemy(ClanInfo clanInfo)
|
public ClanInfo getEnemy(ClanInfo clanInfo)
|
||||||
@ -357,7 +362,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
|||||||
|
|
||||||
public boolean isInClan(Player player)
|
public boolean isInClan(Player player)
|
||||||
{
|
{
|
||||||
return _clanMemberMap.containsKey(player.getName());
|
return _clanMemberUuidMap.containsKey(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClanInfo getClan(String clan)
|
public ClanInfo getClan(String clan)
|
||||||
@ -431,7 +436,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
|||||||
public void join(PlayerJoinEvent event)
|
public void join(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
ClanInfo clanInfo = getClanMemberMap().get(player.getName());
|
ClanInfo clanInfo = _clanMemberUuidMap.get(player.getUniqueId());
|
||||||
if (clanInfo != null)
|
if (clanInfo != null)
|
||||||
{
|
{
|
||||||
clanInfo.playerOnline(player);
|
clanInfo.playerOnline(player);
|
||||||
@ -457,7 +462,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
|||||||
public void quit(PlayerQuitEvent event)
|
public void quit(PlayerQuitEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
ClanInfo clanInfo = getClanMemberMap().get(player.getName());
|
ClanInfo clanInfo = getClanMemberUuidMap().get(player.getUniqueId());
|
||||||
if (clanInfo != null)
|
if (clanInfo != null)
|
||||||
{
|
{
|
||||||
clanInfo.playerOffline(player);
|
clanInfo.playerOffline(player);
|
||||||
@ -482,9 +487,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
|||||||
event.setFormat(C.cAqua + "%1$s " + C.cDAqua + "%2$s");
|
event.setFormat(C.cAqua + "%1$s " + C.cDAqua + "%2$s");
|
||||||
event.getRecipients().clear();
|
event.getRecipients().clear();
|
||||||
|
|
||||||
for (String cur : clan.getMembers().keySet())
|
for (ClansPlayer cur : clan.getMembers().values())
|
||||||
{
|
{
|
||||||
Player player = UtilPlayer.searchOnline(null, cur, false);
|
Player player = UtilPlayer.searchExact(cur.getUuid());
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
continue;
|
continue;
|
||||||
@ -497,9 +502,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
|||||||
event.setFormat(C.cDGreen + clan.getName() + " " + C.cDGreen + "%1$s " + C.cGreen + "%2$s");
|
event.setFormat(C.cDGreen + clan.getName() + " " + C.cDGreen + "%1$s " + C.cGreen + "%2$s");
|
||||||
event.getRecipients().clear();
|
event.getRecipients().clear();
|
||||||
|
|
||||||
for (String cur : clan.getMembers().keySet())
|
for (ClansPlayer cur : clan.getMembers().values())
|
||||||
{
|
{
|
||||||
Player player = UtilPlayer.searchOnline(null, cur, false);
|
Player player = UtilPlayer.searchExact(cur.getUuid());
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
continue;
|
continue;
|
||||||
@ -512,9 +517,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
|||||||
ClanInfo ally = _clanUtility.getClanByClanName(allyName);
|
ClanInfo ally = _clanUtility.getClanByClanName(allyName);
|
||||||
if (ally == null) continue;
|
if (ally == null) continue;
|
||||||
|
|
||||||
for (String playerName : ally.getMembers().keySet())
|
for (ClansPlayer cur : ally.getMembers().values())
|
||||||
{
|
{
|
||||||
Player player = UtilPlayer.searchOnline(null, playerName, false);
|
Player player = UtilPlayer.searchExact(cur.getUuid());
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
continue;
|
continue;
|
||||||
@ -616,11 +621,22 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
|||||||
return _clanUtility.isSafe(a);
|
return _clanUtility.isSafe(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClanRelation getRelation(String playerA, String playerB)
|
// public ClanRelation getRelation(String playerA, String playerB)
|
||||||
|
// {
|
||||||
|
// return getClanUtility().rel(_clanMemberMap.get(playerA), _clanMemberMap.get(playerB));
|
||||||
|
// }
|
||||||
|
|
||||||
|
public ClanRelation getRelation(Player playerA, Player playerB)
|
||||||
{
|
{
|
||||||
return getClanUtility().rel(_clanMemberMap.get(playerA), _clanMemberMap.get(playerB));
|
return getRelation(playerA.getUniqueId(), playerB.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClanRelation getRelation(UUID playerA, UUID playerB)
|
||||||
|
{
|
||||||
|
return getClanUtility().rel(getClanMemberUuidMap().get(playerA), getClanMemberUuidMap().get(playerB));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public long getOnlineTime()
|
public long getOnlineTime()
|
||||||
{
|
{
|
||||||
return _onlineTime;
|
return _onlineTime;
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
package mineplex.game.clans.clans;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class ClansPlayer
|
||||||
|
{
|
||||||
|
private String _playerName;
|
||||||
|
private UUID _uuid;
|
||||||
|
private ClanRole _role;
|
||||||
|
private boolean _online;
|
||||||
|
|
||||||
|
public ClansPlayer(String playerName, UUID uuid, ClanRole role)
|
||||||
|
{
|
||||||
|
_playerName = playerName;
|
||||||
|
_uuid = uuid;
|
||||||
|
_role = role;
|
||||||
|
_online = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPlayerName()
|
||||||
|
{
|
||||||
|
return _playerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUuid()
|
||||||
|
{
|
||||||
|
return _uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClanRole getRole()
|
||||||
|
{
|
||||||
|
return _role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRole(ClanRole role)
|
||||||
|
{
|
||||||
|
_role = role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayerName(String playerName)
|
||||||
|
{
|
||||||
|
_playerName = playerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOnline()
|
||||||
|
{
|
||||||
|
return _online;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnline(boolean online)
|
||||||
|
{
|
||||||
|
_online = online;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package mineplex.game.clans.clans;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
public class ClansPlayerComparator implements Comparator<ClansPlayer>
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public int compare(ClansPlayer o1, ClansPlayer o2)
|
||||||
|
{
|
||||||
|
if (o1 == null || o2 == null)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (o1.getRole() != o2.getRole())
|
||||||
|
{
|
||||||
|
return o2.getRole().ordinal() - o1.getRole().ordinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
return o1.getPlayerName().compareTo(o2.getPlayerName());
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -128,13 +129,17 @@ public class ClansUtility
|
|||||||
//PLAYER
|
//PLAYER
|
||||||
LinkedList<ClanInfo> playerMatchList = new LinkedList<ClanInfo>();
|
LinkedList<ClanInfo> playerMatchList = new LinkedList<ClanInfo>();
|
||||||
|
|
||||||
for (Entry<String, ClanInfo> clanMemberEntry : Clans.getClanMemberMap().entrySet())
|
for (ClanInfo clanInfo : Clans.getClanMap().values())
|
||||||
{
|
{
|
||||||
if (clanMemberEntry.getKey().equalsIgnoreCase(name))
|
for (ClansPlayer player : clanInfo.getMembers().values())
|
||||||
return clanMemberEntry.getValue();
|
{
|
||||||
|
if (player.getPlayerName().equalsIgnoreCase(name))
|
||||||
|
return clanInfo;
|
||||||
|
|
||||||
if (clanMemberEntry.getKey().toLowerCase().contains(name.toLowerCase()))
|
if (player.getPlayerName().toLowerCase().contains(name.toLowerCase()))
|
||||||
playerMatchList.add(clanMemberEntry.getValue());
|
playerMatchList.add(clanInfo);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerMatchList.size() == 1)
|
if (playerMatchList.size() == 1)
|
||||||
@ -214,22 +219,28 @@ public class ClansUtility
|
|||||||
|
|
||||||
public ClanInfo getClanByPlayer(Player player)
|
public ClanInfo getClanByPlayer(Player player)
|
||||||
{
|
{
|
||||||
return getClanByPlayer(player.getName());
|
return getClanByUUID(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClanInfo getClanByPlayer(String name)
|
public ClanInfo getClanByUUID(UUID uuid)
|
||||||
{
|
{
|
||||||
if (!Clans.getClanMemberMap().containsKey(name))
|
return Clans.getClanMemberUuidMap().get(uuid);
|
||||||
return null;
|
|
||||||
|
|
||||||
return Clans.getClanMemberMap().get(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Deprecated
|
||||||
|
// public ClanInfo getClanByPlayer(String name)
|
||||||
|
// {
|
||||||
|
// if (!Clans.getClanMemberMap().containsKey(name))
|
||||||
|
// return null;
|
||||||
|
//
|
||||||
|
// return Clans.getClanMemberMap().get(name);
|
||||||
|
// }
|
||||||
|
|
||||||
public ClanRole getRole(Player player)
|
public ClanRole getRole(Player player)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return getClanByPlayer(player).getMembers().get(player.getName());
|
return getClanByPlayer(player).getMembers().get(player.getUniqueId()).getRole();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -315,7 +326,7 @@ public class ClansUtility
|
|||||||
return owner.getName();
|
return owner.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOwnerStringRel(Location loc, String player)
|
public String getOwnerStringRel(Location loc, Player player)
|
||||||
{
|
{
|
||||||
ClanRelation rel = relPT(player, UtilWorld.chunkToStr(loc.getChunk()));
|
ClanRelation rel = relPT(player, UtilWorld.chunkToStr(loc.getChunk()));
|
||||||
return mRel(rel, getOwnerString(loc), true);
|
return mRel(rel, getOwnerString(loc), true);
|
||||||
@ -328,26 +339,28 @@ public class ClansUtility
|
|||||||
return Clans.getClaimMap().containsKey(chunk);
|
return Clans.getClaimMap().containsKey(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAlliance(String player, Location loc)
|
// public boolean isAlliance(String player, Location loc)
|
||||||
|
// {
|
||||||
|
// if (!Clans.getClanMemberMap().containsKey(player))
|
||||||
|
// return false;
|
||||||
|
//
|
||||||
|
// if (!isClaimed(loc))
|
||||||
|
// return false;
|
||||||
|
//
|
||||||
|
// return getOwner(getClaim(loc)).isAlly(Clans.getClanMemberMap().get(player).getName());
|
||||||
|
// }
|
||||||
|
|
||||||
|
public boolean isSelf(Player player, Location loc)
|
||||||
{
|
{
|
||||||
if (!Clans.getClanMemberMap().containsKey(player))
|
ClanInfo clan = Clans.getClan(player);
|
||||||
|
|
||||||
|
if (clan == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!isClaimed(loc))
|
if (!isClaimed(loc))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return getOwner(getClaim(loc)).isAlly(Clans.getClanMemberMap().get(player).getName());
|
return getOwner(getClaim(loc)).isSelf(clan.getName());
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSelf(String player, Location loc)
|
|
||||||
{
|
|
||||||
if (!Clans.getClanMemberMap().containsKey(player))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!isClaimed(loc))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return getOwner(getClaim(loc)).isSelf(Clans.getClanMemberMap().get(player).getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAdmin(Location loc)
|
public boolean isAdmin(Location loc)
|
||||||
@ -397,7 +410,7 @@ public class ClansUtility
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Player Player
|
//Player Player
|
||||||
public ClanRelation relPP(String pA, String pB)
|
public ClanRelation relPP(Player pA, Player pB)
|
||||||
{
|
{
|
||||||
return rel(getClanByPlayer(pA), getClanByPlayer(pB));
|
return rel(getClanByPlayer(pA), getClanByPlayer(pB));
|
||||||
}
|
}
|
||||||
@ -415,19 +428,19 @@ public class ClansUtility
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Player Clan
|
//Player Clan
|
||||||
public ClanRelation relPC(String pA, String cB)
|
public ClanRelation relPC(Player pA, String cB)
|
||||||
{
|
{
|
||||||
return rel(getClanByPlayer(pA), searchClan(null, cB, false));
|
return rel(getClanByPlayer(pA), searchClan(null, cB, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Player Clan (Object)
|
//Player Clan (Object)
|
||||||
public ClanRelation relPC(String pA, ClanInfo cB)
|
public ClanRelation relPC(Player pA, ClanInfo cB)
|
||||||
{
|
{
|
||||||
return rel(getClanByPlayer(pA), cB);
|
return rel(getClanByPlayer(pA), cB);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Player Territory
|
//Player Territory
|
||||||
public ClanRelation relPT(String pA, String tB)
|
public ClanRelation relPT(Player pA, String tB)
|
||||||
{
|
{
|
||||||
ClanTerritory claim = getClaim(tB);
|
ClanTerritory claim = getClaim(tB);
|
||||||
if (claim != null && claim.Safe)
|
if (claim != null && claim.Safe)
|
||||||
@ -489,7 +502,7 @@ public class ClansUtility
|
|||||||
return relColor(relation, dark) + message + C.mChat;
|
return relColor(relation, dark) + message + C.mChat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean playerSelf(String pA, String pB)
|
public boolean playerSelf(Player pA, Player pB)
|
||||||
{
|
{
|
||||||
ClanInfo cA = getClanByPlayer(pA);
|
ClanInfo cA = getClanByPlayer(pA);
|
||||||
ClanInfo cB = getClanByPlayer(pB);
|
ClanInfo cB = getClanByPlayer(pB);
|
||||||
@ -500,7 +513,7 @@ public class ClansUtility
|
|||||||
return cA.isSelf(cB.getName());
|
return cA.isSelf(cB.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean playerAlly(String pA, String pB)
|
public boolean playerAlly(Player pA, Player pB)
|
||||||
{
|
{
|
||||||
ClanInfo cA = getClanByPlayer(pA);
|
ClanInfo cA = getClanByPlayer(pA);
|
||||||
ClanInfo cB = getClanByPlayer(pB);
|
ClanInfo cB = getClanByPlayer(pB);
|
||||||
@ -511,7 +524,7 @@ public class ClansUtility
|
|||||||
return cA.isAlly(cB.getName());
|
return cA.isAlly(cB.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean playerEnemy(String pA, String pB)
|
public boolean playerEnemy(Player pA, Player pB)
|
||||||
{
|
{
|
||||||
ClanInfo cA = getClanByPlayer(pA);
|
ClanInfo cA = getClanByPlayer(pA);
|
||||||
ClanInfo cB = getClanByPlayer(pB);
|
ClanInfo cB = getClanByPlayer(pB);
|
||||||
@ -527,7 +540,7 @@ public class ClansUtility
|
|||||||
if (damagee == null || damager == null)
|
if (damagee == null || damager == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ClanRelation rel = relPP(damagee.getName(), damager.getName());
|
ClanRelation rel = relPP(damagee, damager);
|
||||||
|
|
||||||
if (rel == ClanRelation.ALLY || rel == ClanRelation.ALLY_TRUST || rel == ClanRelation.SELF)
|
if (rel == ClanRelation.ALLY || rel == ClanRelation.ALLY_TRUST || rel == ClanRelation.SELF)
|
||||||
return false;
|
return false;
|
||||||
|
@ -22,6 +22,7 @@ import mineplex.game.clans.clans.ClanInfo;
|
|||||||
import mineplex.game.clans.clans.ClanRole;
|
import mineplex.game.clans.clans.ClanRole;
|
||||||
import mineplex.game.clans.clans.ClansBlacklist;
|
import mineplex.game.clans.clans.ClansBlacklist;
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
|
import mineplex.game.clans.clans.ClansPlayer;
|
||||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||||
import mineplex.game.clans.clans.ClientClan;
|
import mineplex.game.clans.clans.ClientClan;
|
||||||
import mineplex.game.clans.core.repository.tokens.ClanToken;
|
import mineplex.game.clans.core.repository.tokens.ClanToken;
|
||||||
@ -42,8 +43,8 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
{
|
{
|
||||||
if (args == null || args.length == 0)
|
if (args == null || args.length == 0)
|
||||||
{
|
{
|
||||||
if (Plugin.getClanMemberMap().containsKey(caller.getName()))
|
if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId()))
|
||||||
infoClan(caller, Plugin.getClanMemberMap().get(caller.getName()).getName());
|
infoClan(caller, Plugin.getClanMemberUuidMap().get(caller.getUniqueId()).getName());
|
||||||
|
|
||||||
else
|
else
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
|
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
|
||||||
@ -228,7 +229,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
|
|
||||||
ClientClan client = Plugin.Get(caller);
|
ClientClan client = Plugin.Get(caller);
|
||||||
|
|
||||||
if (Plugin.getClanMemberMap().containsKey(caller.getName()))
|
if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId()))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You are already in a Clan."));
|
UtilPlayer.message(caller, F.main("Clans", "You are already in a Clan."));
|
||||||
return;
|
return;
|
||||||
@ -366,8 +367,8 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clan.getMembers().get(caller.getName()) != ClanRole.LEADER &&
|
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER &&
|
||||||
clan.getMembers().get(caller.getName()) != ClanRole.ADMIN)
|
clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can send invites."));
|
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can send invites."));
|
||||||
return;
|
return;
|
||||||
@ -401,7 +402,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
|
|
||||||
public void join(final Player caller, String[] args)
|
public void join(final Player caller, String[] args)
|
||||||
{
|
{
|
||||||
if (Plugin.getClanMemberMap().containsKey(caller.getName()))
|
if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId()))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You are already in a Clan."));
|
UtilPlayer.message(caller, F.main("Clans", "You are already in a Clan."));
|
||||||
return;
|
return;
|
||||||
@ -469,7 +470,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clan.getMembers().get(caller.getName()) == ClanRole.LEADER && clan.getMembers().size() > 1)
|
if (clan.getMembers().get(caller.getUniqueId()).getRole() == ClanRole.LEADER && clan.getMembers().size() > 1)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving."));
|
UtilPlayer.message(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving."));
|
||||||
return;
|
return;
|
||||||
@ -512,20 +513,22 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String target = UtilPlayer.searchCollection(caller, args[1], clan.getMembers().keySet(), "Clan Member", true);
|
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)
|
if (target == null || clansPlayer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (clan.getMembers().get(caller.getName()) != ClanRole.LEADER &&
|
if (self.getRole() != ClanRole.LEADER &&
|
||||||
clan.getMembers().get(caller.getName()) != ClanRole.ADMIN)
|
self.getRole() != ClanRole.ADMIN)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can kick members."));
|
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can kick members."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((clan.getMembers().get(target) == ClanRole.LEADER && clan.getMembers().get(caller.getName()) == ClanRole.ADMIN) ||
|
if ((clansPlayer.getRole() == ClanRole.LEADER && self.getRole() == ClanRole.ADMIN) ||
|
||||||
(clan.getMembers().get(target) == ClanRole.ADMIN && clan.getMembers().get(caller.getName()) == ClanRole.ADMIN))
|
(clansPlayer.getRole() == ClanRole.ADMIN && self.getRole() == ClanRole.ADMIN))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(target) + "."));
|
UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(target) + "."));
|
||||||
return;
|
return;
|
||||||
@ -548,7 +551,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
|
|
||||||
//Task
|
//Task
|
||||||
if (player != null) Plugin.getClanDataAccess().leave(clan, player, callback);
|
if (player != null) Plugin.getClanDataAccess().leave(clan, player, callback);
|
||||||
else Plugin.getClanDataAccess().leave(clan, target, callback);
|
else Plugin.getClanDataAccess().leave(clan, clansPlayer, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void promote(Player caller, String[] args)
|
public void promote(Player caller, String[] args)
|
||||||
@ -567,7 +570,9 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String target = UtilPlayer.searchCollection(caller, args[1], clan.getMembers().keySet(), "Clan Member", true);
|
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)
|
if (target == null)
|
||||||
return;
|
return;
|
||||||
@ -578,35 +583,35 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clan.getMembers().get(caller.getName()).ordinal() <= clan.getMembers().get(target).ordinal())
|
if (self.getRole().ordinal() <= target.getRole().ordinal())
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(target) + "."));
|
UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(targetName) + "."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Task
|
//Task
|
||||||
String newRank = "?";
|
String newRank = "?";
|
||||||
if (clan.getMembers().get(target) == ClanRole.RECRUIT)
|
if (target.getRole() == ClanRole.RECRUIT)
|
||||||
{
|
{
|
||||||
Plugin.getClanDataAccess().role(clan, target, ClanRole.MEMBER);
|
Plugin.getClanDataAccess().role(clan, target.getUuid(), ClanRole.MEMBER);
|
||||||
newRank = "Member";
|
newRank = "Member";
|
||||||
}
|
}
|
||||||
else if (clan.getMembers().get(target) == ClanRole.MEMBER)
|
else if (target.getRole() == ClanRole.MEMBER)
|
||||||
{
|
{
|
||||||
Plugin.getClanDataAccess().role(clan, target, ClanRole.ADMIN);
|
Plugin.getClanDataAccess().role(clan, target.getUuid(), ClanRole.ADMIN);
|
||||||
newRank = "Admin";
|
newRank = "Admin";
|
||||||
}
|
}
|
||||||
else if (clan.getMembers().get(target) == ClanRole.ADMIN)
|
else if (target.getRole() == ClanRole.ADMIN)
|
||||||
{
|
{
|
||||||
Plugin.getClanDataAccess().role(clan, target, ClanRole.LEADER);
|
Plugin.getClanDataAccess().role(clan, target.getUuid(), ClanRole.LEADER);
|
||||||
newRank = "Leader";
|
newRank = "Leader";
|
||||||
|
|
||||||
//Give Leader
|
//Give Leader
|
||||||
Plugin.getClanDataAccess().role(clan, caller.getName(), ClanRole.ADMIN);
|
Plugin.getClanDataAccess().role(clan, caller.getUniqueId(), ClanRole.ADMIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
clan.inform(F.name(caller.getName()) + " promoted " + F.name(target) + " to " + F.elem(newRank) + ".", null);
|
clan.inform(F.name(caller.getName()) + " promoted " + F.name(targetName) + " to " + F.elem(newRank) + ".", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void demote(Player caller, String[] args)
|
public void demote(Player caller, String[] args)
|
||||||
@ -625,7 +630,9 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String target = UtilPlayer.searchCollection(caller, args[1], clan.getMembers().keySet(), "Clan Member", true);
|
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)
|
if (target == null)
|
||||||
return;
|
return;
|
||||||
@ -636,33 +643,33 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clan.getMembers().get(caller.getName()).ordinal() <= clan.getMembers().get(target).ordinal())
|
if (self.getRole().ordinal() <= target.getRole().ordinal())
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(target) + "."));
|
UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(targetName) + "."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clan.getMembers().get(target) == ClanRole.RECRUIT)
|
if (target.getRole() == ClanRole.RECRUIT)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You cannot demote " + F.name(target) + " any further."));
|
UtilPlayer.message(caller, F.main("Clans", "You cannot demote " + F.name(targetName) + " any further."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Task
|
//Task
|
||||||
String newRank = "?";
|
String newRank = "?";
|
||||||
if (clan.getMembers().get(target) == ClanRole.MEMBER)
|
if (target.getRole() == ClanRole.MEMBER)
|
||||||
{
|
{
|
||||||
Plugin.getClanDataAccess().role(clan, target, ClanRole.RECRUIT);
|
Plugin.getClanDataAccess().role(clan, target.getUuid(), ClanRole.RECRUIT);
|
||||||
newRank = "Recruit";
|
newRank = "Recruit";
|
||||||
}
|
}
|
||||||
else if (clan.getMembers().get(target) == ClanRole.ADMIN)
|
else if (target.getRole() == ClanRole.ADMIN)
|
||||||
{
|
{
|
||||||
Plugin.getClanDataAccess().role(clan, target, ClanRole.MEMBER);
|
Plugin.getClanDataAccess().role(clan, target.getUuid(), ClanRole.MEMBER);
|
||||||
newRank = "Member";
|
newRank = "Member";
|
||||||
}
|
}
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
clan.inform(F.main("Clans", F.name(caller.getName()) + " demoted " + F.name(target) + " to " + F.elem(newRank) + "."), null);
|
clan.inform(F.main("Clans", F.name(caller.getName()) + " demoted " + F.name(targetName) + " to " + F.elem(newRank) + "."), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ally(Player caller, String[] args)
|
public void ally(Player caller, String[] args)
|
||||||
@ -675,7 +682,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cA.getMembers().get(caller.getName()) != ClanRole.LEADER && cA.getMembers().get(caller.getName()) != ClanRole.ADMIN)
|
if (cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Alliances."));
|
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Alliances."));
|
||||||
return;
|
return;
|
||||||
@ -746,7 +753,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
|
|
||||||
public void trust(Player caller, String[] args)
|
public void trust(Player caller, String[] args)
|
||||||
{
|
{
|
||||||
ClanInfo cA = Plugin.getClan(Plugin.getClanMemberMap().get(caller.getName()).getName());
|
ClanInfo cA = Plugin.getClan(Plugin.getClanMemberUuidMap().get(caller.getUniqueId()).getName());
|
||||||
|
|
||||||
if (cA == null)
|
if (cA == null)
|
||||||
{
|
{
|
||||||
@ -754,7 +761,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cA.getMembers().get(caller.getName()) != ClanRole.LEADER && cA.getMembers().get(caller.getName()) != ClanRole.ADMIN)
|
if (cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Trust."));
|
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Trust."));
|
||||||
return;
|
return;
|
||||||
@ -796,7 +803,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
|
|
||||||
public void neutral(Player caller, String[] args)
|
public void neutral(Player caller, String[] args)
|
||||||
{
|
{
|
||||||
ClanInfo cA = Plugin.getClan(Plugin.getClanMemberMap().get(caller.getName()).getName());
|
ClanInfo cA = Plugin.getClanMemberUuidMap().get(caller.getUniqueId());
|
||||||
|
|
||||||
if (cA == null)
|
if (cA == null)
|
||||||
{
|
{
|
||||||
@ -804,7 +811,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cA.getMembers().get(caller.getName()) != ClanRole.LEADER && cA.getMembers().get(caller.getName()) != ClanRole.ADMIN)
|
if (cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage relationships."));
|
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage relationships."));
|
||||||
return;
|
return;
|
||||||
@ -855,7 +862,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clan.getMembers().get(caller.getName()) != ClanRole.LEADER && clan.getMembers().get(caller.getName()) != ClanRole.ADMIN)
|
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can claim Territory."));
|
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can claim Territory."));
|
||||||
return;
|
return;
|
||||||
@ -885,7 +892,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "This Territory is owned by " +
|
UtilPlayer.message(caller, F.main("Clans", "This Territory is owned by " +
|
||||||
Plugin.getClanUtility().mRel(Plugin.getClanUtility().relPC(caller.getName(), ownerClan), ownerClan.getName(), true) + "."));
|
Plugin.getClanUtility().mRel(Plugin.getClanUtility().relPC(caller, ownerClan), ownerClan.getName(), true) + "."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -967,7 +974,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
//Enemies in Land
|
//Enemies in Land
|
||||||
for (Player cur : UtilServer.getPlayers())
|
for (Player cur : UtilServer.getPlayers())
|
||||||
if (UtilMath.offset(cur, caller) < 16)
|
if (UtilMath.offset(cur, caller) < 16)
|
||||||
if (Plugin.getClanUtility().playerEnemy(caller.getName(), cur.getName()))
|
if (Plugin.getClanUtility().playerEnemy(caller, cur))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You cannot claim while enemies are nearby."));
|
UtilPlayer.message(caller, F.main("Clans", "You cannot claim while enemies are nearby."));
|
||||||
return;
|
return;
|
||||||
@ -1036,7 +1043,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
//Role
|
//Role
|
||||||
if (clan.getMembers().get(caller.getName()) != ClanRole.LEADER && clan.getMembers().get(caller.getName()) != ClanRole.ADMIN)
|
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can unclaim Territory."));
|
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can unclaim Territory."));
|
||||||
return;
|
return;
|
||||||
@ -1089,7 +1096,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clan.getMembers().get(caller.getName()) != ClanRole.LEADER)
|
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader can unclaim all Territory."));
|
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader can unclaim all Territory."));
|
||||||
return;
|
return;
|
||||||
@ -1188,7 +1195,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clan.getMembers().get(caller.getName()) != ClanRole.LEADER && clan.getMembers().get(caller.getName()) != ClanRole.ADMIN)
|
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Clan Home."));
|
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Clan Home."));
|
||||||
return;
|
return;
|
||||||
@ -1227,7 +1234,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
if (clan == null)
|
if (clan == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UtilPlayer.message(caller, clan.mDetails(caller.getName()));
|
UtilPlayer.message(caller, clan.mDetails(caller));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void infoTerritory(Player caller, String[] args)
|
public void infoTerritory(Player caller, String[] args)
|
||||||
|
@ -34,7 +34,7 @@ public class ScoreboardElementPlayer implements ScoreboardElement
|
|||||||
if (claim != null)
|
if (claim != null)
|
||||||
{
|
{
|
||||||
//Relation
|
//Relation
|
||||||
ClansUtility.ClanRelation relation = _clansManager.getClanUtility().relPT(player.getName(), claim.Chunk);
|
ClansUtility.ClanRelation relation = _clansManager.getClanUtility().relPT(player, claim.Chunk);
|
||||||
|
|
||||||
//Name
|
//Name
|
||||||
regionString = _clansManager.getClanUtility().mRel(relation, claim.Owner, false);
|
regionString = _clansManager.getClanUtility().mRel(relation, claim.Owner, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user