3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-25 10:30:04 +01:00

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 tofile="${release.dir}/worldedit.updatr" file="worldedit.updatr"/>
<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"/>
<zip destfile="${release.dir}/worldedit-${version}.zip" basedir="${release.dir}" excludes="*.zip"/>
<mkdir dir="${release.dir}/src"/>

Datei anzeigen

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

Datei anzeigen

@ -74,6 +74,7 @@ public class BukkitPlayer extends LocalPlayer {
@Override
public void giveItem(int type, int amt) {
player.getWorld().dropItem(player.getLocation(), new ItemStack(type, amt));
// TODO Auto-generated method stub
}
@ -101,7 +102,8 @@ public class BukkitPlayer extends LocalPlayer {
@Override
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

Datei anzeigen

@ -20,11 +20,7 @@
package com.sk89q.worldedit.bukkit;
import org.bukkit.*;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.ServerInterface;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseItemStack;
public class BukkitServerInterface extends ServerInterface {
public Server server;
@ -34,68 +30,9 @@ public class BukkitServerInterface extends ServerInterface {
}
@Override
public boolean setBlockType(LocalWorld world, Vector pt, int type) {
((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) {
public int resolveItem(String name) {
// TODO Auto-generated method stub
}
@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;
return 0;
}
@Override
@ -104,59 +41,4 @@ public class BukkitServerInterface extends ServerInterface {
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;
import org.bukkit.World;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseItemStack;
public class BukkitWorld extends LocalWorld {
private World world;
@ -34,6 +36,104 @@ public class BukkitWorld extends LocalWorld {
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
public boolean equals(Object other) {
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.BlockBrokenEvent;
import org.bukkit.event.block.BlockPlacedEvent;
import org.bukkit.event.block.BlockRightClickedEvent;
import com.sk89q.worldedit.*;
public class WorldEditBlockListener extends BlockListener {
@ -47,12 +46,12 @@ public class WorldEditBlockListener extends BlockListener {
* @param event Relevant event details
*/
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());
WorldVector pos = new WorldVector(world, event.getBlock().getX(),
event.getBlock().getY(), event.getBlock().getZ());
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
*/
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());
WorldVector pos = new WorldVector(world, event.getBlock().getX(),
event.getBlock().getY(), event.getBlock().getZ());
LocalPlayer player = wrapPlayer(event.getPlayer());
plugin.controller.handleBlockRightClick(player, world, pos);
plugin.controller.handleBlockRightClick(player, pos);
}
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.PlayerEvent;
import org.bukkit.event.player.PlayerListener;
import com.sk89q.worldedit.*;
/**
* 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 com.sk89q.worldedit.*;
/**
* Plugin for Bukkit.
*
* @author sk89qs
*/
public class WorldEditPlugin extends JavaPlugin {
public final ServerInterface server;
public final WorldEditController controller;