Solved Help, irc - admin chat

Discussion in 'Plugin Development' started by JayzaSapphire, Oct 25, 2012.

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


    So.. there's my plugin:
    And then there's an irc plugin:
    And then there's a snippet of code:
    2. @EventHandler(priority = EventPriority.NORMAL)
    3. public void onChat(final AsyncPlayerChatEvent event) {
    4. if (Bukkit.getServer().getPluginManager().getPlugin("mcMMO") != null) {
    5. if (!Users.getProfile(event.getPlayer().getName())
    6. .getAdminChatMode()) {
    7. if (event.isCancelled()) {
    8. return;
    9. }
    10. }
    11. } else if (event.isCancelled()) {
    12. return;
    13. }
    14. [B]//Rest not being posted.[/B]

    And then there's another snippet:
    2. @EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
    3. public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
    4. if (!symbol)return;
    6. Player player = event.getPlayer();
    7. String message = event.getMessage();
    9. if (message.startsWith("@")) {
    10. if (player.hasPermission("atadmin.admin")) {
    11. event.setCancelled(true);
    12. if (message.length() > 1) {
    13. String msg = message.replaceFirst("@", "");
    15. String m = getFormat(player.getName(), msg);
    17. getServer().getConsoleSender().sendMessage(m);
    18. for (Player p : getServer().getOnlinePlayers()) {
    19. if (p.hasPermission("atadmin.admin")) {
    20. p.sendMessage(m);
    21. }
    22. }
    23. } else {
    24. player.sendMessage(ChatColor.RED + "Please specify a message.");
    25. }
    26. }
    27. }
    28. }

    And then there's the problem: MonsterIrc sends the AtAdmin message to the irc channel even though it shouldn't (if i'm right), how to block it?
  2. Offline


    Maybe you should specify the title of your thread more, to attract users, who know something about this.
  3. Offline


  4. try registering your listener higher thn theirs
  5. Offline


    It is higher -.-
  6. you can check their source to verify they dont catch cancelled events, as some plugin delevopers accendly forgot that kind of things some times
  7. Offline


    I posted two sources, one from MonsterIrc and one from my plugin AtAdmin, it shouldn't be sending the messages to irc from what i see.
  8. Offline




    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 29, 2016
  9. Offline


    JayzaSapphire Are you just trying to prevent the event from being sent to IRC or are you trying to tie your plugin with IRC?

    If option 1, then you've got you event priorities wrong. You should be listening on a lower event than MonsterIRC You can read more about priorities here: Event Priorities

    Otherwise if you're looking for option 2, MonsterIRC fires events when IRC chat is received IRC Events and it has it's own API to send messages to IRC IRC API however the API may be a bit outdated. Give it a shot and if its not working let me know and I'll get around to fixing it when I'm not busy with school.

    If your looking for some reference you can see how I do it in my AdminChat/Ticket management plugin here: Admin Chat Sample Notice that I listen on a lower priority and set the event to canceled if it was correctly handled. Take a look at lines 41 and 77-90. They achieve what it seems you are trying to do. :)

  10. Offline


    fletch_to_99 If it was only priorities then the problem is fixed, thankyou.
Thread Status:
Not open for further replies.

Share This Page