Make people not get into a command block?

Discussion in 'Plugin Development' started by Whomp54, Sep 8, 2013.

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

    Whomp54

    Is it possible to do? I want this in a PlayerInteractEvent.
     
  2. I'm not certain, but can't non-ops not access or at least not modify command blocks?
     
  3. Offline

    Whomp54

    The Gaming Grunts
    Well, yes that's true, but I want it so they can't get in them at all. Not even open the GUI.
     
  4. Offline

    tommycake50

    Tried cancelling the event?
     
  5. Offline

    Whomp54

    tommycake50
    yes, and i debugged it also to make sure the event was being cancelled and it is. the GUI still appears.
     
  6. Try something like this:

    Code:java
    1. @EventHandler
    2. public void onBlockClick(PlayerInteractEvent event){
    3. if (event.getAction() == RIGHT_CLICK_BLOCK){
    4. if (event.getItemClicked().equals(Material.COMMAND)){
    5. event.setCancelled(true);
    6. }
    7. }
    8. }
    9.  


    I thought of that off the top of my head. I'm not sure if it's entirely accurate, but it's worth a shot :p
     
  7. Offline

    tommycake50

    I think the GUI is client side.
    So you can't(Of course it gets the tile data from the server tho).
     
  8. Offline

    Whomp54

    tommycake50
    so i cannot do it is what you're saying?
     
  9. Offline

    tommycake50

    Correct.
    EDIT: unless of course you would like to use client side mods.
     
  10. Offline

    Whomp54

  11. Offline

    5pHiNxX

    hei @Whomp54:
    i found a solution:
    Code:java
    1. @EventHandler
    2. public void onBlockClick(PlayerInteractEvent event){
    3. Player player = event.getPlayer();
    4. if (event.getAction() == RIGHT_CLICK_BLOCK){
    5. if (event.getItemClicked().equals(Material.COMMAND)){
    6. player.closeInventory();
    7. event.setCancelled(true);
    8. }
    9. }
    10. }


    player.closeInventory() closes the CommandBlock "inventory" ;)
     
Thread Status:
Not open for further replies.

Share This Page