Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.maxtheorange.Signs;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.inventory.InventoryCloseEvent;
- import org.bukkit.ChatColor;
- import org.bukkit.Material;
- import org.bukkit.Server;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.PlayerInventory;
- import org.bukkit.inventory.meta.BookMeta;
- import org.bukkit.scheduler.BukkitRunnable;
- import org.bukkit.block.Sign;
- import org.bukkit.command.CommandSender;
- public class Books implements Listener{
- public Books(Main instance){
- Main plugin = instance; //Unused Here
- }
- @EventHandler
- public void onPlayerInteract(PlayerInteractEvent e){
- final Player p = e.getPlayer();
- if(e.getAction() == Action.RIGHT_CLICK_BLOCK){
- if(e.getClickedBlock().getType() == Material.WALL_SIGN || e.getClickedBlock().getType() == Material.SIGN_POST){
- Sign sign = (Sign) e.getClickedBlock().getState();
- if(sign.getLine(0).equals("[Book]")){
- PlayerInventory inventory = p.getInventory();
- ItemStack book = new ItemStack(Material.WRITTEN_BOOK, 1);
- BookMeta bm = (BookMeta) book.getItemMeta();
- bm.addPage("Hello THIS IS MY BOOK! GO AWAY I LIKE BOOKS!", "THIS IS STILL MY BOOK");
- bm.setAuthor("SonicPvP");
- bm.setTitle("The Awesome Book");
- book.setItemMeta(bm);
- inventory.addItem(book);
- //player receives book
- new BukkitRunnable() {
- @SuppressWarnings("deprecated") //Unused here
- public void run() {
- for(ItemStack is : p.getInventory().getContents()) {
- if(is.getType() == Material.BOOK) {
- //check meta if you want
- is.setType(Material.AIR);
- p.updateInventory(); // Unused Here
- }
- }
- }
- }.runTaskLater(plugin, 600L); // Plugin cannot be resolved to a variable
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement