Last active
September 4, 2020 07:59
-
-
Save ItsDoot/aa4002a7e741113d4182f1e8a9d6d5f0 to your computer and use it in GitHub Desktop.
chat plugin channel api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.expansemc.chatter.api.channel; | |
import net.kyori.adventure.audience.Audience; | |
import org.spongepowered.api.ResourceKey; | |
import org.spongepowered.api.util.Nameable; | |
/** | |
* A {@link Audience} associated by a {@link ResourceKey} and name. | |
*/ | |
public interface MessageChannel extends Audience, Nameable { | |
ResourceKey getKey(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.expansemc.chatter.api.channel; | |
import com.expansemc.chatter.api.util.OptionalUtil; | |
import org.spongepowered.api.CatalogType; | |
import org.spongepowered.api.ResourceKey; | |
import org.spongepowered.api.Sponge; | |
import java.util.Optional; | |
/** | |
* A cataloged type that provides {@link MessageChannel}s. | |
*/ | |
public interface MessageChannelProvider extends CatalogType { | |
/** | |
* Iterates through all providers to find a {@link MessageChannel} with | |
* the specified {@link ResourceKey}. | |
* | |
* @param key The key to use | |
* @return The message channel, or empty if not found | |
*/ | |
static Optional<MessageChannel> find(ResourceKey key) { | |
return Sponge.getRegistry().getCatalogRegistry().streamAllOf(MessageChannelProvider.class) | |
.flatMap(provider -> OptionalUtil.stream(provider.get(key))) | |
.findFirst(); | |
} | |
/** | |
* Gets a {@link MessageChannel} with the specified {@link ResourceKey}. | |
* | |
* @param key The key to use | |
* @return The message channel, or empty if not found | |
*/ | |
Optional<MessageChannel> get(ResourceKey key); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.expansemc.chatter.api.speaker; | |
import com.expansemc.chatter.api.channel.MessageChannel; | |
import java.util.Collection; | |
public interface Speaker { | |
/** | |
* Gets the focused message channel. | |
* | |
* <p>All untagged messages received from this speaker will be forwarded to this | |
* channel.</p> | |
* | |
* @return The focused channel | |
*/ | |
MessageChannel getFocusedChannel(); | |
/** | |
* Sets the focused message channel. | |
* | |
* @param channel The channel to focus | |
*/ | |
void setFocusedChannel(MessageChannel channel); | |
/** | |
* Gets all open message channels. | |
* | |
* <p>Any messages sent to these channels will be forwarded to this speaker.</p> | |
* | |
* @return All open channels | |
*/ | |
Collection<MessageChannel> getOpenChannels(); | |
void openChannel(MessageChannel channel); | |
void closeChannel(MessageChannel channel); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.expansemc.chatter.api.speaker; | |
import org.spongepowered.api.entity.living.player.Player; | |
public interface SpeakerManager { | |
Speaker getSpeaker(Player player); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment