Update CraftBukkit to Minecraft 1.7.8

By: Travis Watkins <amaranth@ubuntu.com>
This commit is contained in:
CraftBukkit/Spigot
2014-04-10 20:04:38 -05:00
parent db3aa0246f
commit d24dac2c06
13 changed files with 407 additions and 176 deletions

View File

@@ -10,6 +10,7 @@ import net.minecraft.server.BlockCocoa;
import net.minecraft.server.BlockRedstoneWire;
import net.minecraft.server.Blocks;
import net.minecraft.server.EnumSkyBlock;
import net.minecraft.server.GameProfileSerializer;
import net.minecraft.server.Item;
import net.minecraft.server.NBTTagCompound;
import net.minecraft.server.TileEntitySkull;
@@ -423,9 +424,12 @@ public class CraftBlock implements Block {
net.minecraft.server.ItemStack nmsStack = new net.minecraft.server.ItemStack(item, 1, block.getDropData(chunk.getHandle().world, x, y, z));
TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().world.getTileEntity(x, y, z);
if (tileentityskull.getSkullType() == 3 && tileentityskull.getExtraType() != null && tileentityskull.getExtraType().length() > 0) {
if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) {
nmsStack.setTag(new NBTTagCompound());
nmsStack.getTag().setString("SkullOwner", tileentityskull.getExtraType());
NBTTagCompound nbttagcompound = new NBTTagCompound();
GameProfileSerializer.a(nbttagcompound, tileentityskull.getGameProfile());
nmsStack.getTag().set("SkullOwner", nbttagcompound);
}
drops.add(CraftItemStack.asBukkitCopy(nmsStack));

View File

@@ -1,28 +1,30 @@
package org.bukkit.craftbukkit.block;
import com.google.common.base.Strings;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.TileEntitySkull;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import org.bukkit.OfflinePlayer;
import org.bukkit.SkullType;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Skull;
import org.bukkit.craftbukkit.CraftOfflinePlayer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.entity.CraftPlayer;
public class CraftSkull extends CraftBlockState implements Skull {
private final TileEntitySkull skull;
private String player;
private GameProfile profile;
private SkullType skullType;
private byte rotation;
private final int MAX_OWNER_LENGTH = 16;
public CraftSkull(final Block block) {
super(block);
CraftWorld world = (CraftWorld) block.getWorld();
skull = (TileEntitySkull) world.getTileEntityAt(getX(), getY(), getZ());
player = skull.getExtraType();
profile = skull.getGameProfile();
skullType = getSkullType(skull.getSkullType());
rotation = (byte) skull.getRotation();
}
@@ -140,23 +142,36 @@ public class CraftSkull extends CraftBlockState implements Skull {
}
public boolean hasOwner() {
return !Strings.isNullOrEmpty(player);
return profile != null;
}
public String getOwner() {
return player;
return profile.getName();
}
public boolean setOwner(String name) {
if (name == null || name.length() > MAX_OWNER_LENGTH) {
return false;
}
public OfflinePlayer getPlayer() {
return MinecraftServer.getServer().server.getOfflinePlayer(profile);
}
public boolean setPlayer(OfflinePlayer player) {
GameProfile profile;
if (player instanceof CraftPlayer) {
profile = ((CraftPlayer) player).getProfile();
} else if (player instanceof CraftOfflinePlayer) {
profile = ((CraftOfflinePlayer) player).getProfile();
} else {
return false;
}
player = name;
if (skullType != SkullType.PLAYER) {
skullType = SkullType.PLAYER;
if (profile == null) {
return false;
}
this.profile = profile;
return true;
}
@@ -176,7 +191,7 @@ public class CraftSkull extends CraftBlockState implements Skull {
this.skullType = skullType;
if (skullType != SkullType.PLAYER) {
player = "";
profile = null;
}
}
@@ -185,7 +200,8 @@ public class CraftSkull extends CraftBlockState implements Skull {
boolean result = super.update(force, applyPhysics);
if (result) {
skull.setSkullType(getSkullType(skullType), player);
skull.setSkullType(getSkullType(skullType));
skull.setGameProfile(profile);
skull.setRotation(rotation);
skull.update();
}