Code cleanup

This commit is contained in:
Magnus Ulf 2019-05-03 09:25:18 +02:00
parent 0d48819641
commit 61bea411f5
44 changed files with 288 additions and 666 deletions

View File

@ -66,7 +66,6 @@ import com.massivecraft.factions.entity.migrator.MigratorMPlayer001Ranks;
import com.massivecraft.factions.entity.migrator.MigratorMPlayer002UsingAdminMode;
import com.massivecraft.factions.entity.migrator.MigratorTerritoryAccess001Restructure;
import com.massivecraft.factions.event.EventFactionsChunkChangeType;
import com.massivecraft.factions.integration.V18.IntegrationV18;
import com.massivecraft.factions.integration.V19.IntegrationV19;
import com.massivecraft.factions.integration.lwc.IntegrationLwc;
import com.massivecraft.factions.integration.placeholderapi.IntegrationPlaceholderAPI;
@ -196,7 +195,6 @@ public class Factions extends MassivePlugin
return MUtil.list(
IntegrationPlaceholderAPI.class,
IntegrationVentureChat.class,
IntegrationV18.class,
IntegrationV19.class,
IntegrationLwc.class,
IntegrationWorldGuard.class

View File

@ -153,7 +153,7 @@ public class FactionsIndex
@Override
public Set<MPlayer> createValue()
{
return Collections.newSetFromMap(new WeakHashMap<MPlayer, Boolean>());
return Collections.newSetFromMap(new WeakHashMap<>());
}
}

View File

@ -150,7 +150,8 @@ public enum Rel implements Colorized, Named, MPerm.MPermable
{
return this.isAtLeast(TRUCE);
}
@Deprecated
public String getPrefix()
{
return "";

View File

@ -7,12 +7,11 @@ import com.massivecraft.factions.entity.MConf;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
import com.massivecraft.massivecore.predicate.Predicate;
import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.util.ChunkUtil;
import java.util.Set;
import java.util.function.Predicate;
public class CmdFactionsAccessSetFill extends CmdFactionsAccessSetXSimple
{

View File

@ -37,8 +37,7 @@ public class CmdFactionsAccessSetOne extends CmdFactionsAccessSetXSimple
public Set<PS> getChunks()
{
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
final Set<PS> chunks = Collections.singleton(chunk);
return chunks;
return Collections.singleton(chunk);
}
}

View File

@ -39,25 +39,20 @@ public class CmdFactionsFaction extends FactionsCommand
final Faction faction = this.readArg(msenderFaction);
final CommandSender sender = this.sender;
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
{
@Override
public void run()
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
// Event
EventFactionsFactionShowAsync event = new EventFactionsFactionShowAsync(sender, faction);
event.run();
if (event.isCancelled()) return;
// Title
MixinMessage.get().messageOne(sender, Txt.titleize("Faction " + faction.getName(msender)));
// Lines
TreeSet<PriorityLines> priorityLiness = new TreeSet<>(event.getIdPriorityLiness().values());
for (PriorityLines priorityLines : priorityLiness)
{
// Event
EventFactionsFactionShowAsync event = new EventFactionsFactionShowAsync(sender, faction);
event.run();
if (event.isCancelled()) return;
// Title
MixinMessage.get().messageOne(sender, Txt.titleize("Faction " + faction.getName(msender)));
// Lines
TreeSet<PriorityLines> priorityLiness = new TreeSet<>(event.getIdPriorityLiness().values());
for (PriorityLines priorityLines : priorityLiness)
{
MixinMessage.get().messageOne(sender, priorityLines.getLines());
}
MixinMessage.get().messageOne(sender, priorityLines.getLines());
}
});

View File

@ -1,9 +1,5 @@
package com.massivecraft.factions.cmd;
import java.util.List;
import org.bukkit.Bukkit;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.entity.MFlag;
import com.massivecraft.factions.entity.MFlagColl;
@ -12,7 +8,9 @@ import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.Parameter;
import com.massivecraft.massivecore.pager.Pager;
import com.massivecraft.massivecore.pager.Stringifier;
import com.massivecraft.massivecore.predicate.Predicate;
import org.bukkit.Bukkit;
import java.util.List;
public class CmdFactionsFlagList extends FactionsCommand
{
@ -39,36 +37,17 @@ public class CmdFactionsFlagList extends FactionsCommand
// Pager create
String title = "Flag List for " + msenderFaction.describeTo(mplayer);
final Pager<MFlag> pager = new Pager<>(this, title, page, new Stringifier<MFlag>()
{
@Override
public String toString(MFlag mflag, int index)
{
return mflag.getStateDesc(false, false, true, true, true, false);
}
});
final Pager<MFlag> pager = new Pager<>(this, title, page, (Stringifier<MFlag>) (mflag, index) -> mflag.getStateDesc(false, false, true, true, true, false));
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
{
@Override
public void run()
{
// Get items
List<MFlag> items = MFlagColl.get().getAll(mplayer.isOverriding() ? null : new Predicate<MFlag>()
{
@Override
public boolean apply(MFlag mflag)
{
return mflag.isVisible();
}
});
// Pager items
pager.setItems(items);
// Pager message
pager.message();
}
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
// Get items
List<MFlag> items = MFlagColl.get().getAll(mplayer.isOverriding() ? null : MFlag::isVisible);
// Pager items
pager.setItems(items);
// Pager message
pager.message();
});
}

View File

@ -37,14 +37,7 @@ public class CmdFactionsFlagShow extends FactionsCommand
// Pager create
String title = "Flags for " + faction.describeTo(msender);
Pager<MFlag> pager = new Pager<>(this, title, page, MFlag.getAll(), new Stringifier<MFlag>()
{
@Override
public String toString(MFlag mflag, int index)
{
return mflag.getStateDesc(faction.getFlag(mflag), true, true, true, true, true);
}
});
Pager<MFlag> pager = new Pager<>(this, title, page, MFlag.getAll(), (Stringifier<MFlag>) (mflag, index) -> mflag.getStateDesc(faction.getFlag(mflag), true, true, true, true, true));
// Pager args
List<String> pagerArgs = new MassiveList<>(

View File

@ -16,8 +16,6 @@ import com.massivecraft.massivecore.util.TimeDiffUtil;
import com.massivecraft.massivecore.util.TimeUnit;
import com.massivecraft.massivecore.util.Txt;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
@ -55,38 +53,27 @@ public class CmdFactionsInviteList extends FactionsCommand
// Pager Create
final List<Entry<String, Invitation>> invitations = new MassiveList<>(faction.getInvitations().entrySet());
Collections.sort(invitations, new Comparator<Entry<String, Invitation>>()
{
@Override
public int compare(Entry<String, Invitation> i1, Entry<String, Invitation> i2)
{
return ComparatorSmart.get().compare(i2.getValue().getCreationMillis(), i1.getValue().getCreationMillis());
}
});
invitations.sort((i1, i2) -> ComparatorSmart.get().compare(i2.getValue().getCreationMillis(), i1.getValue().getCreationMillis()));
final long now = System.currentTimeMillis();
final Pager<Entry<String, Invitation>> pager = new Pager<>(this, "Invited Players List", page, invitations, new Stringifier<Entry<String, Invitation>>()
{
public String toString(Entry<String, Invitation> entry, int index)
{
String inviteeId = entry.getKey();
String inviterId = entry.getValue().getInviterId();
String inviteeDisplayName = MixinDisplayName.get().getDisplayName(inviteeId, sender);
String inviterDisplayName = inviterId != null ? MixinDisplayName.get().getDisplayName(inviterId, sender) : Txt.parse("<silver>unknown");
String ageDesc = "";
if (entry.getValue().getCreationMillis() != null)
{
long millis = now - entry.getValue().getCreationMillis();
LinkedHashMap<TimeUnit, Long> ageUnitcounts = TimeDiffUtil.limit(TimeDiffUtil.unitcounts(millis, TimeUnit.getAllButMillis()), 2);
ageDesc = TimeDiffUtil.formatedMinimal(ageUnitcounts, "<i>");
ageDesc = " " + ageDesc + Txt.parse(" ago");
}
final Pager<Entry<String, Invitation>> pager = new Pager<>(this, "Invited Players List", page, invitations, (Stringifier<Entry<String, Invitation>>) (entry, index) -> {
String inviteeId = entry.getKey();
String inviterId = entry.getValue().getInviterId();
return Txt.parse("%s<i> was invited by %s<reset>%s<i>.", inviteeDisplayName, inviterDisplayName, ageDesc);
String inviteeDisplayName = MixinDisplayName.get().getDisplayName(inviteeId, sender);
String inviterDisplayName = inviterId != null ? MixinDisplayName.get().getDisplayName(inviterId, sender) : Txt.parse("<silver>unknown");
String ageDesc = "";
if (entry.getValue().getCreationMillis() != null)
{
long millis = now - entry.getValue().getCreationMillis();
LinkedHashMap<TimeUnit, Long> ageUnitcounts = TimeDiffUtil.limit(TimeDiffUtil.unitcounts(millis, TimeUnit.getAllButMillis()), 2);
ageDesc = TimeDiffUtil.formatedMinimal(ageUnitcounts, "<i>");
ageDesc = " " + ageDesc + Txt.parse(" ago");
}
return Txt.parse("%s<i> was invited by %s<reset>%s<i>.", inviteeDisplayName, inviterDisplayName, ageDesc);
});
// Pager Message

View File

@ -43,40 +43,31 @@ public class CmdFactionsList extends FactionsCommand
// We run it asynchronously to spare the primary server thread.
// Pager Create
final Pager<Faction> pager = new Pager<>(this, "Faction List", page, new Stringifier<Faction>() {
@Override
public String toString(Faction faction, int index)
final Pager<Faction> pager = new Pager<>(this, "Faction List", page, (Stringifier<Faction>) (faction, index) -> {
if (faction.isNone())
{
if (faction.isNone())
{
return Txt.parse("<i>Factionless<i> %d online", FactionColl.get().getNone().getMPlayersWhereOnlineTo(sender).size());
}
else
{
return Txt.parse("%s<i> %d/%d online, %d/%d/%d",
faction.getName(msender),
faction.getMPlayersWhereOnlineTo(sender).size(),
faction.getMPlayers().size(),
faction.getLandCount(),
faction.getPowerRounded(),
faction.getPowerMaxRounded()
);
}
return Txt.parse("<i>Factionless<i> %d online", FactionColl.get().getNone().getMPlayersWhereOnlineTo(sender).size());
}
else
{
return Txt.parse("%s<i> %d/%d online, %d/%d/%d",
faction.getName(msender),
faction.getMPlayersWhereOnlineTo(sender).size(),
faction.getMPlayers().size(),
faction.getLandCount(),
faction.getPowerRounded(),
faction.getPowerMaxRounded()
);
}
});
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
{
@Override
public void run()
{
// Pager Items
final List<Faction> factions = FactionColl.get().getAll(ComparatorFactionList.get(sender));
pager.setItems(factions);
// Pager Message
pager.message();
}
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
// Pager Items
final List<Faction> factions = FactionColl.get().getAll(ComparatorFactionList.get(sender));
pager.setItems(factions);
// Pager Message
pager.message();
});
}

View File

@ -4,6 +4,7 @@ import com.massivecraft.factions.util.AsciiMap;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
import com.massivecraft.massivecore.command.type.primitive.TypeBooleanYes;
import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.util.Txt;
public class CmdFactionsMap extends FactionsCommand
@ -37,7 +38,7 @@ public class CmdFactionsMap extends FactionsCommand
if (!showMap) return;
// Show Map
AsciiMap map = new AsciiMap(msender, me, !argSet);
AsciiMap map = new AsciiMap(msender, PS.valueOf(me), !argSet);
message(map.render());
}

View File

@ -39,20 +39,15 @@ public class CmdFactionsPermList extends FactionsCommand
final Pager<MPerm> pager = new Pager<>(this, title, page, (Stringifier<MPerm>) (mp, i) -> mp.getDesc(true, true));
final Predicate<MPerm> predicate = msender.isOverriding() ? null : MPerm::isVisible;
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
{
@Override
public void run()
{
// Get items
List<MPerm> items = MPermColl.get().getAll(predicate);
// Pager items
pager.setItems(items);
// Pager message
pager.message();
}
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
// Get items
List<MPerm> items = MPermColl.get().getAll(predicate);
// Pager items
pager.setItems(items);
// Pager message
pager.message();
});
}

View File

@ -44,7 +44,7 @@ public class CmdFactionsPermShow extends FactionsCommand
for (String permitted : permittedIds)
{
permables.add(idToMPermable(permitted));
permables.add(MPerm.idToMPermable(permitted));
}
String removeString = Txt.parse(" of ") + faction.getDisplayName(msender);

View File

@ -37,7 +37,7 @@ public class CmdFactionsRankList extends FactionsCommand
List<Rank> ranks = faction.getRanks().getAll(Comparator.comparingInt(Rank::getPriority).reversed());
String title = "Rank list for " + faction.describeTo(msender);
Pager<Rank> 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();
}

