com.planet_ink.coffee_mud.Libraries
Class CMChannels

java.lang.Object
  extended by com.planet_ink.coffee_mud.Libraries.StdLibrary
      extended by com.planet_ink.coffee_mud.Libraries.CMChannels
All Implemented Interfaces:
CMObject, Tickable, ChannelsLibrary, CMLibrary, java.lang.Cloneable, java.lang.Comparable<CMObject>

public class CMChannels
extends StdLibrary
implements ChannelsLibrary


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.planet_ink.coffee_mud.Libraries.interfaces.ChannelsLibrary
ChannelsLibrary.ChannelFlag, ChannelsLibrary.ChannelMsg, ChannelsLibrary.CMChannel
 
Field Summary
 java.lang.String[] baseChannelNames
           
 java.util.List<ChannelsLibrary.CMChannel> channelList
           
protected  Language commonLang
           
static java.util.Set<ChannelsLibrary.ChannelFlag> emptyFlags
           
static java.util.List<ChannelsLibrary.ChannelMsg> emptyQueue
           
 int QUEUE_SIZE
           
 
Fields inherited from class com.planet_ink.coffee_mud.Libraries.StdLibrary
isDebugging, name, serviceClient, tickStatus
 
Fields inherited from interface com.planet_ink.coffee_mud.core.interfaces.Tickable
STATUS_AFFECT, STATUS_ALIVE, STATUS_BEHAVIOR, STATUS_CLASS, STATUS_DEAD, STATUS_END, STATUS_FIGHT, STATUS_MISC, STATUS_MISC2, STATUS_MISC3, STATUS_MISC4, STATUS_MISC5, STATUS_MISC6, STATUS_MISC7, STATUS_NOT, STATUS_OTHER, STATUS_RACE, STATUS_REBIRTH, STATUS_SCRIPT, STATUS_START, STATUS_WEATHER, TICKID_AREA, TICKID_BEAMWEAPON, TICKID_CLAN, TICKID_CLANITEM, TICKID_DEADBODY_DECAY, TICKID_ELECTRONICS, TICKID_EMAIL, TICKID_EXIT_BEHAVIOR, TICKID_EXIT_REOPEN, TICKID_ITEM_BEHAVIOR, TICKID_ITEM_BOUNCEBACK, TICKID_LIGHT_FLICKERS, TICKID_LIVEAUCTION, TICKID_LONGERMASK, TICKID_MISCELLANEOUS, TICKID_MOB, TICKID_PROPERTY_SPECIAL, TICKID_QUEST, TICKID_READYTOSTOP, TICKID_ROOM_BEHAVIOR, TICKID_ROOM_ITEM_REJUV, TICKID_SOLITARYMASK, TICKID_SPECIALCOMBAT, TICKID_SPECIALMANEUVER, TICKID_SPELL_AFFECT, TICKID_SUPPORT, TICKID_TIMEAUCTION, TICKID_TRAP_DESTRUCTION, TICKID_TRAP_RESET
 
Constructor Summary
CMChannels()
           
 
Method Summary
 boolean activate()
          Activates the library.
 void channelQueUp(int channelNumber, CMMsg msg)
          Adds the given channel message CMMsg event message to the que for the given channel number.
 java.util.List<Session> clearInvalidSnoopers(Session mySession, int channelCode)
          Searches all users online for any sessions that are snooping on the given session, and also are not permitted to read the given channel number.
 void createAndSendChannelMessage(MOB mob, java.lang.String channelName, java.lang.String message, boolean systemMsg)
          Creates and sends the given string message on the channel with the given name to all sessions who are allowed to receive the message from the given sender.
 ChannelsLibrary.CMChannel createNewChannel(java.lang.String name)
           
 ChannelsLibrary.CMChannel createNewChannel(java.lang.String name, java.lang.String mask, java.util.Set<ChannelsLibrary.ChannelFlag> flags, java.lang.String colorOverrideANSI, java.lang.String colorOverrideWords)
           
 ChannelsLibrary.CMChannel createNewChannel(java.lang.String name, java.lang.String i3Name, java.lang.String imc2Name, java.lang.String mask, java.util.Set<ChannelsLibrary.ChannelFlag> flags, java.lang.String colorOverrideANSI, java.lang.String colorOverrideWords)
          Creates a new channel object.
 java.lang.String findChannelName(java.lang.String channelName)
          Returns the official channel name of the channel with the given name or which starts with the given name.
 ChannelsLibrary.CMChannel getChannel(int channelNumber)
          Returns the CMChannel object for the given registered channel from 0 - getNumChannels(); Basically this is almost all you need, but there's more....
 int getChannelCodeNumber(java.lang.String channelName)
          Returns the bitmask appropriate to the channel of the given name, or which starts with the given string.
 int getChannelIndex(java.lang.String channelName)
          Returns the official index number of the channel with the given name or which starts with the given name.
 java.lang.String[] getChannelNames()
          Returns an array of all the names of all the channels.
 java.util.List<ChannelsLibrary.ChannelMsg> getChannelQue(int channelNumber, int numNewToSkip, int numToReturn)
          Generates a list of previous channel messages, in ChannelMsg object format.
protected  Language getCommonLanguage()
           
 java.lang.String getExtraChannelDesc(java.lang.String channelName)
          Returns the friendly readable description of the channel with the given name, or which starts with the given string.
 java.util.List<java.lang.String> getFlaggedChannelNames(ChannelsLibrary.ChannelFlag flag)
          Returns the list of channel names that have the given ChannelFlag set.
 java.util.List<ChannelsLibrary.CMChannel> getI3ChannelsList()
          Returns all the CMChannel objects for any channels flagged as being mapped to I3.
 java.util.List<ChannelsLibrary.CMChannel> getIMC2ChannelsList()
          Returns all the CMChannel objects for any channels flagged as being mapped to IMC2.
 int getNumChannels()
          Returns the number of registered channels
 java.lang.String ID()
          The CoffeeMud Java Class ID shared by all instances of this object.
 int loadChannels(java.lang.String list, java.lang.String ilist, java.lang.String imc2list)
          Clears the channels list and then reloads it from the three given comma-delimited list of coded strings.
 boolean mayReadThisChannel(MOB sender, boolean areaReq, MOB M, int channelNumber)
          Returns whether the given Mob can read a channel message from the given sender, on a particular channel.
 boolean mayReadThisChannel(MOB sender, boolean areaReq, MOB M, int channelNumber, boolean offlineOK)
          Returns whether the given Mob can read a channel message from the given sender, on a particular channel.
 boolean mayReadThisChannel(MOB sender, boolean areaReq, Session ses, int channelNumber)
          Returns whether the given Mob can read a channel message from the given sender, on a particular channel.
 boolean mayReadThisChannel(MOB M, int channelNumber, boolean zapCheckOnly)
          Returns whether the given Mob can read a channel message from the given sender, on a particular channel.
 java.lang.String parseOutFlags(java.lang.String mask, java.util.Set<ChannelsLibrary.ChannelFlag> flags, java.lang.String[] colorOverride)
           
 void restoreInvalidSnoopers(Session mySession, java.util.List<Session> invalid)
          Iterates through the given list of sessions and forces them all to snoop on the given session.
 boolean sendChannelCMMsgTo(Session ses, boolean areareq, int channelInt, CMMsg msg, MOB sender)
          Sends the given channel message from the given sender to the given session on the given channelNumbered channel.
 boolean shutdown()
          Shuts down the library.
 boolean tick(Tickable ticking, int tickID)
          this is the method which is called periodically by the threading engine.
 
Methods inherited from class com.planet_ink.coffee_mud.Libraries.StdLibrary
checkDatabase, compareTo, copyOf, getServiceClient, getTickStatus, initializeClass, L, name, newInstance, propertiesLoaded, setThreadStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.planet_ink.coffee_mud.Libraries.interfaces.CMLibrary
getServiceClient, L, propertiesLoaded
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.CMObject
copyOf, initializeClass, name, newInstance
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

