Filled instant pickup drops

Discussion in 'Plugin Requests' started by cato11112, May 15, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    cato11112

    I need a plugin that make it so if you mine a block you will instantly pick it up. you will be able to drop items but you will be able to instantly pickup the blocks you mine.
     
  2. Offline

    Jomens235

  3. Offline

    cato11112

    you just made it?
    EDIT: it is working but it picks up the exactly same block type that i mine. this plugin should be renamed to PermanentSilktouch
     
    Last edited: May 16, 2015
  4. Offline

    Jomens235

    @cato11112 Would you like me to change it then? I didn't think you wanted anything else other than to pick up what you break.
     
  5. Offline

    cato11112

    what i meant was a plugin that picks up what you normaly would get without silk touch. can you make it so you can use a silktouch tool to pick up everything like the first version of the plugin instead?
     
  6. Offline

    Rascal Two

    Unfortunately I'm on mobile and can't test this code, but what I'd do is this:

    Code:java
    1.  
    2. public void onBlockBreakEvent(BlockBreakEvent e){
    3. e.setCanclled(true);
    4. e.getPlayer().getInventory().addItem(e.getBlock().getDrops().get(o));
    5. e.getBlock().setType(Material.AIR);
    6. }
    7.  


    Seems right in my head, will edit later if it's right/wrong.

    What You @cato11112 have probably done is this:
    Code:java
    1.  
    2. e.getPlayer().getInventory().addItem(new ItemStack(e.getBlock().getType()));
    3.  
     
  7. Offline

    Jomens235

    Last edited: May 19, 2015
  8. Offline

    Rascal Two

    @Jomens235
    Yea the code I had was a little wrong but the concept was correct:

    Code:java
    1.  
    2. public void onBlockBreakEvent(BlockBreakEvent e){
    3. e.setCancelled(true); // Or don't, it does not make a apparent difference
    4. ArrayList<ItemStack> drops = (ArrayList<ItemStack>) e.getBlock().getDrops();
    5. e.getPlayer().getInventory().addItem(drops.get(0));
    6. e.getBlock().setType(Material.AIR);
    7. }
    8.  


    When I tested it out setting the event to cancelled dosen't seem to do anything different compared to not canceling it. Probably safer to not set it canceled anyway :)
     
  9. Offline

    Jomens235

    @Rascal Two Oh. I didn't use that in mine because I thought it would set breaking the block to false... :eek:
     
  10. Offline

    cato11112

    The plugin works great now. Ty
     
    Last edited: May 20, 2015
  11. Offline

    Rascal Two

    Don't forget to set the thread to Filled ;)
     
  12. Offline

    cato11112

    Ty for reminding me on that. totally forgot that :p
     
Thread Status:
Not open for further replies.

Share This Page