Updated Bukkit support.

Dieser Commit ist enthalten in:
sk89q 2011-01-08 13:03:18 -08:00
Ursprung d9ef073aef
Commit 3a065c0edb
8 geänderte Dateien mit 122 neuen und 132 gelöschten Zeilen

Datei anzeigen

@ -58,6 +58,8 @@
</copy> </copy>
<copy tofile="${release.dir}/worldedit.updatr" file="worldedit.updatr"/> <copy tofile="${release.dir}/worldedit.updatr" file="worldedit.updatr"/>
<replace file="${release.dir}/worldedit.updatr" token="%version%" value="${version}"/> <replace file="${release.dir}/worldedit.updatr" token="%version%" value="${version}"/>
<copy tofile="${release.dir}/plugin.yml" file="plugin.yml"/>
<replace file="${release.dir}/plugin.yml" token="WEVERSIONMACRO" value="${version}"/>
<copy tofile="${release.dir}/WorldEdit.jar" file="${dist.dir}/WorldEdit.jar"/> <copy tofile="${release.dir}/WorldEdit.jar" file="${dist.dir}/WorldEdit.jar"/>
<zip destfile="${release.dir}/worldedit-${version}.zip" basedir="${release.dir}" excludes="*.zip"/> <zip destfile="${release.dir}/worldedit-${version}.zip" basedir="${release.dir}" excludes="*.zip"/>
<mkdir dir="${release.dir}/src"/> <mkdir dir="${release.dir}/src"/>

Datei anzeigen

@ -1,2 +1,3 @@
name: WorldEdit name: WorldEdit
main: com.sk89q.worldedit.bukkit.WorldEditPlugin main: com.sk89q.worldedit.bukkit.WorldEditPlugin
version: WEVERSIONMACRO

Datei anzeigen

@ -74,6 +74,7 @@ public class BukkitPlayer extends LocalPlayer {
@Override @Override
public void giveItem(int type, int amt) { public void giveItem(int type, int amt) {
player.getWorld().dropItem(player.getLocation(), new ItemStack(type, amt));
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@ -101,7 +102,8 @@ public class BukkitPlayer extends LocalPlayer {
@Override @Override
public void setPosition(Vector pos, float pitch, float yaw) { public void setPosition(Vector pos, float pitch, float yaw) {
// TODO Auto-generated method stub player.teleportTo(new Location(player.getWorld(), pos.getX(), pos.getY(),
pos.getZ(), yaw, pitch));
} }
@Override @Override

Datei anzeigen

@ -20,11 +20,7 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import org.bukkit.*; import org.bukkit.*;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.ServerInterface; import com.sk89q.worldedit.ServerInterface;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseItemStack;
public class BukkitServerInterface extends ServerInterface { public class BukkitServerInterface extends ServerInterface {
public Server server; public Server server;
@ -34,68 +30,9 @@ public class BukkitServerInterface extends ServerInterface {
} }
@Override @Override
public boolean setBlockType(LocalWorld world, Vector pt, int type) { public int resolveItem(String name) {
((BukkitWorld)world).getWorld().getBlockAt(
pt.getBlockX(),
pt.getBlockY(),
pt.getBlockZ()).setTypeID(type);
return true;
}
@Override
public int getBlockType(LocalWorld world, Vector pt) {
return ((BukkitWorld)world).getWorld().getBlockAt(
pt.getBlockX(),
pt.getBlockY(),
pt.getBlockZ()).getTypeID();
}
@Override
public void setBlockData(LocalWorld world, Vector pt, int data) {
((BukkitWorld)world).getWorld().getBlockAt(
pt.getBlockX(),
pt.getBlockY(),
pt.getBlockZ()).setData((byte)data);
}
@Override
public int getBlockData(LocalWorld world, Vector pt) {
return ((BukkitWorld)world).getWorld().getBlockAt(
pt.getBlockX(),
pt.getBlockY(),
pt.getBlockZ()).getData();
}
@Override
public void setSignText(LocalWorld world, Vector pt, String[] text) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return 0;
}
@Override
public String[] getSignText(LocalWorld world, Vector pt) {
// TODO Auto-generated method stub
return null;
}
@Override
public BaseItemStack[] getChestContents(LocalWorld world, Vector pt) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean setChestContents(LocalWorld world, Vector pt, BaseItemStack[] contents) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean clearChest(LocalWorld world, Vector pt) {
// TODO Auto-generated method stub
return false;
} }
@Override @Override
@ -104,59 +41,4 @@ public class BukkitServerInterface extends ServerInterface {
return false; return false;
} }
@Override
public void setMobSpawnerType(LocalWorld world, Vector pt, String mobType) {
// TODO Auto-generated method stub
}
@Override
public String getMobSpawnerType(LocalWorld world, Vector pt) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean generateTree(EditSession editSession, LocalWorld world,
Vector pt) {
// TODO Auto-generated method stub
return false;
}
@Override
public void dropItem(LocalWorld world, Vector pt, int type, int count, int times) {
// TODO Auto-generated method stub
}
@Override
public void dropItem(LocalWorld world, Vector pt, int type, int count) {
// TODO Auto-generated method stub
}
@Override
public void dropItem(LocalWorld world, Vector pt, int type) {
// TODO Auto-generated method stub
}
@Override
public void simulateBlockMine(LocalWorld world, Vector pt) {
// TODO Auto-generated method stub
}
@Override
public int resolveItem(String name) {
// TODO Auto-generated method stub
return 0;
}
@Override
public int killMobs(LocalWorld world, Vector origin, int radius) {
// TODO Auto-generated method stub
return 0;
}
} }

