forked from Upstream/mmocore
!permission condition for droptables
This commit is contained in:
parent
abd789a755
commit
c8ef767134
@ -0,0 +1,23 @@
|
||||
package net.Indyuce.mmocore.api.droptable.condition;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.mmogroup.mmolib.api.MMOLineConfig;
|
||||
|
||||
public class PermissionCondition extends Condition {
|
||||
private final String perm;
|
||||
|
||||
public PermissionCondition(MMOLineConfig config) {
|
||||
super(config);
|
||||
|
||||
config.validate("node");
|
||||
perm = config.getString("node");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMet(ConditionInstance entity) {
|
||||
if (entity.getEntity() instanceof Player)
|
||||
return ((Player) entity).hasPermission(perm);
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package net.Indyuce.mmocore.api.load;
|
||||
|
||||
import net.Indyuce.mmocore.api.droptable.condition.LevelCondition;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import net.Indyuce.mmocore.api.block.BlockType;
|
||||
@ -8,6 +7,8 @@ import net.Indyuce.mmocore.api.block.SkullBlockType;
|
||||
import net.Indyuce.mmocore.api.block.VanillaBlockType;
|
||||
import net.Indyuce.mmocore.api.droptable.condition.BiomeCondition;
|
||||
import net.Indyuce.mmocore.api.droptable.condition.Condition;
|
||||
import net.Indyuce.mmocore.api.droptable.condition.LevelCondition;
|
||||
import net.Indyuce.mmocore.api.droptable.condition.PermissionCondition;
|
||||
import net.Indyuce.mmocore.api.droptable.condition.WorldCondition;
|
||||
import net.Indyuce.mmocore.api.droptable.dropitem.DropItem;
|
||||
import net.Indyuce.mmocore.api.droptable.dropitem.DropTableDropItem;
|
||||
@ -120,6 +121,9 @@ public class DefaultMMOLoader extends MMOLoader {
|
||||
|
||||
if (config.getKey().equals("level"))
|
||||
return new LevelCondition(config);
|
||||
|
||||
if (config.getKey().equals("permission"))
|
||||
return new PermissionCondition(config);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user