Skip to content

Commit

Permalink
feat: re-add CrashClaim support
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Oct 19, 2024
1 parent 95eb066 commit 6593e4d
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 1 deletion.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ repositories {
mavenCentral()
//mavenLocal()
maven("https://repo.codemc.org/repository/maven-public/")
maven("https://repo.oraxen.com/releases")
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://ci.ender.zone/plugin/repository/everything/")
maven("https://repo.glaremasters.me/repository/towny/")
Expand Down Expand Up @@ -43,6 +44,7 @@ dependencies {
compileOnly("net.william278.huskclaims:huskclaims-bukkit:1.4")
compileOnly("net.william278.husktowns:husktowns-bukkit:3.0.4")
compileOnly(files("libs/Residence5.1.6.2.jar"))
compileOnly("net.crashcraft:CrashClaim:1.0.43")
}

java {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pluginVersion=1.6.1
pluginVersion=1.6.2
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 @@ -42,6 +42,11 @@ public static void init(JavaPlugin plugin) {
} catch (Exception | NoClassDefFoundError e) {
if (debug) e.printStackTrace();
}
try {
handleCompatibility("CrashClaim", plugin, (m, p) -> new CrashClaimCompat(m, p));
} catch (Exception | NoClassDefFoundError e) {
if (debug) e.printStackTrace();
}
try {
handleCompatibility("GriefPrevention", plugin, (m, p) -> new GriefPreventionCompat(m, p));
} catch (Exception | NoClassDefFoundError e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package io.th0rgal.protectionlib.compatibilities;

import io.th0rgal.protectionlib.ProtectionCompatibility;
import net.crashcraft.crashclaim.CrashClaim;
import net.crashcraft.crashclaim.api.CrashClaimAPI;
import net.crashcraft.crashclaim.permissions.PermissionRoute;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;

public class CrashClaimCompat extends ProtectionCompatibility {
private static CrashClaimAPI crashClaim;

public CrashClaimCompat(JavaPlugin mainPlugin, Plugin plugin) {
super(mainPlugin, plugin);
crashClaim = new CrashClaimAPI((CrashClaim) plugin);
}

/**
* @param player Player looking to place a block
* @param target Place where the player seeks to place a block
* @return true if he can put the block
*/
@Override
public boolean canBuild(Player player, Location target) {
return crashClaim.getClaim(target) == null ||
crashClaim.getPermissionHelper().getBypassManager().isBypass(player.getUniqueId()) ||
crashClaim.getClaim(target).hasPermission(player.getUniqueId(), target, PermissionRoute.BUILD);
}

/**
* @param player Player looking to break a block
* @param target Place where the player seeks to break a block
* @return true if he can break the block
*/
@Override
public boolean canBreak(Player player, Location target) {
return crashClaim.getClaim(target) == null ||
crashClaim.getPermissionHelper().getBypassManager().isBypass(player.getUniqueId()) ||
crashClaim.getClaim(target).hasPermission(player.getUniqueId(), target, PermissionRoute.BUILD);
}

/**
* @param player Player looking to interact with a block
* @param target Place where the player seeks to interact with a block
* @return true if he can interact with the block
*/
@Override
public boolean canInteract(Player player, Location target) {
return crashClaim.getClaim(target) == null ||
crashClaim.getPermissionHelper().getBypassManager().isBypass(player.getUniqueId()) ||
crashClaim.getClaim(target).hasPermission(player.getUniqueId(), target, PermissionRoute.INTERACTIONS);
}

/**
* @param player Player looking to use an item
* @param target Place where the player seeks to use an item at a location
* @return true if he can use the item at the location
*/
public boolean canUse(Player player, Location target) {
return crashClaim.getClaim(target) == null ||
crashClaim.getPermissionHelper().getBypassManager().isBypass(player.getUniqueId()) ||
crashClaim.getClaim(target).hasPermission(player.getUniqueId(), target, PermissionRoute.INTERACTIONS);
}
}

0 comments on commit 6593e4d

Please sign in to comment.