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;
|
||||
|
||||
Reference in New Issue
Block a user