add biome condition

usage:
- 'biome{name=SWAMP}'
This commit is contained in:
Blackdigits 2020-02-05 23:44:37 +07:00
parent 52f0a906bb
commit a438c3978c
2 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,24 @@
package net.Indyuce.mmocore.api.droptable.condition;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import org.bukkit.block.Biome;
import java.util.Arrays;
import java.util.List;
public class BiomeCondition extends Condition {
private final List<String> names;
public BiomeCondition(MMOLineConfig config) {
super(config);
config.validate("name");
names = Arrays.asList(config.getString("name").split("\\,"));
}
@Override
public boolean isMet(ConditionInstance entity) {
Biome currentBiome = entity.getEntity().getLocation().getBlock().getBiome();
return names.contains(currentBiome.name());
}
}

View File

@ -1,5 +1,6 @@
package net.Indyuce.mmocore.api.load;
import net.Indyuce.mmocore.api.droptable.condition.BiomeCondition;
import org.bukkit.configuration.ConfigurationSection;
import net.Indyuce.mmocore.api.droptable.condition.Condition;
@ -105,6 +106,9 @@ public class DefaultMMOLoader implements MMOLoader {
if (config.getKey().equals("world"))
return new WorldCondition(config);
if (config.getKey().equals("biome"))
return new BiomeCondition(config);
return null;
}