QUEUE_SIZE

public final int QUEUE_SIZE
See Also:
Constant Field Values

baseChannelNames

public java.lang.String[] baseChannelNames

channelList

public java.util.List<ChannelsLibrary.CMChannel> channelList

commonLang

protected Language commonLang

emptyQueue

public static final java.util.List<ChannelsLibrary.ChannelMsg> emptyQueue

emptyFlags

public static final java.util.Set<ChannelsLibrary.ChannelFlag> emptyFlags
Constructor Detail

CMChannels

public CMChannels()
Method Detail

ID

public java.lang.String ID()
Description copied from interface: CMObject
The CoffeeMud Java Class ID shared by all instances of this object. Unlike the Java Class name, this method does not include package information. However, it must return a String value unique to its class category in the ClassLoader. Class categories include Libraries, Common, Areas, Abilities, Behaviors, CharClasses, Commands, Exits Locales, MOBS, Races, WebMacros, Basic Items, Armor, Weapons, ClanItems, Tech. The name is typically identical to the class name.

Specified by:
ID in interface CMObject
Overrides:
ID in class StdLibrary
Returns:
the name of this class

getNumChannels

public int getNumChannels()
Description copied from interface: ChannelsLibrary
Returns the number of registered channels

Specified by:
getNumChannels in interface ChannelsLibrary
Returns:
the number of registered channels
See Also:
ChannelsLibrary.getChannelIndex(String)

getChannel

public ChannelsLibrary.CMChannel getChannel(int channelNumber)
Description copied from interface: ChannelsLibrary
Returns the CMChannel object for the given registered channel from 0 - getNumChannels(); Basically this is almost all you need, but there's more....

Specified by:
getChannel in interface ChannelsLibrary
Parameters:
channelNumber - the index of the channel
Returns:
the CMChannel object
See Also:
ChannelsLibrary.getNumChannels()

createNewChannel

public ChannelsLibrary.CMChannel createNewChannel(java.lang.String name)

createNewChannel

public ChannelsLibrary.CMChannel createNewChannel(java.lang.String name,
                                                  java.lang.String mask,
                                                  java.util.Set<ChannelsLibrary.ChannelFlag> flags,
                                                  java.lang.String colorOverrideANSI,
                                                  java.lang.String colorOverrideWords)

createNewChannel

public ChannelsLibrary.CMChannel createNewChannel(java.lang.String name,
                                                  java.lang.String i3Name,
                                                  java.lang.String imc2Name,
                                                  java.lang.String mask,
                                                  java.util.Set<ChannelsLibrary.ChannelFlag> flags,
                                                  java.lang.String colorOverrideANSI,
                                                  java.lang.String colorOverrideWords)
Description copied from interface: ChannelsLibrary
Creates a new channel object.

Specified by:
createNewChannel in interface ChannelsLibrary
Parameters:
name - the channel name
i3Name - empty string, or the mapped name of the i3 channel
imc2Name - empty string, or the mapped name of the imc2 channel
mask - the zapper mask for who may read the channel
flags - the channel flags to set for the given channel
colorOverrideANSI - empty string for default, or the color code for this channel
colorOverrideWords - empty string for default, or the color code for this channel
Returns:
the newly created channel object
See Also:
ChannelsLibrary.CMChannel, ChannelsLibrary.ChannelFlag

getChannelQue

public java.util.List<ChannelsLibrary.ChannelMsg> getChannelQue(int channelNumber,
                                                                int numNewToSkip,
                                                                int numToReturn)
Description copied from interface: ChannelsLibrary
Generates a list of previous channel messages, in ChannelMsg object format. This may potentially hit the database.

Specified by:
getChannelQue in interface ChannelsLibrary
Parameters:
channelNumber - the channel id number/index
numNewToSkip - starting message number (0 based)
numToReturn - total number of messages to return
Returns:
the list of messages
See Also:
ChannelsLibrary.getChannelIndex(String), ChannelsLibrary.ChannelMsg

mayReadThisChannel

