Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for NoBuildPlus #39

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,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"))
}

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 @@ -67,6 +67,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);
}


}