Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-08 04:20:06 +01:00
Updated Bukkit plugin.
Dieser Commit ist enthalten in:
Ursprung
0dfb88c41d
Commit
e1939e0d4c
@ -21,23 +21,25 @@ package com.sk89q.worldedit.bukkit;
|
|||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.bags.BlockBag;
|
import com.sk89q.worldedit.bags.BlockBag;
|
||||||
|
|
||||||
public class BukkitPlayer extends WorldEditPlayer {
|
public class BukkitPlayer extends LocalPlayer {
|
||||||
private Player player;
|
private Player player;
|
||||||
|
|
||||||
public BukkitPlayer(Player player) {
|
public BukkitPlayer(ServerInterface server, Player player) {
|
||||||
|
super(server);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector getBlockTrace(int range) {
|
public WorldVector getBlockTrace(int range) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector getSolidBlockTrace(int range) {
|
public WorldVector getSolidBlockTrace(int range) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -54,9 +56,10 @@ public class BukkitPlayer extends WorldEditPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector getPosition() {
|
public WorldVector getPosition() {
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
return new Vector(loc.getX(), loc.getY(), loc.getZ());
|
return new WorldVector(new BukkitWorld(loc.getWorld()),
|
||||||
|
loc.getX(), loc.getY(), loc.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -119,4 +122,10 @@ public class BukkitPlayer extends WorldEditPlayer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocalWorld getWorld() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.bukkit;
|
|||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import com.sk89q.worldedit.EditSession;
|
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.Vector;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
@ -33,53 +34,66 @@ public class BukkitServerInterface extends ServerInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlockType(Vector pt, int type) {
|
public boolean setBlockType(LocalWorld world, Vector pt, int type) {
|
||||||
// TODO Auto-generated method stub
|
((BukkitWorld)world).getWorld().getBlockAt(
|
||||||
return false;
|
pt.getBlockX(),
|
||||||
|
pt.getBlockY(),
|
||||||
|
pt.getBlockZ()).setTypeID(type);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBlockType(Vector pt) {
|
public int getBlockType(LocalWorld world, Vector pt) {
|
||||||
return server.getWorlds()[0].getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getType();
|
return ((BukkitWorld)world).getWorld().getBlockAt(
|
||||||
|
pt.getBlockX(),
|
||||||
|
pt.getBlockY(),
|
||||||
|
pt.getBlockZ()).getTypeID();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBlockData(Vector pt, int data) {
|
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
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBlockData(Vector pt) {
|
public String[] getSignText(LocalWorld world, Vector pt) {
|
||||||
return server.getWorlds()[0].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
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseItemStack[] getChestContents(Vector pt) {
|
public BaseItemStack[] getChestContents(LocalWorld world, Vector pt) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setChestContents(Vector pt, BaseItemStack[] contents) {
|
public boolean setChestContents(LocalWorld world, Vector pt, BaseItemStack[] contents) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean clearChest(Vector pt) {
|
public boolean clearChest(LocalWorld world, Vector pt) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -91,43 +105,44 @@ public class BukkitServerInterface extends ServerInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMobSpawnerType(Vector pt, String mobType) {
|
public void setMobSpawnerType(LocalWorld world, Vector pt, String mobType) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMobSpawnerType(Vector pt) {
|
public String getMobSpawnerType(LocalWorld world, Vector pt) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean generateTree(EditSession editSession, Vector pt) {
|
public boolean generateTree(EditSession editSession, LocalWorld world,
|
||||||
|
Vector pt) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dropItem(Vector pt, int type, int count, int times) {
|
public void dropItem(LocalWorld world, Vector pt, int type, int count, int times) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dropItem(Vector pt, int type, int count) {
|
public void dropItem(LocalWorld world, Vector pt, int type, int count) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dropItem(Vector pt, int type) {
|
public void dropItem(LocalWorld world, Vector pt, int type) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simulateBlockMine(Vector pt) {
|
public void simulateBlockMine(LocalWorld world, Vector pt) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -139,7 +154,7 @@ public class BukkitServerInterface extends ServerInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int killMobs(Vector origin, int radius) {
|
public int killMobs(LocalWorld world, Vector origin, int radius) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
51
src/com/sk89q/worldedit/bukkit/BukkitWorld.java
Normale Datei
51
src/com/sk89q/worldedit/bukkit/BukkitWorld.java
Normale Datei
@ -0,0 +1,51 @@
|
|||||||
|
// $Id$
|
||||||
|
/*
|
||||||
|
* WorldEdit
|
||||||
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||||
|
*
|
||||||
|
* 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.bukkit;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.LocalWorld;
|
||||||
|
|
||||||
|
public class BukkitWorld extends LocalWorld {
|
||||||
|
private World world;
|
||||||
|
|
||||||
|
public BukkitWorld(World world) {
|
||||||
|
this.world = world;
|
||||||
|
}
|
||||||
|
|
||||||
|
public World getWorld() {
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
if (!(other instanceof BukkitWorld)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ((BukkitWorld)other).world.equals(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return world.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -19,8 +19,10 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
|
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.BlockRightClickedEvent;
|
import org.bukkit.event.block.BlockRightClickedEvent;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
|
|
||||||
@ -48,20 +50,26 @@ public class WorldEditBlockListener extends BlockListener {
|
|||||||
Vector pos = new Vector(event.getBlock().getX(),
|
Vector pos = new Vector(event.getBlock().getX(),
|
||||||
event.getBlock().getY(),
|
event.getBlock().getY(),
|
||||||
event.getBlock().getZ());
|
event.getBlock().getZ());
|
||||||
WorldEditPlayer player = new BukkitPlayer(plugin.getServer().getOnlinePlayers()[0]);
|
LocalWorld world = new BukkitWorld(event.getBlock().getWorld());
|
||||||
plugin.controller.handleBlockLeftClick(player, pos);
|
LocalPlayer player = wrapPlayer(event.getPlayer());
|
||||||
|
plugin.controller.handleBlockLeftClick(player, world, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player right clicks a block
|
* Called when a player places a block
|
||||||
*
|
*
|
||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
public void onBlockRightClicked(BlockRightClickedEvent event) {
|
public void onBlockPlaced(BlockPlacedEvent event) {
|
||||||
Vector pos = new Vector(event.getBlock().getX(),
|
Vector pos = new Vector(event.getBlock().getX(),
|
||||||
event.getBlock().getY(),
|
event.getBlock().getY(),
|
||||||
event.getBlock().getZ());
|
event.getBlock().getZ());
|
||||||
WorldEditPlayer player = new BukkitPlayer(plugin.getServer().getOnlinePlayers()[0]);
|
LocalWorld world = new BukkitWorld(event.getBlock().getWorld());
|
||||||
plugin.controller.handleBlockRightClick(player, pos);
|
LocalPlayer player = wrapPlayer(event.getPlayer());
|
||||||
|
plugin.controller.handleBlockRightClick(player, world, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BukkitPlayer wrapPlayer(Player player) {
|
||||||
|
return new BukkitPlayer(plugin.server, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,11 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
|
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.*;
|
||||||
import com.sk89q.worldedit.WorldEditPlayer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles all events thrown in relation to a Player
|
* Handles all events thrown in relation to a Player
|
||||||
@ -49,8 +49,7 @@ public class WorldEditPlayerListener extends PlayerListener {
|
|||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
public void onPlayerQuit(PlayerEvent event) {
|
public void onPlayerQuit(PlayerEvent event) {
|
||||||
WorldEditPlayer player = new BukkitPlayer(plugin.getServer().getOnlinePlayers()[0]);
|
plugin.controller.handleDisconnect(wrapPlayer(event.getPlayer()));
|
||||||
plugin.controller.handleDisconnect(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,7 +58,11 @@ public class WorldEditPlayerListener extends PlayerListener {
|
|||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
public void onPlayerCommand(PlayerChatEvent event) {
|
public void onPlayerCommand(PlayerChatEvent event) {
|
||||||
WorldEditPlayer player = new BukkitPlayer(plugin.getServer().getOnlinePlayers()[0]);
|
plugin.controller.handleCommand(wrapPlayer(event.getPlayer()),
|
||||||
plugin.controller.handleCommand(player, event.getMessage().split(" "));
|
event.getMessage().split(" "));
|
||||||
|
}
|
||||||
|
|
||||||
|
private BukkitPlayer wrapPlayer(Player player) {
|
||||||
|
return new BukkitPlayer(plugin.server, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
|
|
||||||
public class WorldEditPlugin extends JavaPlugin {
|
public class WorldEditPlugin extends JavaPlugin {
|
||||||
public final WorldEditController controller =
|
public final ServerInterface server;
|
||||||
new WorldEditController();
|
public final WorldEditController controller;
|
||||||
|
|
||||||
private final WorldEditPlayerListener playerListener =
|
private final WorldEditPlayerListener playerListener =
|
||||||
new WorldEditPlayerListener(this);
|
new WorldEditPlayerListener(this);
|
||||||
@ -41,25 +41,17 @@ public class WorldEditPlugin extends JavaPlugin {
|
|||||||
public WorldEditPlugin(PluginLoader pluginLoader, Server instance,
|
public WorldEditPlugin(PluginLoader pluginLoader, Server instance,
|
||||||
PluginDescriptionFile desc, File plugin, ClassLoader cLoader) {
|
PluginDescriptionFile desc, File plugin, ClassLoader cLoader) {
|
||||||
super(pluginLoader, instance, desc, plugin, cLoader);
|
super(pluginLoader, instance, desc, plugin, cLoader);
|
||||||
|
|
||||||
|
LocalConfiguration config = new LocalConfiguration() {
|
||||||
|
@Override
|
||||||
|
public void load() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
disallowedBlocks = new HashSet<Integer>();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
ServerInterface.setup(new BukkitServerInterface(getServer()));
|
server = new BukkitServerInterface(getServer());
|
||||||
|
controller = new WorldEditController(server, config);
|
||||||
controller.profile = true;
|
|
||||||
controller.allowedBlocks = new HashSet<Integer>();
|
|
||||||
controller.defaultChangeLimit = -1;
|
|
||||||
controller.maxChangeLimit = -1;
|
|
||||||
controller.shellSaveType = "sh";
|
|
||||||
controller.snapshotRepo = null;
|
|
||||||
controller.maxRadius = -1;
|
|
||||||
controller.maxSuperPickaxeSize = 5;
|
|
||||||
controller.logComands = false;
|
|
||||||
controller.registerHelp = true;
|
|
||||||
controller.wandItem = 271;
|
|
||||||
controller.superPickaxeDrop = true;
|
|
||||||
controller.superPickaxeManyDrop = true;
|
|
||||||
controller.noDoubleSlash = true;
|
|
||||||
controller.useInventory = false;
|
|
||||||
controller.useInventoryOverride = false;
|
|
||||||
|
|
||||||
registerEvents();
|
registerEvents();
|
||||||
}
|
}
|
||||||
@ -79,7 +71,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
|||||||
playerListener, Priority.Normal, this);
|
playerListener, Priority.Normal, this);
|
||||||
getServer().getPluginManager().registerEvent(Event.Type.BLOCK_DAMAGED,
|
getServer().getPluginManager().registerEvent(Event.Type.BLOCK_DAMAGED,
|
||||||
blockListener, Priority.Normal, this);
|
blockListener, Priority.Normal, this);
|
||||||
getServer().getPluginManager().registerEvent(Event.Type.BLOCK_RIGHTCLICKED,
|
getServer().getPluginManager().registerEvent(Event.Type.BLOCK_PLACED,
|
||||||
blockListener, Priority.Normal, this);
|
blockListener, Priority.Normal, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren