Help with EnderFurnace in MC1.8

Discussion in 'Spigot Plugin Development' started by Newpredator, Jun 29, 2016.

  1. Im programming an annihilation plugin. This plugin have an enderfurnace. I have this code but not is ender, (dont work).
    If someone can help me I will be very greatful




    Code (Text):
    package me.newpredator.Annihilation.listeners;
    import java.util.HashMap;

    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
    import org.bukkit.craftbukkit.v1_8_R1.inventory.CraftInventoryFurnace;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.InventoryHolder;

    import me.newpredator.Annihilation.Annihilation;
    import me.newpredator.Annihilation.object.GameTeam;
    import me.newpredator.Annihilation.object.PlayerMeta;
    import net.minecraft.server.v1_8_R1.EntityHuman;
    import net.minecraft.server.v1_8_R1.EntityPlayer;
    import net.minecraft.server.v1_8_R1.TileEntityFurnace;

    public class EnderFurnaceListener
      implements Listener
    {
      private HashMap<GameTeam, Location> locations;
      private HashMap<String, VirtualFurnace> furnaces;
     
      public EnderFurnaceListener(Annihilation plugin)
      {
        this.locations = new HashMap<GameTeam, Location>();
        this.furnaces = new HashMap<String, VirtualFurnace>();
       
        Bukkit.getScheduler().runTaskTimer(plugin, new Runnable()
        {
          public void run()
          {
            for (EnderFurnaceListener.VirtualFurnace f : EnderFurnaceListener.this.furnaces.values()) {
              try
              {
                f.c();
              }
              catch (Exception localException) {}
            }
          }
        }, 0L, 1L);
      }
     
      public void setFurnaceLocation(GameTeam team, Location loc)
      {
        this.locations.put(team, loc);
      }
     
      @EventHandler
      public void onFurnaceOpen(PlayerInteractEvent e)
      {
        if (e.getAction() != Action.RIGHT_CLICK_BLOCK) {
          return;
        }
        Block b = e.getClickedBlock();
        if (b.getType() != Material.BURNING_FURNACE) {
          return;
        }
        Location loc = b.getLocation();
        Player player = e.getPlayer();
        GameTeam team = PlayerMeta.getMeta(player).getTeam();
        if ((team == null) || (!this.locations.containsKey(team))) {
          return;
        }
        if (((Location)this.locations.get(team)).equals(loc))
        {
          EntityPlayer handle = ((CraftPlayer)player).getHandle();
          handle.openContainer(getFurnace(player));
          player.sendMessage(Annihilation.getInstance().getConfig().getString("prefix").replace("&", "§") + " §7Has entrado en el horno §3PRIVADO.");
        }
        else if (this.locations.containsValue(loc))
        {
          e.setCancelled(true);
        }
      }
     
      @EventHandler
      public void onFurnaceBreak(BlockBreakEvent e)
      {
        if (this.locations.values().contains(e.getBlock().getLocation())) {
          e.setCancelled(true);
        }
      }
     
      private VirtualFurnace getFurnace(Player player)
      {
        if (!this.furnaces.containsKey(player.getName()))
        {
          EntityPlayer handle = ((CraftPlayer)player).getHandle();
          this.furnaces.put(player.getName(), new VirtualFurnace(handle));
        }
        return (VirtualFurnace)this.furnaces.get(player.getName());
      }
     
      public class VirtualFurnace
        extends TileEntityFurnace
      {
        public VirtualFurnace(EntityHuman entity)
        {
          this.world = entity.world;
        }
       

        public InventoryHolder getOwner()
        {
          return new InventoryHolder()
          {
            public Inventory getInventory()
            {
              return new CraftInventoryFurnace(EnderFurnaceListener.VirtualFurnace.this);
            }
          };
        }
      }
    }
     
     
  2. MiniDigger

    Supporter

    what are you actually trying to do? what is an ender furnace?
     
  3. Its a furnace but is ender like the enderchest. Is a private furnace. Like shotbow network.
    This code dont get nothing erros in the console. But dont is ender :(, for the 1.7 work.