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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user