Solved Clear Inventory [Trash]

Discussion in 'Plugin Development' started by badboysteee98, May 3, 2014.

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

    badboysteee98

    So I need to make a Trash sign for my Server but this is the problem I'm getting.

    When I put something into the Trash sign it saves where I want it to clear every time I open it. Anyway I can do this

    My Code (Main Class)
    Code:java
    1. private Bin bin;
    2.  
    3. public void onEnable() {
    4.  
    5. bin = new Bin(this);
    6. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    7. }
    8.  
    9. @EventHandler
    10. public void onPlayerInteract(PlayerInteractEvent e) {
    11. Player player = e.getPlayer();
    12.  
    13. if(!(e.getAction() == Action.RIGHT_CLICK_BLOCK)) return;
    14.  
    15. if(e.getClickedBlock().getState() instanceof Sign) {
    16. Sign s = (Sign) e.getClickedBlock().getState();
    17. if(s.getLine(1).equalsIgnoreCase("§lTrash")) {
    18. bin.show(player);
    19. }
    20. }
    21.  
    22. }


    My Code (Menu Class)
    Code:java
    1. private Inventory inv;
    2.  
    3. @EventHandler
    4. public void onSignChange(SignChangeEvent e) {
    5. if(e.getLine(0).equalsIgnoreCase("[Trash]")) {
    6. e.setLine(0, "");
    7. e.setLine(1, ChatColor.BOLD + "Trash");
    8. }
    9. }
    10.  
    11. public Bin(Plugin p) {
    12. inv = Bukkit.getServer().createInventory(null, 36, "Trash Bin");
    13.  
    14. Bukkit.getServer().getPluginManager().registerEvents(this, p);
    15. }
    16.  
    17. public void show(Player p) {
    18. p.openInventory(inv);
    19. }


    Thanks in advanced for the help :)

    Anyone know how to do this?

    Bumping this as I would need it doing today

    If any will point me in the right direct that will help also :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
Thread Status:
Not open for further replies.

Share This Page