Skip to content

Commit

Permalink
Merge pull request #39 from Ez4p1xEL/master
Browse files Browse the repository at this point in the history
Add support for NoBuildPlus
  • Loading branch information
Th0rgal authored Nov 21, 2024
2 parents 6593e4d + d571d0c commit 6465494
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dependencies {
implementation(files("libs/GriefPrevention-16.18.jar"))
compileOnly("net.william278.huskclaims:huskclaims-bukkit:1.4")
compileOnly("net.william278.husktowns:husktowns-bukkit:3.0.4")
compileOnly(files("libs/NoBuildPlus-1.4.6.jar"))
compileOnly(files("libs/Residence5.1.6.2.jar"))
compileOnly("net.crashcraft:CrashClaim:1.0.43")
}
Expand Down
Binary file added libs/NoBuildPlus-1.4.6.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions src/main/java/io/th0rgal/protectionlib/ProtectionLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ public static void init(JavaPlugin plugin) {
} catch (Exception | NoClassDefFoundError e) {
if (debug) e.printStackTrace();
}
try {
handleCompatibility("NoBuildPlus", plugin, (m, p) -> new NoBuildPlusCompat(m, p));
} catch (Exception | NoClassDefFoundError e) {
if (debug) e.printStackTrace();
}
}

public static void setDebug(boolean debug) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package io.th0rgal.protectionlib.compatibilities;

import io.th0rgal.protectionlib.ProtectionCompatibility;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import p1xel.nobuildplus.API.NBPAPI;
import p1xel.nobuildplus.Flags;
import p1xel.nobuildplus.NoBuildPlus;

public class NoBuildPlusCompat extends ProtectionCompatibility {

NoBuildPlus plugin = NoBuildPlus.getInstance();

NBPAPI api = plugin.getAPI();

public NoBuildPlusCompat(JavaPlugin mainPlugin, Plugin plugin) {
super(mainPlugin, plugin);
}

@Override
public boolean canBuild(Player player, Location target) {
return !api.canExecute(target.getWorld().getName(), Flags.build);
}

@Override
public boolean canBreak(Player player, Location target) {
return !api.canExecute(target.getWorld().getName(), Flags.destroy);
}

@Override
public boolean canInteract(Player player, Location target) {
return !api.canExecute(target.getWorld().getName(), Flags.use);
}

@Override
public boolean canUse(Player player, Location target) {
return !api.canExecute(target.getWorld().getName(), Flags.use);
}


}

0 comments on commit 6465494

Please sign in to comment.