Added Residence support.

This commit is contained in:
Fernando Pettinelli 2021-08-29 17:44:17 -04:00
parent de8bf59168
commit a601b86d68
3 changed files with 65 additions and 0 deletions

View File

@ -352,6 +352,13 @@
<version>1.15.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.Zrips</groupId>
<artifactId>Residence</artifactId>
<version>4.9.0.6</version>
<scope>provided</scope>
</dependency>
<!-- End Plugin Hooks -->
<dependency>

View File

@ -15,6 +15,7 @@ import com.songoda.core.hooks.protection.GriefPreventionProtection;
import com.songoda.core.hooks.protection.LandsProtection;
import com.songoda.core.hooks.protection.Protection;
import com.songoda.core.hooks.protection.RedProtectProtection;
import com.songoda.core.hooks.protection.ResidenceProtection;
import com.songoda.core.hooks.protection.UltimateClaimsProtection;
import com.songoda.core.hooks.stackers.StackMob;
import com.songoda.core.hooks.stackers.Stacker;
@ -50,6 +51,7 @@ public final class PluginHook<T extends Class> {
public static final PluginHook PROTECTION_REDPROTECT = new PluginHook(Protection.class, "RedProtect", RedProtectProtection.class);
public static final PluginHook PROTECTION_ULTIMATECLAIMS = new PluginHook(Protection.class, "UltimateClaims", UltimateClaimsProtection.class);
public static final PluginHook PROTECTION_BENTOBOX = new PluginHook(Protection.class, "BentoBox", BentoBoxProtection.class);
public static final PluginHook PROTECTION_RESIDENCE = new PluginHook(Protection.class, "Residence", ResidenceProtection.class);
/******* Start Manager stuff *******/

View File

@ -0,0 +1,56 @@
package com.songoda.core.hooks.protection;
import com.bekvon.bukkit.residence.Residence;
import com.bekvon.bukkit.residence.containers.Flags;
import com.bekvon.bukkit.residence.containers.ResidencePlayer;
import com.bekvon.bukkit.residence.protection.FlagPermissions;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class ResidenceProtection extends Protection {
private final Residence instance;
public ResidenceProtection(Plugin plugin) {
super(plugin);
this.instance = Residence.getInstance();
}
@Override
public boolean canPlace(Player player, Location location) {
ResidencePlayer rPlayer = Residence.getInstance().getPlayerManager().getResidencePlayer(player);
return rPlayer.canPlaceBlock(location.getBlock(), false);
}
@Override
public boolean canBreak(Player player, Location location) {
ResidencePlayer rPlayer = Residence.getInstance().getPlayerManager().getResidencePlayer(player);
return rPlayer.canBreakBlock(location.getBlock(), false);
}
@Override
public boolean canInteract(Player player, Location location) {
return hasPerms(player, location, Flags.use);
}
private boolean hasPerms(Player player, Location location, Flags flag) {
if (instance.isDisabledWorldListener(location.getWorld()))
return true;
if (instance.isResAdminOn(player))
return true;
FlagPermissions perms = instance.getPermsByLocForPlayer(location, player);
return perms.playerHas(player, flag, true);
}
@Override
public String getName() {
return "Residence";
}
@Override
public boolean isEnabled() {
return instance != null;
}
}