What event tracks command blocks?

Discussion in 'Spigot Plugin Development' started by TheGamerPlayz, Jun 2, 2016.

  1. What event is called when a command block activates? Also command blocks that don't require redstone
     
  2. BlockRedstoneEvent. CommandBlocks do not activate unless they are powered by redstone one way or another.
     
  3. What about repeating CommandBlocks?
     
    • Agree Agree x 1
  4. Any way of force opening a a command block?

    PS sorry for hijacking
     
    • Useful Useful x 1
  5. @IceGroose no. When a notchian (default) client clicks on a command block it opens it without sending a packet. Only when it's done doing stuff they send a packet
     
  6. Haven't test it yet, just check manually right away without checking what command did the sender fires (On theory)
     
  7. @Banbeucmas the method is only called with commands that are actually registered in your plugin.yml. The ServerCommandEvent might be caled on command blocks, but I don't know
     
  8. It does not have to send a packet on open, I need it to open a command block when I send a packet
     
  9. On theory again
    Found this on Javadoc
    Code (Text):
    This event is called when a command is run from the server console. It is called early in the command handling process, and modifications in this event (via setCommand(String)) will be shown in the behavior.
    You remember that even when the command by CmdBlock is annouced, it still on console right, i think ConsoleSender and BlockCommandSender are different
     
  10. @IceGroose as I said, there's nothing that can open a command block
     
  11. Can we use the PlayerInteractEvent and check if the block clicked is a CmdBlock (On theory again :p ik, i am noob on CmdBlock)
     
  12. @Banbeucmas they wanted to open a command block window, not check if one is opened
     
  13. Now i am currently null on what they are trying to accomplish @IceGroose explain clearly?
     
  14. @Banbeucmas
     
  15. that thread got locked because of the OP's arrogance, they were testing some stuff to make it work on 1.8 but the result has never been posted so I have no clue if he managed to get it working

    Edit: this pretty much answers the question. So sad they removed it, it was the coolest way of getting a string value
    https://www.spigotmc.org/threads/solved-question-1-8-1-force-opening-command-block-gui.44518/
     
    #19 IceGroose, Jun 2, 2016
    Last edited: Jun 2, 2016
  16. Code (Text):
    private Core plugin;

    public CommandBlockListener(Core plugin)
    {
      this.plugin = plugin;
      plugin.getServer().getPluginManager().registerEvents(this, plugin);
    }
              @EventHandler
              public void onPlayerChat(PlayerCommandPreprocessEvent e)
              {
                Player player = e.getPlayer();
               
                boolean cmbhas = this.plugin.getConfig().getList("command").contains(e.getMessage().replace("/", ""));
                if ((!player.hasPermission("cmb.bypass")) &&
                  (cmbhas))
                {
                  e.setCancelled(true);
                  player.sendMessage("You are not allowed to use this command!");
                }
              }
            }
     
    Hope this was what your looking for