Adds LockettePro integration
The LockettePro integration adds a new option (default true) which allows the leader of a faction to break any LockettePro sign in their faction. This prevents griefing faction members from placing a signs on a bunch of shared chests. This also prevents chests in the wilderness from being protected even when taken over by a faction.
This commit is contained in:
		@@ -68,6 +68,7 @@ import com.massivecraft.factions.entity.migrator.MigratorMPlayer002UsingAdminMod
 | 
			
		||||
import com.massivecraft.factions.entity.migrator.MigratorTerritoryAccess001Restructure;
 | 
			
		||||
import com.massivecraft.factions.event.EventFactionsChunkChangeType;
 | 
			
		||||
import com.massivecraft.factions.integration.dynmap.IntegrationDynmap;
 | 
			
		||||
import com.massivecraft.factions.integration.lockette.IntegrationLockette;
 | 
			
		||||
import com.massivecraft.factions.integration.lwc.IntegrationLwc;
 | 
			
		||||
import com.massivecraft.factions.integration.placeholderapi.IntegrationPlaceholderAPI;
 | 
			
		||||
import com.massivecraft.factions.integration.venturechat.IntegrationVentureChat;
 | 
			
		||||
@@ -205,6 +206,7 @@ public class Factions extends MassivePlugin {
 | 
			
		||||
                IntegrationPlaceholderAPI.class,
 | 
			
		||||
                IntegrationVentureChat.class,
 | 
			
		||||
                IntegrationLwc.class,
 | 
			
		||||
                IntegrationLockette.class,
 | 
			
		||||
                IntegrationWorldGuard.class,
 | 
			
		||||
                IntegrationDynmap.class
 | 
			
		||||
        );
 | 
			
		||||
 
 | 
			
		||||
@@ -651,6 +651,13 @@ public class MConf extends Entity<MConf> {
 | 
			
		||||
            EventFactionsChunkChangeType.PILLAGE, false // when unclaiming (to wilderness) from another player faction
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    // -------------------------------------------- //
 | 
			
		||||
    // INTEGRATION: LockettePro
 | 
			
		||||
    // -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
    // Whether a leader of a faction can remove a lockette sign in their faction, regardless of the actual owner
 | 
			
		||||
    public boolean locketteLeaderRemoveOverride = true;
 | 
			
		||||
 | 
			
		||||
    // -------------------------------------------- //
 | 
			
		||||
    // INTEGRATION: WorldGuard
 | 
			
		||||
    // -------------------------------------------- //
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,69 @@
 | 
			
		||||
package com.massivecraft.factions.integration.lockette;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.engine.ProtectCase;
 | 
			
		||||
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.factions.entity.MPlayer;
 | 
			
		||||
import com.massivecraft.massivecore.Engine;
 | 
			
		||||
import com.massivecraft.massivecore.ps.PS;
 | 
			
		||||
import org.bukkit.block.Sign;
 | 
			
		||||
import org.bukkit.event.EventHandler;
 | 
			
		||||
import org.bukkit.event.EventPriority;
 | 
			
		||||
import org.bukkit.event.block.BlockBreakEvent;
 | 
			
		||||
 | 
			
		||||
public class EngineLockette extends Engine {
 | 
			
		||||
 | 
			
		||||
    // -------------------------------------------- //
 | 
			
		||||
    // INSTANCE & CONSTRUCT
 | 
			
		||||
    // -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
    private static EngineLockette i = new EngineLockette();
 | 
			
		||||
 | 
			
		||||
    public static EngineLockette get() {
 | 
			
		||||
        return i;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @EventHandler(priority = EventPriority.HIGHEST)
 | 
			
		||||
    public void onLocketteBreak(BlockBreakEvent event) {
 | 
			
		||||
        if (!event.isCancelled() || !(event.getBlock().getState() instanceof Sign)) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // If disabled, do nothing
 | 
			
		||||
        if (!MConf.get().locketteLeaderRemoveOverride) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Check if we are dealing with a protection sign
 | 
			
		||||
        String firstLine = ((Sign) event.getBlock().getState()).getLine(0);
 | 
			
		||||
        if (firstLine.contains("#")) {
 | 
			
		||||
            firstLine = firstLine.split("#", 2)[0];
 | 
			
		||||
        }
 | 
			
		||||
        if (!firstLine.equalsIgnoreCase("[Private]")) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // If in wilderness, don't allow any overrides
 | 
			
		||||
        PS ps = PS.valueOf(event.getBlock());
 | 
			
		||||
        Faction hostFaction = BoardColl.get().getFactionAt(ps);
 | 
			
		||||
        if (hostFaction.isNone()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        MPlayer player = MPlayer.get(event.getPlayer());
 | 
			
		||||
        MPerm perm = ProtectCase.BUILD.getPerm(event.getBlock());
 | 
			
		||||
 | 
			
		||||
        // Only allow if the player is the leader of the faction the sign is in
 | 
			
		||||
        if (player.getFaction() != hostFaction || !player.getRank().isLeader()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Require build permissions to remove the lockette sign
 | 
			
		||||
        if (perm != null && perm.has(player, ps, false)) {
 | 
			
		||||
            event.setCancelled(false);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,30 @@
 | 
			
		||||
package com.massivecraft.factions.integration.lockette;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.massivecore.Engine;
 | 
			
		||||
import com.massivecraft.massivecore.Integration;
 | 
			
		||||
 | 
			
		||||
public class IntegrationLockette extends Integration {
 | 
			
		||||
    // -------------------------------------------- //
 | 
			
		||||
    // INSTANCE & CONSTRUCT
 | 
			
		||||
    // -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
    private static IntegrationLockette i = new IntegrationLockette();
 | 
			
		||||
 | 
			
		||||
    public static IntegrationLockette get() {
 | 
			
		||||
        return i;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private IntegrationLockette() {
 | 
			
		||||
        this.setPluginName("LockettePro");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // -------------------------------------------- //
 | 
			
		||||
    // OVERRIDE
 | 
			
		||||
    // -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Engine getEngine() {
 | 
			
		||||
        return EngineLockette.get();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user