mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Add biome support
Add a BiomeTypes interface Add methods in ServerInterface to retrieve the implemented BiomeTypes Add a getBiome method to LocalWorld and subclasses Add /biomeinfo & /biomelist commands Add a BiomeTypeMask Closes #181
This commit is contained in:
@ -0,0 +1,47 @@
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import com.sk89q.worldedit.BiomeType;
|
||||
import com.sk89q.worldedit.BiomeTypes;
|
||||
import com.sk89q.worldedit.UnknownBiomeTypeException;
|
||||
|
||||
public class BukkitBiomeTypes implements BiomeTypes {
|
||||
|
||||
public BukkitBiomeTypes() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String name) {
|
||||
try {
|
||||
Biome.valueOf(name.toUpperCase(Locale.ENGLISH));
|
||||
return true;
|
||||
} catch (IllegalArgumentException exc) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType get(String name) throws UnknownBiomeTypeException {
|
||||
try {
|
||||
Biome biome = Biome.valueOf(name.toUpperCase(Locale.ENGLISH));
|
||||
return new BiomeType(biome.name());
|
||||
} catch (IllegalArgumentException exc) {
|
||||
throw new UnknownBiomeTypeException(name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BiomeType> all() {
|
||||
List<BiomeType> biomes = new ArrayList<BiomeType>();
|
||||
for (Biome biome : Biome.values()) {
|
||||
biomes.add(new BiomeType(biome.name()));
|
||||
}
|
||||
return biomes;
|
||||
}
|
||||
|
||||
}
|
@ -36,6 +36,7 @@ import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import com.sk89q.worldedit.BiomeTypes;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
|
||||
@ -43,10 +44,12 @@ public class BukkitServerInterface extends ServerInterface {
|
||||
public Server server;
|
||||
public WorldEditPlugin plugin;
|
||||
private CommandRegistration dynamicCommands;
|
||||
private BukkitBiomeTypes biomes;
|
||||
|
||||
public BukkitServerInterface(WorldEditPlugin plugin, Server server) {
|
||||
this.plugin = plugin;
|
||||
this.server = server;
|
||||
this.biomes = new BukkitBiomeTypes();
|
||||
dynamicCommands = new CommandRegistration(plugin);
|
||||
}
|
||||
|
||||
@ -67,6 +70,11 @@ public class BukkitServerInterface extends ServerInterface {
|
||||
plugin.loadConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeTypes getBiomes() {
|
||||
return biomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int schedule(long delay, long period, Runnable task) {
|
||||
return Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, task, delay, period);
|
||||
|
@ -25,6 +25,7 @@ import java.util.Map;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Chest;
|
||||
@ -53,6 +54,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.sk89q.worldedit.BiomeType;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
@ -195,6 +197,17 @@ public class BukkitWorld extends LocalWorld {
|
||||
return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getLightLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get biome type
|
||||
*
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
public BiomeType getBiome(Vector2D pt) {
|
||||
Biome bukkitBiome = world.getBiome(pt.getBlockX(), pt.getBlockZ());
|
||||
return new BiomeType(bukkitBiome.name());
|
||||
}
|
||||
|
||||
/**
|
||||
* Regenerate an area.
|
||||
*
|
||||
|
Reference in New Issue
Block a user