Skip to content

Commit

Permalink
FIx 1.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Aug 18, 2017
1 parent 54daf4d commit ebba776
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
Expand Up @@ -15,16 +15,30 @@
import org.bukkit.SkullType;
import org.bukkit.block.Block;
import org.bukkit.block.Skull;
import org.bukkit.craftbukkit.v1_12_R1.block.CraftBlockEntityState;
import org.bukkit.craftbukkit.v1_12_R1.block.CraftBlockState;
import org.bukkit.craftbukkit.v1_12_R1.block.CraftSkull;

import java.util.UUID;

public class BlockHelper_v1_12_R1 implements BlockHelper {

public <T extends TileEntity> T getTE(CraftBlockEntityState<T> cbs) {
try {
return (T) cbs.getClass().getField("tileEntity").get(cbs);
}
catch (IllegalAccessException e) {
e.printStackTrace();
}
catch (NoSuchFieldException e) {
e.printStackTrace();
}
return null;
}

@Override
public PlayerProfile getPlayerProfile(Skull skull) {
GameProfile profile = ((CraftSkull) skull).getTileEntity().getGameProfile();
GameProfile profile = getTE(((CraftSkull) skull)).getGameProfile();
if (profile == null) {
return null;
}
Expand All @@ -41,15 +55,15 @@ public void setPlayerProfile(Skull skull, PlayerProfile playerProfile) {
gameProfile.getProperties().put("textures",
new Property("textures", playerProfile.getTexture(), playerProfile.getTextureSignature()));
}
TileEntitySkull tileEntity = ((CraftSkull) skull).getTileEntity();
TileEntitySkull tileEntity = getTE((CraftSkull) skull);
tileEntity.setSkullType(SkullType.PLAYER.ordinal());
tileEntity.setGameProfile(gameProfile);
skull.getBlock().getState().update();
}

@Override
public CompoundTag getNbtData(Block block) {
TileEntity tileEntity = ((CraftBlockState) block.getState()).getTileEntity();
TileEntity tileEntity = getTE((CraftBlockEntityState) (CraftBlockState) block.getState());
if (tileEntity == null) {
return null;
}
Expand All @@ -58,11 +72,11 @@ public CompoundTag getNbtData(Block block) {

@Override
public void setNbtData(Block block, CompoundTag compoundTag) {
TileEntity tileEntity = ((CraftBlockState) block.getState()).getTileEntity();
TileEntity tileEntity = getTE((CraftBlockEntityState) (CraftBlockState) block.getState());
if (tileEntity == null) {
return;
}
tileEntity.a(((CompoundTag_v1_12_R1) compoundTag).toNMSTag());
tileEntity.load(((CompoundTag_v1_12_R1) compoundTag).toNMSTag());
tileEntity.update();
}

Expand Down
Expand Up @@ -2,12 +2,14 @@

import net.aufdemrand.denizen.nms.NMSHandler;
import net.aufdemrand.denizen.nms.interfaces.FakePlayer;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;

import java.util.HashSet;
import java.util.List;

public class CraftFakePlayer_v1_12_R1 extends CraftPlayer implements FakePlayer {
Expand Down Expand Up @@ -50,4 +52,14 @@ public String getEntityTypeName() {
public String getFullName() {
return fullName;
}

@Override
public Block getTargetBlock(HashSet<Byte> hashSet, int i) {
return null;
}

@Override
public List<Block> getLastTwoTargetBlocks(HashSet<Byte> hashSet, int i) {
return null;
}
}

0 comments on commit ebba776

Please sign in to comment.