Update for recent SpoutAPI changes

Dieser Commit ist enthalten in:
zml2008 2012-03-23 21:37:59 -07:00
Ursprung 97c370549f
Commit 54eed713ab
14 geänderte Dateien mit 134 neuen und 53 gelöschten Zeilen

Datei anzeigen

@ -1,7 +1,6 @@
// $Id$
/* /*
* WorldEdit * WorldEdit
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors * Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,6 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// $Id$
package com.sk89q.worldedit.spout; package com.sk89q.worldedit.spout;
import com.sk89q.worldedit.SessionCheck; import com.sk89q.worldedit.SessionCheck;

Datei anzeigen

@ -1,3 +1,21 @@
/*
* WorldEdit
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
*
* 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.spout; package com.sk89q.worldedit.spout;
import org.spout.api.generator.biome.BiomeType; import org.spout.api.generator.biome.BiomeType;

Datei anzeigen

@ -1,3 +1,21 @@
/*
* WorldEdit
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
*
* 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.spout; package com.sk89q.worldedit.spout;
import java.util.ArrayList; import java.util.ArrayList;

Datei anzeigen

@ -1,7 +1,6 @@
// $Id$
/* /*
* WorldEdit * WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors * Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,6 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// $Id$
package com.sk89q.worldedit.spout; package com.sk89q.worldedit.spout;
import com.sk89q.worldedit.LocalPlayer; import com.sk89q.worldedit.LocalPlayer;

Datei anzeigen

@ -1,7 +1,6 @@
// $Id$
/* /*
* WorldEdit * WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors * Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,6 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// $Id$
package com.sk89q.worldedit.spout; package com.sk89q.worldedit.spout;
import com.sk89q.util.StringUtil; import com.sk89q.util.StringUtil;
@ -31,7 +33,8 @@ import com.sk89q.worldedit.cui.CUIEvent;
import org.spout.api.entity.Entity; import org.spout.api.entity.Entity;
import org.spout.api.geo.discrete.Point; import org.spout.api.geo.discrete.Point;
import org.spout.api.inventory.ItemStack; import org.spout.api.inventory.ItemStack;
import org.spout.api.material.MaterialData; import org.spout.api.material.MaterialRegistry;
import org.spout.api.material.source.MaterialData;
import org.spout.api.player.Player; import org.spout.api.player.Player;
public class SpoutPlayer extends LocalPlayer { public class SpoutPlayer extends LocalPlayer {
@ -75,7 +78,7 @@ public class SpoutPlayer extends LocalPlayer {
@Override @Override
public void giveItem(int type, int amt) { public void giveItem(int type, int amt) {
player.getEntity().getInventory().addItem(new ItemStack(MaterialData.getMaterial((short)type), amt)); player.getEntity().getInventory().addItem(new ItemStack(MaterialRegistry.get((short) type), amt));
} }
@Override @Override

Datei anzeigen

@ -1,7 +1,6 @@
// $Id$
/* /*
* WorldEdit * WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors * Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,6 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// $Id$
package com.sk89q.worldedit.spout; package com.sk89q.worldedit.spout;
import com.sk89q.worldedit.WorldVector; import com.sk89q.worldedit.WorldVector;
@ -30,7 +32,7 @@ import com.sk89q.worldedit.blocks.BlockID;
import org.spout.api.inventory.Inventory; import org.spout.api.inventory.Inventory;
import org.spout.api.inventory.ItemStack; import org.spout.api.inventory.ItemStack;
import org.spout.api.material.Material; import org.spout.api.material.Material;
import org.spout.api.material.MaterialData; import org.spout.api.material.MaterialRegistry;
import org.spout.api.player.Player; import org.spout.api.player.Player;
public class SpoutPlayerBlockBag extends BlockBag { public class SpoutPlayerBlockBag extends BlockBag {
@ -81,7 +83,10 @@ public class SpoutPlayerBlockBag extends BlockBag {
final short damage = item.getDamage(); final short damage = item.getDamage();
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1; int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
assert(amount == 1); assert(amount == 1);
final Material mat = MaterialData.getMaterial(id, damage); Material mat = MaterialRegistry.get(id);
if (mat.hasSubMaterials()) {
mat = mat.getSubMaterial(damage);
}
if (id == BlockID.AIR) { if (id == BlockID.AIR) {
throw new IllegalArgumentException("Can't fetch air block"); throw new IllegalArgumentException("Can't fetch air block");
@ -132,9 +137,12 @@ public class SpoutPlayerBlockBag extends BlockBag {
*/ */
@Override @Override
public void storeItem(BaseItem item) throws BlockBagException { public void storeItem(BaseItem item) throws BlockBagException {
final int id = item.getType(); final short id = (short) item.getType();
final short damage = item.getDamage(); final short damage = item.getDamage();
final Material mat = MaterialData.getMaterial((short) id, damage); Material mat = MaterialRegistry.get(id);
if (mat.hasSubMaterials()) {
mat = mat.getSubMaterial(damage);
}
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1; int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
assert(amount <= mat.getMaxStackSize()); assert(amount <= mat.getMaxStackSize());

Datei anzeigen

@ -1,7 +1,6 @@
// $Id$
/* /*
* WorldEdit * WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors * Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,6 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// $Id$
package com.sk89q.worldedit.spout; package com.sk89q.worldedit.spout;
import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.Command;
@ -29,7 +31,7 @@ import org.spout.api.Game;
import org.spout.api.Spout; import org.spout.api.Spout;
import org.spout.api.geo.World; import org.spout.api.geo.World;
import org.spout.api.material.Material; import org.spout.api.material.Material;
import org.spout.api.material.MaterialData; import org.spout.api.material.MaterialRegistry;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
@ -51,7 +53,7 @@ public class SpoutServerInterface extends ServerInterface {
@Override @Override
public int resolveItem(String name) { public int resolveItem(String name) {
Material mat = MaterialData.getMaterial(name); Material mat = MaterialRegistry.get(name);
return mat == null ? 0 : mat.getId(); return mat == null ? 0 : mat.getId();
} }

Datei anzeigen

@ -1,7 +1,6 @@
// $Id$
/* /*
* WorldEdit * WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors * Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,6 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// $Id$
package com.sk89q.worldedit.spout; package com.sk89q.worldedit.spout;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;

Datei anzeigen

@ -1,7 +1,6 @@
// $Id$
/* /*
* WorldEdit * WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors * Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,6 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// $Id$
package com.sk89q.worldedit.spout; package com.sk89q.worldedit.spout;
import com.sk89q.worldedit.BiomeType; import com.sk89q.worldedit.BiomeType;
@ -37,7 +39,9 @@ import org.spout.api.generator.biome.BiomeGenerator;
import org.spout.api.geo.World; import org.spout.api.geo.World;
import org.spout.api.geo.cuboid.Chunk; import org.spout.api.geo.cuboid.Chunk;
import org.spout.api.inventory.ItemStack; import org.spout.api.inventory.ItemStack;
import org.spout.api.material.MaterialData; import org.spout.api.material.BlockMaterial;
import org.spout.api.material.Material;
import org.spout.api.material.MaterialRegistry;
import org.spout.api.math.Vector3; import org.spout.api.math.Vector3;
import org.spout.vanilla.controller.object.Item; import org.spout.vanilla.controller.object.Item;
import org.spout.vanilla.controller.object.falling.PrimedTnt; import org.spout.vanilla.controller.object.falling.PrimedTnt;
@ -84,7 +88,11 @@ public class SpoutWorld extends LocalWorld {
*/ */
@Override @Override
public boolean setBlockType(Vector pt, int type) { public boolean setBlockType(Vector pt, int type) {
return world.setBlockId(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ(), (short) type, WorldEditPlugin.getInstance()); Material mat = MaterialRegistry.get((short) type);
if (mat != null && mat instanceof BlockMaterial) {
return world.setBlockMaterial(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ(), (BlockMaterial) mat, (short)0, true, WorldEditPlugin.getInstance());
}
return false;
} }
/** /**
@ -108,7 +116,11 @@ public class SpoutWorld extends LocalWorld {
*/ */
@Override @Override
public boolean setTypeIdAndData(Vector pt, int type, int data) { public boolean setTypeIdAndData(Vector pt, int type, int data) {
return world.setBlockIdAndData(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ(), (short) type, (short) data, WorldEditPlugin.getInstance()); Material mat = MaterialRegistry.get((short) type);
if (mat != null && mat instanceof BlockMaterial) {
return world.setBlockMaterial(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ(), (BlockMaterial) mat, (short)data, true, WorldEditPlugin.getInstance());
}
return false;
} }
/** /**
@ -132,7 +144,7 @@ public class SpoutWorld extends LocalWorld {
*/ */
@Override @Override
public int getBlockType(Vector pt) { public int getBlockType(Vector pt) {
return world.getBlockId(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); return world.getBlockMaterial(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getId();
} }
/** /**
@ -143,7 +155,7 @@ public class SpoutWorld extends LocalWorld {
*/ */
@Override @Override
public void setBlockData(Vector pt, int data) { public void setBlockData(Vector pt, int data) {
setTypeIdAndData(pt, world.getBlockId(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()), data); world.setBlockData(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ(), (short) data, true, WorldEditPlugin.getInstance());
} }
/** /**
@ -414,7 +426,11 @@ public class SpoutWorld extends LocalWorld {
*/ */
@Override @Override
public void dropItem(Vector pt, BaseItemStack item) { public void dropItem(Vector pt, BaseItemStack item) {
ItemStack bukkitItem = new ItemStack(MaterialData.getMaterial((short)item.getType(), item.getDamage()), item.getAmount(), item.getDamage()); Material mat = MaterialRegistry.get((short) item.getType());
if (mat.hasSubMaterials()) {
mat = mat.getSubMaterial(item.getDamage());
}
ItemStack bukkitItem = new ItemStack(mat, item.getDamage(), item.getAmount());
world.createAndSpawnEntity(SpoutUtil.toPoint(world, pt), new Item(bukkitItem, new Vector3(pt.getX(), pt.getY(), pt.getZ()))); world.createAndSpawnEntity(SpoutUtil.toPoint(world, pt), new Item(bukkitItem, new Vector3(pt.getX(), pt.getY(), pt.getZ())));
} }
@ -662,7 +678,7 @@ public class SpoutWorld extends LocalWorld {
*/ */
@Override @Override
public boolean isValidBlockType(int type) { public boolean isValidBlockType(int type) {
return MaterialData.getBlock((short)type) != null; return MaterialRegistry.get((short)type) instanceof BlockMaterial;
} }
@Override @Override

Datei anzeigen

@ -1,7 +1,6 @@
// $Id$
/* /*
* WorldEdit * WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors * Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,6 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// $Id$
package com.sk89q.worldedit.spout; package com.sk89q.worldedit.spout;
import com.sk89q.util.StringUtil; import com.sk89q.util.StringUtil;

Datei anzeigen

@ -1,7 +1,6 @@
// $Id$
/* /*
* WorldEdit * WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors * Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,6 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// $Id$
package com.sk89q.worldedit.spout; package com.sk89q.worldedit.spout;
import com.sk89q.util.yaml.YAMLProcessor; import com.sk89q.util.yaml.YAMLProcessor;

Datei anzeigen

@ -1,4 +1,3 @@
// $Id$
/* /*
* WorldEdit * WorldEdit
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors * Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
@ -17,6 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// $Id$
package com.sk89q.worldedit.spout.selections; package com.sk89q.worldedit.spout.selections;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;

Datei anzeigen

@ -1,4 +1,3 @@
// $Id$
/* /*
* WorldEdit * WorldEdit
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors * Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
@ -17,6 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// $Id$
package com.sk89q.worldedit.spout.selections; package com.sk89q.worldedit.spout.selections;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;

Datei anzeigen

@ -1,4 +1,3 @@
// $Id$
/* /*
* WorldEdit * WorldEdit
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors * Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
@ -17,6 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// $Id$
package com.sk89q.worldedit.spout.selections; package com.sk89q.worldedit.spout.selections;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;