2014-04-04 22:03:18 +00:00
|
|
|
/*
|
|
|
|
* WorldEdit, a Minecraft world manipulation toolkit
|
|
|
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
|
|
* Copyright (C) WorldEdit team and contributors
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser 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 Lesser General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2013-02-24 20:16:12 +00:00
|
|
|
package com.sk89q.worldedit.forge;
|
|
|
|
|
2014-04-06 19:07:10 +00:00
|
|
|
import com.sk89q.util.StringUtil;
|
|
|
|
import com.sk89q.worldedit.*;
|
|
|
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
|
|
|
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
2013-02-25 06:22:05 +00:00
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.network.packet.Packet250CustomPayload;
|
2013-08-13 01:26:17 +00:00
|
|
|
import net.minecraft.util.ChatMessageComponent;
|
2013-02-25 06:22:05 +00:00
|
|
|
|
2013-02-24 20:16:12 +00:00
|
|
|
public class ForgePlayer extends LocalPlayer {
|
|
|
|
private EntityPlayerMP player;
|
|
|
|
|
|
|
|
protected ForgePlayer(EntityPlayerMP player) {
|
2014-04-06 19:07:10 +00:00
|
|
|
super((ServerInterface) ForgeWorldEdit.inst.getPlatform());
|
2013-02-24 20:16:12 +00:00
|
|
|
this.player = player;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getItemInHand() {
|
|
|
|
ItemStack is = this.player.getCurrentEquippedItem();
|
|
|
|
return is == null ? 0 : is.itemID;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
return this.player.username;
|
|
|
|
}
|
|
|
|
|
|
|
|
public WorldVector getPosition() {
|
2014-04-06 19:07:10 +00:00
|
|
|
return new WorldVector(ForgeWorldEdit.inst.getWorld(this.player.worldObj), this.player.posX, this.player.posY, this.player.posZ);
|
2013-02-24 20:16:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public LocalWorld getWorld() {
|
2014-04-06 19:07:10 +00:00
|
|
|
return ForgeWorldEdit.inst.getWorld(this.player.worldObj);
|
2013-02-24 20:16:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public double getPitch() {
|
2013-09-29 13:30:06 +00:00
|
|
|
return this.player.rotationPitch;
|
2013-02-24 20:16:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public double getYaw() {
|
2013-09-29 13:30:06 +00:00
|
|
|
return this.player.rotationYaw;
|
2013-02-24 20:16:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void giveItem(int type, int amt) {
|
|
|
|
this.player.inventory.addItemStackToInventory(new ItemStack(type, amt, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void dispatchCUIEvent(CUIEvent event) {
|
|
|
|
String[] params = event.getParameters();
|
|
|
|
String send = event.getTypeId();
|
|
|
|
if (params.length > 0) {
|
|
|
|
send = send + "|" + StringUtil.joinString(params, "|");
|
|
|
|
}
|
2014-04-06 19:07:10 +00:00
|
|
|
Packet250CustomPayload packet = new Packet250CustomPayload(ForgeWorldEdit.CUI_PLUGIN_CHANNEL, send.getBytes(WECUIPacketHandler.UTF_8_CHARSET));
|
2013-02-24 20:16:12 +00:00
|
|
|
this.player.playerNetServerHandler.sendPacketToPlayer(packet);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void printRaw(String msg) {
|
2013-08-13 01:26:17 +00:00
|
|
|
for (String part : msg.split("\n")) {
|
2013-09-29 13:30:06 +00:00
|
|
|
this.player.sendChatToPlayer(ChatMessageComponent.createFromText(part));
|
2013-08-13 01:26:17 +00:00
|
|
|
}
|
2013-02-24 20:16:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void printDebug(String msg) {
|
2013-08-13 01:26:17 +00:00
|
|
|
for (String part : msg.split("\n")) {
|
2013-09-29 13:30:06 +00:00
|
|
|
this.player.sendChatToPlayer(ChatMessageComponent.createFromText("\u00a77" + part));
|
2013-08-13 01:26:17 +00:00
|
|
|
}
|
2013-02-24 20:16:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void print(String msg) {
|
2013-08-13 01:26:17 +00:00
|
|
|
for (String part : msg.split("\n")) {
|
2013-09-29 13:30:06 +00:00
|
|
|
this.player.sendChatToPlayer(ChatMessageComponent.createFromText("\u00a7d" + part));
|
2013-08-13 01:26:17 +00:00
|
|
|
}
|
2013-02-24 20:16:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void printError(String msg) {
|
2013-08-13 01:26:17 +00:00
|
|
|
for (String part : msg.split("\n")) {
|
2013-09-29 13:30:06 +00:00
|
|
|
this.player.sendChatToPlayer(ChatMessageComponent.createFromText("\u00a7c" + part));
|
2013-08-13 01:26:17 +00:00
|
|
|
}
|
2013-02-24 20:16:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setPosition(Vector pos, float pitch, float yaw) {
|
|
|
|
this.player.playerNetServerHandler.setPlayerLocation(pos.getX(), pos.getY(), pos.getZ(), pitch, yaw);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String[] getGroups() {
|
|
|
|
return new String[]{}; // WorldEditMod.inst.getPermissionsResolver().getGroups(this.player.username);
|
|
|
|
}
|
|
|
|
|
|
|
|
public BlockBag getInventoryBlockBag() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasPermission(String perm) {
|
|
|
|
return ForgeUtil.hasPermission(this.player, perm);
|
|
|
|
}
|
|
|
|
}
|