Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Micalhl committed Mar 23, 2024
1 parent d19b7db commit 8e1a049
Showing 1 changed file with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.momirealms.antigrieflib.comp.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
Expand Down Expand Up @@ -102,6 +103,40 @@ public boolean canInteract(Player player, Location location) {
return true;
}

/**
* Detects if a player has permission to interact with an entity
*
* @param player player
* @param entity entity
* @return has perm or not
*/
public boolean canInteractEntity(Player player, Entity entity) {
if (ignoreOP && player.isOp()) return true;
for (AntiGriefPlugin antiGriefPlugin : plugins) {
if (!antiGriefPlugin.canInteractEntity(player, entity)) {
return false;
}
}
return true;
}

/**
* Detects if a player has permission to damage an entity
*
* @param player player
* @param entity entity
* @return has perm or not
*/
public boolean canDamage(Player player, Entity entity) {
if (ignoreOP && player.isOp()) return true;
for (AntiGriefPlugin antiGriefPlugin : plugins) {
if (!antiGriefPlugin.canDamage(player, entity)) {
return false;
}
}
return true;
}

public static class Builder {

private final AntiGriefLib lib;
Expand Down Expand Up @@ -151,7 +186,7 @@ public AntiGriefLib build() {
}
}

private void registerNewCompatibility(AntiGriefPlugin antiGriefPlugin) {
public void registerNewCompatibility(AntiGriefPlugin antiGriefPlugin) {
this.plugins.add(antiGriefPlugin);
}

Expand Down

0 comments on commit 8e1a049

Please sign in to comment.