2012-06-08 15:28:36 +02:00
|
|
|
package com.Acrobot.Breeze.Utils;
|
|
|
|
|
2012-12-22 21:04:48 +01:00
|
|
|
import org.bukkit.Material;
|
2012-06-08 15:28:36 +02:00
|
|
|
import org.bukkit.block.Block;
|
|
|
|
import org.bukkit.block.Sign;
|
2012-12-26 21:42:22 +01:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.inventory.Inventory;
|
|
|
|
import org.bukkit.inventory.InventoryHolder;
|
2012-07-07 19:24:06 +02:00
|
|
|
import org.bukkit.material.Attachable;
|
2012-06-08 15:28:36 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Acrobot
|
|
|
|
*/
|
|
|
|
public class BlockUtil {
|
|
|
|
/**
|
|
|
|
* Checks if the block is a sign
|
|
|
|
*
|
|
|
|
* @param block Block to check
|
|
|
|
* @return Is this block a sign?
|
|
|
|
*/
|
|
|
|
public static boolean isSign(Block block) {
|
|
|
|
return block.getState() instanceof Sign;
|
|
|
|
}
|
2012-07-07 19:24:06 +02:00
|
|
|
|
2012-12-22 21:04:48 +01:00
|
|
|
/**
|
|
|
|
* Checks if the block is a chest
|
|
|
|
*
|
|
|
|
* @param block Block to check
|
|
|
|
* @return Is this block a chest?
|
|
|
|
*/
|
|
|
|
public static boolean isChest(Block block) {
|
|
|
|
return block.getType() == Material.CHEST;
|
|
|
|
}
|
|
|
|
|
2012-07-07 19:24:06 +02:00
|
|
|
/**
|
|
|
|
* Gets the block to which the sign is attached
|
|
|
|
*
|
|
|
|
* @param sign Sign which is attached
|
|
|
|
* @return Block to which the sign is attached
|
|
|
|
*/
|
|
|
|
public static Block getAttachedFace(Sign sign) {
|
|
|
|
return sign.getBlock().getRelative(((Attachable) sign.getData()).getAttachedFace());
|
|
|
|
}
|
2012-12-26 21:42:22 +01:00
|
|
|
|
|
|
|
/**
|
2012-12-31 02:34:39 +01:00
|
|
|
* Opens the holder's inventory GUI
|
2012-12-26 21:42:22 +01:00
|
|
|
*
|
2012-12-31 02:34:39 +01:00
|
|
|
* @param holder Inventory holder
|
2012-12-26 21:42:22 +01:00
|
|
|
* @param player Player on whose screen the GUI is going to be shown
|
|
|
|
* @return Was the opening successful?
|
|
|
|
*/
|
2012-12-31 02:34:39 +01:00
|
|
|
public static boolean openBlockGUI(InventoryHolder holder, Player player) {
|
|
|
|
Inventory inventory = holder.getInventory();
|
2012-12-26 21:42:22 +01:00
|
|
|
player.openInventory(inventory);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2012-06-08 15:28:36 +02:00
|
|
|
}
|