2011-12-25 23:56:20 +00:00
|
|
|
// $Id$
|
|
|
|
/*
|
|
|
|
* WorldEdit
|
|
|
|
* Copyright (C) 2010 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/>.
|
|
|
|
*/
|
|
|
|
|
2011-12-15 11:02:00 +00:00
|
|
|
package com.sk89q.worldedit.bukkit;
|
|
|
|
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import com.sk89q.worldedit.LocalPlayer;
|
|
|
|
import com.sk89q.worldedit.LocalWorld;
|
|
|
|
import com.sk89q.worldedit.PlayerNeededException;
|
|
|
|
import com.sk89q.worldedit.ServerInterface;
|
|
|
|
import com.sk89q.worldedit.Vector;
|
|
|
|
import com.sk89q.worldedit.WorldVector;
|
2014-04-03 02:08:50 +00:00
|
|
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
2011-12-15 11:02:00 +00:00
|
|
|
|
|
|
|
public class BukkitCommandSender extends LocalPlayer {
|
|
|
|
private CommandSender sender;
|
|
|
|
private WorldEditPlugin plugin;
|
|
|
|
|
|
|
|
public BukkitCommandSender(WorldEditPlugin plugin, ServerInterface server, CommandSender sender) {
|
|
|
|
super(server);
|
|
|
|
this.plugin = plugin;
|
|
|
|
this.sender = sender;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getName() {
|
|
|
|
return sender.getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void printRaw(String msg) {
|
2011-12-25 06:34:53 +00:00
|
|
|
for (String part : msg.split("\n")) {
|
|
|
|
sender.sendMessage(part);
|
|
|
|
}
|
2011-12-15 11:02:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-12-25 06:34:53 +00:00
|
|
|
public void print(String msg) {
|
|
|
|
for (String part : msg.split("\n")) {
|
|
|
|
sender.sendMessage("\u00A7d" + part);
|
|
|
|
}
|
2011-12-15 11:02:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-12-25 06:34:53 +00:00
|
|
|
public void printDebug(String msg) {
|
|
|
|
for (String part : msg.split("\n")) {
|
|
|
|
sender.sendMessage("\u00A77" + part);
|
|
|
|
}
|
2011-12-15 11:02:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void printError(String msg) {
|
2011-12-25 06:34:53 +00:00
|
|
|
for (String part : msg.split("\n")) {
|
|
|
|
sender.sendMessage("\u00A7c" + part);
|
|
|
|
}
|
2011-12-15 11:02:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String[] getGroups() {
|
|
|
|
return new String[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasPermission(String perm) {
|
|
|
|
if (!plugin.getLocalConfiguration().noOpPermissions && sender.isOp()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return plugin.getPermissionsResolver().hasPermission(null, sender.getName(), perm);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isPlayer() {
|
|
|
|
return sender instanceof Player;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemInHand() {
|
|
|
|
throw new PlayerNeededException();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public WorldVector getPosition() {
|
|
|
|
throw new PlayerNeededException();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public LocalWorld getWorld() {
|
|
|
|
throw new PlayerNeededException();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public double getPitch() {
|
|
|
|
throw new PlayerNeededException();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public double getYaw() {
|
|
|
|
throw new PlayerNeededException();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void giveItem(int type, int amt) {
|
|
|
|
throw new PlayerNeededException();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setPosition(Vector pos, float pitch, float yaw) {
|
|
|
|
throw new PlayerNeededException();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public BlockBag getInventoryBlockBag() {
|
|
|
|
throw new PlayerNeededException();
|
|
|
|
}
|
|
|
|
}
|