View File

@ -15,6 +15,7 @@ import com.massivecraft.factions.event.EventFactionsMembershipChange;
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
import com.massivecraft.factions.event.EventFactionsRankChange;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.collections.MassiveSet;
import com.massivecraft.massivecore.util.Txt;
import java.util.HashSet;
@ -317,8 +318,7 @@ public class CmdFactionsRankSet extends FactionsCommand
}
// Create recipients
Set<MPlayer> recipients = new HashSet<>();
recipients.addAll(targetFaction.getMPlayers());
Set<MPlayer> recipients = new MassiveSet<>(targetFaction.getMPlayers());
recipients.add(msender);
// Were they demoted or promoted?

View File

@ -54,42 +54,30 @@ public class CmdFactionsRelationList extends FactionsCommand
final Set<Rel> relations = this.readArg(RELEVANT_RELATIONS);
// Pager Create
final Pager<String> pager = new Pager<>(this, "", page, new Stringifier<String>()
{
@Override
public String toString(String item, int index)
{
return item;
}
});
final Pager<String> pager = new Pager<>(this, "", page, (Stringifier<String>) (item, index) -> item);
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
{
@Override
public void run()
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
// Prepare Items
List<String> relNames = new MassiveList<>();
for (Entry<Rel, List<String>> entry : FactionColl.get().getRelationNames(faction, relations).entrySet())
{
// Prepare Items
List<String> relNames = new MassiveList<>();
for (Entry<Rel, List<String>> entry : FactionColl.get().getRelationNames(faction, relations).entrySet())
Rel relation = entry.getKey();
String coloredName = relation.getColor().toString() + relation.getName();
for (String name : entry.getValue())
{
Rel relation = entry.getKey();
String coloredName = relation.getColor().toString() + relation.getName();
for (String name : entry.getValue())
{
relNames.add(coloredName + SEPERATOR + name);
}
relNames.add(coloredName + SEPERATOR + name);
}
// Pager Title
pager.setTitle(Txt.parse("<white>%s's <green>Relations <a>(%d)", faction.getName(), relNames.size()));
// Pager Items
pager.setItems(relNames);
// Pager Message
pager.message();
}
// Pager Title
pager.setTitle(Txt.parse("<white>%s's <green>Relations <a>(%d)", faction.getName(), relNames.size()));
// Pager Items
pager.setItems(relNames);
// Pager Message
pager.message();
});
}

View File

