Decoupled LWC integration. This is a good example of what integrations should look like. We are using events only. For this reason the LWC integration could be placed in another plugin and this is good practice. Im not saying we should move the LWC integration to another plugin but its good practice that its possible.
This commit is contained in:
@ -16,7 +16,6 @@ import com.massivecraft.factions.Const;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.RelationParticipator;
|
||||
import com.massivecraft.factions.TerritoryAccess;
|
||||
import com.massivecraft.factions.integration.LWCFeatures;
|
||||
import com.massivecraft.factions.util.AsciiCompass;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
import com.massivecraft.mcore.store.Entity;
|
||||
@ -110,14 +109,7 @@ public class Board extends Entity<Board> implements BoardInterface
|
||||
ps = ps.getChunkCoords(true);
|
||||
|
||||
if (territoryAccess == null || (territoryAccess.getHostFactionId().equals(Const.FACTIONID_NONE) && territoryAccess.isDefault()))
|
||||
{
|
||||
// TODO: Listen to an event instead!
|
||||
// NOTE: And this is probably the place where the event should be triggered!
|
||||
if (UConf.get(ps).lwcRemoveOnUnclaim && LWCFeatures.getEnabled())
|
||||
{
|
||||
LWCFeatures.clearAllProtections(ps);
|
||||
}
|
||||
|
||||
{
|
||||
this.map.remove(ps);
|
||||
}
|
||||
else
|
||||
|
@ -125,8 +125,12 @@ public class UConf extends Entity<UConf>
|
||||
// INTEGRATION: LWC
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean lwcRemoveOnUnclaim = false;
|
||||
public boolean lwcRemoveOnCapture = false;
|
||||
public Map<FactionsEventChunkChangeType, Boolean> lwcRemoveOnChange = MUtil.map(
|
||||
FactionsEventChunkChangeType.BUY, false,
|
||||
FactionsEventChunkChangeType.SELL, false,
|
||||
FactionsEventChunkChangeType.CONQUER, false,
|
||||
FactionsEventChunkChangeType.PILLAGE, false
|
||||
);
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INTEGRATION: ECONOMY
|
||||
|
@ -18,7 +18,6 @@ import com.massivecraft.factions.event.FactionsEventChunkChange;
|
||||
import com.massivecraft.factions.event.FactionsEventMembershipChange;
|
||||
import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.integration.LWCFeatures;
|
||||
import com.massivecraft.factions.integration.Worldguard;
|
||||
import com.massivecraft.factions.util.RelationUtil;
|
||||
import com.massivecraft.mcore.mixin.Mixin;
|
||||
@ -649,12 +648,6 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
||||
event.run();
|
||||
if (event.isCancelled()) return false;
|
||||
|
||||
// TODO: The LWC integration should listen to Monitor for the claim event.
|
||||
if (LWCFeatures.getEnabled() && forFaction.isNormal() && UConf.get(forFaction).lwcRemoveOnCapture)
|
||||
{
|
||||
LWCFeatures.clearOtherProtections(psChunk, this.getFaction());
|
||||
}
|
||||
|
||||
// announce success
|
||||
Set<UPlayer> informTheseUPlayers = new HashSet<UPlayer>();
|
||||
informTheseUPlayers.add(this);
|
||||
|
Reference in New Issue
Block a user