use of org.spongepowered.api.network.ChannelRegistrationException in project LanternServer by LanternPowered.
the class LanternChannelRegistrar method create.
private LanternChannelBinding create(Object plugin, String channel, boolean rawChannel) throws ChannelRegistrationException {
final PluginContainer container = checkPlugin(plugin, "plugin");
checkNotNullOrEmpty(channel, "channel");
checkArgument(channel.length() <= MAX_NAME_LENGTH, "channel length may not be longer then 20");
if (!isChannelAvailable(channel)) {
throw new ChannelRegistrationException("Channel with name \"" + channel + "\" is already registered!");
}
final LanternChannelBinding binding;
if (rawChannel) {
binding = new LanternRawDataChannel(this, channel, container);
} else {
binding = new LanternIndexedMessageChannel(this, channel, container);
}
binding.bound = true;
final MessagePlayInOutRegisterChannels message = new MessagePlayInOutRegisterChannels(Sets.newHashSet(channel));
for (Player player : this.server.getOnlinePlayers()) {
((NetworkSession) player.getConnection()).send(message);
}
return binding;
}
use of org.spongepowered.api.network.ChannelRegistrationException in project SpongeForge by SpongePowered.
the class SpongeModNetworkManager method createRawChannel.
@Override
public RawDataChannel createRawChannel(Object plugin, String channelName) throws ChannelRegistrationException {
SpongeRawChannel channel;
PluginContainer pluginContainer = checkCreateChannelArgs(plugin, channelName);
try {
channel = new SpongeRawChannel(this, channelName, pluginContainer);
} catch (Exception e) {
throw new ChannelRegistrationException("Error registering channel \"" + channelName + "\" to " + pluginContainer, e);
}
return this.registerChannel(channel);
}
use of org.spongepowered.api.network.ChannelRegistrationException in project SpongeForge by SpongePowered.
the class SpongeModNetworkManager method createChannel.
@Override
public IndexedMessageChannel createChannel(Object plugin, String channelName) throws ChannelRegistrationException {
SpongeIndexedMessageChannel channel;
PluginContainer pluginContainer = checkCreateChannelArgs(plugin, channelName);
try {
channel = new SpongeIndexedMessageChannel(this, channelName, pluginContainer);
} catch (Exception e) {
throw new ChannelRegistrationException("Error registering channel \"" + channelName + "\" to " + pluginContainer, e);
}
return this.registerChannel(channel);
}
Aggregations