Solved Issue with muting the global chat

Discussion in 'Spigot Plugin Development' started by theblackquake, May 24, 2016.

  1. I'm new to java at this moment, but recently I ran over an issue, the issue is whenever I try muting the global chat it doesn't do that. From my current knowledge in java I believe this code should work:
    http://hastebin.com/vecuherali.java
    The main issue is that there are no con sold errors and all the messages send through except the one on cancel event, and I made sure I don't have any perms when I chat. Thanks.
     
  2. You are missing an annotation and didn't register your event:
    Code (Text):
    public void onEnable() {
      getServer().getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    public void myMethod(ThisIsAnExampleEvent e) {
      // ...
    }
    Also you have to implement Listener not listener (capital L).
    And there's a return true in your last line which seems to be a bit out of place. I think it should be inside the onCommand method.

    This is a minor thing: Java code usually looks like this:
    Code (Text):
    public void methodWithBrackets() {
      // ..
    }
    And not like in C/C++:
    Code (Text):
    public void this_is_more_c_like()
    {
      // ..
    }
     
    • Informative Informative x 1
  3. You event handler isn't annotated and you never register your events. Check out http://wiki.bukkit.org/Event_API_Reference#The_Basics

    Also I would recommend annotating your onCommand with @Override just as good practice to make sure you are actually overriding something (you didn't make a typo, extend the wrong class etc) as well as making it clear to other developers reading your code.
     
    • Informative Informative x 1
  4. first line, Listener not listener (case sensitive) and what the others said
     
    • Useful Useful x 1
  5. You sir, use a very interesting naming convention. Other than that, others already solved your issue. Mark this as solved?
     
  6. Thanks, it is now working with no issues.


    Well I use these terms a lot, so using it while learning how to code just motivates me to continue.
     
  7. So you can mark the post as solved. also optional you can rate the posts that you helped with "Useful" or "Informative" ^^