Datei anzeigen

@ -20,8 +20,10 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import org.bukkit.World; import org.bukkit.World;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseItemStack;
public class BukkitWorld extends LocalWorld { public class BukkitWorld extends LocalWorld {
private World world; private World world;
@ -34,6 +36,104 @@ public class BukkitWorld extends LocalWorld {
return world; return world;
} }
@Override
public boolean setBlockType(Vector pt, int type) {
return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setTypeID(type);
}
@Override
public int getBlockType(Vector pt) {
return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getTypeID();
}
@Override
public void setBlockData(Vector pt, int data) {
world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setData((byte)data);
}
@Override
public int getBlockData(Vector pt) {
return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getData();
}
@Override
public void setSignText(Vector pt, String[] text) {
// TODO Auto-generated method stub
}
@Override
public String[] getSignText(Vector pt) {
// TODO Auto-generated method stub
return null;
}
@Override
public BaseItemStack[] getChestContents(Vector pt) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean setChestContents(Vector pt, BaseItemStack[] contents) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean clearChest(Vector pt) {
// TODO Auto-generated method stub
return false;
}
@Override
public void setMobSpawnerType(Vector pt, String mobType) {
// TODO Auto-generated method stub
}
@Override
public String getMobSpawnerType(Vector pt) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean generateTree(EditSession editSession, Vector pt) {
// TODO Auto-generated method stub
return false;
}
@Override
public void dropItem(Vector pt, int type, int count, int times) {
// TODO Auto-generated method stub
}
@Override
public void dropItem(Vector pt, int type, int count) {
// TODO Auto-generated method stub
}
@Override
public void dropItem(Vector pt, int type) {
// TODO Auto-generated method stub
}
@Override
public void simulateBlockMine(Vector pt) {
// TODO Auto-generated method stub
}
@Override
public int killMobs(Vector origin, int radius) {
// TODO Auto-generated method stub
return 0;
}
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (!(other instanceof BukkitWorld)) { if (!(other instanceof BukkitWorld)) {

Datei anzeigen

@ -23,7 +23,6 @@ import org.bukkit.Player;
import org.bukkit.event.block.BlockListener; import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockBrokenEvent; import org.bukkit.event.block.BlockBrokenEvent;
import org.bukkit.event.block.BlockPlacedEvent; import org.bukkit.event.block.BlockPlacedEvent;
import org.bukkit.event.block.BlockRightClickedEvent;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.*;
public class WorldEditBlockListener extends BlockListener { public class WorldEditBlockListener extends BlockListener {
@ -47,12 +46,12 @@ public class WorldEditBlockListener extends BlockListener {
* @param event Relevant event details * @param event Relevant event details
*/ */
public void onBlockBroken(BlockBrokenEvent event) { public void onBlockBroken(BlockBrokenEvent event) {
Vector pos = new Vector(event.getBlock().getX(),
event.getBlock().getY(),
event.getBlock().getZ());
LocalWorld world = new BukkitWorld(event.getBlock().getWorld()); LocalWorld world = new BukkitWorld(event.getBlock().getWorld());
WorldVector pos = new WorldVector(world, event.getBlock().getX(),
event.getBlock().getY(), event.getBlock().getZ());
LocalPlayer player = wrapPlayer(event.getPlayer()); LocalPlayer player = wrapPlayer(event.getPlayer());
plugin.controller.handleBlockLeftClick(player, world, pos);
plugin.controller.handleBlockLeftClick(player, pos);
} }
/** /**
@ -61,12 +60,12 @@ public class WorldEditBlockListener extends BlockListener {
* @param event Relevant event details * @param event Relevant event details
*/ */
public void onBlockPlaced(BlockPlacedEvent event) { public void onBlockPlaced(BlockPlacedEvent event) {
Vector pos = new Vector(event.getBlock().getX(),
event.getBlock().getY(),
event.getBlock().getZ());
LocalWorld world = new BukkitWorld(event.getBlock().getWorld()); LocalWorld world = new BukkitWorld(event.getBlock().getWorld());
WorldVector pos = new WorldVector(world, event.getBlock().getX(),
event.getBlock().getY(), event.getBlock().getZ());
LocalPlayer player = wrapPlayer(event.getPlayer()); LocalPlayer player = wrapPlayer(event.getPlayer());
plugin.controller.handleBlockRightClick(player, world, pos);
plugin.controller.handleBlockRightClick(player, pos);
} }
private BukkitPlayer wrapPlayer(Player player) { private BukkitPlayer wrapPlayer(Player player) {

Datei anzeigen

@ -23,7 +23,6 @@ import org.bukkit.*;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerListener;
import com.sk89q.worldedit.*;
/** /**
* Handles all events thrown in relation to a Player * Handles all events thrown in relation to a Player

Datei anzeigen

@ -29,6 +29,11 @@ import org.bukkit.plugin.PluginLoader;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.*;
/**
* Plugin for Bukkit.
*
* @author sk89qs
*/
public class WorldEditPlugin extends JavaPlugin { public class WorldEditPlugin extends JavaPlugin {
public final ServerInterface server; public final ServerInterface server;
public final WorldEditController controller; public final WorldEditController controller;