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:
Kristian Knarvik 2023-04-05 15:17:55 +02:00
parent bdc9b35a9b
commit 0cd16fb5a6
5 changed files with 113 additions and 0 deletions

View File

@ -119,6 +119,11 @@
<artifactId>dynmap-api</artifactId> <artifactId>dynmap-api</artifactId>
<version>3.1-beta-2</version> <version>3.1-beta-2</version>
</dependency> </dependency>
<dependency>
<groupId>me.crafter.mc</groupId>
<artifactId>lockettepro</artifactId>
<version>2.10-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
<!-- Build --> <!-- Build -->

View File

@ -68,6 +68,7 @@ import com.massivecraft.factions.entity.migrator.MigratorMPlayer002UsingAdminMod
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.dynmap.IntegrationDynmap; 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.lwc.IntegrationLwc;
import com.massivecraft.factions.integration.placeholderapi.IntegrationPlaceholderAPI; import com.massivecraft.factions.integration.placeholderapi.IntegrationPlaceholderAPI;
import com.massivecraft.factions.integration.venturechat.IntegrationVentureChat; import com.massivecraft.factions.integration.venturechat.IntegrationVentureChat;
@ -205,6 +206,7 @@ public class Factions extends MassivePlugin {
IntegrationPlaceholderAPI.class, IntegrationPlaceholderAPI.class,
IntegrationVentureChat.class, IntegrationVentureChat.class,
IntegrationLwc.class, IntegrationLwc.class,
IntegrationLockette.class,
IntegrationWorldGuard.class, IntegrationWorldGuard.class,
IntegrationDynmap.class IntegrationDynmap.class
); );

View File

@ -651,6 +651,13 @@ public class MConf extends Entity<MConf> {
EventFactionsChunkChangeType.PILLAGE, false // when unclaiming (to wilderness) from another player faction 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 // INTEGRATION: WorldGuard
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -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);
}
}
}

View File

@ -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();
}
}