All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jpower.irc.Channel Maven / Gradle / Ivy

There is a newer version: 0.0.5
Show newest version
package jpower.irc;

import java.util.Map;
import java.util.HashMap;

public class Channel implements Sendable
{

   private final PowerIrc client;
   private final String name;
   private String topic;
   private Map users;
   private Map ops;
   private Map voices;

   public Channel(PowerIrc client, String name)
   {
      this.client = client;
      this.name = name;
      users = new HashMap<>();
      ops = new HashMap<>();
      voices = new HashMap<>();
   }

   public String getName()
   {
      return name;
   }

   protected void addUser(User user)
   {
      if (users.containsKey(user)) return;
      users.put(user.getUsername(), user);
   }

   protected void setOp(User user)
   {
      if (ops.containsKey(user)) return;
      ops.put(user.getNickname(), user);
   }

   protected void removeOp(User user)
   {
      ops.remove(user);
   }

   protected void setVoice(User user)
   {
      try
      {
         if (voices.containsKey(user)) return;
         voices.put(user.getNickname(), user);
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
   }

   protected void removeVoice(User user)
   {
      voices.remove(user);
   }

   public void userJoin(User user)
   {
      if (users.containsKey(user)) return;
      users.put(user.getUsername(), user);
   }

   public void userPart(User user)
   {
      users.remove(user);
   }

   public void message(String message)
   {
      client.privmsg(this, message);
   }

   public Map getUsers()
   {
      return users;
   }

   public Map getOps()
   {
      return ops;
   }

   public Map getVoices()
   {
      return voices;
   }

   public void setTopic(String topic)
   {
      this.topic = topic;
   }

   public String getTopic()
   {
      return topic;
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy