diff --git a/src/main/java/com/b1n_ry/yigd/compat/InvModCompat.java b/src/main/java/com/b1n_ry/yigd/compat/InvModCompat.java index 0ba1eb1..3a3b598 100644 --- a/src/main/java/com/b1n_ry/yigd/compat/InvModCompat.java +++ b/src/main/java/com/b1n_ry/yigd/compat/InvModCompat.java @@ -45,7 +45,7 @@ else if (compatConfig.enableBeansBackpacksCompat) invCompatMods.add(new BeansBackpacksCompat()); } - if (loader.isModLoaded("common-protection-api")) + if (compatConfig.enableClaimApiCompat && loader.isModLoaded("common-protection-api")) CommonProtectionApiCompat.init(); if (loader.isModLoaded("orpheus")) OrpheusCompat.init(); diff --git a/src/main/java/com/b1n_ry/yigd/compat/misc_compat_mods/CommonProtectionApiCompat.java b/src/main/java/com/b1n_ry/yigd/compat/misc_compat_mods/CommonProtectionApiCompat.java index 02b9104..684f719 100644 --- a/src/main/java/com/b1n_ry/yigd/compat/misc_compat_mods/CommonProtectionApiCompat.java +++ b/src/main/java/com/b1n_ry/yigd/compat/misc_compat_mods/CommonProtectionApiCompat.java @@ -11,23 +11,31 @@ public class CommonProtectionApiCompat { public static void init() { - AllowBlockUnderGraveGenerationEvent.EVENT.register((grave, currentUnder) -> - YigdConfig.getConfig().graveConfig.blockUnderGrave.generateOnProtectedLand || !ProtectionImpl.isProtected(grave.getWorld(), grave.getPos().down())); + AllowBlockUnderGraveGenerationEvent.EVENT.register((grave, currentUnder) -> { + if (ProtectionImpl.canPlaceBlock(grave.getWorld(), grave.getPos().down(), grave.getOwner(), null)) { + return YigdConfig.getConfig().graveConfig.blockUnderGrave.generateInOwnClaim; + } else { + return YigdConfig.getConfig().graveConfig.blockUnderGrave.generateOnProtectedLand; + } + }); AllowGraveGenerationEvent.EVENT.register((context, grave) -> { - if (ProtectionImpl.isProtected(context.world(), grave.getPos())) + if (ProtectionImpl.canPlaceBlock(context.world(), grave.getPos(), grave.getOwner(), context.player())) { + return YigdConfig.getConfig().compatConfig.standardDropRuleInOwnClaim == DropRule.PUT_IN_GRAVE; + } else { return YigdConfig.getConfig().compatConfig.standardDropRuleInClaim == DropRule.PUT_IN_GRAVE; - - return true; + } }); DropRuleEvent.EVENT.register((item, slot, context, modify) -> { if (context == null || !modify) return GraveOverrideAreas.INSTANCE.defaultDropRule; - if (ProtectionImpl.isProtected(context.world(), BlockPos.ofFloored(context.deathPos()))) + var player = context.player(); + if (ProtectionImpl.canPlaceBlock(context.world(), BlockPos.ofFloored(context.deathPos()), player.getGameProfile(), player)) { + return YigdConfig.getConfig().compatConfig.standardDropRuleInOwnClaim; + } else { return YigdConfig.getConfig().compatConfig.standardDropRuleInClaim; - - return GraveOverrideAreas.INSTANCE.defaultDropRule; + } }); } } diff --git a/src/main/java/com/b1n_ry/yigd/config/YigdConfig.java b/src/main/java/com/b1n_ry/yigd/config/YigdConfig.java index 69db968..e769254 100644 --- a/src/main/java/com/b1n_ry/yigd/config/YigdConfig.java +++ b/src/main/java/com/b1n_ry/yigd/config/YigdConfig.java @@ -272,14 +272,22 @@ public static class BlockUnderGrave { add(new MapEntry("minecraft:the_end", "minecraft:end_stone")); add(new MapEntry("misc", "minecraft:dirt")); }}; + @Comment("Defines whether the block under grave can be generated in claims where the player can NOT place blocks if the claim api compat is enabled.") public boolean generateOnProtectedLand = false; + @Comment("Defines whether the block under grave can be generated in claims where the player CAN place blocks if the claim api compat is enabled.") + public boolean generateInOwnClaim = true; } } public static class CompatConfig { - @Comment("While PUT_IN_GRAVE, other drop rules will be prioritized") + @Comment("Enables compatibility with Common Protection API (\"Claim API\"), if present") + public boolean enableClaimApiCompat = true; + @Comment("Defines the standard drop rule in claims where the player can NOT place blocks. While PUT_IN_GRAVE, other drop rules will be prioritized") + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + public DropRule standardDropRuleInClaim = DropRule.DROP; + @Comment("Defines the standard drop rule in claims where the player CAN place blocks. While PUT_IN_GRAVE, other drop rules will be prioritized") @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - public DropRule standardDropRuleInClaim = DropRule.PUT_IN_GRAVE; + public DropRule standardDropRuleInOwnClaim = DropRule.PUT_IN_GRAVE; public boolean enableAccessoriesCompat = true; @Comment("While PUT_IN_GRAVE, other drop rules will be prioritized")