9
0
mirror of https://gitlab.com/SamB440/rpgregions-2.git synced 2025-12-27 10:49:08 +00:00

Add permissions for region effects

This commit is contained in:
Sam
2020-04-14 11:08:09 +01:00
parent d5676d3a3d
commit c486b3cee4
2 changed files with 24 additions and 3 deletions

View File

@@ -21,7 +21,9 @@ public class PotionRegionEffect extends RegionEffect {
@Override
public void effect(Player player) {
player.addPotionEffect(potionEffect);
if (this.isIgnorePerm() || player.hasPermission(this.getPermission())) {
player.addPotionEffect(potionEffect);
}
}
@Override

View File

@@ -6,13 +6,15 @@ import org.bukkit.inventory.ItemStack;
import java.util.List;
public abstract class RegionEffect {
private final boolean wearingRequired;
private final List<ItemStack> ignoreItems;
private final boolean ignorePerm;
public RegionEffect(boolean wearingRequired, List<ItemStack> ignoreItems) {
this.wearingRequired = wearingRequired;
this.ignoreItems = ignoreItems;
this.ignorePerm = true;
}
/**
@@ -39,12 +41,29 @@ public abstract class RegionEffect {
/**
* Whether the ItemStack is within #getIgnoreItems()
* @param item
* @param item the {@link ItemStack}
* @return true if item is ignored
*/
public boolean shouldIgnore(ItemStack item) {
return ignoreItems.contains(item);
}
/**
* Gets the permission for this effect to apply.
* @return permission the player requires
*/
public String getPermission() {
return "rpgregions.effect." + getName();
}
/**
* Whether the permission should be ignored or not.
* @return true if permission is ignored
*/
public boolean isIgnorePerm() {
return ignorePerm;
}
/**
* User friendly name of this effect.
* @return name of effect