-
-
Notifications
You must be signed in to change notification settings - Fork 2
Channels_old
The biggest aspect of Strings is the channels feature.
There are 7 types of channels, but for typical player chatting only 3 types are used.
Common Channel types:
- StringChannel
- WorldChannel
- Proximity
Each of these channels works in a slightly different way.
All individual channel settings are found in channels.yml.
All of these channels share the following things in common:
- Chat Formatting
Each channel's chat formatting can be configured.
The format can be whatever you want, as long as the placeholders{displayname}and{prefix}are used. - Default Chat Colors
Each channel can define a default chat color to use if the player's chat color is default. - Enabling Events
Calling events allows plugins like DiscordSRV to receive messages, and allows other plugins to process messages.
I recommend keeping events enabled unless its a private chat, such as a staff chat. - Profanity Filtering
(This feature is not out yet, and profanity will not be filtered yet.) - URL and Link Filtering
URL and link filtering can be enabled on a channel by channel basis. A whitelist can be found inconfig.yml. - (!) Membership
Each channel can define a membership level.
For most use cases membership should either bedefaultorpermission.
Channels with default membership will send messages to all online players
If the player doesn't have an active channel set, a channel with the membership ofdefaultwill be chosen to send messages.
Channels withpermissionmembership are more private, and players must manually join them and set them to active to receive/send messages.\ - (!) Priority
Priority is only considered for channels withdefaultmembership.
The higher the number, the higher the priority.
This determines what channel players will send messages to when their active channel is "default".
StringChannels are global channels that make no consideration to player's worlds or proximity.
By default, Strings has two channels, both are StringChannels. These channels are "global" and "staff".
This is the most basic type of channel so there are no additional configuration options.
In channels.yml these channels are type: stringchannel.
These channels are like StringChannels, except that if the membership is default, only players in a certain world will receive the messages.
These channels can still be manually joined with /channel join and if the channel is joined, you will receive messages no matter what world you are in.
In channels.yml these channels are type: world.
This type of channel is also like StringChannels, except that when a player sends a message, only players in a defined distance will receive the message.
Just as WorldChannels, if you manually join the channel, you will receive messages in this channel no matter what distance you are from the player.
In channels.yml these channels are type: proximity.
All channels in the API are represented as "StringsChannel"(s), not "StringChannel"(s).
Channels can be retrieved from the StringsAPI instance with StringsAPI#getChannel(String name), which will return a Optional.
You can get a Set of StringsChannels with StringsAPI#getChannels().
Finally, you can get StringsChannels from StringsUsers with StringsUser#getActiveChannel() and StringsUser#getChannels().
StringsUser's active channel can be set with StringsUser#setActiveChannel(StringChannel channel).
As all Channel types are represented as StringsChannel in the API, the following methods are available:
StringsChannel#getWorld()StringsChannel#getProximity()
Both of these methods return Optionals, and if the channel these methods are called on are not channels of the proper type, the Optional will be empty.
To avoid checking these, you can check what type of channel you're working with using the Type enum.
Calling StringsChannel#getType() will typically provide you with one of the following:
-
Type.NORMAL(StringChannel) -
Type.WORLD(WorldChannel) -
Type.PROXIMITY(ProximityChannel)
There are many additional methods, and for a comprehensive list you can check the JavaDocs.