mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-26 17:31:38 +01:00
Build 51
# Fixed IOOBE when items are set in a container at a slot greater than the container size. # Fixed NPE when a flower pot is placed without content when a structure is pasted on island creation. # Fixed NPE when saving a structure with flower pots for 1.10-1.12 servers # Fixed NSME when a flower pot is placed when a structure is pasted on island creation. # Fixed permission message being sent to a player when they feed a pig with baked or poisonous potatoes when 'AnimalTaming' setting is disabled. # Fixed permission message being sent to a player when they feed a wolf with cod when 'AnimalTaming' setting is disabled. # Fixed players being able to feed ocelots with raw salmon, tropical fish, puffer fish when 'AnimalTaming' setting is disabled on 1.13 servers. # Fixed players being able to feed chickens with beetroot seeds when 'AnimalTaming' setting is disabled. # Fixed players being able to feed turtles when 'AnimalTaming' setting is disabled. # Fixed players being able to feed llamas when 'AnimalTaming' setting is disabled. # Fixed the structure tool selection not working since build 50. # Fixed events not being unregistered when reloading the plugin.
This commit is contained in:
parent
58510f2090
commit
70e7bef250
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SkyBlock</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>50</version>
|
||||
<version>51</version>
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
<plugins>
|
||||
|
@ -2,6 +2,7 @@ package me.goodandevil.skyblock;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -190,6 +191,8 @@ public class SkyBlock extends JavaPlugin {
|
||||
if (this.ownershipManager != null) {
|
||||
this.ownershipManager.onDisable();
|
||||
}
|
||||
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
public static SkyBlock getInstance() {
|
||||
|
@ -394,33 +394,6 @@ public class Interact implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getItem() != null) {
|
||||
try {
|
||||
ItemStack structureTool = StructureUtil.getTool();
|
||||
|
||||
if ((event.getItem().getType() == structureTool.getType()) && (event.getItem().hasItemMeta())
|
||||
&& (event.getItem().getItemMeta().getDisplayName()
|
||||
.equals(structureTool.getItemMeta().getDisplayName()))) {
|
||||
if (player.hasPermission("skyblock.admin.structure.selection")
|
||||
|| player.hasPermission("skyblock.admin.structure.*")
|
||||
|| player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
skyblock.getPlayerDataManager().getPlayerData(player).getArea().setPosition(2,
|
||||
block.getLocation());
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager()
|
||||
.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Structure.Tool.Position.Message")
|
||||
.replace("%position", "2"));
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
if (player.getTargetBlock((Set<Material>) null, 5).getType() == Material.FIRE) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Fire")) {
|
||||
@ -432,33 +405,6 @@ public class Interact implements Listener {
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getItem() != null) {
|
||||
try {
|
||||
ItemStack structureTool = StructureUtil.getTool();
|
||||
|
||||
if ((event.getItem().getType() == structureTool.getType()) && (event.getItem().hasItemMeta())
|
||||
&& (event.getItem().getItemMeta().getDisplayName()
|
||||
.equals(structureTool.getItemMeta().getDisplayName()))) {
|
||||
if (player.hasPermission("skyblock.admin.structure.selection")
|
||||
|| player.hasPermission("skyblock.admin.structure.*")
|
||||
|| player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
skyblock.getPlayerDataManager().getPlayerData(player).getArea().setPosition(1,
|
||||
block.getLocation());
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager()
|
||||
.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Structure.Tool.Position.Message")
|
||||
.replace("%position", "1"));
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == Action.PHYSICAL) {
|
||||
if (block.getType() == Materials.FARMLAND.parseMaterial()) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Crop")) {
|
||||
@ -493,6 +439,65 @@ public class Interact implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteractStructure(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
if (event.getItem() != null) {
|
||||
try {
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
ItemStack structureTool = StructureUtil.getTool();
|
||||
|
||||
if ((event.getItem().getType() == structureTool.getType()) && (event.getItem().hasItemMeta())
|
||||
&& (event.getItem().getItemMeta().getDisplayName()
|
||||
.equals(structureTool.getItemMeta().getDisplayName()))) {
|
||||
if (player.hasPermission("skyblock.admin.structure.selection")
|
||||
|| player.hasPermission("skyblock.admin.structure.*")
|
||||
|| player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
skyblock.getPlayerDataManager().getPlayerData(player).getArea().setPosition(1,
|
||||
event.getClickedBlock().getLocation());
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager()
|
||||
.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Structure.Tool.Position.Message")
|
||||
.replace("%position", "1"));
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
ItemStack structureTool = StructureUtil.getTool();
|
||||
|
||||
if ((event.getItem().getType() == structureTool.getType()) && (event.getItem().hasItemMeta())
|
||||
&& (event.getItem().getItemMeta().getDisplayName()
|
||||
.equals(structureTool.getItemMeta().getDisplayName()))) {
|
||||
if (player.hasPermission("skyblock.admin.structure.selection")
|
||||
|| player.hasPermission("skyblock.admin.structure.*")
|
||||
|| player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
skyblock.getPlayerDataManager().getPlayerData(player).getArea().setPosition(2,
|
||||
event.getClickedBlock().getLocation());
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager()
|
||||
.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Structure.Tool.Position.Message")
|
||||
.replace("%position", "2"));
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||
@ -612,14 +617,19 @@ public class Interact implements Listener {
|
||||
}
|
||||
} else if (entity.getType() == EntityType.PIG) {
|
||||
if (!(is.getType() == Materials.CARROT.parseMaterial()
|
||||
|| is.getType() == Materials.POTATO.parseMaterial() || is.getType() == Material.BAKED_POTATO
|
||||
|| is.getType() == Material.POISONOUS_POTATO)) {
|
||||
|| is.getType() == Materials.POTATO.parseMaterial())) {
|
||||
return;
|
||||
}
|
||||
} else if (entity.getType() == EntityType.CHICKEN) {
|
||||
if (!(is.getType() == Materials.WHEAT_SEEDS.parseMaterial() || is.getType() == Material.PUMPKIN_SEEDS
|
||||
|| is.getType() == Material.MELON_SEEDS)) {
|
||||
return;
|
||||
if (NMSUtil.getVersionNumber() > 8) {
|
||||
if (!(is.getType() == Materials.BEETROOT_SEEDS.parseMaterial())) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (entity.getType() == EntityType.WOLF) {
|
||||
if (!(is.getType() == Material.BONE || is.getType() == Materials.PORKCHOP.parseMaterial()
|
||||
@ -628,13 +638,13 @@ public class Interact implements Listener {
|
||||
|| is.getType() == Material.MUTTON || is.getType() == Material.ROTTEN_FLESH
|
||||
|| is.getType() == Materials.COOKED_PORKCHOP.parseMaterial()
|
||||
|| is.getType() == Material.COOKED_BEEF || is.getType() == Material.COOKED_CHICKEN
|
||||
|| is.getType() == Material.COOKED_RABBIT || is.getType() == Material.COOKED_MUTTON
|
||||
|| is.getType() == Materials.COD.parseMaterial()
|
||||
|| is.getType() == Materials.COOKED_COD.parseMaterial())) {
|
||||
|| is.getType() == Material.COOKED_RABBIT || is.getType() == Material.COOKED_MUTTON)) {
|
||||
return;
|
||||
}
|
||||
} else if (entity.getType() == EntityType.OCELOT) {
|
||||
if (!(is.getType() == Materials.COD.parseMaterial())) {
|
||||
if (!(is.getType() == Materials.COD.parseMaterial() || is.getType() == Materials.SALMON.parseMaterial()
|
||||
|| is.getType() == Materials.TROPICAL_FISH.parseMaterial()
|
||||
|| is.getType() == Materials.PUFFERFISH.parseMaterial())) {
|
||||
return;
|
||||
}
|
||||
} else if (entity.getType() == EntityType.RABBIT) {
|
||||
@ -644,7 +654,27 @@ public class Interact implements Listener {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
int NMSVersion = NMSUtil.getVersionNumber();
|
||||
|
||||
if (NMSVersion > 10) {
|
||||
if (entity.getType() == EntityType.LLAMA) {
|
||||
if (!(is.getType() == Materials.HAY_BLOCK.parseMaterial())) {
|
||||
return;
|
||||
}
|
||||
} else if (NMSVersion > 12) {
|
||||
if (entity.getType() == EntityType.TURTLE) {
|
||||
if (!(is.getType() == Materials.SEAGRASS.parseMaterial())) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!islandManager.hasPermission(player, entity.getLocation(), "AnimalBreeding")) {
|
||||
|
@ -95,7 +95,6 @@ public class nInventoryUtil {
|
||||
}
|
||||
};
|
||||
|
||||
// TODO Check if listener is already registered
|
||||
Bukkit.getPluginManager().registerEvents(listener, SkyBlock.getInstance());
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.goodandevil.skyblock.utils.world.block;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -210,7 +211,7 @@ public final class BlockUtil {
|
||||
blockData.setFacing(((Stairs) materialData).getFacing().toString());
|
||||
blockData.setDataType(BlockDataType.STAIRS.toString());
|
||||
} else if (materialData instanceof org.bukkit.material.FlowerPot) {
|
||||
if (NMSVersion == 8 || NMSVersion == 9) {
|
||||
if (NMSVersion >= 8 && NMSVersion <= 12) {
|
||||
try {
|
||||
World world = block.getWorld();
|
||||
|
||||
@ -221,22 +222,36 @@ public final class BlockUtil {
|
||||
.newInstance(block.getX(), block.getY(), block.getZ());
|
||||
Object tileEntity = worldHandle.getClass().getMethod("getTileEntity", blockPositionClass)
|
||||
.invoke(worldHandle, blockPosition);
|
||||
Object item = tileEntity.getClass().getMethod("b").invoke(tileEntity);
|
||||
Object itemStackNMS = NMSUtil.getNMSClass("ItemStack").getConstructor(NMSUtil.getNMSClass("Item"))
|
||||
.newInstance(item);
|
||||
|
||||
ItemStack itemStack = (ItemStack) NMSUtil.getCraftClass("inventory.CraftItemStack")
|
||||
.getMethod("asBukkitCopy", itemStackNMS.getClass()).invoke(null, itemStackNMS);
|
||||
int data = (int) tileEntity.getClass().getMethod("c").invoke(tileEntity);
|
||||
Field aField = tileEntity.getClass().getDeclaredField("a");
|
||||
aField.setAccessible(true);
|
||||
|
||||
blockData.setFlower(itemStack.getType().name() + ":" + data);
|
||||
Object item = aField.get(tileEntity);
|
||||
|
||||
if (item != null) {
|
||||
Object itemStackNMS = NMSUtil.getNMSClass("ItemStack")
|
||||
.getConstructor(NMSUtil.getNMSClass("Item")).newInstance(item);
|
||||
|
||||
ItemStack itemStack = (ItemStack) NMSUtil.getCraftClass("inventory.CraftItemStack")
|
||||
.getMethod("asBukkitCopy", itemStackNMS.getClass()).invoke(null, itemStackNMS);
|
||||
|
||||
Field fField = tileEntity.getClass().getDeclaredField("f");
|
||||
fField.setAccessible(true);
|
||||
|
||||
int data = (int) fField.get(tileEntity);
|
||||
|
||||
blockData.setFlower(itemStack.getType().name() + ":" + data);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
org.bukkit.material.FlowerPot flowerPot = (org.bukkit.material.FlowerPot) materialData;
|
||||
blockData.setFlower(
|
||||
flowerPot.getContents().getItemType().toString() + ":" + flowerPot.getContents().getData());
|
||||
|
||||
if (flowerPot.getContents() != null && flowerPot.getContents().getItemType() != Material.AIR) {
|
||||
blockData.setFlower(
|
||||
flowerPot.getContents().getItemType().toString() + ":" + flowerPot.getContents().getData());
|
||||
}
|
||||
}
|
||||
|
||||
blockData.setDataType(BlockDataType.FLOWERPOT.toString());
|
||||
@ -281,8 +296,10 @@ public final class BlockUtil {
|
||||
beacon.setSecondaryEffect(PotionEffectType.getByName(potionEffect[1].toUpperCase()));
|
||||
|
||||
for (Integer slotList : blockData.getInventory().keySet()) {
|
||||
ItemStack is = ItemStackUtil.deserializeItemStack(blockData.getInventory().get(slotList));
|
||||
beacon.getInventory().setItem(slotList, is);
|
||||
if (slotList < beacon.getInventory().getSize()) {
|
||||
ItemStack is = ItemStackUtil.deserializeItemStack(blockData.getInventory().get(slotList));
|
||||
beacon.getInventory().setItem(slotList, is);
|
||||
}
|
||||
}
|
||||
} else if (blockTypeState == BlockStateType.BREWINGSTAND) {
|
||||
BrewingStand brewingStand = (BrewingStand) block.getState();
|
||||
@ -296,29 +313,37 @@ public final class BlockUtil {
|
||||
Chest chest = (Chest) block.getState();
|
||||
|
||||
for (Integer slotList : blockData.getInventory().keySet()) {
|
||||
ItemStack is = ItemStackUtil.deserializeItemStack(blockData.getInventory().get(slotList));
|
||||
chest.getInventory().setItem(slotList, is);
|
||||
if (slotList < chest.getInventory().getSize()) {
|
||||
ItemStack is = ItemStackUtil.deserializeItemStack(blockData.getInventory().get(slotList));
|
||||
chest.getInventory().setItem(slotList, is);
|
||||
}
|
||||
}
|
||||
} else if (blockTypeState == BlockStateType.DISPENSER) {
|
||||
Dispenser dispenser = (Dispenser) block.getState();
|
||||
|
||||
for (Integer slotList : blockData.getInventory().keySet()) {
|
||||
ItemStack is = ItemStackUtil.deserializeItemStack(blockData.getInventory().get(slotList));
|
||||
dispenser.getInventory().setItem(slotList, is);
|
||||
if (slotList < dispenser.getInventory().getSize()) {
|
||||
ItemStack is = ItemStackUtil.deserializeItemStack(blockData.getInventory().get(slotList));
|
||||
dispenser.getInventory().setItem(slotList, is);
|
||||
}
|
||||
}
|
||||
} else if (blockTypeState == BlockStateType.DROPPER) {
|
||||
Dropper dropper = (Dropper) block.getState();
|
||||
|
||||
for (Integer slotList : blockData.getInventory().keySet()) {
|
||||
ItemStack is = ItemStackUtil.deserializeItemStack(blockData.getInventory().get(slotList));
|
||||
dropper.getInventory().setItem(slotList, is);
|
||||
if (slotList < dropper.getInventory().getSize()) {
|
||||
ItemStack is = ItemStackUtil.deserializeItemStack(blockData.getInventory().get(slotList));
|
||||
dropper.getInventory().setItem(slotList, is);
|
||||
}
|
||||
}
|
||||
} else if (blockTypeState == BlockStateType.HOPPER) {
|
||||
Hopper hopper = (Hopper) block.getState();
|
||||
|
||||
for (Integer slotList : blockData.getInventory().keySet()) {
|
||||
ItemStack is = ItemStackUtil.deserializeItemStack(blockData.getInventory().get(slotList));
|
||||
hopper.getInventory().setItem(slotList, is);
|
||||
if (slotList < hopper.getInventory().getSize()) {
|
||||
ItemStack is = ItemStackUtil.deserializeItemStack(blockData.getInventory().get(slotList));
|
||||
hopper.getInventory().setItem(slotList, is);
|
||||
}
|
||||
}
|
||||
} else if (blockTypeState == BlockStateType.CREATURESPAWNER) {
|
||||
CreatureSpawner creatureSpawner = (CreatureSpawner) block.getState();
|
||||
@ -330,8 +355,10 @@ public final class BlockUtil {
|
||||
furnace.setCookTime(blockData.getCookTime());
|
||||
|
||||
for (Integer slotList : blockData.getInventory().keySet()) {
|
||||
ItemStack is = ItemStackUtil.deserializeItemStack(blockData.getInventory().get(slotList));
|
||||
furnace.getInventory().setItem(slotList, is);
|
||||
if (slotList < furnace.getInventory().getSize()) {
|
||||
ItemStack is = ItemStackUtil.deserializeItemStack(blockData.getInventory().get(slotList));
|
||||
furnace.getInventory().setItem(slotList, is);
|
||||
}
|
||||
}
|
||||
} else if (blockTypeState == BlockStateType.JUKEBOX) {
|
||||
Jukebox jukebox = (Jukebox) block.getState();
|
||||
@ -372,9 +399,11 @@ public final class BlockUtil {
|
||||
ShulkerBox shulkerBox = (ShulkerBox) block.getState();
|
||||
|
||||
for (Integer slotList : blockData.getInventory().keySet()) {
|
||||
ItemStack is = ItemStackUtil
|
||||
.deserializeItemStack(blockData.getInventory().get(slotList));
|
||||
shulkerBox.getInventory().setItem(slotList, is);
|
||||
if (slotList < shulkerBox.getInventory().getSize()) {
|
||||
ItemStack is = ItemStackUtil
|
||||
.deserializeItemStack(blockData.getInventory().get(slotList));
|
||||
shulkerBox.getInventory().setItem(slotList, is);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,63 +418,74 @@ public final class BlockUtil {
|
||||
stairs.setFacingDirection(BlockFace.valueOf(blockData.getFacing()));
|
||||
block.getState().setData(stairs);
|
||||
} else if (blockDataType == BlockDataType.FLOWERPOT) {
|
||||
if (NMSVersion == 8 || NMSVersion == 9) {
|
||||
if (NMSVersion >= 8 && NMSVersion <= 12) {
|
||||
if (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.AIR) {
|
||||
setBlockFast(block.getWorld(), block.getX(), block.getY() - 1, block.getZ(), Material.STONE,
|
||||
(byte) 0);
|
||||
}
|
||||
|
||||
try {
|
||||
String[] flower = blockData.getFlower().split(":");
|
||||
int materialData = Integer.parseInt(flower[1]);
|
||||
if (blockData.getFlower() != null && !blockData.getFlower().isEmpty()) {
|
||||
try {
|
||||
String[] flower = blockData.getFlower().split(":");
|
||||
int materialData = Integer.parseInt(flower[1]);
|
||||
|
||||
material = me.goodandevil.skyblock.utils.item.MaterialUtil.getMaterial(NMSVersion,
|
||||
blockData.getVersion(), flower[0].toUpperCase(), materialData);
|
||||
material = me.goodandevil.skyblock.utils.item.MaterialUtil.getMaterial(NMSVersion,
|
||||
blockData.getVersion(), flower[0].toUpperCase(), materialData);
|
||||
|
||||
if (material != null) {
|
||||
ItemStack is = new ItemStack(material, 1, (byte) materialData);
|
||||
if (material != null) {
|
||||
ItemStack is = new ItemStack(material, 1, (byte) materialData);
|
||||
|
||||
World world = block.getWorld();
|
||||
World world = block.getWorld();
|
||||
|
||||
Class<?> blockPositionClass = NMSUtil.getNMSClass("BlockPosition");
|
||||
Class<?> blockPositionClass = NMSUtil.getNMSClass("BlockPosition");
|
||||
|
||||
Object worldHandle = world.getClass().getMethod("getHandle").invoke(world);
|
||||
Object blockPosition = blockPositionClass.getConstructor(int.class, int.class, int.class)
|
||||
.newInstance(block.getX(), block.getY(), block.getZ());
|
||||
Object tileEntity = worldHandle.getClass().getMethod("getTileEntity", blockPositionClass)
|
||||
.invoke(worldHandle, blockPosition);
|
||||
Object itemStack = NMSUtil.getCraftClass("inventory.CraftItemStack")
|
||||
.getMethod("asNMSCopy", is.getClass()).invoke(null, is);
|
||||
Object item = itemStack.getClass().getMethod("getItem").invoke(itemStack);
|
||||
Object data = itemStack.getClass().getMethod("getData").invoke(itemStack);
|
||||
Object worldHandle = world.getClass().getMethod("getHandle").invoke(world);
|
||||
Object blockPosition = blockPositionClass.getConstructor(int.class, int.class, int.class)
|
||||
.newInstance(block.getX(), block.getY(), block.getZ());
|
||||
Object tileEntity = worldHandle.getClass().getMethod("getTileEntity", blockPositionClass)
|
||||
.invoke(worldHandle, blockPosition);
|
||||
Object itemStack = NMSUtil.getCraftClass("inventory.CraftItemStack")
|
||||
.getMethod("asNMSCopy", is.getClass()).invoke(null, is);
|
||||
Object item = itemStack.getClass().getMethod("getItem").invoke(itemStack);
|
||||
Object data = itemStack.getClass().getMethod("getData").invoke(itemStack);
|
||||
|
||||
tileEntity.getClass().getMethod("a", NMSUtil.getNMSClass("Item"), int.class).invoke(tileEntity,
|
||||
item, data);
|
||||
tileEntity.getClass().getMethod("update").invoke(tileEntity);
|
||||
Field aField = tileEntity.getClass().getDeclaredField("a");
|
||||
aField.setAccessible(true);
|
||||
aField.set(tileEntity, item);
|
||||
|
||||
Field fField = tileEntity.getClass().getDeclaredField("f");
|
||||
fField.setAccessible(true);
|
||||
fField.set(tileEntity, data);
|
||||
|
||||
tileEntity.getClass().getMethod("update").invoke(tileEntity);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
org.bukkit.material.FlowerPot flowerPot = (org.bukkit.material.FlowerPot) block.getState().getData();
|
||||
String[] flower = blockData.getFlower().split(":");
|
||||
material = null;
|
||||
if (blockData.getFlower() != null && !blockData.getFlower().isEmpty()) {
|
||||
org.bukkit.material.FlowerPot flowerPot = (org.bukkit.material.FlowerPot) block.getState()
|
||||
.getData();
|
||||
String[] flower = blockData.getFlower().split(":");
|
||||
material = null;
|
||||
|
||||
if (blockData.getVersion() > 12) {
|
||||
if (NMSVersion > 12) {
|
||||
material = Material.valueOf(flower[0].toUpperCase());
|
||||
if (blockData.getVersion() > 12) {
|
||||
if (NMSVersion > 12) {
|
||||
material = Material.valueOf(flower[0].toUpperCase());
|
||||
}
|
||||
} else {
|
||||
if (NMSVersion < 13) {
|
||||
material = Material.valueOf(flower[0].toUpperCase());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (NMSVersion < 13) {
|
||||
material = Material.valueOf(flower[0].toUpperCase());
|
||||
|
||||
if (material != null) {
|
||||
flowerPot.setContents(new MaterialData(material, (byte) Integer.parseInt(flower[1])));
|
||||
}
|
||||
}
|
||||
|
||||
if (material != null) {
|
||||
flowerPot.setContents(new MaterialData(material, (byte) Integer.parseInt(flower[1])));
|
||||
block.getState().setData(flowerPot);
|
||||
}
|
||||
|
||||
block.getState().setData(flowerPot);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: SkyBlock
|
||||
main: me.goodandevil.skyblock.SkyBlock
|
||||
version: 50
|
||||
version: 51
|
||||
api-version: 1.13
|
||||
description: A unique SkyBlock plugin
|
||||
author: GoodAndEvil
|
||||
|
Loading…
Reference in New Issue
Block a user