Update for Spout changes

Dieser Commit ist enthalten in:
zml2008 2012-11-25 17:16:35 -08:00
Ursprung afd8ebe66f
Commit 672e6fc584
6 geänderte Dateien mit 28 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -36,8 +36,8 @@ import org.spout.api.geo.discrete.Point;
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.entity.Player; import org.spout.api.entity.Player;
import org.spout.vanilla.component.inventory.window.Window; import org.spout.vanilla.component.inventory.PlayerInventory;
import org.spout.vanilla.component.living.Human; import org.spout.vanilla.component.living.neutral.Human;
import org.spout.vanilla.material.VanillaMaterial; import org.spout.vanilla.material.VanillaMaterial;
import org.spout.vanilla.material.VanillaMaterials; import org.spout.vanilla.material.VanillaMaterials;
@ -55,7 +55,7 @@ public class SpoutPlayer extends LocalPlayer {
@Override @Override
public int getItemInHand() { public int getItemInHand() {
if (player.has(Human.class)) { if (player.has(Human.class)) {
return ((VanillaMaterial) player.get(Human.class).getInventory().getQuickbar() return ((VanillaMaterial) player.get(PlayerInventory.class).getQuickbar()
.getCurrentItem().getMaterial()).getMinecraftId(); .getCurrentItem().getMaterial()).getMinecraftId();
} else { } else {
return 0; return 0;
@ -87,7 +87,7 @@ public class SpoutPlayer extends LocalPlayer {
@Override @Override
public void giveItem(int type, int amt) { public void giveItem(int type, int amt) {
if (player.has(Human.class)) { if (player.has(Human.class)) {
player.get(Human.class).getInventory().add(new ItemStack(VanillaMaterials.getMaterial((short) type), amt)); player.get(PlayerInventory.class).add(new ItemStack(VanillaMaterials.getMaterial((short) type), amt));
} }
} }

Datei anzeigen

@ -34,9 +34,8 @@ import org.spout.api.inventory.ItemStack;
import org.spout.api.material.Material; import org.spout.api.material.Material;
import org.spout.api.entity.Player; import org.spout.api.entity.Player;
import org.spout.vanilla.component.inventory.PlayerInventory; import org.spout.vanilla.component.inventory.PlayerInventory;
import org.spout.vanilla.component.living.Human; import org.spout.vanilla.component.living.neutral.Human;
import org.spout.vanilla.material.VanillaMaterials; import org.spout.vanilla.material.VanillaMaterials;
import org.spout.vanilla.util.VanillaPlayerUtil;
public class SpoutPlayerBlockBag extends BlockBag { public class SpoutPlayerBlockBag extends BlockBag {
/** /**
@ -80,7 +79,7 @@ public class SpoutPlayerBlockBag extends BlockBag {
boolean includesFullInventory = true; boolean includesFullInventory = true;
ItemStack[] items; ItemStack[] items;
Human human = player.get(Human.class); Human human = player.get(Human.class);
PlayerInventory inv = human.getInventory(); PlayerInventory inv = player.get(PlayerInventory.class);
if (human.isCreative()) { if (human.isCreative()) {
includesFullInventory = false; includesFullInventory = false;
items = new ItemStack[inv.getQuickbar().size()]; items = new ItemStack[inv.getQuickbar().size()];
@ -237,7 +236,7 @@ public class SpoutPlayerBlockBag extends BlockBag {
@Override @Override
public void flushChanges() { public void flushChanges() {
if (items != null) { if (items != null) {
PlayerInventory inv = player.get(Human.class).getInventory(); PlayerInventory inv = player.get(PlayerInventory.class);
for (int i = 0; i < inv.getQuickbar().size(); i++) { for (int i = 0; i < inv.getQuickbar().size(); i++) {
inv.getQuickbar().set(i, items.inventory[i]); inv.getQuickbar().set(i, items.inventory[i]);
} }

Datei anzeigen

@ -102,7 +102,7 @@ public class SpoutUtil {
} }
public static Block toBlock(BlockWorldVector pt) { public static Block toBlock(BlockWorldVector pt) {
return toWorld(pt).getBlock(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ(), WorldEditPlugin.getInstance()); return toWorld(pt).getBlock(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
} }
public static World toWorld(WorldVector pt) { public static World toWorld(WorldVector pt) {

Datei anzeigen

@ -41,6 +41,7 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import org.spout.api.component.Component; import org.spout.api.component.Component;
import org.spout.api.entity.Entity; import org.spout.api.entity.Entity;
import org.spout.api.event.cause.PluginCause;
import org.spout.api.generator.biome.BiomeGenerator; import org.spout.api.generator.biome.BiomeGenerator;
import org.spout.api.geo.LoadOption; import org.spout.api.geo.LoadOption;
import org.spout.api.geo.World; import org.spout.api.geo.World;
@ -110,7 +111,7 @@ public class SpoutWorld extends LocalWorld {
final int x = pt.getBlockX(); final int x = pt.getBlockX();
final int y = pt.getBlockY(); final int y = pt.getBlockY();
final int z = pt.getBlockZ(); final int z = pt.getBlockZ();
return world.getChunkFromBlock(x, y, z, LoadOption.LOAD_GEN).setBlockMaterial(x, y, z, (BlockMaterial) mat, (short) 0, WorldEditPlugin.getInstance()); return world.getChunkFromBlock(x, y, z, LoadOption.LOAD_GEN).setBlockMaterial(x, y, z, (BlockMaterial) mat, (short) 0, WorldEditPlugin.asCause());
} }
return false; return false;
} }
@ -141,7 +142,7 @@ public class SpoutWorld extends LocalWorld {
final int x = pt.getBlockX(); final int x = pt.getBlockX();
final int y = pt.getBlockY(); final int y = pt.getBlockY();
final int z = pt.getBlockZ(); final int z = pt.getBlockZ();
return world.getChunkFromBlock(x, y, z, LoadOption.LOAD_GEN).setBlockMaterial(x, y, z, (BlockMaterial) mat, (short) data, WorldEditPlugin.getInstance()); return world.getChunkFromBlock(x, y, z, LoadOption.LOAD_GEN).setBlockMaterial(x, y, z, (BlockMaterial) mat, (short) data, WorldEditPlugin.asCause());
} }
return false; return false;
} }
@ -185,7 +186,7 @@ public class SpoutWorld extends LocalWorld {
final int x = pt.getBlockX(); final int x = pt.getBlockX();
final int y = pt.getBlockY(); final int y = pt.getBlockY();
final int z = pt.getBlockZ(); final int z = pt.getBlockZ();
world.getChunkFromBlock(x, y, z, LoadOption.LOAD_GEN).setBlockData(x, y, z, (short) data, WorldEditPlugin.getInstance()); world.getChunkFromBlock(x, y, z, LoadOption.LOAD_GEN).setBlockData(x, y, z, (short) data, WorldEditPlugin.asCause());
} }
/** /**

Datei anzeigen

@ -24,7 +24,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import org.spout.api.protocol.Message; import org.spout.api.protocol.Message;
import org.spout.api.util.SpoutToStringStyle; import org.spout.api.util.SpoutToStringStyle;
public class WorldEditCUIMessage implements Message { public class WorldEditCUIMessage implements Message {
private final String message; private final String message;
public WorldEditCUIMessage(String mesage) { public WorldEditCUIMessage(String mesage) {
@ -50,4 +50,9 @@ public class WorldEditCUIMessage implements Message {
.append("message", message) .append("message", message)
.toString(); .toString();
} }
@Override
public int getChannelId() {
return DEFAULT_CHANNEL;
}
} }

Datei anzeigen

@ -34,9 +34,12 @@ import com.sk89q.worldedit.spout.selections.Selection;
import com.sk89q.worldedit.util.YAMLConfiguration; import com.sk89q.worldedit.util.YAMLConfiguration;
import org.spout.api.Server; import org.spout.api.Server;
import org.spout.api.command.CommandSource; import org.spout.api.command.CommandSource;
import org.spout.api.event.Cause;
import org.spout.api.event.cause.PluginCause;
import org.spout.api.geo.World; import org.spout.api.geo.World;
import org.spout.api.entity.Player; import org.spout.api.entity.Player;
import org.spout.api.plugin.CommonPlugin; import org.spout.api.plugin.CommonPlugin;
import org.spout.api.plugin.Plugin;
import org.spout.api.protocol.Protocol; import org.spout.api.protocol.Protocol;
import org.spout.api.scheduler.TaskPriority; import org.spout.api.scheduler.TaskPriority;
@ -65,8 +68,10 @@ public class WorldEditPlugin extends CommonPlugin {
private YAMLConfiguration config; private YAMLConfiguration config;
private static WorldEditPlugin instance; private static WorldEditPlugin instance;
private static PluginCause instanceCause;
{ {
instance = this; instance = this;
instanceCause = new PluginCause(this);
} }
/** /**
@ -105,7 +110,7 @@ public class WorldEditPlugin extends CommonPlugin {
proto.registerPacket(WorldEditCUICodec.class, new WorldEditCUIMessageHandler(this)); proto.registerPacket(WorldEditCUICodec.class, new WorldEditCUIMessageHandler(this));
} }
getEngine().getScheduler().scheduleAsyncRepeatingTask(this, getEngine().getScheduler().scheduleSyncRepeatingTask(this,
new SessionTimer(controller, getServer()), 6 * 1000, 6 * 1000, TaskPriority.LOWEST); new SessionTimer(controller, getServer()), 6 * 1000, 6 * 1000, TaskPriority.LOWEST);
} }
@ -356,4 +361,8 @@ public class WorldEditPlugin extends CommonPlugin {
static WorldEditPlugin getInstance() { static WorldEditPlugin getInstance() {
return instance; return instance;
} }
static Cause<Plugin> asCause() {
return instanceCause;
}
} }