mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-12-28 05:37:44 +01:00
add biome condition
usage: - 'biome{name=SWAMP}'
This commit is contained in:
parent
52f0a906bb
commit
a438c3978c
@ -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());
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user