Java 8
This commit is contained in:
		@@ -6,6 +6,7 @@ import com.massivecraft.factions.cmd.type.TypeMPerm;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.FactionColl;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm.MPermable;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayerColl;
 | 
			
		||||
import com.massivecraft.factions.entity.Rank;
 | 
			
		||||
@@ -13,6 +14,8 @@ import com.massivecraft.massivecore.MassiveException;
 | 
			
		||||
import com.massivecraft.massivecore.collections.MassiveList;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsPermShow extends FactionsCommand
 | 
			
		||||
@@ -39,16 +42,16 @@ public class CmdFactionsPermShow extends FactionsCommand
 | 
			
		||||
		MPerm mperm = this.readArg();
 | 
			
		||||
		Faction faction = this.readArg(msenderFaction);
 | 
			
		||||
 | 
			
		||||
		var permittedIds = faction.getPerms().get(mperm.getId());
 | 
			
		||||
		var permables = new MassiveList<MPerm.MPermable>();
 | 
			
		||||
		Set<String> permittedIds = faction.getPerms().get(mperm.getId());
 | 
			
		||||
		List<MPermable> permables = new MassiveList<>();
 | 
			
		||||
 | 
			
		||||
		for (var permitted : permittedIds)
 | 
			
		||||
		for (String permitted : permittedIds)
 | 
			
		||||
		{
 | 
			
		||||
			permables.add(idToMPermable(permitted));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var removeString = Txt.parse(" of ") + faction.getDisplayName(msender);
 | 
			
		||||
		var permableList = permables.stream()
 | 
			
		||||
		String removeString = Txt.parse(" of ") + faction.getDisplayName(msender);
 | 
			
		||||
		List<String> permableList = permables.stream()
 | 
			
		||||
				.map(permable -> permable.getDisplayName(msender))
 | 
			
		||||
				.map(s -> s.replace(removeString, ""))
 | 
			
		||||
				.collect(Collectors.toList());
 | 
			
		||||
@@ -66,7 +69,7 @@ public class CmdFactionsPermShow extends FactionsCommand
 | 
			
		||||
		Faction faction = Faction.get(id);
 | 
			
		||||
		if (faction != null) return faction;
 | 
			
		||||
 | 
			
		||||
		for (var f : FactionColl.get().getAll())
 | 
			
		||||
		for (Faction f : FactionColl.get().getAll())
 | 
			
		||||
		{
 | 
			
		||||
			Rank rank = f.getRank(id);
 | 
			
		||||
			if (rank != null) return rank;
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@ import com.massivecraft.massivecore.util.MUtil;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsPermView extends FactionsCommand
 | 
			
		||||
@@ -37,7 +38,7 @@ public class CmdFactionsPermView extends FactionsCommand
 | 
			
		||||
	{
 | 
			
		||||
		// Arg: Faction
 | 
			
		||||
		Faction faction = this.readArgAt(1, msenderFaction);
 | 
			
		||||
		var permableType = TypeMPermable.get(faction);
 | 
			
		||||
		TypeMPermable permableType = TypeMPermable.get(faction);
 | 
			
		||||
		MPerm.MPermable permable = permableType.read(this.argAt(0), sender);
 | 
			
		||||
 | 
			
		||||
		if (permable == faction)
 | 
			
		||||
@@ -45,9 +46,9 @@ public class CmdFactionsPermView extends FactionsCommand
 | 
			
		||||
			throw new MassiveException().addMsg("<b>A faction can't have perms for itself.");
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var perms = new MassiveList<MPerm>();
 | 
			
		||||
		List<MPerm> perms = new MassiveList<>();
 | 
			
		||||
 | 
			
		||||
		for (var mperm : MPerm.getAll())
 | 
			
		||||
		for (MPerm mperm : MPerm.getAll())
 | 
			
		||||
		{
 | 
			
		||||
			if (faction.isPermitted(permable.getId(), mperm.getId())) perms.add(mperm);
 | 
			
		||||
		}
 | 
			
		||||
@@ -58,11 +59,11 @@ public class CmdFactionsPermView extends FactionsCommand
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			var permNames = perms.stream().map(perm -> Txt.parse("<h>") + perm.getName()).collect(Collectors.toList());
 | 
			
		||||
			List<String> permNames = perms.stream().map(perm -> Txt.parse("<h>") + perm.getName()).collect(Collectors.toList());
 | 
			
		||||
			String names = Txt.implodeCommaAnd(permNames, Txt.parse("<i>"));
 | 
			
		||||
 | 
			
		||||
			// Create messages
 | 
			
		||||
			var permissionSingularPlural = permNames.size() == 1 ? "permission" : "permissions";
 | 
			
		||||
			String permissionSingularPlural = permNames.size() == 1 ? "permission" : "permissions";
 | 
			
		||||
			msg("<i>In <reset>%s <reset>%s <i>specifically has the %s: <reset>%s<i>.", faction.describeTo(msender), permable.getDisplayName(sender), permissionSingularPlural, names);
 | 
			
		||||
		}
 | 
			
		||||
		if (permable instanceof MPlayer)
 | 
			
		||||
@@ -70,7 +71,7 @@ public class CmdFactionsPermView extends FactionsCommand
 | 
			
		||||
			MPlayer mplayer = (MPlayer) permable;
 | 
			
		||||
			msg("<i>They may have other permissions through their faction membership, rank or relation to <reset>%s<i>.", faction.describeTo(msender));
 | 
			
		||||
 | 
			
		||||
			var msons = new MassiveList<Mson>();
 | 
			
		||||
			List<Mson> msons = new MassiveList<>();
 | 
			
		||||
 | 
			
		||||
			if (mplayer.getFaction() != faction) msons.add(Mson.parse("<command>[faction]").command(this, mplayer.getFaction().getName(), faction.getName()));
 | 
			
		||||
			msons.add(Mson.parse("<command>[rank]").command(this, mplayer.getFaction().getName() + "-" + mplayer.getRank().getName(), faction.getName()));
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,7 @@ import com.massivecraft.massivecore.MassiveException;
 | 
			
		||||
import com.massivecraft.massivecore.collections.MassiveList;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsPermViewall extends FactionsCommand
 | 
			
		||||
@@ -35,7 +36,7 @@ public class CmdFactionsPermViewall extends FactionsCommand
 | 
			
		||||
	{
 | 
			
		||||
		// Arg: Faction
 | 
			
		||||
		Faction faction = this.readArgAt(1, msenderFaction);
 | 
			
		||||
		var permableType = TypeMPermable.get(faction);
 | 
			
		||||
		TypeMPermable permableType = TypeMPermable.get(faction);
 | 
			
		||||
		MPerm.MPermable permable = permableType.read(this.argAt(0), sender);
 | 
			
		||||
 | 
			
		||||
		// Self check
 | 
			
		||||
@@ -45,7 +46,7 @@ public class CmdFactionsPermViewall extends FactionsCommand
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Create list of all applicable permables
 | 
			
		||||
		var permables = new MassiveList<MPermable>();
 | 
			
		||||
		List<MPermable> permables = new MassiveList<>();
 | 
			
		||||
		permables.add(permable);
 | 
			
		||||
 | 
			
		||||
		if (permable instanceof MPlayer)
 | 
			
		||||
@@ -69,14 +70,14 @@ public class CmdFactionsPermViewall extends FactionsCommand
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Find the perms they have
 | 
			
		||||
		var perms = new MassiveList<MPerm>();
 | 
			
		||||
		List<MPerm> perms = new MassiveList<>();
 | 
			
		||||
 | 
			
		||||
		perm:
 | 
			
		||||
		for (var mperm : MPerm.getAll())
 | 
			
		||||
		for (MPerm mperm : MPerm.getAll())
 | 
			
		||||
		{
 | 
			
		||||
			String mpermId = mperm.getId();
 | 
			
		||||
			permable:
 | 
			
		||||
			for (var mpa : permables)
 | 
			
		||||
			for (MPermable mpa : permables)
 | 
			
		||||
			{
 | 
			
		||||
				if (!faction.isPermitted(mpa.getId(), mperm.getId())) continue permable;
 | 
			
		||||
				perms.add(mperm);
 | 
			
		||||
@@ -91,11 +92,11 @@ public class CmdFactionsPermViewall extends FactionsCommand
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			var permNames = perms.stream().map(perm -> Txt.parse("<h>") + perm.getName()).collect(Collectors.toList());
 | 
			
		||||
			List<String> permNames = perms.stream().map(perm -> Txt.parse("<h>") + perm.getName()).collect(Collectors.toList());
 | 
			
		||||
			String names = Txt.implodeCommaAnd(permNames, Txt.parse("<i>"));
 | 
			
		||||
 | 
			
		||||
			// Create messages
 | 
			
		||||
			var permissionSingularPlural = permNames.size() == 1 ? "permission" : "permissions";
 | 
			
		||||
			String permissionSingularPlural = permNames.size() == 1 ? "permission" : "permissions";
 | 
			
		||||
			msg("<i>In <reset>%s <reset>%s <i>has the %s: <reset>%s<i> either specifically granted to them or through rank, relation or faction membership.", faction.describeTo(msender), permable.getDisplayName(sender), permissionSingularPlural, names);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -63,7 +63,7 @@ public class CmdFactionsRankEditPriority extends FactionsCommand
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var priorPriority = rank.getPriority();
 | 
			
		||||
		int priorPriority = rank.getPriority();
 | 
			
		||||
		rank.setPriority(priority);
 | 
			
		||||
 | 
			
		||||
		// Visual
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,7 @@ import com.massivecraft.massivecore.pager.Pager;
 | 
			
		||||
import com.massivecraft.massivecore.pager.Stringifier;
 | 
			
		||||
 | 
			
		||||
import java.util.Comparator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public class CmdFactionsRankList extends FactionsCommand
 | 
			
		||||
{
 | 
			
		||||
@@ -33,10 +34,10 @@ public class CmdFactionsRankList extends FactionsCommand
 | 
			
		||||
		final int page = this.readArg();
 | 
			
		||||
		Faction faction = this.readArg(msenderFaction);
 | 
			
		||||
 | 
			
		||||
		var ranks = faction.getRanks().getAll(Comparator.comparingInt(Rank::getPriority).reversed());
 | 
			
		||||
		List<Rank> ranks = faction.getRanks().getAll(Comparator.comparingInt(Rank::getPriority).reversed());
 | 
			
		||||
 | 
			
		||||
		String title = "Rank list for " + faction.describeTo(msender);
 | 
			
		||||
		var pager = new Pager(this, title, page, ranks, (Stringifier<Rank>) (r, i) -> r.getVisual());
 | 
			
		||||
		Pager<Rank> pager = new Pager(this, title, page, ranks, (Stringifier<Rank>) (r, i) -> r.getVisual());
 | 
			
		||||
		pager.message();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@ import com.massivecraft.massivecore.command.type.TypeAbstract;
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
public class TypeMPermable extends TypeAbstract<MPerm.MPermable>
 | 
			
		||||
@@ -109,8 +110,8 @@ public class TypeMPermable extends TypeAbstract<MPerm.MPermable>
 | 
			
		||||
 | 
			
		||||
	public Collection<String> getTabList(CommandSender sender, String arg)
 | 
			
		||||
	{
 | 
			
		||||
		var ret = new MassiveList<String>();
 | 
			
		||||
		var faction = this.getFaction();
 | 
			
		||||
		List<String> ret = new MassiveList<>();
 | 
			
		||||
		Faction faction = this.getFaction();
 | 
			
		||||
		if (faction == null) faction = MPlayer.get(sender).getFaction();
 | 
			
		||||
		ret.addAll(faction.getRanks().getAll().stream().map(Rank::getName).collect(Collectors.toList()));
 | 
			
		||||
		ret.addAll(TypeRelation.get().getTabList(sender, arg));
 | 
			
		||||
@@ -119,7 +120,7 @@ public class TypeMPermable extends TypeAbstract<MPerm.MPermable>
 | 
			
		||||
		// Faction specific ranks
 | 
			
		||||
		if (arg.length() >= 2)
 | 
			
		||||
		{
 | 
			
		||||
			for (var f : FactionColl.get().getAll())
 | 
			
		||||
			for (Faction f : FactionColl.get().getAll())
 | 
			
		||||
			{
 | 
			
		||||
				String name = f.getName();
 | 
			
		||||
				if (arg.length() <= name.length() && !name.toLowerCase().startsWith(arg.toLowerCase())) continue;
 | 
			
		||||
 
 | 
			
		||||
@@ -36,6 +36,7 @@ import java.util.Comparator;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Optional;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
@@ -757,15 +758,15 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
 | 
			
		||||
	{
 | 
			
		||||
		Map<String, Set<String>> ret = new MassiveMap<>();
 | 
			
		||||
 | 
			
		||||
		var leaderId = this.getRanks().getAll().stream().filter(r -> r.getName().equalsIgnoreCase("leader")).map(Rank::getId).findFirst();
 | 
			
		||||
		var officerId = this.getRanks().getAll().stream().filter(r -> r.getName().equalsIgnoreCase("officer")).map(Rank::getId).findFirst();
 | 
			
		||||
		var memberId = this.getRanks().getAll().stream().filter(r -> r.getName().equalsIgnoreCase("member")).map(Rank::getId).findFirst();
 | 
			
		||||
		var recruitId = this.getRanks().getAll().stream().filter(r -> r.getName().equalsIgnoreCase("recruit")).map(Rank::getId).findAny();
 | 
			
		||||
		Optional<String> leaderId = this.getRanks().getAll().stream().filter(r -> r.getName().equalsIgnoreCase("leader")).map(Rank::getId).findFirst();
 | 
			
		||||
		Optional<String> officerId = this.getRanks().getAll().stream().filter(r -> r.getName().equalsIgnoreCase("officer")).map(Rank::getId).findFirst();
 | 
			
		||||
		Optional<String> memberId = this.getRanks().getAll().stream().filter(r -> r.getName().equalsIgnoreCase("member")).map(Rank::getId).findFirst();
 | 
			
		||||
		Optional<String> recruitId = this.getRanks().getAll().stream().filter(r -> r.getName().equalsIgnoreCase("recruit")).map(Rank::getId).findAny();
 | 
			
		||||
 | 
			
		||||
		for (var mperm : MPerm.getAll())
 | 
			
		||||
		for (MPerm mperm : MPerm.getAll())
 | 
			
		||||
		{
 | 
			
		||||
			var id = mperm.getId();
 | 
			
		||||
			var value = new MassiveSet<>(mperm.getStandard());
 | 
			
		||||
			String id = mperm.getId();
 | 
			
		||||
			MassiveSet<String> value = new MassiveSet<>(mperm.getStandard());
 | 
			
		||||
 | 
			
		||||
			if (value.remove("LEADER") && leaderId.isPresent()) value.add(leaderId.get());
 | 
			
		||||
			if (value.remove("OFFICER") && officerId.isPresent()) value.add(officerId.get());
 | 
			
		||||
@@ -812,7 +813,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
 | 
			
		||||
	public Set<String> getPermitted(String permId)
 | 
			
		||||
	{
 | 
			
		||||
		if (permId == null) throw new NullPointerException("permId");
 | 
			
		||||
		var permables = this.perms.get(permId);
 | 
			
		||||
		Set<String> permables = this.perms.get(permId);
 | 
			
		||||
 | 
			
		||||
		if (permables == null)
 | 
			
		||||
		{
 | 
			
		||||
@@ -837,7 +838,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
 | 
			
		||||
		if (permableId == null) throw new NullPointerException("permableId");
 | 
			
		||||
		if (permId == null) throw new NullPointerException("permId");
 | 
			
		||||
 | 
			
		||||
		var permables = this.perms.get(permId);
 | 
			
		||||
		Set<String> permables = this.perms.get(permId);
 | 
			
		||||
		if (permables == null)
 | 
			
		||||
		{
 | 
			
		||||
			// No perms was found, but likely this is just a new MPerm.
 | 
			
		||||
@@ -857,7 +858,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
 | 
			
		||||
	{
 | 
			
		||||
		boolean changed = false;
 | 
			
		||||
 | 
			
		||||
		var perms = this.perms.get(permId);
 | 
			
		||||
		Set<String> perms = this.perms.get(permId);
 | 
			
		||||
		if (perms == null)
 | 
			
		||||
		{
 | 
			
		||||
			// No perms was found, but likely this is just a new MPerm.
 | 
			
		||||
@@ -889,7 +890,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
 | 
			
		||||
 | 
			
		||||
	public void setPermittedRelations(String permId, Collection<MPerm.MPermable> permables)
 | 
			
		||||
	{
 | 
			
		||||
		var ids = permables.stream().map(MPerm.MPermable::getId).collect(Collectors.toSet());
 | 
			
		||||
		Set<String> ids = permables.stream().map(MPerm.MPermable::getId).collect(Collectors.toSet());
 | 
			
		||||
		this.getPerms().put(permId, ids);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -1119,7 +1120,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
 | 
			
		||||
		MPlayer oldLeader = this.getLeader();
 | 
			
		||||
		Rank leaderRank = oldLeader.getRank();
 | 
			
		||||
 | 
			
		||||
		var replacements = Collections.<MPlayer>emptyList();
 | 
			
		||||
		List<MPlayer> replacements = Collections.<MPlayer>emptyList();
 | 
			
		||||
		for (Rank rank = leaderRank; rank != null; rank = rank.getRankBelow())
 | 
			
		||||
		{
 | 
			
		||||
			//Skip first
 | 
			
		||||
 
 | 
			
		||||
@@ -395,7 +395,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		var ret = this.has(mplayer, hostFaction, verboose);
 | 
			
		||||
		boolean ret = this.has(mplayer, hostFaction, verboose);
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -407,7 +407,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
 | 
			
		||||
	{
 | 
			
		||||
		if (faction == null) throw new NullPointerException("faction");
 | 
			
		||||
 | 
			
		||||
		var list = new MassiveList<MPermable>();
 | 
			
		||||
		List<MPermable> list = new MassiveList<>();
 | 
			
		||||
 | 
			
		||||
		list.addAll(Arrays.asList(Rel.values()));
 | 
			
		||||
		list.remove(Rel.FACTION);
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,10 @@ import com.massivecraft.massivecore.store.EntityInternalMap;
 | 
			
		||||
import com.massivecraft.massivecore.util.Txt;
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.Map.Entry;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
public class Rank extends EntityInternal<Rank> implements MPerm.MPermable
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
@@ -22,12 +26,12 @@ public class Rank extends EntityInternal<Rank> implements MPerm.MPermable
 | 
			
		||||
	@Override
 | 
			
		||||
	public void preDetach(String id)
 | 
			
		||||
	{
 | 
			
		||||
		for (var f : FactionColl.get().getAll())
 | 
			
		||||
		for (Faction f : FactionColl.get().getAll())
 | 
			
		||||
		{
 | 
			
		||||
			for (var it = f.getPerms().entrySet().iterator(); it.hasNext();)
 | 
			
		||||
			for (Iterator<Entry<String, Set<String>>> it = f.getPerms().entrySet().iterator(); it.hasNext();)
 | 
			
		||||
			{
 | 
			
		||||
				var entry = it.next();
 | 
			
		||||
				var value = entry.getValue();
 | 
			
		||||
				Entry<String, Set<String>> entry = it.next();
 | 
			
		||||
				Set<String> value = entry.getValue();
 | 
			
		||||
				value.remove(id);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@@ -51,8 +55,8 @@ public class Rank extends EntityInternal<Rank> implements MPerm.MPermable
 | 
			
		||||
 | 
			
		||||
	public Faction getFaction()
 | 
			
		||||
	{
 | 
			
		||||
		var internalMap = (EntityInternalMap<Rank>) this.getContainer();
 | 
			
		||||
		var faction = (Faction) internalMap.getEntity();
 | 
			
		||||
		EntityInternalMap<Rank> internalMap = (EntityInternalMap<Rank>) this.getContainer();
 | 
			
		||||
		Faction faction = (Faction) internalMap.getEntity();
 | 
			
		||||
		return faction;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -52,14 +52,14 @@ public class MigratorFaction002Ranks extends MigratorRoot
 | 
			
		||||
		map.put(idMember, member);
 | 
			
		||||
		map.put(idRecruit, recruit);
 | 
			
		||||
 | 
			
		||||
		var jsonMap = MassiveCore.gson.toJsonTree(map, (new TypeToken<Map<String,Rank>>(){}).getType());
 | 
			
		||||
		JsonElement jsonMap = MassiveCore.gson.toJsonTree(map, (new TypeToken<Map<String,Rank>>(){}).getType());
 | 
			
		||||
		entity.add("ranks", jsonMap);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		var priorPerms = entity.get("perms");
 | 
			
		||||
		var newPerms = getPerms(priorPerms, idLeader, idOfficer, idMember, idRecruit);
 | 
			
		||||
		JsonElement priorPerms = entity.get("perms");
 | 
			
		||||
		Map<String, Set<String>> newPerms = getPerms(priorPerms, idLeader, idOfficer, idMember, idRecruit);
 | 
			
		||||
 | 
			
		||||
		var jsonPerms = MassiveCore.gson.toJsonTree(newPerms, (new TypeToken<Map<String,Set<String>>>(){}).getType());
 | 
			
		||||
		JsonElement jsonPerms = MassiveCore.gson.toJsonTree(newPerms, (new TypeToken<Map<String,Set<String>>>(){}).getType());
 | 
			
		||||
		entity.add("perms", jsonPerms);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,13 @@
 | 
			
		||||
package com.massivecraft.factions.entity.migrator;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.JsonArray;
 | 
			
		||||
import com.google.gson.JsonElement;
 | 
			
		||||
import com.google.gson.JsonObject;
 | 
			
		||||
import com.massivecraft.factions.entity.MConf;
 | 
			
		||||
import com.massivecraft.massivecore.store.migrator.MigratorRoot;
 | 
			
		||||
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
 | 
			
		||||
public class MigratorMConf004Rank extends MigratorRoot
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
@@ -56,17 +59,17 @@ public class MigratorMConf004Rank extends MigratorRoot
 | 
			
		||||
			JsonObject map = element.getAsJsonObject();
 | 
			
		||||
			if (map.has("MEMBER"))
 | 
			
		||||
			{
 | 
			
		||||
				var e = map.remove("MEMBER");
 | 
			
		||||
				JsonElement e = map.remove("MEMBER");
 | 
			
		||||
				map.add("FACTION", e);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if (element.isJsonArray())
 | 
			
		||||
		{
 | 
			
		||||
			var array = element.getAsJsonArray();
 | 
			
		||||
			var success = false;
 | 
			
		||||
			for (var it = array.iterator(); it.hasNext(); )
 | 
			
		||||
			JsonArray array = element.getAsJsonArray();
 | 
			
		||||
			boolean success = false;
 | 
			
		||||
			for (Iterator<JsonElement> it = array.iterator(); it.hasNext(); )
 | 
			
		||||
			{
 | 
			
		||||
				var e = it.next();
 | 
			
		||||
				JsonElement e = it.next();
 | 
			
		||||
				if (!e.getAsString().equals("MEMBER")) continue;
 | 
			
		||||
				it.remove();
 | 
			
		||||
				success = true;
 | 
			
		||||
 
 | 
			
		||||
@@ -4,8 +4,11 @@ import com.google.gson.JsonObject;
 | 
			
		||||
import com.google.gson.JsonPrimitive;
 | 
			
		||||
import com.massivecraft.factions.entity.Faction;
 | 
			
		||||
import com.massivecraft.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.factions.entity.Rank;
 | 
			
		||||
import com.massivecraft.massivecore.store.migrator.MigratorRoot;
 | 
			
		||||
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
 | 
			
		||||
public class MigratorMPlayer001Ranks extends MigratorRoot
 | 
			
		||||
{
 | 
			
		||||
	// -------------------------------------------- //
 | 
			
		||||
@@ -26,12 +29,12 @@ public class MigratorMPlayer001Ranks extends MigratorRoot
 | 
			
		||||
	@Override
 | 
			
		||||
	public void migrateInner(JsonObject entity)
 | 
			
		||||
	{
 | 
			
		||||
		var role = entity.remove("role").getAsString();
 | 
			
		||||
		var factionId = entity.get("factionId").getAsString();
 | 
			
		||||
		var faction = Faction.get(factionId);
 | 
			
		||||
		String role = entity.remove("role").getAsString();
 | 
			
		||||
		String factionId = entity.get("factionId").getAsString();
 | 
			
		||||
		Faction faction = Faction.get(factionId);
 | 
			
		||||
 | 
			
		||||
		var ranks = faction.getRanks().getAll();
 | 
			
		||||
		for (var rank : ranks)
 | 
			
		||||
		Collection<Rank> ranks = faction.getRanks().getAll();
 | 
			
		||||
		for (Rank rank : ranks)
 | 
			
		||||
		{
 | 
			
		||||
			if (!rank.getName().equalsIgnoreCase(role)) continue;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user