Code cleanup
This commit is contained in:
parent
0d48819641
commit
61bea411f5
@ -66,7 +66,6 @@ import com.massivecraft.factions.entity.migrator.MigratorMPlayer001Ranks;
|
|||||||
import com.massivecraft.factions.entity.migrator.MigratorMPlayer002UsingAdminMode;
|
import com.massivecraft.factions.entity.migrator.MigratorMPlayer002UsingAdminMode;
|
||||||
import com.massivecraft.factions.entity.migrator.MigratorTerritoryAccess001Restructure;
|
import com.massivecraft.factions.entity.migrator.MigratorTerritoryAccess001Restructure;
|
||||||
import com.massivecraft.factions.event.EventFactionsChunkChangeType;
|
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.V19.IntegrationV19;
|
||||||
import com.massivecraft.factions.integration.lwc.IntegrationLwc;
|
import com.massivecraft.factions.integration.lwc.IntegrationLwc;
|
||||||
import com.massivecraft.factions.integration.placeholderapi.IntegrationPlaceholderAPI;
|
import com.massivecraft.factions.integration.placeholderapi.IntegrationPlaceholderAPI;
|
||||||
@ -196,7 +195,6 @@ public class Factions extends MassivePlugin
|
|||||||
return MUtil.list(
|
return MUtil.list(
|
||||||
IntegrationPlaceholderAPI.class,
|
IntegrationPlaceholderAPI.class,
|
||||||
IntegrationVentureChat.class,
|
IntegrationVentureChat.class,
|
||||||
IntegrationV18.class,
|
|
||||||
IntegrationV19.class,
|
IntegrationV19.class,
|
||||||
IntegrationLwc.class,
|
IntegrationLwc.class,
|
||||||
IntegrationWorldGuard.class
|
IntegrationWorldGuard.class
|
||||||
|
@ -153,7 +153,7 @@ public class FactionsIndex
|
|||||||
@Override
|
@Override
|
||||||
public Set<MPlayer> createValue()
|
public Set<MPlayer> createValue()
|
||||||
{
|
{
|
||||||
return Collections.newSetFromMap(new WeakHashMap<MPlayer, Boolean>());
|
return Collections.newSetFromMap(new WeakHashMap<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,6 +151,7 @@ public enum Rel implements Colorized, Named, MPerm.MPermable
|
|||||||
return this.isAtLeast(TRUCE);
|
return this.isAtLeast(TRUCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public String getPrefix()
|
public String getPrefix()
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
|
@ -7,12 +7,11 @@ import com.massivecraft.factions.entity.MConf;
|
|||||||
import com.massivecraft.massivecore.MassiveException;
|
import com.massivecraft.massivecore.MassiveException;
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
|
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
||||||
import com.massivecraft.massivecore.predicate.Predicate;
|
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
import com.massivecraft.massivecore.ps.PS;
|
||||||
import com.massivecraft.massivecore.util.ChunkUtil;
|
import com.massivecraft.massivecore.util.ChunkUtil;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class CmdFactionsAccessSetFill extends CmdFactionsAccessSetXSimple
|
public class CmdFactionsAccessSetFill extends CmdFactionsAccessSetXSimple
|
||||||
{
|
{
|
||||||
|
@ -37,8 +37,7 @@ public class CmdFactionsAccessSetOne extends CmdFactionsAccessSetXSimple
|
|||||||
public Set<PS> getChunks()
|
public Set<PS> getChunks()
|
||||||
{
|
{
|
||||||
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
||||||
final Set<PS> chunks = Collections.singleton(chunk);
|
return Collections.singleton(chunk);
|
||||||
return chunks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,25 +39,20 @@ public class CmdFactionsFaction extends FactionsCommand
|
|||||||
final Faction faction = this.readArg(msenderFaction);
|
final Faction faction = this.readArg(msenderFaction);
|
||||||
final CommandSender sender = this.sender;
|
final CommandSender sender = this.sender;
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
|
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
|
||||||
{
|
// Event
|
||||||
@Override
|
EventFactionsFactionShowAsync event = new EventFactionsFactionShowAsync(sender, faction);
|
||||||
public void run()
|
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
|
MixinMessage.get().messageOne(sender, priorityLines.getLines());
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.entity.MFlag;
|
import com.massivecraft.factions.entity.MFlag;
|
||||||
import com.massivecraft.factions.entity.MFlagColl;
|
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.command.Parameter;
|
||||||
import com.massivecraft.massivecore.pager.Pager;
|
import com.massivecraft.massivecore.pager.Pager;
|
||||||
import com.massivecraft.massivecore.pager.Stringifier;
|
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
|
public class CmdFactionsFlagList extends FactionsCommand
|
||||||
{
|
{
|
||||||
@ -39,36 +37,17 @@ public class CmdFactionsFlagList extends FactionsCommand
|
|||||||
|
|
||||||
// Pager create
|
// Pager create
|
||||||
String title = "Flag List for " + msenderFaction.describeTo(mplayer);
|
String title = "Flag List for " + msenderFaction.describeTo(mplayer);
|
||||||
final Pager<MFlag> pager = new Pager<>(this, title, page, new Stringifier<MFlag>()
|
final Pager<MFlag> pager = new Pager<>(this, title, page, (Stringifier<MFlag>) (mflag, index) -> mflag.getStateDesc(false, false, true, true, true, false));
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public String toString(MFlag mflag, int index)
|
|
||||||
{
|
|
||||||
return mflag.getStateDesc(false, false, true, true, true, false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
|
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
|
||||||
{
|
// Get items
|
||||||
@Override
|
List<MFlag> items = MFlagColl.get().getAll(mplayer.isOverriding() ? null : MFlag::isVisible);
|
||||||
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 items
|
||||||
pager.setItems(items);
|
pager.setItems(items);
|
||||||
|
|
||||||
// Pager message
|
// Pager message
|
||||||
pager.message();
|
pager.message();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,14 +37,7 @@ public class CmdFactionsFlagShow extends FactionsCommand
|
|||||||
|
|
||||||
// Pager create
|
// Pager create
|
||||||
String title = "Flags for " + faction.describeTo(msender);
|
String title = "Flags for " + faction.describeTo(msender);
|
||||||
Pager<MFlag> pager = new Pager<>(this, title, page, MFlag.getAll(), new Stringifier<MFlag>()
|
Pager<MFlag> pager = new Pager<>(this, title, page, MFlag.getAll(), (Stringifier<MFlag>) (mflag, index) -> mflag.getStateDesc(faction.getFlag(mflag), true, true, true, true, true));
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public String toString(MFlag mflag, int index)
|
|
||||||
{
|
|
||||||
return mflag.getStateDesc(faction.getFlag(mflag), true, true, true, true, true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Pager args
|
// Pager args
|
||||||
List<String> pagerArgs = new MassiveList<>(
|
List<String> pagerArgs = new MassiveList<>(
|
||||||
|
@ -16,8 +16,6 @@ import com.massivecraft.massivecore.util.TimeDiffUtil;
|
|||||||
import com.massivecraft.massivecore.util.TimeUnit;
|
import com.massivecraft.massivecore.util.TimeUnit;
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
import com.massivecraft.massivecore.util.Txt;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@ -55,38 +53,27 @@ public class CmdFactionsInviteList extends FactionsCommand
|
|||||||
// Pager Create
|
// Pager Create
|
||||||
final List<Entry<String, Invitation>> invitations = new MassiveList<>(faction.getInvitations().entrySet());
|
final List<Entry<String, Invitation>> invitations = new MassiveList<>(faction.getInvitations().entrySet());
|
||||||
|
|
||||||
Collections.sort(invitations, new Comparator<Entry<String, Invitation>>()
|
invitations.sort((i1, i2) -> ComparatorSmart.get().compare(i2.getValue().getCreationMillis(), i1.getValue().getCreationMillis()));
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public int compare(Entry<String, Invitation> i1, Entry<String, Invitation> i2)
|
|
||||||
{
|
|
||||||
return ComparatorSmart.get().compare(i2.getValue().getCreationMillis(), i1.getValue().getCreationMillis());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
final long now = System.currentTimeMillis();
|
final long now = System.currentTimeMillis();
|
||||||
|
|
||||||
final Pager<Entry<String, Invitation>> pager = new Pager<>(this, "Invited Players List", page, invitations, new Stringifier<Entry<String, Invitation>>()
|
final Pager<Entry<String, Invitation>> pager = new Pager<>(this, "Invited Players List", page, invitations, (Stringifier<Entry<String, Invitation>>) (entry, index) -> {
|
||||||
{
|
String inviteeId = entry.getKey();
|
||||||
public String toString(Entry<String, Invitation> entry, int index)
|
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)
|
||||||
{
|
{
|
||||||
String inviteeId = entry.getKey();
|
long millis = now - entry.getValue().getCreationMillis();
|
||||||
String inviterId = entry.getValue().getInviterId();
|
LinkedHashMap<TimeUnit, Long> ageUnitcounts = TimeDiffUtil.limit(TimeDiffUtil.unitcounts(millis, TimeUnit.getAllButMillis()), 2);
|
||||||
|
ageDesc = TimeDiffUtil.formatedMinimal(ageUnitcounts, "<i>");
|
||||||
String inviteeDisplayName = MixinDisplayName.get().getDisplayName(inviteeId, sender);
|
ageDesc = " " + ageDesc + Txt.parse(" ago");
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Txt.parse("%s<i> was invited by %s<reset>%s<i>.", inviteeDisplayName, inviterDisplayName, ageDesc);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Pager Message
|
// Pager Message
|
||||||
|
@ -43,40 +43,31 @@ public class CmdFactionsList extends FactionsCommand
|
|||||||
// We run it asynchronously to spare the primary server thread.
|
// We run it asynchronously to spare the primary server thread.
|
||||||
|
|
||||||
// Pager Create
|
// Pager Create
|
||||||
final Pager<Faction> pager = new Pager<>(this, "Faction List", page, new Stringifier<Faction>() {
|
final Pager<Faction> pager = new Pager<>(this, "Faction List", page, (Stringifier<Faction>) (faction, index) -> {
|
||||||
@Override
|
if (faction.isNone())
|
||||||
public String toString(Faction faction, int index)
|
|
||||||
{
|
{
|
||||||
if (faction.isNone())
|
return Txt.parse("<i>Factionless<i> %d online", FactionColl.get().getNone().getMPlayersWhereOnlineTo(sender).size());
|
||||||
{
|
}
|
||||||
return Txt.parse("<i>Factionless<i> %d online", FactionColl.get().getNone().getMPlayersWhereOnlineTo(sender).size());
|
else
|
||||||
}
|
{
|
||||||
else
|
return Txt.parse("%s<i> %d/%d online, %d/%d/%d",
|
||||||
{
|
faction.getName(msender),
|
||||||
return Txt.parse("%s<i> %d/%d online, %d/%d/%d",
|
faction.getMPlayersWhereOnlineTo(sender).size(),
|
||||||
faction.getName(msender),
|
faction.getMPlayers().size(),
|
||||||
faction.getMPlayersWhereOnlineTo(sender).size(),
|
faction.getLandCount(),
|
||||||
faction.getMPlayers().size(),
|
faction.getPowerRounded(),
|
||||||
faction.getLandCount(),
|
faction.getPowerMaxRounded()
|
||||||
faction.getPowerRounded(),
|
);
|
||||||
faction.getPowerMaxRounded()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
|
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
|
||||||
{
|
// Pager Items
|
||||||
@Override
|
final List<Faction> factions = FactionColl.get().getAll(ComparatorFactionList.get(sender));
|
||||||
public void run()
|
pager.setItems(factions);
|
||||||
{
|
|
||||||
// Pager Items
|
|
||||||
final List<Faction> factions = FactionColl.get().getAll(ComparatorFactionList.get(sender));
|
|
||||||
pager.setItems(factions);
|
|
||||||
|
|
||||||
// Pager Message
|
// Pager Message
|
||||||
pager.message();
|
pager.message();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.massivecraft.factions.util.AsciiMap;
|
|||||||
import com.massivecraft.massivecore.MassiveException;
|
import com.massivecraft.massivecore.MassiveException;
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeBooleanYes;
|
import com.massivecraft.massivecore.command.type.primitive.TypeBooleanYes;
|
||||||
|
import com.massivecraft.massivecore.ps.PS;
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
import com.massivecraft.massivecore.util.Txt;
|
||||||
|
|
||||||
public class CmdFactionsMap extends FactionsCommand
|
public class CmdFactionsMap extends FactionsCommand
|
||||||
@ -37,7 +38,7 @@ public class CmdFactionsMap extends FactionsCommand
|
|||||||
if (!showMap) return;
|
if (!showMap) return;
|
||||||
|
|
||||||
// Show Map
|
// Show Map
|
||||||
AsciiMap map = new AsciiMap(msender, me, !argSet);
|
AsciiMap map = new AsciiMap(msender, PS.valueOf(me), !argSet);
|
||||||
message(map.render());
|
message(map.render());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 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;
|
final Predicate<MPerm> predicate = msender.isOverriding() ? null : MPerm::isVisible;
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
|
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
|
||||||
{
|
// Get items
|
||||||
@Override
|
List<MPerm> items = MPermColl.get().getAll(predicate);
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
// Get items
|
|
||||||
List<MPerm> items = MPermColl.get().getAll(predicate);
|
|
||||||
|
|
||||||
// Pager items
|
// Pager items
|
||||||
pager.setItems(items);
|
pager.setItems(items);
|
||||||
|
|
||||||
// Pager message
|
// Pager message
|
||||||
pager.message();
|
pager.message();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public class CmdFactionsPermShow extends FactionsCommand
|
|||||||
|
|
||||||
for (String permitted : permittedIds)
|
for (String permitted : permittedIds)
|
||||||
{
|
{
|
||||||
permables.add(idToMPermable(permitted));
|
permables.add(MPerm.idToMPermable(permitted));
|
||||||
}
|
}
|
||||||
|
|
||||||
String removeString = Txt.parse(" of ") + faction.getDisplayName(msender);
|
String removeString = Txt.parse(" of ") + faction.getDisplayName(msender);
|
||||||
|
@ -37,7 +37,7 @@ public class CmdFactionsRankList extends FactionsCommand
|
|||||||
List<Rank> 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);
|
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();
|
pager.message();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ import com.massivecraft.factions.event.EventFactionsMembershipChange;
|
|||||||
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
|
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
|
||||||
import com.massivecraft.factions.event.EventFactionsRankChange;
|
import com.massivecraft.factions.event.EventFactionsRankChange;
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
import com.massivecraft.massivecore.MassiveException;
|
||||||
|
import com.massivecraft.massivecore.collections.MassiveSet;
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
import com.massivecraft.massivecore.util.Txt;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -317,8 +318,7 @@ public class CmdFactionsRankSet extends FactionsCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create recipients
|
// Create recipients
|
||||||
Set<MPlayer> recipients = new HashSet<>();
|
Set<MPlayer> recipients = new MassiveSet<>(targetFaction.getMPlayers());
|
||||||
recipients.addAll(targetFaction.getMPlayers());
|
|
||||||
recipients.add(msender);
|
recipients.add(msender);
|
||||||
|
|
||||||
// Were they demoted or promoted?
|
// Were they demoted or promoted?
|
||||||
|
@ -54,42 +54,30 @@ public class CmdFactionsRelationList extends FactionsCommand
|
|||||||
final Set<Rel> relations = this.readArg(RELEVANT_RELATIONS);
|
final Set<Rel> relations = this.readArg(RELEVANT_RELATIONS);
|
||||||
|
|
||||||
// Pager Create
|
// Pager Create
|
||||||
final Pager<String> pager = new Pager<>(this, "", page, new Stringifier<String>()
|
final Pager<String> pager = new Pager<>(this, "", page, (Stringifier<String>) (item, index) -> item);
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public String toString(String item, int index)
|
|
||||||
{
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
|
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
|
||||||
{
|
// Prepare Items
|
||||||
@Override
|
List<String> relNames = new MassiveList<>();
|
||||||
public void run()
|
for (Entry<Rel, List<String>> entry : FactionColl.get().getRelationNames(faction, relations).entrySet())
|
||||||
{
|
{
|
||||||
// Prepare Items
|
Rel relation = entry.getKey();
|
||||||
List<String> relNames = new MassiveList<>();
|
String coloredName = relation.getColor().toString() + relation.getName();
|
||||||
for (Entry<Rel, List<String>> entry : FactionColl.get().getRelationNames(faction, relations).entrySet())
|
|
||||||
|
for (String name : entry.getValue())
|
||||||
{
|
{
|
||||||
Rel relation = entry.getKey();
|
relNames.add(coloredName + SEPERATOR + name);
|
||||||
String coloredName = relation.getColor().toString() + relation.getName();
|
|
||||||
|
|
||||||
for (String name : entry.getValue())
|
|
||||||
{
|
|
||||||
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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,44 +42,34 @@ public class CmdFactionsRelationWishes extends FactionsCommand
|
|||||||
final Faction faction = this.readArg(msenderFaction);
|
final Faction faction = this.readArg(msenderFaction);
|
||||||
|
|
||||||
// Pager Create
|
// Pager Create
|
||||||
final Pager<Entry<Faction, Rel>> pager = new Pager<>(this, "", page, new Stringifier<Entry<Faction, Rel>>()
|
final Pager<Entry<Faction, Rel>> pager = new Pager<>(this, "", page, (Stringifier<Entry<Faction, Rel>>) (item, index) -> {
|
||||||
{
|
Rel rel = item.getValue();
|
||||||
@Override
|
Faction fac = item.getKey();
|
||||||
public String toString(Entry<Faction, Rel> item, int index)
|
return rel.getColor().toString() + rel.getName() + CmdFactionsRelationList.SEPERATOR + fac.describeTo(faction, true);
|
||||||
{
|
|
||||||
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()
|
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
|
||||||
{
|
Map<Faction, Rel> realWishes = new MassiveMap<>();
|
||||||
@Override
|
|
||||||
public void run()
|
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())
|
// A wish is not a wish anymore if both factions have atleast equal "wishes"
|
||||||
{
|
if (fac.getRelationTo(faction).isAtLeast(rel)) continue;
|
||||||
Rel rel = entry.getValue();
|
realWishes.put(fac, rel);
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,6 @@ public class CmdFactionsSeeChunkOld extends FactionsCommand
|
|||||||
msg("<i>Visualized %s", chunk.toString(PSFormatHumanSpace.get()));
|
msg("<i>Visualized %s", chunk.toString(PSFormatHumanSpace.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public static void showPillar(Player player, World world, int blockX, int blockZ)
|
public static void showPillar(Player player, World world, int blockX, int blockZ)
|
||||||
{
|
{
|
||||||
for (int blockY = 0; blockY < world.getMaxHeight(); blockY++)
|
for (int blockY = 0; blockY < world.getMaxHeight(); blockY++)
|
||||||
|
@ -37,8 +37,7 @@ public class CmdFactionsSetOne extends CmdFactionsSetXSimple
|
|||||||
public Set<PS> getChunks()
|
public Set<PS> getChunks()
|
||||||
{
|
{
|
||||||
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
||||||
final Set<PS> chunks = Collections.singleton(chunk);
|
return Collections.singleton(chunk);
|
||||||
return chunks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,53 +46,48 @@ public class CmdFactionsStatus extends FactionsCommand
|
|||||||
|
|
||||||
// Sort list
|
// Sort list
|
||||||
final List<MPlayer> mplayers = faction.getMPlayers();
|
final List<MPlayer> mplayers = faction.getMPlayers();
|
||||||
Collections.sort(mplayers, sortedBy);
|
mplayers.sort(sortedBy);
|
||||||
|
|
||||||
// Pager Create
|
// Pager Create
|
||||||
String title = Txt.parse("<i>Status of %s<i>.", faction.describeTo(msender, true));
|
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>()
|
final Pager<MPlayer> pager = new Pager<>(this, title, page, mplayers, (Stringifier<MPlayer>) (mplayer, index) -> {
|
||||||
{
|
// Name
|
||||||
@Override
|
String displayName = mplayer.getNameAndSomething(msender.getColorTo(mplayer).toString(), "");
|
||||||
public String toString(MPlayer mplayer, int index)
|
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
|
color = "<green>";
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,18 +57,13 @@ public class CmdFactionsTop extends FactionsCommand
|
|||||||
// NOTE: The faction list is quite slow and mostly thread safe.
|
// NOTE: The faction list is quite slow and mostly thread safe.
|
||||||
// We run it asynchronously to spare the primary server thread.
|
// We run it asynchronously to spare the primary server thread.
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
|
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
|
||||||
{
|
// Pager Items
|
||||||
@Override
|
List<Faction> factions = FactionColl.get().getAll((f1, f2) -> (int) (getNumber(category, f2) - getNumber(category, f1)));
|
||||||
public void run()
|
pager.setItems(factions);
|
||||||
{
|
|
||||||
// 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();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,8 +81,7 @@ public class TypeMPermable extends TypeAbstract<MPerm.MPermable>
|
|||||||
TypeRank typeRank = new TypeRank(this.getFaction());
|
TypeRank typeRank = new TypeRank(this.getFaction());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Rank rank = typeRank.read(arg, sender);
|
return typeRank.read(arg, sender);
|
||||||
return rank;
|
|
||||||
}
|
}
|
||||||
catch (MassiveException ex)
|
catch (MassiveException ex)
|
||||||
{
|
{
|
||||||
@ -91,8 +90,7 @@ public class TypeMPermable extends TypeAbstract<MPerm.MPermable>
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Rel rel = TypeRelation.get().read(arg, sender);
|
return TypeRelation.get().read(arg, sender);
|
||||||
return rel;
|
|
||||||
}
|
}
|
||||||
catch (MassiveException ex)
|
catch (MassiveException ex)
|
||||||
{
|
{
|
||||||
@ -101,8 +99,7 @@ public class TypeMPermable extends TypeAbstract<MPerm.MPermable>
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MPlayer mplayer = TypeMPlayer.get().read(arg, sender);
|
return TypeMPlayer.get().read(arg, sender);
|
||||||
return mplayer;
|
|
||||||
}
|
}
|
||||||
catch (MassiveException ex)
|
catch (MassiveException ex)
|
||||||
{
|
{
|
||||||
@ -111,8 +108,7 @@ public class TypeMPermable extends TypeAbstract<MPerm.MPermable>
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Faction faction = TypeFaction.get().read(arg, sender);
|
return TypeFaction.get().read(arg, sender);
|
||||||
return faction;
|
|
||||||
}
|
}
|
||||||
catch (MassiveException ex)
|
catch (MassiveException ex)
|
||||||
{
|
{
|
||||||
@ -126,8 +122,7 @@ public class TypeMPermable extends TypeAbstract<MPerm.MPermable>
|
|||||||
String rankName = arg.substring(idx+1);
|
String rankName = arg.substring(idx+1);
|
||||||
|
|
||||||
Faction faction = TypeFaction.get().read(factionName, sender);
|
Faction faction = TypeFaction.get().read(factionName, sender);
|
||||||
Rank rank = TypeRank.get(faction).read(rankName, sender);
|
return TypeRank.get(faction).read(rankName, sender);
|
||||||
return rank;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new MassiveException().addMsg("<b>No rank, relation, player or faction matches: <h>%s<b>.", arg);
|
throw new MassiveException().addMsg("<b>No rank, relation, player or faction matches: <h>%s<b>.", arg);
|
||||||
|
@ -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
|
// 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)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void canCombatDamageHappen(EntityCombustByEntityEvent event)
|
public void canCombatDamageHappen(EntityCombustByEntityEvent event)
|
||||||
{
|
{
|
||||||
@ -57,7 +56,6 @@ public class EngineCanCombatHappen extends Engine
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void canCombatDamageHappen(PotionSplashEvent event)
|
public void canCombatDamageHappen(PotionSplashEvent event)
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,6 @@ public class EngineExploit extends Engine
|
|||||||
// OBSIDIAN GENERATORS
|
// OBSIDIAN GENERATORS
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void obsidianGenerators(BlockFromToEvent event)
|
public void obsidianGenerators(BlockFromToEvent event)
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,7 @@ import org.bukkit.entity.Wither;
|
|||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.BlockExplodeEvent;
|
||||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
@ -23,7 +24,6 @@ import java.util.Collection;
|
|||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -133,4 +133,14 @@ public class EngineFlagExplosion extends Engine
|
|||||||
event.setCancelled(true);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,14 +36,7 @@ public class EngineLastActivity extends Engine
|
|||||||
public static void updateLastActivitySoon(final CommandSender sender)
|
public static void updateLastActivitySoon(final CommandSender sender)
|
||||||
{
|
{
|
||||||
if (sender == null) throw new RuntimeException("sender");
|
if (sender == null) throw new RuntimeException("sender");
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Factions.get(), new Runnable()
|
Bukkit.getScheduler().scheduleSyncDelayedTask(Factions.get(), () -> updateLastActivity(sender));
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
updateLastActivity(sender);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can't be cancelled
|
// Can't be cancelled
|
||||||
|
@ -56,14 +56,7 @@ public class EngineMotd extends Engine
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Factions.get(), new Runnable()
|
Bukkit.getScheduler().scheduleSyncDelayedTask(Factions.get(), () -> MixinMessage.get().messageOne(player, messages), MConf.get().motdDelayTicks);
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
MixinMessage.get().messageOne(player, messages);
|
|
||||||
}
|
|
||||||
}, MConf.get().motdDelayTicks);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import com.massivecraft.factions.entity.FactionColl;
|
|||||||
import com.massivecraft.factions.entity.MConf;
|
import com.massivecraft.factions.entity.MConf;
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
import com.massivecraft.factions.entity.MPerm;
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
import com.massivecraft.factions.entity.MPlayer;
|
||||||
import com.massivecraft.factions.integration.spigot.IntegrationSpigot;
|
|
||||||
import com.massivecraft.factions.util.EnumerationUtil;
|
import com.massivecraft.factions.util.EnumerationUtil;
|
||||||
import com.massivecraft.massivecore.Engine;
|
import com.massivecraft.massivecore.Engine;
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
import com.massivecraft.massivecore.ps.PS;
|
||||||
@ -18,6 +17,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Projectile;
|
import org.bukkit.entity.Projectile;
|
||||||
import org.bukkit.event.Cancellable;
|
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.hanging.HangingPlaceEvent;
|
||||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class EnginePermBuild extends Engine
|
public class EnginePermBuild extends Engine
|
||||||
@ -193,6 +195,29 @@ public class EnginePermBuild extends Engine
|
|||||||
useEntity(event.getPlayer(), event.getRightClicked(), true, event);
|
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
|
// BUILD > ENTITY
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -237,61 +262,67 @@ public class EnginePermBuild extends Engine
|
|||||||
// BUILD > PISTON
|
// BUILD > PISTON
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NOTE: These piston listeners are only called on 1.7 servers.
|
* 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
|
||||||
* Originally each affected block in the territory was tested, but since we found that pistons can only push
|
* could have easily been stolen. That is the reason why every block
|
||||||
* up to 12 blocks and the width of any territory is 16 blocks, it should be safe (and much more lightweight) to test
|
* needs to be checked now, whether he moved into a territory which
|
||||||
* only the final target block as done below.
|
* he actually may not move into.
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@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?
|
// Is checking deactivated by MConf?
|
||||||
if (IntegrationSpigot.get().isIntegrationActive() || !MConf.get().handlePistonProtectionThroughDenyBuild) return;
|
if ( ! 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
|
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock()));
|
||||||
Block block = event.getBlock();
|
|
||||||
Block targetBlock = block.getRelative(event.getDirection(), event.getLength() + 1);
|
|
||||||
|
|
||||||
// Factions involved
|
List<Block> blocks = event.getBlocks();
|
||||||
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
|
// Check for all extended blocks
|
||||||
if (targetFaction == pistonFaction) return;
|
for (Block block : blocks)
|
||||||
|
{
|
||||||
|
// Block which is being pushed into
|
||||||
|
Block targetBlock = block.getRelative(event.getDirection());
|
||||||
|
|
||||||
// If potentially pushing into air/water/lava in another territory, we need to check it out
|
// Members of a faction might not have build rights in their own territory, but pistons should still work regardless
|
||||||
if (!targetBlock.isEmpty() && !targetBlock.isLiquid()) return;
|
Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(targetBlock));
|
||||||
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) return;
|
if (targetFaction == pistonFaction) continue;
|
||||||
|
|
||||||
event.setCancelled(true);
|
// Perm check
|
||||||
|
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) continue;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void buildPiston(BlockPistonRetractEvent event)
|
public void blockBuild(BlockPistonRetractEvent event)
|
||||||
{
|
{
|
||||||
// Is using Spigot or is checking deactivated by MConf?
|
// Is checking deactivated by MConf?
|
||||||
if (IntegrationSpigot.get().isIntegrationActive() || ! MConf.get().handlePistonProtectionThroughDenyBuild) return;
|
if ( ! 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
|
|
||||||
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock()));
|
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
|
List<Block> blocks = event.getBlocks();
|
||||||
if (targetFaction == pistonFaction) return;
|
|
||||||
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
// 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -167,7 +167,7 @@ public class EngineShow extends Engine
|
|||||||
List<String> followerNamesOffline = new ArrayList<>();
|
List<String> followerNamesOffline = new ArrayList<>();
|
||||||
|
|
||||||
List<MPlayer> followers = faction.getMPlayers();
|
List<MPlayer> followers = faction.getMPlayers();
|
||||||
Collections.sort(followers, ComparatorMPlayerRole.get());
|
followers.sort(ComparatorMPlayerRole.get());
|
||||||
for (MPlayer follower : followers)
|
for (MPlayer follower : followers)
|
||||||
{
|
{
|
||||||
if (follower.isOnline(sender))
|
if (follower.isOnline(sender))
|
||||||
|
@ -44,7 +44,7 @@ public class EngineTeleportHomeOnDeath extends Engine
|
|||||||
if (faction.isNone()) return;
|
if (faction.isNone()) return;
|
||||||
|
|
||||||
// ... and the faction has a home ...
|
// ... 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;
|
if (warps.isEmpty()) return;
|
||||||
|
|
||||||
Warp warp = warps.get(0);
|
Warp warp = warps.get(0);
|
||||||
|
@ -187,9 +187,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
|
|||||||
@Override
|
@Override
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
String ret = this.name;
|
return this.name;
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name)
|
public void setName(String name)
|
||||||
|
@ -90,7 +90,7 @@ public class FactionColl extends Coll<Faction>
|
|||||||
faction.setPermittedRelations(MPerm.getPermDoor(), MPerm.getPermables(faction));
|
faction.setPermittedRelations(MPerm.getPermDoor(), MPerm.getPermables(faction));
|
||||||
faction.setPermittedRelations(MPerm.getPermContainer(), MPerm.getPermables(faction));
|
faction.setPermittedRelations(MPerm.getPermContainer(), MPerm.getPermables(faction));
|
||||||
faction.setPermittedRelations(MPerm.getPermButton(), 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.
|
faction.setPermittedRelations(MPerm.getPermDeposit(), Collections.singleton(faction.getLeaderRank())); // Wilderness deposit should be limited as an anti spam meassure.
|
||||||
|
|
||||||
return faction;
|
return faction;
|
||||||
@ -233,7 +233,7 @@ public class FactionColl extends Coll<Faction>
|
|||||||
boolean peaceful = faction.getFlag(flagPeaceful);
|
boolean peaceful = faction.getFlag(flagPeaceful);
|
||||||
for (Rel rel : rels)
|
for (Rel rel : rels)
|
||||||
{
|
{
|
||||||
ret.put(rel, new ArrayList<String>());
|
ret.put(rel, new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill
|
// Fill
|
||||||
|
@ -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 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 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 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); }
|
public static MPerm getPermLever() { return getCreative(PRIORITY_LEVER, ID_LEVER, ID_LEVER, "use levers", MUtil.set("LEADER", "OFFICER", "MEMBER", "RECRUIT", "ALLY"), true, true, true); }
|
||||||
@ -413,8 +413,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean ret = this.has(mplayer, hostFaction, verboose);
|
return this.has(mplayer, hostFaction, verboose);
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -3,7 +3,6 @@ package com.massivecraft.factions.entity;
|
|||||||
import com.massivecraft.massivecore.store.EntityInternal;
|
import com.massivecraft.massivecore.store.EntityInternal;
|
||||||
import com.massivecraft.massivecore.store.EntityInternalMap;
|
import com.massivecraft.massivecore.store.EntityInternalMap;
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
import com.massivecraft.massivecore.util.Txt;
|
||||||
import org.apache.commons.lang.ObjectUtils.Null;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
@ -95,8 +95,7 @@ public class Vote extends EntityInternal<Vote> implements Named
|
|||||||
public Faction getFaction()
|
public Faction getFaction()
|
||||||
{
|
{
|
||||||
EntityInternalMap<Vote> internalMap = (EntityInternalMap<Vote>) this.getContainer();
|
EntityInternalMap<Vote> internalMap = (EntityInternalMap<Vote>) this.getContainer();
|
||||||
Faction faction = (Faction) internalMap.getEntity();
|
return (Faction) internalMap.getEntity();
|
||||||
return faction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clean()
|
public void clean()
|
||||||
|
@ -39,8 +39,7 @@ public class Warp extends EntityInternal<Warp> implements Named
|
|||||||
public Faction getFaction()
|
public Faction getFaction()
|
||||||
{
|
{
|
||||||
EntityInternalMap<?> internalMap = (EntityInternalMap<?>) this.getContainer();
|
EntityInternalMap<?> internalMap = (EntityInternalMap<?>) this.getContainer();
|
||||||
Faction faction = (Faction) internalMap.getEntity();
|
return (Faction) internalMap.getEntity();
|
||||||
return faction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -10,7 +10,6 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -123,26 +123,12 @@ public class EngineLwc extends Engine
|
|||||||
|
|
||||||
public static void removeAlienProtectionsAsync(final PS chunkPs, final Faction faction)
|
public static void removeAlienProtectionsAsync(final PS chunkPs, final Faction faction)
|
||||||
{
|
{
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
|
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> removeAlienProtectionsRaw(chunkPs, faction));
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
removeAlienProtectionsRaw(chunkPs, faction);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeAlienProtectionsAsyncNextTick(final PS chunkPs, final Faction faction)
|
public static void removeAlienProtectionsAsyncNextTick(final PS chunkPs, final Faction faction)
|
||||||
{
|
{
|
||||||
Bukkit.getScheduler().runTaskLater(Factions.get(), new Runnable()
|
Bukkit.getScheduler().runTaskLater(Factions.get(), () -> removeAlienProtectionsAsync(chunkPs, faction), 0);
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
removeAlienProtectionsAsync(chunkPs, faction);
|
|
||||||
}
|
|
||||||
}, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -26,13 +26,7 @@ public class VisualizeUtil
|
|||||||
}
|
}
|
||||||
public static Set<Location> getPlayerLocations(UUID uuid)
|
public static Set<Location> getPlayerLocations(UUID uuid)
|
||||||
{
|
{
|
||||||
Set<Location> ret = playerLocations.get(uuid);
|
return playerLocations.computeIfAbsent(uuid, k -> new HashSet<>());
|
||||||
if (ret == null)
|
|
||||||
{
|
|
||||||
ret = new HashSet<>();
|
|
||||||
playerLocations.put(uuid, ret);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
Loading…
Reference in New Issue
Block a user