public boolean mayReadThisChannel(MOB sender,
                                  boolean areaReq,
                                  MOB M,
                                  int channelNumber)
Description copied from interface: ChannelsLibrary
Returns whether the given Mob can read a channel message from the given sender, on a particular channel.

Specified by:
mayReadThisChannel in interface ChannelsLibrary
Parameters:
sender - the sender of the channel message
areaReq - true if the message can only be read by someone in the senders Area
M - the potential receiver of the message to confirm
channelNumber - the channel index number
Returns:
true if the mob can read the senders message, false otherwise
See Also:
ChannelsLibrary.getNumChannels(), ChannelsLibrary.mayReadThisChannel(MOB, int, boolean), ChannelsLibrary.mayReadThisChannel(MOB, boolean, Session, int), ChannelsLibrary.mayReadThisChannel(MOB, boolean, MOB, int, boolean)

mayReadThisChannel

public boolean mayReadThisChannel(MOB sender,
                                  boolean areaReq,
                                  MOB M,
                                  int channelNumber,
                                  boolean offlineOK)
Description copied from interface: ChannelsLibrary
Returns whether the given Mob can read a channel message from the given sender, on a particular channel.

Specified by:
mayReadThisChannel in interface ChannelsLibrary
Parameters:
sender - the sender of the channel message
areaReq - true if the message can only be read by someone in the senders Area
M - the potential receiver of the message to confirm
channelNumber - the channel index number
offlineOK - true if the channel reader can be read, or offline, false if they must be online
Returns:
true if the mob can read the senders message, false otherwise
See Also:
ChannelsLibrary.getChannelIndex(String), ChannelsLibrary.mayReadThisChannel(MOB, int, boolean), ChannelsLibrary.mayReadThisChannel(MOB, boolean, Session, int), ChannelsLibrary.mayReadThisChannel(MOB, boolean, MOB, int)

mayReadThisChannel

public boolean mayReadThisChannel(MOB sender,
                                  boolean areaReq,
                                  Session ses,
                                  int channelNumber)
Description copied from interface: ChannelsLibrary
Returns whether the given Mob can read a channel message from the given sender, on a particular channel.

Specified by:
mayReadThisChannel in interface ChannelsLibrary
Parameters:
sender - the sender of the channel message
areaReq - true if the message can only be read by someone in the senders Area
ses - the potential receiver session of the message to confirm
channelNumber - the channel index number
Returns:
true if the mob can read the senders message, false otherwise
See Also:
ChannelsLibrary.getNumChannels(), ChannelsLibrary.mayReadThisChannel(MOB, int, boolean), ChannelsLibrary.mayReadThisChannel(MOB, boolean, MOB, int), ChannelsLibrary.mayReadThisChannel(MOB, boolean, MOB, int, boolean)

mayReadThisChannel

public boolean mayReadThisChannel(MOB M,
                                  int channelNumber,
                                  boolean zapCheckOnly)
Description copied from interface: ChannelsLibrary
Returns whether the given Mob can read a channel message from the given sender, on a particular channel.

Specified by:
mayReadThisChannel in interface ChannelsLibrary
Parameters:
M - the potential receiver of the message to confirm
channelNumber - the channel index number
zapCheckOnly - the channel index number
Returns:
true if the mob can read the senders message, false otherwise
See Also:
ChannelsLibrary.getChannelIndex(String), ChannelsLibrary.mayReadThisChannel(MOB, boolean, MOB, int), ChannelsLibrary.mayReadThisChannel(MOB, boolean, Session, int), ChannelsLibrary.mayReadThisChannel(MOB, boolean, MOB, int, boolean)

channelQueUp

public void channelQueUp(int channelNumber,
                         CMMsg msg)
Description copied from interface: ChannelsLibrary
Adds the given channel message CMMsg event message to the que for the given channel number. Will cause a database write.

Specified by:
channelQueUp in interface ChannelsLibrary
Parameters:
channelNumber - the channel index number
msg - the channel message msg that was sent around
See Also:
ChannelsLibrary.getNumChannels(), ChannelsLibrary.getChannelIndex(String)

