Remove whitelist and blacklists for now till we have them properly thought through.

This commit is contained in:
Olof Larsson 2014-09-17 14:35:57 +02:00
parent 3ade89cf1f
commit 84815a6cd8
2 changed files with 4 additions and 76 deletions

View File

@ -422,19 +422,6 @@ public class MConf extends Entity<MConf>
EventFactionsChunkChangeType.PILLAGE, false EventFactionsChunkChangeType.PILLAGE, false
); );
public Map<Rel, Boolean> lwcAllowIn = MUtil.map(
Rel.ALLY, false,
Rel.ENEMY, false,
Rel.NEUTRAL, false,
Rel.TRUCE, false
);
public Set<String> lwcDisallowIn = MUtil.set(
MConf.get().factionIdWarzone,
MConf.get().factionIdSafezone,
MConf.get().factionIdNone
);
// -------------------------------------------- // // -------------------------------------------- //
// INTEGRATION: ECONOMY // INTEGRATION: ECONOMY
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -17,15 +17,13 @@ import com.griefcraft.lwc.LWC;
import com.griefcraft.model.Protection; import com.griefcraft.model.Protection;
import com.griefcraft.scripting.event.LWCProtectionRegisterEvent; import com.griefcraft.scripting.event.LWCProtectionRegisterEvent;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.event.EventFactionsChunkChange; import com.massivecraft.factions.event.EventFactionsChunkChange;
import com.massivecraft.factions.event.EventFactionsChunkChangeType; import com.massivecraft.factions.event.EventFactionsChunkChangeType;
import com.massivecraft.factions.listeners.FactionsListenerMain;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.util.Txt;
public class EngineLwc implements Listener public class EngineLwc implements Listener
@ -70,48 +68,11 @@ public class EngineLwc implements Listener
removeAlienProtections(event.getChunk(), newFaction); removeAlienProtections(event.getChunk(), newFaction);
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onCreateProtection(LWCProtectionRegisterEvent event) public void onCreateProtection(LWCProtectionRegisterEvent event)
{ {
Faction factionHere = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock())); if (FactionsListenerMain.canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), false)) return;
MPlayer mplayer = MPlayer.get(event.getPlayer()); event.setCancelled(true);
Rel relation = factionHere.getRelationTo(mplayer.getFaction());
Boolean notAllowedHere = false;
// Are they allowed to have LWC protections in this faction land
if (MConf.get().lwcDisallowIn.contains(factionHere.getId()))
{
notAllowedHere = true;
}
// Should we ignore the relationship check?
Boolean ignore =
factionHere.getId().equals(MConf.get().factionIdNone) ||
factionHere.getId().equals(MConf.get().factionIdSafezone) ||
factionHere.getId().equals(MConf.get().factionIdWarzone);
if ( ! ignore)
{
if (!MConf.get().lwcAllowIn.containsKey(relation))
{
notAllowedHere = true;
}
else
{
if(!MConf.get().lwcAllowIn.get(relation))
{
notAllowedHere = true;
}
}
}
if (notAllowedHere)
{
event.setCancelled(true);
mplayer.msg(Txt.parse("<red>You cannot create this LWC protection in this faction."));
}
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -125,26 +86,6 @@ public class EngineLwc implements Listener
{ {
MPlayer owner = MPlayer.get(protection.getOwner()); MPlayer owner = MPlayer.get(protection.getOwner());
if (nonAliens.contains(owner)) continue; if (nonAliens.contains(owner)) continue;
// Compare the relationship to the faction
Rel rel = owner.getRelationTo(faction);
Boolean passRelationTest = true;
// If the relationship isn't in the MConf, consider it failed
if ( ! MConf.get().lwcAllowIn.containsKey(rel))
{
passRelationTest = false;
}
else
{
if ( ! MConf.get().lwcAllowIn.get(rel))
{
passRelationTest = false;
}
}
if ( ! passRelationTest) continue;
protection.remove(); protection.remove();
} }
} }