How To Make Infinite Chest Plugin?

Discussion in 'Plugin Development' started by Ambamore2000, Dec 25, 2013.

  1. Offline

    Ambamore2000

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    All I got so far:
    Code:java
    1. package me.Ambamore2000.Plugin;
    2.  
    3. import org.bukkit.plugin.java.JavaPlugin;
    4.  
    5. public final class Plugin extends JavaPlugin {
    6.  
    7. @Override
    8. public void onEnable(){
    9. getLogger().info("Enabled!");
    10.  
    11. }
    12. @Override
    13. public void onDisable(){
    14. getLogger().info("Disabled!");
    15. }
    16.  
    17. }

    I wanted to make an infinite chest thing (Part of a plugin I am working on) but I am stuck. Please help me.
  2. Offline

    Gater12

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  3. Offline

    Ambamore2000

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @Gater12 No, like, it is infinite. So, like, when you take something out, the items are put back in, but you still keep it.
  4. Offline

    Gater12

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @Ambamore2000 Listen for InventoryClickEvent. If it's from a special inventory, get the clicked item, cancel the event, and add the clicked item to the player's inventory.
  5. Offline

    Ambamore2000

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @Gater12
    Can you show me how to, just incase, 'cause I'm not sure if I'm correct.
  6. Offline

    Ambamore2000

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  7. Offline

    Gater12

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  8. Offline

    Ambamore2000

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Code:java
    1. package me.Ambamore2000.Plugin;
    2.  
    3. import org.bukkit.event.EventHandler;
    4. import org.bukkit.event.Listener;
    5. import org.bukkit.event.inventory.InventoryDragEvent;
    6. import org.bukkit.plugin.java.JavaPlugin;
    7.  
    8. public final class Mainclass extends JavaPlugin implements Listener {
    9. @Override
    10. public void onEnable(){
    11. getLogger().info("onEnable has been invoked!");
    12. }
    13. @Override
    14. public void onDisable(){
    15. getLogger().info("onDisable has been invoked!");
    16. }
    17. @EventHandler
    18. public void InvChest (InventoryDragEvent event) {
    19. }
    20. }


    --I only got the event part
    ----There is no InventoryClickEvent, so I put InventoryDragEvent, cause that sounds the closest related.
  9. Offline

    Gater12

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  10. Offline

    Ambamore2000

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  11. Offline

    Ambamore2000

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @Gater12
    Maybe, but can you do the rest for me? I'm not a... profetional.
  12. Offline

    sgavster

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Code:java
    1. public void onClick(InventoryClickEvent e) {
    2. //check if it's the right inventory
    3. if(e.getCurrentItem() == null) return;//make sure it's not null
    4. e.setCancelled(true);//cancel it
    5. Player p = (Player) e.getWhoClicked();
    6. p.getInventory().addItem(new ItemStack(e.getCurrentItem().getType(), e.getCurrentItem().getAmount(), (byte) e.getCurrentItem().getData());//add the item to their inventory
    7. }
  13. Offline

    Ambamore2000

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @sgavster
    So would it be:
    Code:java
    1. package me.Ambamore2000.Plugin;
    2.  
    3. import org.bukkit.event.EventHandler;
    4. import org.bukkit.event.Listener;
    5. import org.bukkit.event.inventory.InventoryDragEvent;
    6. import org.bukkit.plugin.java.JavaPlugin;
    7.  
    8. public final class Mainclass extends JavaPlugin implements Listener {
    9. @Override
    10. public void onEnable(){
    11. getLogger().info("onEnable has been invoked!");
    12. }
    13. @Override
    14. public void onDisable(){
    15. getLogger().info("onDisable has been invoked!");
    16. }
    17. @EventHandler
    18. public void onClick(InventoryClickEvent e) {
    19. //check if it's the right inventory
    20. if(e.getCurrentItem() == null) return;//make sure it's not null
    21. e.setCancelled(true);//cancel it
    22. Player p = (Player) e.getWhoClicked();
    23. p.getInventory().addItem(new ItemStack(e.getCurrentItem().getType(), e.getCurrentItem().getAmount(), (byte) e.getCurrentItem().getData());//add the item to their inventory
    24. }
  14. Offline

    Ambamore2000

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  15. Offline

    Darkrunner999

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    This is not correct. You say that you want infinite 'chests'. You need to get the contents of the chest, then return the item clicked by the player while the event is cancelled. However, your code does work, just not with chests.
  16. Offline

    Ambamore2000

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  17. Offline

    repsor

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    If you want others to code it for you, why don't you just make a plugin in request? :p
    _Cookie_ likes this.
  18. Offline

    sgavster

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    You need to register your events.
  19. Offline

    _AdamGinger

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I'm not very good with coding but is it similar to the [Free] signs from essentials? Is that what you are trying to achieve?
  20. Offline

    Ambamore2000

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @AdamGinger
    Sortof.
  21. Online

    AoH_Ruthless

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @Ambamore2000
    You cannot expect others to code for you ... The answer was given to you several times. I'm sorry to be rude, but you cannot just blindly copy and paste code, say it does not work, and expect someone else to spoonfeed you the answer.

    In your other recent posts, you mention not having a complete understanding of Java. I would strongly advise you to stop where you are and learn the fundamentals of java first.
    xTigerRebornx likes this.
  22. Offline

    Luke_Lax

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Like suggested before, either make a plugin request or take a look at TheNewBoston's YouTube bukkit coding tutorials :) asking people to do it for you and saying here's what I have (onEnable & disable) is kind of insulting :3
  23. Offline

    Ambamore2000

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @Gater12
    Somethings wrong. It doesn't say it exists on my eclipse.
  24. Offline

    Gater12

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  25. Offline

    Ambamore2000

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @Gater12
    No, it's fixed. I typed it wrong before (InventoryClikEvent) and then now typed it correctly, and imported it.

    --When you say, "Listen for InventoryClickEvent. If it's from a special inventory, get the clicked item, cancel the event, and add the clicked item to the player's inventory."
    I don't get the part from "If it's from a special inventory" thru the end.
  26. Offline

    xTigerRebornx

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @Ambamore2000 Check something about the inventory that would guarantees it is the inventory you want it to be (I.E. Give the inventory a unique name, then check for that name), "special inventory" is just referring to the inventory that you want to have infinite of the item
  27. Offline

    CeramicTitan BukkitDev Staff

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @Ambamore2000
    Why dont you look at the source of essentials and see how they do their free signs
  28. Offline

    xTigerRebornx

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @CeramicTitan Eh, I can pseudo-code the Free sign
    Player clicks sign->check if it is free sign->get block from sign->create inventory with max stack of item in everyslot->profit
  29. Offline

    CeramicTitan BukkitDev Staff

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    The infinite chest plugin is actually quite easy in heinsight.
    Listen to PlayerInteractEvent, check If the right clicked block is a chest, create a fake inventory and set that inventory to the chests inventory

    This post has been edited 1 time. It was last edited by CeramicTitan Dec 28, 2013.
  30. Offline

    Ambamore2000

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @CeramicTitan
    How to do "check If the right clicked block is a chest" and "create a fake inventory and set that inventory to the chests inventory"?

Share This Page