HeroChat Integration

Discussion in 'Plugin Development' started by rob4001, May 31, 2011.

Thread Status:
Not open for further replies.
  1. I have a plugin that has the name of a Herochat Channel as a string and im wanting a method to send a mesage to that spesific channel

    Thanks in advance
     
  2. Offline

    chronopolis

    Ask the HeroChat developer.
     
  3. He is on holiday :S and ive tried the IRC but noone responds :(

    What i have so far

    Code:
     public void enableHeroChat()
        {
            Plugin p = server.getPluginManager().getPlugin("HeroChat");
            if(p != null)
            {
                if(!p.isEnabled())
                    server.getPluginManager().enablePlugin(p);
                hcChannelName = Settings.getString("herochat-channel-name", null);
                HeroChat hc = server.getPluginManager().
                ChannelManager cm = p.getChannelManager();
                Channel c = cm.getChannel(hcChannelName);
            } else
            {
                System.out.println("[iAuction] HeroChat system is enabled but could not be loaded!");
            }
        }
    Code:
    public void broadcast(String msg)
        {if(hcEnabled)
        {
            c.sendMessage(tag, msg);
        }else{
            server.broadcastMessage((new StringBuilder(String.valueOf(tag))).append(msg).toString());
        }
        }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 16, 2016
  4. Offline

    Redyugi

    I went on to Github and looked at his source, and it looks like you are doing it mostly right. (It's 12:05 am here. So if I am wrong...) Are you getting errors with that or something?
     
  5. My problem is fetching the HeroChat ChannelManager

    p is a plugin and when fetching the ChannelManager it wants a HeroChat

    and when i
    HeroChat hc = server.getPluginManager().getPlugin("HeroChat");
    it says trying to fetch Plugin not HeroChat

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

    Archelaus

    JavaPlugin hc = server.getPluginManager().getPlugin("HeroChat");
     
  7. I reqired hc to be the instance of HeroChat that was running on the server

    Here is my completed code(No errors but not tested yet)

    To enable Herochat Functionallity

    Code:
    public void enableHeroChat()
        {
            Plugin p = server.getPluginManager().getPlugin("HeroChat");
            if(p != null)
            {
                if(!p.isEnabled())
                    server.getPluginManager().enablePlugin(p);
                hcChannelName = Settings.getString("herochat-channel-name", null);
                ChannelManager cm= ((HeroChat)p).getChannelManager();
                Channel c = cm.getChannel(hcChannelName);
    
            } else
            {
                System.out.println("[iAuction] HeroChat system is enabled but could not be loaded!");
            }
        }
    and to send the mesage to the channel
    Code:
    if(hcEnabled)
        {
            c.sendMessage(tag, msg,c.getMsgFormat(),c.getPlayers(),false,true);
        }
    Thanks for all the help
     
Thread Status:
Not open for further replies.

Share This Page