geforkt von Mirrors/FastAsyncWorldEdit
Added support for new tree types to TreeGenerator and make adding more tree types later easier
Dieser Commit ist enthalten in:
Ursprung
7f7178957a
Commit
b6d1146427
2
pom.xml
2
pom.xml
@ -49,7 +49,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.1-R6</version>
|
||||
<version>1.2.3-R0.3-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Archive reading library for snapshots -->
|
||||
|
@ -2787,7 +2787,7 @@ public class EditSession {
|
||||
*
|
||||
* @param region the region to hollow out.
|
||||
* @param thickness the thickness of the shell to leave (manhattan distance)
|
||||
* @param patternThe block pattern to use
|
||||
* @param pattern The block pattern to use
|
||||
*
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException
|
||||
|
@ -25,6 +25,7 @@ import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
|
||||
/**
|
||||
* Represents a world.
|
||||
@ -33,7 +34,7 @@ import com.sk89q.worldedit.regions.Region;
|
||||
*/
|
||||
public abstract class LocalWorld {
|
||||
/**
|
||||
* Named flags to use as parameters to {@link LocalWorld#killMobs(Vector, int, int)}
|
||||
* Named flags to use as parameters to {@link LocalWorld#killMobs(Vector, double, int)}
|
||||
*/
|
||||
public class KillFlags {
|
||||
public static final int PETS = 1 << 0;
|
||||
@ -185,9 +186,13 @@ public abstract class LocalWorld {
|
||||
* @param pt
|
||||
* @return
|
||||
* @throws MaxChangedBlocksException
|
||||
* @deprecated use {@link #generateTree(com.sk89q.worldedit.util.TreeGenerator.TreeType, EditSession, Vector)} instead
|
||||
*/
|
||||
public abstract boolean generateTree(EditSession editSession, Vector pt)
|
||||
throws MaxChangedBlocksException;
|
||||
@Deprecated
|
||||
public boolean generateTree(EditSession editSession, Vector pt)
|
||||
throws MaxChangedBlocksException {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a big tree at a location.
|
||||
@ -196,9 +201,13 @@ public abstract class LocalWorld {
|
||||
* @param pt
|
||||
* @return
|
||||
* @throws MaxChangedBlocksException
|
||||
* @deprecated use {@link #generateTree(com.sk89q.worldedit.util.TreeGenerator.TreeType, EditSession, Vector)} instead
|
||||
*/
|
||||
public abstract boolean generateBigTree(EditSession editSession, Vector pt)
|
||||
throws MaxChangedBlocksException;
|
||||
@Deprecated
|
||||
public boolean generateBigTree(EditSession editSession, Vector pt)
|
||||
throws MaxChangedBlocksException {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a birch tree at a location.
|
||||
@ -207,9 +216,13 @@ public abstract class LocalWorld {
|
||||
* @param pt
|
||||
* @return
|
||||
* @throws MaxChangedBlocksException
|
||||
* @deprecated use {@link #generateTree(com.sk89q.worldedit.util.TreeGenerator.TreeType, EditSession, Vector)} instead
|
||||
*/
|
||||
public abstract boolean generateBirchTree(EditSession editSession, Vector pt)
|
||||
throws MaxChangedBlocksException;
|
||||
@Deprecated
|
||||
public boolean generateBirchTree(EditSession editSession, Vector pt)
|
||||
throws MaxChangedBlocksException {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a redwood tree at a location.
|
||||
@ -218,9 +231,13 @@ public abstract class LocalWorld {
|
||||
* @param pt
|
||||
* @return
|
||||
* @throws MaxChangedBlocksException
|
||||
* @deprecated use {@link #generateTree(com.sk89q.worldedit.util.TreeGenerator.TreeType, EditSession, Vector)} instead
|
||||
*/
|
||||
public abstract boolean generateRedwoodTree(EditSession editSession, Vector pt)
|
||||
throws MaxChangedBlocksException;
|
||||
@Deprecated
|
||||
public boolean generateRedwoodTree(EditSession editSession, Vector pt)
|
||||
throws MaxChangedBlocksException {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a tall redwood tree at a location.
|
||||
@ -229,9 +246,38 @@ public abstract class LocalWorld {
|
||||
* @param pt
|
||||
* @return
|
||||
* @throws MaxChangedBlocksException
|
||||
* @deprecated use {@link #generateTree(com.sk89q.worldedit.util.TreeGenerator.TreeType, EditSession, Vector)} instead
|
||||
*/
|
||||
public abstract boolean generateTallRedwoodTree(EditSession editSession, Vector pt)
|
||||
throws MaxChangedBlocksException;
|
||||
@Deprecated
|
||||
public boolean generateTallRedwoodTree(EditSession editSession, Vector pt)
|
||||
throws MaxChangedBlocksException {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a tree
|
||||
* @param type The type of tree to generate
|
||||
* @param editSession The EditSession to pass block changes through
|
||||
* @param pt The point where the base of the tree should be located
|
||||
* @return Whether the tree generation was successful
|
||||
* @throws MaxChangedBlocksException if too many blocks were changed by the EditSession
|
||||
*/
|
||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector pt)
|
||||
throws MaxChangedBlocksException {
|
||||
switch (type) {
|
||||
case BIG_TREE:
|
||||
return generateBigTree(editSession, pt);
|
||||
case BIRCH:
|
||||
return generateBirchTree(editSession, pt);
|
||||
case REDWOOD:
|
||||
return generateRedwoodTree(editSession, pt);
|
||||
case TALL_REDWOOD:
|
||||
return generateTallRedwoodTree(editSession, pt);
|
||||
default:
|
||||
case TREE:
|
||||
return generateTree(editSession, pt);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop an item.
|
||||
@ -276,8 +322,7 @@ public abstract class LocalWorld {
|
||||
/**
|
||||
* Kill mobs in an area, excluding pet wolves.
|
||||
*
|
||||
* @param origin
|
||||
* @param radius
|
||||
* @param origin -1 for the whole world
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
@ -288,9 +333,9 @@ public abstract class LocalWorld {
|
||||
/**
|
||||
* Kill mobs in an area.
|
||||
*
|
||||
* @param origin
|
||||
* @param origin The center of the area to kill mobs in
|
||||
* @param radius -1 for all mobs
|
||||
* @param flags various flags that determine what to kill
|
||||
* @param killPets whether to kill pets
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
@ -303,7 +348,7 @@ public abstract class LocalWorld {
|
||||
*
|
||||
* @param origin
|
||||
* @param radius
|
||||
* @param killflags
|
||||
* @param flags
|
||||
* @return
|
||||
*/
|
||||
public int killMobs(Vector origin, double radius, int flags) {
|
||||
|
@ -19,9 +19,12 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Furnace;
|
||||
@ -395,9 +398,9 @@ public class BukkitWorld extends LocalWorld {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean generateTree(EditSession editSession, Vector pt) {
|
||||
return world.generateTree(BukkitUtil.toLocation(world, pt), TreeType.TREE,
|
||||
new EditSessionBlockChangeDelegate(editSession));
|
||||
return generateTree(TreeGenerator.TreeType.TREE, editSession, pt);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -407,9 +410,9 @@ public class BukkitWorld extends LocalWorld {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean generateBigTree(EditSession editSession, Vector pt) {
|
||||
return world.generateTree(BukkitUtil.toLocation(world, pt), TreeType.BIG_TREE,
|
||||
new EditSessionBlockChangeDelegate(editSession));
|
||||
return generateTree(TreeGenerator.TreeType.BIG_TREE, editSession, pt);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -419,9 +422,9 @@ public class BukkitWorld extends LocalWorld {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean generateBirchTree(EditSession editSession, Vector pt) {
|
||||
return world.generateTree(BukkitUtil.toLocation(world, pt), TreeType.BIRCH,
|
||||
new EditSessionBlockChangeDelegate(editSession));
|
||||
return generateTree(TreeGenerator.TreeType.BIRCH, editSession, pt);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -431,9 +434,9 @@ public class BukkitWorld extends LocalWorld {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean generateRedwoodTree(EditSession editSession, Vector pt) {
|
||||
return world.generateTree(BukkitUtil.toLocation(world, pt), TreeType.REDWOOD,
|
||||
new EditSessionBlockChangeDelegate(editSession));
|
||||
return generateTree(TreeGenerator.TreeType.REDWOOD, editSession, pt);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -443,8 +446,53 @@ public class BukkitWorld extends LocalWorld {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean generateTallRedwoodTree(EditSession editSession, Vector pt) {
|
||||
return world.generateTree(BukkitUtil.toLocation(world, pt), TreeType.TALL_REDWOOD,
|
||||
return generateTree(TreeGenerator.TreeType.TALL_REDWOOD, editSession, pt);
|
||||
}
|
||||
|
||||
/**
|
||||
* An EnumMap that stores which WorldEdit TreeTypes apply to which Bukkit TreeTypes
|
||||
*/
|
||||
private static final EnumMap<TreeGenerator.TreeType, TreeType> treeTypeMapping =
|
||||
new EnumMap<TreeGenerator.TreeType, TreeType>(TreeGenerator.TreeType.class);
|
||||
|
||||
static {
|
||||
// Mappings for new TreeType values not yet in Bukkit
|
||||
treeTypeMapping.put(TreeGenerator.TreeType.SWAMP, TreeType.TREE);
|
||||
treeTypeMapping.put(TreeGenerator.TreeType.JUNGLE_BUSH, TreeType.TREE);
|
||||
try {
|
||||
treeTypeMapping.put(TreeGenerator.TreeType.SHORT_JUNGLE, TreeType.valueOf("SMALL_JUNGLE"));
|
||||
} catch (IllegalArgumentException e) {
|
||||
treeTypeMapping.put(TreeGenerator.TreeType.SHORT_JUNGLE, TreeType.TREE);
|
||||
}
|
||||
for (TreeGenerator.TreeType type : TreeGenerator.TreeType.values()) {
|
||||
try {
|
||||
TreeType bukkitType = TreeType.valueOf(type.name());
|
||||
treeTypeMapping.put(type, bukkitType);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Unhandled TreeType
|
||||
}
|
||||
}
|
||||
// Other mappings for WE-specific values
|
||||
treeTypeMapping.put(TreeGenerator.TreeType.RANDOM, TreeType.BROWN_MUSHROOM);
|
||||
treeTypeMapping.put(TreeGenerator.TreeType.RANDOM_REDWOOD, TreeType.REDWOOD);
|
||||
treeTypeMapping.put(TreeGenerator.TreeType.PINE, TreeType.REDWOOD);
|
||||
for (TreeGenerator.TreeType type : TreeGenerator.TreeType.values()) {
|
||||
if (treeTypeMapping.get(type) == null) {
|
||||
WorldEdit.logger.severe("No TreeType mapping for TreeGenerator.TreeType." + type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static TreeType toBukkitTreeType(TreeGenerator.TreeType type) {
|
||||
return treeTypeMapping.get(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector pt) {
|
||||
TreeType bukkitType = toBukkitTreeType(type);
|
||||
return type != null && world.generateTree(BukkitUtil.toLocation(world, pt), bukkitType,
|
||||
new EditSessionBlockChangeDelegate(editSession));
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
@ -53,6 +54,14 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setTypeId(int x, int y, int z, int typeId) {
|
||||
return setRawTypeId(x, y, z, typeId);
|
||||
}
|
||||
|
||||
public boolean setTypeIdAndData(int x, int y, int z, int typeId, int data) {
|
||||
return setRawTypeIdAndData(x, y, z, typeId, data);
|
||||
}
|
||||
|
||||
public int getTypeId(int x, int y, int z) {
|
||||
return editSession.getBlockType(new Vector(x, y, z));
|
||||
}
|
||||
@ -60,4 +69,8 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
||||
public int getHeight() {
|
||||
return editSession.getWorld().getMaxY() + 1;
|
||||
}
|
||||
|
||||
public boolean isEmpty(int x, int y, int z) {
|
||||
return editSession.getBlockType(new Vector(x, y, z)) == BlockID.AIR;
|
||||
}
|
||||
}
|
||||
|
@ -23,11 +23,13 @@ import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.EntityType;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.material.MaterialData;
|
||||
|
||||
@ -365,69 +367,10 @@ public class SpoutWorld extends LocalWorld {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a tree at a location.
|
||||
*
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean generateTree(EditSession editSession, Vector pt) {
|
||||
/*return world.generateTree(SpoutUtil.toLocation(world, pt), TreeType.TREE,
|
||||
new EditSessionBlockChangeDelegate(editSession));*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a big tree at a location.
|
||||
*
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean generateBigTree(EditSession editSession, Vector pt) {
|
||||
/*return world.generateTree(SpoutUtil.toLocation(world, pt), TreeType.BIG_TREE,
|
||||
new EditSessionBlockChangeDelegate(editSession));*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a birch tree at a location.
|
||||
*
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean generateBirchTree(EditSession editSession, Vector pt) {
|
||||
/*return world.generateTree(SpoutUtil.toLocation(world, pt), TreeType.BIRCH,
|
||||
new EditSessionBlockChangeDelegate(editSession));*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a redwood tree at a location.
|
||||
*
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean generateRedwoodTree(EditSession editSession, Vector pt) {
|
||||
/*return world.generateTree(SpoutUtil.toLocation(world, pt), TreeType.REDWOOD,
|
||||
new EditSessionBlockChangeDelegate(editSession));*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a redwood tree at a location.
|
||||
*
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean generateTallRedwoodTree(EditSession editSession, Vector pt) {
|
||||
/*return world.generateTree(SpoutUtil.toLocation(world, pt), TreeType.TALL_REDWOOD,
|
||||
new EditSessionBlockChangeDelegate(editSession));*/
|
||||
return false;
|
||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector pt)
|
||||
throws MaxChangedBlocksException {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,14 +37,40 @@ import com.sk89q.worldedit.blocks.BlockID;
|
||||
*/
|
||||
public class TreeGenerator {
|
||||
public enum TreeType {
|
||||
TREE("Regular tree", new String[] { "tree", "regular" }),
|
||||
BIG_TREE("Big tree", new String[] { "big", "bigtree" }),
|
||||
REDWOOD("Redwood", new String[] { "redwood", "sequoia", "sequoioideae" }),
|
||||
TALL_REDWOOD("Tall redwood", new String[] { "tallredwood", "tallsequoia", "tallsequoioideae" }),
|
||||
BIRCH("Birch", new String[] { "birch", "white", "whitebark" }),
|
||||
PINE("Pine", new String[] { "pine" }),
|
||||
RANDOM_REDWOOD("Random redwood", new String[] { "randredwood", "randomredwood", "anyredwood" }),
|
||||
RANDOM("Random", new String[] { "rand", "random" });
|
||||
TREE("Regular tree", "tree", "regular"),
|
||||
BIG_TREE("Big tree", "big", "bigtree"),
|
||||
REDWOOD("Redwood", "redwood", "sequoia", "sequoioideae"),
|
||||
TALL_REDWOOD("Tall redwood", "tallredwood", "tallsequoia", "tallsequoioideae"),
|
||||
BIRCH("Birch", "birch", "white", "whitebark"),
|
||||
PINE("Pine", "pine") {
|
||||
public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException {
|
||||
makePineTree(editSession, pos);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
RANDOM_REDWOOD("Random redwood", "randredwood", "randomredwood", "anyredwood" ) {
|
||||
public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException {
|
||||
TreeType[] choices = new TreeType[] {
|
||||
TreeType.REDWOOD, TreeType.TALL_REDWOOD
|
||||
};
|
||||
return choices[rand.nextInt(choices.length)].generate(editSession, pos);
|
||||
}
|
||||
},
|
||||
JUNGLE("Jungle", "jungle"),
|
||||
SHORT_JUNGLE("Short jungle", "shortjungle", "smalljungle"),
|
||||
JUNGLE_BUSH("Jungle bush", "junglebush", "jungleshrub"),
|
||||
RED_MUSHROOM("Red Mushroom", "redmushroom", "redgiantmushroom"),
|
||||
BROWN_MUSHROOM("Brown Mushroom", "brownmushroom", "browngiantmushroom"),
|
||||
SWAMP("Swamp", "swamp", "swamptree"),
|
||||
RANDOM("Random", "rand", "random" ) {
|
||||
public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException {
|
||||
TreeType[] choices = new TreeType[] {
|
||||
TreeType.TREE, TreeType.BIG_TREE, TreeType.BIRCH,
|
||||
TreeType.REDWOOD, TreeType.TALL_REDWOOD, TreeType.PINE
|
||||
};
|
||||
return choices[rand.nextInt(choices.length)].generate(editSession, pos);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Stores a map of the names for fast access.
|
||||
@ -62,16 +88,15 @@ public class TreeGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
TreeType(String name, String lookupKey) {
|
||||
this.name = name;
|
||||
this.lookupKeys = new String[] { lookupKey };
|
||||
}
|
||||
|
||||
TreeType(String name, String[] lookupKeys) {
|
||||
TreeType(String name, String... lookupKeys) {
|
||||
this.name = name;
|
||||
this.lookupKeys = lookupKeys;
|
||||
}
|
||||
|
||||
public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException {
|
||||
return editSession.getWorld().generateTree(this, editSession, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user-friendly tree type name.
|
||||
*
|
||||
@ -101,6 +126,7 @@ public class TreeGenerator {
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
@Deprecated
|
||||
public TreeGenerator(TreeType type) {
|
||||
this.type = type;
|
||||
}
|
||||
@ -115,57 +141,23 @@ public class TreeGenerator {
|
||||
*/
|
||||
public boolean generate(EditSession editSession, Vector pos)
|
||||
throws MaxChangedBlocksException {
|
||||
return generate(type, editSession, pos);
|
||||
return type.generate(editSession, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a tree.
|
||||
*
|
||||
* @param world
|
||||
* @param type
|
||||
* @param editSession
|
||||
* @param pos
|
||||
* @return
|
||||
* @throws MaxChangedBlocksException
|
||||
* @deprecated use {@link TreeType#generate(com.sk89q.worldedit.EditSession, com.sk89q.worldedit.Vector)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
private boolean generate(TreeType type, EditSession editSession, Vector pos)
|
||||
throws MaxChangedBlocksException {
|
||||
LocalWorld world = editSession.getWorld();
|
||||
|
||||
TreeType[] choices;
|
||||
TreeType realType;
|
||||
|
||||
switch (type) {
|
||||
case TREE:
|
||||
return world.generateTree(editSession, pos);
|
||||
case BIG_TREE:
|
||||
return world.generateBigTree(editSession, pos);
|
||||
case BIRCH:
|
||||
return world.generateBirchTree(editSession, pos);
|
||||
case REDWOOD:
|
||||
return world.generateRedwoodTree(editSession, pos);
|
||||
case TALL_REDWOOD:
|
||||
return world.generateTallRedwoodTree(editSession, pos);
|
||||
case PINE:
|
||||
makePineTree(editSession, pos);
|
||||
return true;
|
||||
case RANDOM_REDWOOD:
|
||||
choices =
|
||||
new TreeType[] {
|
||||
TreeType.REDWOOD, TreeType.TALL_REDWOOD
|
||||
};
|
||||
realType = choices[rand.nextInt(choices.length)];
|
||||
return generate(realType, editSession, pos);
|
||||
case RANDOM:
|
||||
choices =
|
||||
new TreeType[] {
|
||||
TreeType.TREE, TreeType.BIG_TREE, TreeType.BIRCH,
|
||||
TreeType.REDWOOD, TreeType.TALL_REDWOOD, TreeType.PINE
|
||||
};
|
||||
realType = choices[rand.nextInt(choices.length)];
|
||||
return generate(realType, editSession, pos);
|
||||
}
|
||||
|
||||
return false;
|
||||
return type.generate(editSession, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
|
35
src/test/java/com/sk89q/worldedit/bukkit/BukkitWorldTest.java
Normale Datei
35
src/test/java/com/sk89q/worldedit/bukkit/BukkitWorldTest.java
Normale Datei
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class BukkitWorldTest {
|
||||
@Test
|
||||
public void testTreeTypeMapping() {
|
||||
for (TreeGenerator.TreeType type : TreeGenerator.TreeType.values()) {
|
||||
Assert.assertFalse("No mapping for: " + type, BukkitWorld.toBukkitTreeType(type) == null);
|
||||
}
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren