!permission condition for droptables

This commit is contained in:
ASangarin 2020-11-03 22:40:53 +01:00
parent abd789a755
commit c8ef767134
2 changed files with 28 additions and 1 deletions

View File

@ -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;
}
}

View File

@ -1,6 +1,5 @@
package net.Indyuce.mmocore.api.load; package net.Indyuce.mmocore.api.load;
import net.Indyuce.mmocore.api.droptable.condition.LevelCondition;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import net.Indyuce.mmocore.api.block.BlockType; 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.block.VanillaBlockType;
import net.Indyuce.mmocore.api.droptable.condition.BiomeCondition; import net.Indyuce.mmocore.api.droptable.condition.BiomeCondition;
import net.Indyuce.mmocore.api.droptable.condition.Condition; 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.condition.WorldCondition;
import net.Indyuce.mmocore.api.droptable.dropitem.DropItem; import net.Indyuce.mmocore.api.droptable.dropitem.DropItem;
import net.Indyuce.mmocore.api.droptable.dropitem.DropTableDropItem; import net.Indyuce.mmocore.api.droptable.dropitem.DropTableDropItem;
@ -121,6 +122,9 @@ public class DefaultMMOLoader extends MMOLoader {
if (config.getKey().equals("level")) if (config.getKey().equals("level"))
return new LevelCondition(config); return new LevelCondition(config);
if (config.getKey().equals("permission"))
return new PermissionCondition(config);
return null; return null;
} }