@ -42,44 +42,34 @@ public class CmdFactionsRelationWishes extends FactionsCommand
final Faction faction = this.readArg(msenderFaction);
// Pager Create
final Pager<Entry<Faction, Rel>> pager = new Pager<>(this, "", page, new Stringifier<Entry<Faction, Rel>>()
{
@Override
public String toString(Entry<Faction, Rel> item, int index)
{
Rel rel = item.getValue();
Faction fac = item.getKey();
return rel.getColor().toString() + rel.getName() + CmdFactionsRelationList.SEPERATOR + fac.describeTo(faction, true);
}
final Pager<Entry<Faction, Rel>> pager = new Pager<>(this, "", page, (Stringifier<Entry<Faction, Rel>>) (item, index) -> {
Rel rel = item.getValue();
Faction fac = item.getKey();
return rel.getColor().toString() + rel.getName() + CmdFactionsRelationList.SEPERATOR + fac.describeTo(faction, true);
});
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
{
@Override
public void run()
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
Map<Faction, Rel> realWishes = new MassiveMap<>();
for (Entry<String, Rel> entry : faction.getRelationWishes().entrySet())
{
Map<Faction, Rel> realWishes = new MassiveMap<>();
Rel rel = entry.getValue();
Faction fac = FactionColl.get().getFixed(entry.getKey());
if (fac == null) continue;
for (Entry<String, Rel> entry : faction.getRelationWishes().entrySet())
{
Rel rel = entry.getValue();
Faction fac = FactionColl.get().getFixed(entry.getKey());
if (fac == null) continue;
// A wish is not a wish anymore if both factions have atleast equal "wishes"
if (fac.getRelationTo(faction).isAtLeast(rel)) continue;
realWishes.put(fac, rel);
}
// Pager Title
pager.setTitle(Txt.parse("<white>%s's <green>Relation wishes <a>(%d)", faction.getName(), realWishes.size()));
// Pager Items
pager.setItems(MUtil.entriesSortedByValues(realWishes));
// Pager Message
pager.message();
// A wish is not a wish anymore if both factions have atleast equal "wishes"
if (fac.getRelationTo(faction).isAtLeast(rel)) continue;
realWishes.put(fac, rel);
}
// Pager Title
pager.setTitle(Txt.parse("<white>%s's <green>Relation wishes <a>(%d)", faction.getName(), realWishes.size()));
// Pager Items
pager.setItems(MUtil.entriesSortedByValues(realWishes));
// Pager Message
pager.message();
});
}
}

View File

@ -60,8 +60,7 @@ public class CmdFactionsSeeChunkOld extends FactionsCommand
// Inform
msg("<i>Visualized %s", chunk.toString(PSFormatHumanSpace.get()));
}
@SuppressWarnings("deprecation")
public static void showPillar(Player player, World world, int blockX, int blockZ)
{
for (int blockY = 0; blockY < world.getMaxHeight(); blockY++)

View File

@ -37,8 +37,7 @@ public class CmdFactionsSetOne extends CmdFactionsSetXSimple
public Set<PS> getChunks()
{
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
final Set<PS> chunks = Collections.singleton(chunk);
return chunks;
return Collections.singleton(chunk);
}
}

View File

@ -46,53 +46,48 @@ public class CmdFactionsStatus extends FactionsCommand
// Sort list
final List<MPlayer> mplayers = faction.getMPlayers();
Collections.sort(mplayers, sortedBy);
mplayers.sort(sortedBy);
// Pager Create
String title = Txt.parse("<i>Status of %s<i>.", faction.describeTo(msender, true));
final Pager<MPlayer> pager = new Pager<>(this, title, page, mplayers, new Stringifier<MPlayer>()
{
@Override
public String toString(MPlayer mplayer, int index)
final Pager<MPlayer> pager = new Pager<>(this, title, page, mplayers, (Stringifier<MPlayer>) (mplayer, index) -> {
// Name
String displayName = mplayer.getNameAndSomething(msender.getColorTo(mplayer).toString(), "");
int length = 15 - displayName.length();
length = length <= 0 ? 1 : length;
String whiteSpace = Txt.repeat(" ", length);
// Power
double currentPower = mplayer.getPower();
double maxPower = mplayer.getPowerMax();
String color;
double percent = currentPower / maxPower;
if (percent > 0.75)
{
// Name
String displayName = mplayer.getNameAndSomething(msender.getColorTo(mplayer).toString(), "");
int length = 15 - displayName.length();
length = length <= 0 ? 1 : length;
String whiteSpace = Txt.repeat(" ", length);
// Power
double currentPower = mplayer.getPower();
double maxPower = mplayer.getPowerMax();
String color;
double percent = currentPower / maxPower;
if (percent > 0.75)
{
color = "<green>";
}
else if (percent > 0.5)
{
color = "<yellow>";
}
else if (percent > 0.25)
{
color = "<rose>";
}
else
{
color = "<red>";
}
String power = Txt.parse("<art>Power: %s%.0f<gray>/<green>%.0f", Txt.parse(color), currentPower, maxPower);
// Time
long lastActiveMillis = mplayer.getLastActivityMillis() - System.currentTimeMillis();
LinkedHashMap<TimeUnit, Long> activeTimes = TimeDiffUtil.limit(TimeDiffUtil.unitcounts(lastActiveMillis, TimeUnit.getAllButMillis()), 3);
String lastActive = mplayer.isOnline(msender) ? Txt.parse("<lime>Online right now.") : Txt.parse("<i>Last active: " + TimeDiffUtil.formatedMinimal(activeTimes, "<i>"));
return Txt.parse("%s%s %s %s", displayName, whiteSpace, power, lastActive);
color = "<green>";
}
else if (percent > 0.5)
{
color = "<yellow>";
}
else if (percent > 0.25)
{
color = "<rose>";
}
else
{
color = "<red>";
}
String power = Txt.parse("<art>Power: %s%.0f<gray>/<green>%.0f", Txt.parse(color), currentPower, maxPower);
// Time
long lastActiveMillis = mplayer.getLastActivityMillis() - System.currentTimeMillis();
LinkedHashMap<TimeUnit, Long> activeTimes = TimeDiffUtil.limit(TimeDiffUtil.unitcounts(lastActiveMillis, TimeUnit.getAllButMillis()), 3);
String lastActive = mplayer.isOnline(msender) ? Txt.parse("<lime>Online right now.") : Txt.parse("<i>Last active: " + TimeDiffUtil.formatedMinimal(activeTimes, "<i>"));
return Txt.parse("%s%s %s %s", displayName, whiteSpace, power, lastActive);
});

View File

@ -57,18 +57,13 @@ public class CmdFactionsTop extends FactionsCommand
// NOTE: The faction list is quite slow and mostly thread safe.
// We run it asynchronously to spare the primary server thread.
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
{
@Override
public void run()
{
// Pager Items
List<Faction> factions = FactionColl.get().getAll((f1, f2) -> (int) (getNumber(category, f2) - getNumber(category, f1)));
pager.setItems(factions);
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
// Pager Items
List<Faction> factions = FactionColl.get().getAll((f1, f2) -> (int) (getNumber(category, f2) - getNumber(category, f1)));
pager.setItems(factions);
// Pager Message
pager.message();
}
// Pager Message
pager.message();
});
}

