mirror of
https://github.com/songoda/SongodaCore.git
synced 2025-02-18 20:41:32 +01:00
Added Towny protection, and fixed UltimateClaims and Lands NPEs.
This commit is contained in:
parent
32dfc01a2a
commit
1873b2f647
@ -360,6 +360,13 @@
|
|||||||
<groupId>com.songoda</groupId>
|
<groupId>com.songoda</groupId>
|
||||||
<artifactId>UltimateClaims</artifactId>
|
<artifactId>UltimateClaims</artifactId>
|
||||||
<version>1.3.2</version>
|
<version>1.3.2</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.palmergames</groupId>
|
||||||
|
<artifactId>Towny</artifactId>
|
||||||
|
<version>0.96.5.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- End Plugin Hooks -->
|
<!-- End Plugin Hooks -->
|
||||||
|
@ -44,6 +44,7 @@ public final class PluginHook<T extends Class> {
|
|||||||
public static final PluginHook PROTECTION_LANDS = new PluginHook(Protection.class, "Lands", LandsProtection.class);
|
public static final PluginHook PROTECTION_LANDS = new PluginHook(Protection.class, "Lands", LandsProtection.class);
|
||||||
public static final PluginHook PROTECTION_REDPROTECT = new PluginHook(Protection.class, "RedProtect", RedProtectProtection.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_ULTIMATECLAIMS = new PluginHook(Protection.class, "UltimateClaims", UltimateClaimsProtection.class);
|
||||||
|
public static final PluginHook PROTECTION_TOWNY = new PluginHook(Protection.class, "Towny", TownyProtection.class);
|
||||||
|
|
||||||
/******* Start Manager stuff *******/
|
/******* Start Manager stuff *******/
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.songoda.core.hooks.protection;
|
package com.songoda.core.hooks.protection;
|
||||||
|
|
||||||
import me.angeschossen.lands.api.integration.LandsIntegration;
|
import me.angeschossen.lands.api.integration.LandsIntegration;
|
||||||
|
import me.angeschossen.lands.api.land.Area;
|
||||||
import me.angeschossen.lands.api.role.enums.RoleSetting;
|
import me.angeschossen.lands.api.role.enums.RoleSetting;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -17,17 +18,26 @@ public class LandsProtection extends Protection {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlace(Player player, Location location) {
|
public boolean canPlace(Player player, Location location) {
|
||||||
return landsIntegration.getAreaByLoc(location).canSetting(player, RoleSetting.BLOCK_PLACE, false);
|
return hasPerms(player, location, RoleSetting.BLOCK_PLACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBreak(Player player, Location location) {
|
public boolean canBreak(Player player, Location location) {
|
||||||
return landsIntegration.getAreaByLoc(location).canSetting(player, RoleSetting.BLOCK_BREAK, false);
|
return hasPerms(player, location, RoleSetting.BLOCK_BREAK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteract(Player player, Location location) {
|
public boolean canInteract(Player player, Location location) {
|
||||||
return landsIntegration.getAreaByLoc(location).canSetting(player, RoleSetting.INTERACT_CONTAINER, false);
|
return hasPerms(player, location, RoleSetting.INTERACT_CONTAINER);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasPerms(Player player, Location location, RoleSetting roleSetting) {
|
||||||
|
Area area = landsIntegration.getAreaByLoc(location);
|
||||||
|
if (area == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return area.canSetting(player, roleSetting, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.songoda.core.hooks.protection;
|
||||||
|
|
||||||
|
import com.palmergames.bukkit.towny.object.TownyPermission;
|
||||||
|
import com.palmergames.bukkit.towny.utils.PlayerCacheUtil;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class TownyProtection extends Protection {
|
||||||
|
public TownyProtection(Plugin plugin) {
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPlace(Player player, Location location) {
|
||||||
|
return PlayerCacheUtil.getCachePermission(player, location, location.getBlock().getType(), TownyPermission.ActionType.BUILD);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBreak(Player player, Location location) {
|
||||||
|
return PlayerCacheUtil.getCachePermission(player, location, location.getBlock().getType(), TownyPermission.ActionType.DESTROY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canInteract(Player player, Location location) {
|
||||||
|
return PlayerCacheUtil.getCachePermission(player, location, location.getBlock().getType(), TownyPermission.ActionType.ITEM_USE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Towny";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.songoda.core.hooks.protection;
|
package com.songoda.core.hooks.protection;
|
||||||
|
|
||||||
import com.songoda.ultimateclaims.UltimateClaims;
|
import com.songoda.ultimateclaims.UltimateClaims;
|
||||||
|
import com.songoda.ultimateclaims.claim.Claim;
|
||||||
import com.songoda.ultimateclaims.member.ClaimPerm;
|
import com.songoda.ultimateclaims.member.ClaimPerm;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -17,17 +18,26 @@ public class UltimateClaimsProtection extends Protection {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlace(Player player, Location location) {
|
public boolean canPlace(Player player, Location location) {
|
||||||
return instance.getClaimManager().getClaim(location.getChunk()).playerHasPerms(player, ClaimPerm.PLACE);
|
return hasPerms(player, location, ClaimPerm.PLACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBreak(Player player, Location location) {
|
public boolean canBreak(Player player, Location location) {
|
||||||
return instance.getClaimManager().getClaim(location.getChunk()).playerHasPerms(player, ClaimPerm.BREAK);
|
return hasPerms(player, location, ClaimPerm.BREAK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteract(Player player, Location location) {
|
public boolean canInteract(Player player, Location location) {
|
||||||
return instance.getClaimManager().getClaim(location.getChunk()).playerHasPerms(player, ClaimPerm.INTERACT);
|
return hasPerms(player, location, ClaimPerm.INTERACT);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasPerms(Player player, Location location, ClaimPerm claimPerm) {
|
||||||
|
Claim claim = instance.getClaimManager().getClaim(location.getChunk());
|
||||||
|
if (claim == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return claim.playerHasPerms(player, claimPerm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user