Update for latest SpoutAPI

This commit is contained in:
zml2008 2012-05-10 18:27:50 -07:00
parent 15977e85a5
commit 3c00535d2e
5 changed files with 14 additions and 14 deletions

View File

@ -18,15 +18,15 @@
package com.sk89q.worldedit.spout; package com.sk89q.worldedit.spout;
import org.spout.api.generator.biome.BiomeType; import org.spout.api.generator.biome.Biome;
/** /**
* @author zml2008 * @author zml2008
*/ */
public class SpoutBiomeType implements com.sk89q.worldedit.BiomeType { public class SpoutBiomeType implements com.sk89q.worldedit.BiomeType {
private final BiomeType type; private final Biome type;
public SpoutBiomeType(BiomeType type) { public SpoutBiomeType(Biome type) {
this.type = type; this.type = type;
} }
@ -35,7 +35,7 @@ public class SpoutBiomeType implements com.sk89q.worldedit.BiomeType {
return type.getName().toLowerCase().replace(" ", ""); return type.getName().toLowerCase().replace(" ", "");
} }
public BiomeType getSpoutBiome() { public Biome getSpoutBiome() {
return type; return type;
} }

View File

@ -26,7 +26,7 @@ import java.util.Map;
import com.sk89q.worldedit.BiomeTypes; import com.sk89q.worldedit.BiomeTypes;
import com.sk89q.worldedit.UnknownBiomeTypeException; import com.sk89q.worldedit.UnknownBiomeTypeException;
import org.spout.api.generator.biome.BiomeGenerator; import org.spout.api.generator.biome.BiomeGenerator;
import org.spout.api.generator.biome.BiomeType; import org.spout.api.generator.biome.Biome;
public class SpoutBiomeTypes implements BiomeTypes { public class SpoutBiomeTypes implements BiomeTypes {
private final Map<String, SpoutBiomeType> types = new HashMap<String, SpoutBiomeType>(); private final Map<String, SpoutBiomeType> types = new HashMap<String, SpoutBiomeType>();
@ -46,7 +46,7 @@ public class SpoutBiomeTypes implements BiomeTypes {
} }
public void registerBiomeTypes(BiomeGenerator generator) { public void registerBiomeTypes(BiomeGenerator generator) {
for (BiomeType type : generator.getBiomes()) { for (Biome type : generator.getBiomes()) {
final SpoutBiomeType weType = new SpoutBiomeType(type); final SpoutBiomeType weType = new SpoutBiomeType(type);
if (!types.containsKey(weType.getName())) { if (!types.containsKey(weType.getName())) {
types.put(weType.getName(), weType); types.put(weType.getName(), weType);

View File

@ -207,8 +207,8 @@ public class SpoutPlayerBlockBag extends BlockBag {
public void flushChanges() { public void flushChanges() {
if (items != null) { if (items != null) {
Inventory inv = player.getEntity().getInventory(); Inventory inv = player.getEntity().getInventory();
for (int i = 0; i < items.length && i < player.getEntity().getInventorySize(); ++i) { for (int i = 0; i < items.length && i < inv.getSize(); ++i) {
inv.setItem(items[i], i); inv.setItem(i, items[i]);
} }
items = null; items = null;
} }

View File

@ -93,8 +93,8 @@ public class SpoutServerInterface extends ServerInterface {
public void onCommandRegistration(List<Command> commands, CommandsManager<LocalPlayer> manager) { public void onCommandRegistration(List<Command> commands, CommandsManager<LocalPlayer> manager) {
for (Command command : commands) { for (Command command : commands) {
org.spout.api.command.Command spoutCommand = game.getRootCommand().addSubCommand(plugin, command.aliases()[0]) org.spout.api.command.Command spoutCommand = game.getRootCommand().addSubCommand(plugin, command.aliases()[0])
.addAlias(command.aliases()).setRawExecutor(executor). .addAlias(command.aliases()).setRawExecutor(executor)
setUsage(command.usage()).setHelp(command.desc()); .setHelp("/" + command.aliases()[0] + " " + command.usage() + " - " + command.desc());
Method cmdMethod = manager.getMethods().get(null).get(command.aliases()[0]); Method cmdMethod = manager.getMethods().get(null).get(command.aliases()[0]);
if (cmdMethod != null && cmdMethod.isAnnotationPresent(CommandPermissions.class)) { if (cmdMethod != null && cmdMethod.isAnnotationPresent(CommandPermissions.class)) {
spoutCommand.setPermissions(false, cmdMethod.getAnnotation(CommandPermissions.class).value()); spoutCommand.setPermissions(false, cmdMethod.getAnnotation(CommandPermissions.class).value());

View File

@ -94,7 +94,7 @@ public class SpoutWorld extends LocalWorld {
public boolean setBlockType(Vector pt, int type) { public boolean setBlockType(Vector pt, int type) {
Material mat = MaterialRegistry.get((short) type); Material mat = MaterialRegistry.get((short) type);
if (mat != null && mat instanceof BlockMaterial) { if (mat != null && mat instanceof BlockMaterial) {
return world.setBlockMaterial(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ(), (BlockMaterial) mat, (short)0, true, WorldEditPlugin.getInstance()); return world.setBlockMaterial(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ(), (BlockMaterial) mat, (short)0, WorldEditPlugin.getInstance());
} }
return false; return false;
} }
@ -122,7 +122,7 @@ public class SpoutWorld extends LocalWorld {
public boolean setTypeIdAndData(Vector pt, int type, int data) { public boolean setTypeIdAndData(Vector pt, int type, int data) {
Material mat = MaterialRegistry.get((short) type); Material mat = MaterialRegistry.get((short) type);
if (mat != null && mat instanceof BlockMaterial) { if (mat != null && mat instanceof BlockMaterial) {
return world.setBlockMaterial(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ(), (BlockMaterial) mat, (short)data, true, WorldEditPlugin.getInstance()); return world.setBlockMaterial(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ(), (BlockMaterial) mat, (short)data, WorldEditPlugin.getInstance());
} }
return false; return false;
} }
@ -159,7 +159,7 @@ public class SpoutWorld extends LocalWorld {
*/ */
@Override @Override
public void setBlockData(Vector pt, int data) { public void setBlockData(Vector pt, int data) {
world.setBlockData(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ(), (short) data, true, WorldEditPlugin.getInstance()); world.setBlockData(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ(), (short) data, WorldEditPlugin.getInstance());
} }
/** /**
@ -210,7 +210,7 @@ public class SpoutWorld extends LocalWorld {
} }
public void setBiome(Vector2D pt, BiomeType biome) { public void setBiome(Vector2D pt, BiomeType biome) {
if (biome instanceof SpoutBiomeType && if (biome instanceof SpoutBiomeType &&
world.getGenerator() instanceof BiomeGenerator) { world.getGenerator() instanceof BiomeGenerator) {
BiomeGenerator gen = (BiomeGenerator) world.getGenerator(); BiomeGenerator gen = (BiomeGenerator) world.getGenerator();
gen.setBiome(new Vector3(pt.getBlockX(), 0, pt.getBlockZ()), ((SpoutBiomeType) biome).getSpoutBiome()); gen.setBiome(new Vector3(pt.getBlockX(), 0, pt.getBlockZ()), ((SpoutBiomeType) biome).getSpoutBiome());