getChannelIndex

public int getChannelIndex(java.lang.String channelName)
Description copied from interface: ChannelsLibrary
Returns the official index number of the channel with the given name or which starts with the given name. It is case insensitive search.

Specified by:
getChannelIndex in interface ChannelsLibrary
Parameters:
channelName - the channel string to search for
Returns:
the official index number of the channel
See Also:
ChannelsLibrary.getNumChannels()

getChannelCodeNumber

public int getChannelCodeNumber(java.lang.String channelName)
Description copied from interface: ChannelsLibrary
Returns the bitmask appropriate to the channel of the given name, or which starts with the given string. The bitmask is used for the individual player toggle switches.

Specified by:
getChannelCodeNumber in interface ChannelsLibrary
Parameters:
channelName - the name of the channel
Returns:
the bitmask appropriate to the channel

findChannelName

public java.lang.String findChannelName(java.lang.String channelName)
Description copied from interface: ChannelsLibrary
Returns the official channel name of the channel with the given name or which starts with the given name. It is case insensitive search.

Specified by:
findChannelName in interface ChannelsLibrary
Parameters:
channelName - the channel string to search for
Returns:
the official channel name of the channel
See Also:
ChannelsLibrary.getNumChannels()

getFlaggedChannelNames

public java.util.List<java.lang.String> getFlaggedChannelNames(ChannelsLibrary.ChannelFlag flag)
Description copied from interface: ChannelsLibrary
Returns the list of channel names that have the given ChannelFlag set.

Specified by:
getFlaggedChannelNames in interface ChannelsLibrary
Parameters:
flag - the flag to find channels for
Returns:
the list of channel names with the flag set.
See Also:
ChannelsLibrary.ChannelFlag

getExtraChannelDesc

public java.lang.String getExtraChannelDesc(java.lang.String channelName)
Description copied from interface: ChannelsLibrary
Returns the friendly readable description of the channel with the given name, or which starts with the given string. It's mostly requirements to read or write to the channel.

Specified by:
getExtraChannelDesc in interface ChannelsLibrary
Parameters:
channelName - the name of the channel
Returns:
the friendly readable description of the channel

getIMC2ChannelsList

public java.util.List<ChannelsLibrary.CMChannel> getIMC2ChannelsList()
Description copied from interface: ChannelsLibrary
Returns all the CMChannel objects for any channels flagged as being mapped to IMC2.

Specified by:
getIMC2ChannelsList in interface ChannelsLibrary
Returns:
all the CMChannel objects for IMC2

getI3ChannelsList

public java.util.List<ChannelsLibrary.CMChannel> getI3ChannelsList()
Description copied from interface: ChannelsLibrary
Returns all the CMChannel objects for any channels flagged as being mapped to I3.

Specified by:
getI3ChannelsList in interface ChannelsLibrary
Returns:
all the CMChannel objects for I3

getChannelNames

public java.lang.String[] getChannelNames()
Description copied from interface: ChannelsLibrary
Returns an array of all the names of all the channels.

Specified by:
getChannelNames in interface ChannelsLibrary
Returns:
an array of all the names of all the channels.
See Also:
ChannelsLibrary.getNumChannels()

clearInvalidSnoopers

public java.util.List<Session> clearInvalidSnoopers(Session mySession,
                                                    int channelCode)
Description copied from interface: ChannelsLibrary
Searches all users online for any sessions that are snooping on the given session, and also are not permitted to read the given channel number. It then returns all the offending sessions, after forcing them to stop snooping.

Specified by:
clearInvalidSnoopers in interface ChannelsLibrary
Parameters:
mySession - the session to search for snoopers of
channelCode - the channel number to cross reference snoopers by
Returns:
all the offending sessions
See Also:
ChannelsLibrary.getNumChannels(), ChannelsLibrary.restoreInvalidSnoopers(Session, List)

restoreInvalidSnoopers

public void restoreInvalidSnoopers(Session mySession,
                                   java.util.List<Session> invalid)
Description copied from interface: ChannelsLibrary
Iterates through the given list of sessions and forces them all to snoop on the given session. This makes sense if you check the clearInvalidSnoopers method.

Specified by:
restoreInvalidSnoopers in interface ChannelsLibrary
Parameters:
mySession - the session to search restoring snooping on
invalid - the list of sessions to force resnooping
See Also:
ChannelsLibrary.clearInvalidSnoopers(Session, int)

parseOutFlags

public java.lang.String parseOutFlags(java.lang.String mask,
                                      java.util.Set<ChannelsLibrary.ChannelFlag> flags,
                                      java.lang.String[] colorOverride)

loadChannels

public int loadChannels(java.lang.String list,
                        java.lang.String ilist,
                        java.lang.String imc2list)
Description copied from interface: ChannelsLibrary
Clears the channels list and then reloads it from the three given comma-delimited list of coded strings.

Specified by:
loadChannels in interface ChannelsLibrary
Parameters:
list - the main game channel list
ilist - the list of i3 channels
imc2list - the list of imc2 channels
Returns:
the total number of channels loaded

sendChannelCMMsgTo

public boolean sendChannelCMMsgTo(Session ses,
                                  boolean areareq,
                                  int channelInt,
                                  CMMsg msg,
                                  MOB sender)
Description copied from interface: ChannelsLibrary
Sends the given channel message from the given sender to the given session on the given channelNumbered channel.

Specified by:
sendChannelCMMsgTo in interface ChannelsLibrary
Parameters:
ses - the session to send the channel message to
areareq - true if the sender and session must be in the same area, false otherwise
channelInt - the channel index number of the message
msg - the constructed CMMsg channel message
sender - the sender of the channel message
Returns:
true if the message was sent, and false otherwise
See Also:
ChannelsLibrary.getNumChannels(), ChannelsLibrary.createAndSendChannelMessage(MOB, String, String, boolean)

createAndSendChannelMessage

public void createAndSendChannelMessage(MOB mob,
                                        java.lang.String channelName,
                                        java.lang.String message,
                                        boolean systemMsg)
Description copied from interface: ChannelsLibrary
Creates and sends the given string message on the channel with the given name to all sessions who are allowed to receive the message from the given sender.

Specified by:
createAndSendChannelMessage in interface ChannelsLibrary
Parameters:
mob - the sender of the message
channelName - the name of the channel to send the message on
message - the string message to send on the channel
systemMsg - true to format as a system message, false for a normal chat message
See Also:
ChannelsLibrary.sendChannelCMMsgTo(Session, boolean, int, CMMsg, MOB)

getCommonLanguage

protected Language getCommonLanguage()

activate

public boolean activate()
Description copied from interface: CMLibrary
Activates the library. This is called after the mud is booted, but before connections are accepted.

Specified by:
activate in interface CMLibrary
Overrides:
activate in class StdLibrary
Returns:
true if activation was successful, false if you're screwed
See Also:
CMLibrary.shutdown()

tick

public boolean tick(Tickable ticking,
                    int tickID)
Description copied from interface: Tickable
this is the method which is called periodically by the threading engine. How often it is called depends on the parameters passed to the threadding engine when it is submitted for thread access. Typically the period is once per TIME_TICK period, but that is determined when the object is submitted to the thread engine.

Specified by:
tick in interface Tickable
Overrides:
tick in class StdLibrary
Parameters:
ticking - a reference to this Tickable object
tickID - the TICKID_ constant describing this periodic call, as defined in Tickable
Returns:
true always, unless this object no longer wishes to ever tick again, in which case false
See Also:
Tickable, ServiceEngine, TickableGroup

shutdown

public boolean shutdown()
Description copied from interface: CMLibrary
Shuts down the library. Called at system shutdown time obviously, but is sometimes called just to reset the library.

Specified by:
shutdown in interface CMLibrary
Overrides:
shutdown in class StdLibrary
Returns:
true if shutdown was successful, false if there's nothing you can do about it
See Also:
CMLibrary.activate()