View File

@ -81,8 +81,7 @@ public class TypeMPermable extends TypeAbstract<MPerm.MPermable>
TypeRank typeRank = new TypeRank(this.getFaction());
try
{
Rank rank = typeRank.read(arg, sender);
return rank;
return typeRank.read(arg, sender);
}
catch (MassiveException ex)
{
@ -91,8 +90,7 @@ public class TypeMPermable extends TypeAbstract<MPerm.MPermable>
try
{
Rel rel = TypeRelation.get().read(arg, sender);
return rel;
return TypeRelation.get().read(arg, sender);
}
catch (MassiveException ex)
{
@ -101,8 +99,7 @@ public class TypeMPermable extends TypeAbstract<MPerm.MPermable>
try
{
MPlayer mplayer = TypeMPlayer.get().read(arg, sender);
return mplayer;
return TypeMPlayer.get().read(arg, sender);
}
catch (MassiveException ex)
{
@ -111,8 +108,7 @@ public class TypeMPermable extends TypeAbstract<MPerm.MPermable>
try
{
Faction faction = TypeFaction.get().read(arg, sender);
return faction;
return TypeFaction.get().read(arg, sender);
}
catch (MassiveException ex)
{
@ -126,8 +122,7 @@ public class TypeMPermable extends TypeAbstract<MPerm.MPermable>
String rankName = arg.substring(idx+1);
Faction faction = TypeFaction.get().read(factionName, sender);
Rank rank = TypeRank.get(faction).read(rankName, sender);
return rank;
return TypeRank.get(faction).read(rankName, sender);
}
throw new MassiveException().addMsg("<b>No rank, relation, player or faction matches: <h>%s<b>.", arg);

View File

@ -48,7 +48,6 @@ public class EngineCanCombatHappen extends Engine
}
// mainly for flaming arrows; don't want allies or people in safe zones to be ignited even after damage event is cancelled
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void canCombatDamageHappen(EntityCombustByEntityEvent event)
{
@ -57,7 +56,6 @@ public class EngineCanCombatHappen extends Engine
event.setCancelled(true);
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void canCombatDamageHappen(PotionSplashEvent event)
{

View File

@ -33,8 +33,7 @@ public class EngineExploit extends Engine
// -------------------------------------------- //
// OBSIDIAN GENERATORS
// -------------------------------------------- //
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void obsidianGenerators(BlockFromToEvent event)
{

View File

@ -12,6 +12,7 @@ import org.bukkit.entity.Wither;
import org.bukkit.event.Cancellable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockExplodeEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
@ -23,7 +24,6 @@ import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -133,4 +133,14 @@ public class EngineFlagExplosion extends Engine
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockExplosion(BlockExplodeEvent event)
{
Location location = event.getBlock().getLocation();
Cancellable cancellable = event;
Collection<Block> blocks = event.blockList();
EngineFlagExplosion.get().blockExplosion(location, cancellable, blocks);
}
}

View File

@ -36,14 +36,7 @@ public class EngineLastActivity extends Engine
public static void updateLastActivitySoon(final CommandSender sender)
{
if (sender == null) throw new RuntimeException("sender");
Bukkit.getScheduler().scheduleSyncDelayedTask(Factions.get(), new Runnable()
{
@Override
public void run()
{
updateLastActivity(sender);
}
});
Bukkit.getScheduler().scheduleSyncDelayedTask(Factions.get(), () -> updateLastActivity(sender));
}
// Can't be cancelled

View File

@ -56,14 +56,7 @@ public class EngineMotd extends Engine
}
else
{
Bukkit.getScheduler().scheduleSyncDelayedTask(Factions.get(), new Runnable()
{
@Override
public void run()
{
MixinMessage.get().messageOne(player, messages);
}
}, MConf.get().motdDelayTicks);
Bukkit.getScheduler().scheduleSyncDelayedTask(Factions.get(), () -> MixinMessage.get().messageOne(player, messages), MConf.get().motdDelayTicks);
}
}

View File

@ -9,7 +9,6 @@ import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.MPerm;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.integration.spigot.IntegrationSpigot;
import com.massivecraft.factions.util.EnumerationUtil;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.ps.PS;
@ -18,6 +17,7 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.Cancellable;
@ -38,10 +38,12 @@ import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.projectiles.ProjectileSource;
import java.util.List;
import java.util.Map;
public class EnginePermBuild extends Engine
@ -192,7 +194,30 @@ public class EnginePermBuild extends Engine
if (isOffHand(event)) return;
useEntity(event.getPlayer(), event.getRightClicked(), true, event);
}
// This is a special Spigot event that fires for Minecraft 1.8 armor stands.
// It also fires for other entity types but for those the event is buggy.
// It seems we can only cancel interaction with armor stands from here.
// Thus we only handle armor stands from here and handle everything else in EngineMain.
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void handleArmorStand(PlayerInteractAtEntityEvent event)
{
// Ignore Off Hand
if (isOffHand(event)) return;
// Gather Info
final Player player = event.getPlayer();
if (MUtil.isntPlayer(player)) return;
final Entity entity = event.getRightClicked();
final boolean verboose = true;
// Only care for armor stands.
if (entity.getType() != EntityType.ARMOR_STAND) return;
// If we can't use, block it
EnginePermBuild.useEntity(player, entity, verboose, event);
}
// -------------------------------------------- //
// BUILD > ENTITY
// -------------------------------------------- //
@ -237,61 +262,67 @@ public class EnginePermBuild extends Engine
// BUILD > PISTON
// -------------------------------------------- //
/*
* NOTE: These piston listeners are only called on 1.7 servers.
*
* Originally each affected block in the territory was tested, but since we found that pistons can only push
* up to 12 blocks and the width of any territory is 16 blocks, it should be safe (and much more lightweight) to test
* only the final target block as done below.
*/
/*
* Note: With 1.8 and the slime blocks, retracting and extending pistons
* became more of a problem. Blocks located on the border of a chunk
* could have easily been stolen. That is the reason why every block
* needs to be checked now, whether he moved into a territory which
* he actually may not move into.
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void buildPiston(BlockPistonExtendEvent event)
public void blockBuild(BlockPistonExtendEvent event)
{
// Is using Spigot or is checking deactivated by MConf?
if (IntegrationSpigot.get().isIntegrationActive() || !MConf.get().handlePistonProtectionThroughDenyBuild) return;
// Targets end-of-the-line empty (air) block which is being pushed into, including if piston itself would extend into air
Block block = event.getBlock();
Block targetBlock = block.getRelative(event.getDirection(), event.getLength() + 1);
// Factions involved
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(block));
Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(targetBlock));
// Members of a faction might not have build rights in their own territory, but pistons should still work regardless
if (targetFaction == pistonFaction) return;
// If potentially pushing into air/water/lava in another territory, we need to check it out
if (!targetBlock.isEmpty() && !targetBlock.isLiquid()) return;
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) return;
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void buildPiston(BlockPistonRetractEvent event)
{
// Is using Spigot or is checking deactivated by MConf?
if (IntegrationSpigot.get().isIntegrationActive() || ! MConf.get().handlePistonProtectionThroughDenyBuild) return;
// If not a sticky piston, retraction should be fine
if ( ! event.isSticky()) return;
Block retractBlock = event.getRetractLocation().getBlock();
PS retractPs = PS.valueOf(retractBlock);
// if potentially retracted block is just air/water/lava, no worries
if (retractBlock.isEmpty() || retractBlock.isLiquid()) return;
// Factions involved
// Is checking deactivated by MConf?
if ( ! MConf.get().handlePistonProtectionThroughDenyBuild) return;
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock()));
Faction targetFaction = BoardColl.get().getFactionAt(retractPs);
// Members of a faction might not have build rights in their own territory, but pistons should still work regardless
if (targetFaction == pistonFaction) return;
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) return;
event.setCancelled(true);
List<Block> blocks = event.getBlocks();
// Check for all extended blocks
for (Block block : blocks)
{
// Block which is being pushed into
Block targetBlock = block.getRelative(event.getDirection());
// Members of a faction might not have build rights in their own territory, but pistons should still work regardless
Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(targetBlock));
if (targetFaction == pistonFaction) continue;
// Perm check
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) continue;
event.setCancelled(true);
return;
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockBuild(BlockPistonRetractEvent event)
{
// Is checking deactivated by MConf?
if ( ! MConf.get().handlePistonProtectionThroughDenyBuild) return;
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock()));
List<Block> blocks = event.getBlocks();
// Check for all retracted blocks
for (Block block : blocks)
{
// Is the retracted block air/water/lava? Don't worry about it
if (block.isEmpty() || block.isLiquid()) return;
// Members of a faction might not have build rights in their own territory, but pistons should still work regardless
Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(block));
if (targetFaction == pistonFaction) continue;
// Perm check
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) continue;
event.setCancelled(true);
return;
}
}
// -------------------------------------------- //

View File

@ -167,7 +167,7 @@ public class EngineShow extends Engine
List<String> followerNamesOffline = new ArrayList<>();
List<MPlayer> followers = faction.getMPlayers();
Collections.sort(followers, ComparatorMPlayerRole.get());
followers.sort(ComparatorMPlayerRole.get());
for (MPlayer follower : followers)
{
if (follower.isOnline(sender))

View File

@ -44,7 +44,7 @@ public class EngineTeleportHomeOnDeath extends Engine
if (faction.isNone()) return;
// ... and the faction has a home ...
List<Warp> warps = faction.getWarps().getAll(warp -> warp.getName().equalsIgnoreCase(MConf.get().warpsTeleportToOnDeathName));
List<Warp> warps = faction.getWarps().getAll((java.util.function.Predicate<Warp>) (warp -> warp.getName().equalsIgnoreCase(MConf.get().warpsTeleportToOnDeathName)));
if (warps.isEmpty()) return;
Warp warp = warps.get(0);

View File

@ -187,9 +187,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
@Override
public String getName()
{
String ret = this.name;
return ret;
return this.name;
}
public void setName(String name)

View File

@ -90,7 +90,7 @@ public class FactionColl extends Coll<Faction>
faction.setPermittedRelations(MPerm.getPermDoor(), MPerm.getPermables(faction));
faction.setPermittedRelations(MPerm.getPermContainer(), MPerm.getPermables(faction));
faction.setPermittedRelations(MPerm.getPermButton(), MPerm.getPermables(faction));
faction.setPermittedRelations(MPerm.getPermLever(), MPerm.getPermables(faction));;
faction.setPermittedRelations(MPerm.getPermLever(), MPerm.getPermables(faction));
faction.setPermittedRelations(MPerm.getPermDeposit(), Collections.singleton(faction.getLeaderRank())); // Wilderness deposit should be limited as an anti spam meassure.
return faction;
@ -233,7 +233,7 @@ public class FactionColl extends Coll<Faction>
boolean peaceful = faction.getFlag(flagPeaceful);
for (Rel rel : rels)
{
ret.put(rel, new ArrayList<String>());
ret.put(rel, new ArrayList<>());
}
// Fill

View File

@ -146,7 +146,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
}
public static MPerm getPermBuild() { return getCreative(PRIORITY_BUILD, ID_BUILD, ID_BUILD, "edit the terrain", MUtil.set("LEADER", "OFFICER", "MEMBER"), true, true, true); }
public static MPerm getPermPainbuild() { return getCreative(PRIORITY_PAINBUILD, ID_PAINBUILD, ID_PAINBUILD, "edit, take damage", new MassiveSet<String>(), true, true, true); }
public static MPerm getPermPainbuild() { return getCreative(PRIORITY_PAINBUILD, ID_PAINBUILD, ID_PAINBUILD, "edit, take damage", new MassiveSet<>(), true, true, true); }
public static MPerm getPermDoor() { return getCreative(PRIORITY_DOOR, ID_DOOR, ID_DOOR, "use doors", MUtil.set("LEADER", "OFFICER", "MEMBER", "RECRUIT", "ALLY"), true, true, true); }
public static MPerm getPermButton() { return getCreative(PRIORITY_BUTTON, ID_BUTTON, ID_BUTTON, "use stone buttons", MUtil.set("LEADER", "OFFICER", "MEMBER", "RECRUIT", "ALLY"), true, true, true); }
public static MPerm getPermLever() { return getCreative(PRIORITY_LEVER, ID_LEVER, ID_LEVER, "use levers", MUtil.set("LEADER", "OFFICER", "MEMBER", "RECRUIT", "ALLY"), true, true, true); }
@ -412,9 +412,8 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
return accessStatus.hasAccess();
}
}
boolean ret = this.has(mplayer, hostFaction, verboose);
return ret;
return this.has(mplayer, hostFaction, verboose);
}
// -------------------------------------------- //

View File

@ -3,7 +3,6 @@ package com.massivecraft.factions.entity;
import com.massivecraft.massivecore.store.EntityInternal;
import com.massivecraft.massivecore.store.EntityInternalMap;
import com.massivecraft.massivecore.util.Txt;
import org.apache.commons.lang.ObjectUtils.Null;
import org.bukkit.ChatColor;
import java.util.Map.Entry;

View File

@ -95,8 +95,7 @@ public class Vote extends EntityInternal<Vote> implements Named
public Faction getFaction()
{
EntityInternalMap<Vote> internalMap = (EntityInternalMap<Vote>) this.getContainer();
Faction faction = (Faction) internalMap.getEntity();
return faction;
return (Faction) internalMap.getEntity();
}
public void clean()

View File

@ -39,8 +39,7 @@ public class Warp extends EntityInternal<Warp> implements Named
public Faction getFaction()
{
EntityInternalMap<?> internalMap = (EntityInternalMap<?>) this.getContainer();
Faction faction = (Faction) internalMap.getEntity();
return faction;
return (Faction) internalMap.getEntity();
}
// -------------------------------------------- //

View File

@ -10,7 +10,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.event.HandlerList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

View File

@ -1,55 +0,0 @@
package com.massivecraft.factions.integration.V18;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.engine.EngineCanCombatHappen;
import com.massivecraft.factions.engine.EngineFlagExplosion;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.MassivePlugin;
import com.massivecraft.massivecore.util.MUtil;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockExplodeEvent;
import org.bukkit.event.entity.AreaEffectCloudApplyEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.projectiles.ProjectileSource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class EngineV18 extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static EngineV18 i = new EngineV18();
public static EngineV18 get() { return i; }
@Override
public MassivePlugin getActivePlugin()
{
return Factions.get();
}
// -------------------------------------------- //
// LISTENER
// -------------------------------------------- //
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockExplosion(BlockExplodeEvent event)
{
Location location = event.getBlock().getLocation();
Cancellable cancellable = event;
Collection<Block> blocks = event.blockList();
EngineFlagExplosion.get().blockExplosion(location, cancellable, blocks);
}
}

View File

@ -1,31 +0,0 @@
package com.massivecraft.factions.integration.V18;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.Integration;
public class IntegrationV18 extends Integration
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static IntegrationV18 i = new IntegrationV18();
public static IntegrationV18 get() { return i; }
private IntegrationV18()
{
this.setClassNames(
"org.bukkit.entity.ArmorStand"
);
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Engine getEngine()
{
return EngineV18.get();
}
}

View File

@ -123,26 +123,12 @@ public class EngineLwc extends Engine
public static void removeAlienProtectionsAsync(final PS chunkPs, final Faction faction)
{
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
{
@Override
public void run()
{
removeAlienProtectionsRaw(chunkPs, faction);
}
});
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> removeAlienProtectionsRaw(chunkPs, faction));
}
public static void removeAlienProtectionsAsyncNextTick(final PS chunkPs, final Faction faction)
{
Bukkit.getScheduler().runTaskLater(Factions.get(), new Runnable()
{
@Override
public void run()
{
removeAlienProtectionsAsync(chunkPs, faction);
}
}, 0);
Bukkit.getScheduler().runTaskLater(Factions.get(), () -> removeAlienProtectionsAsync(chunkPs, faction), 0);
}
}

View File

@ -1,123 +0,0 @@
package com.massivecraft.factions.integration.spigot;
import com.massivecraft.factions.engine.EnginePermBuild;
import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.MPerm;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.util.MUtil;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import java.util.List;
public class EngineSpigot extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static EngineSpigot i = new EngineSpigot();
public static EngineSpigot get() { return i; }
// -------------------------------------------- //
// LISTENER
// -------------------------------------------- //
// This is a special Spigot event that fires for Minecraft 1.8 armor stands.
// It also fires for other entity types but for those the event is buggy.
// It seems we can only cancel interaction with armor stands from here.
// Thus we only handle armor stands from here and handle everything else in EngineMain.
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event)
{
// Ignore Off Hand
if (isOffHand(event)) return;
// Gather Info
final Player player = event.getPlayer();
if (MUtil.isntPlayer(player)) return;
final Entity entity = event.getRightClicked();
final boolean verboose = true;
// Only care for armor stands.
if (entity.getType() != EntityType.ARMOR_STAND) return;
// If we can't use, block it
EnginePermBuild.useEntity(player, entity, verboose, event);
}
/*
* Note: With 1.8 and the slime blocks, retracting and extending pistons
* became more of a problem. Blocks located on the border of a chunk
* could have easily been stolen. That is the reason why every block
* needs to be checked now, whether he moved into a territory which
* he actually may not move into.
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockBuild(BlockPistonExtendEvent event)
{
// Is checking deactivated by MConf?
if ( ! MConf.get().handlePistonProtectionThroughDenyBuild) return;
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock()));
List<Block> blocks = event.getBlocks();
// Check for all extended blocks
for (Block block : blocks)
{
// Block which is being pushed into
Block targetBlock = block.getRelative(event.getDirection());
// Members of a faction might not have build rights in their own territory, but pistons should still work regardless
Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(targetBlock));
if (targetFaction == pistonFaction) continue;
// Perm check
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) continue;
event.setCancelled(true);
return;
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockBuild(BlockPistonRetractEvent event)
{
// Is checking deactivated by MConf?
if ( ! MConf.get().handlePistonProtectionThroughDenyBuild) return;
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock()));
List<Block> blocks = event.getBlocks();
// Check for all retracted blocks
for (Block block : blocks)
{
// Is the retracted block air/water/lava? Don't worry about it
if (block.isEmpty() || block.isLiquid()) return;
// Members of a faction might not have build rights in their own territory, but pistons should still work regardless
Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(block));
if (targetFaction == pistonFaction) continue;
// Perm check
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) continue;
event.setCancelled(true);
return;
}
}
}

View File

@ -1,29 +0,0 @@
package com.massivecraft.factions.integration.spigot;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.Integration;
public class IntegrationSpigot extends Integration
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static IntegrationSpigot i = new IntegrationSpigot();
public static IntegrationSpigot get() { return i; }
private IntegrationSpigot()
{
this.setPredicate(PredicateSpigot.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Engine getEngine()
{
return EngineSpigot.get();
}
}

View File

@ -1,36 +0,0 @@
package com.massivecraft.factions.integration.spigot;
import com.massivecraft.massivecore.Integration;
import com.massivecraft.massivecore.predicate.Predicate;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
public class PredicateSpigot implements Predicate<Integration>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static PredicateSpigot i = new PredicateSpigot();
public static PredicateSpigot get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean apply(Integration integration)
{
try
{
// This line will throw if the class does not exist.
PlayerInteractAtEntityEvent.class.getName();
return true;
}
catch (Throwable t)
{
return false;
}
}
}

View File

@ -26,13 +26,7 @@ public class VisualizeUtil
}
public static Set<Location> getPlayerLocations(UUID uuid)
{
Set<Location> ret = playerLocations.get(uuid);
if (ret == null)
{
ret = new HashSet<>();
playerLocations.put(uuid, ret);
}
return ret;
return playerLocations.computeIfAbsent(uuid, k -> new HashSet<>());
}
// -------------------------------------------- //