use of com.github.games647.fastlogin.core.message.ChannelMessage in project ChangeSkin by games647.
the class AbstractForwardCommand method onBungeeCord.
protected void onBungeeCord(CommandSender sender, String commandName, String... args) {
Player proxy;
boolean isPlayer = sender instanceof Player;
if (isPlayer) {
proxy = (Player) sender;
} else {
Optional<? extends Player> optPlayer = Bukkit.getOnlinePlayers().stream().findAny();
if (!optPlayer.isPresent()) {
sender.sendMessage(ChatColor.DARK_RED + "No player is online to forward this message to Bungee");
return;
}
proxy = optPlayer.get();
}
ChannelMessage message = new ForwardMessage(commandName, Joiner.on(' ').join(args), isPlayer, sender.isOp());
plugin.sendPluginMessage(proxy, message);
}
use of com.github.games647.fastlogin.core.message.ChannelMessage in project FastLogin by games647.
the class ToggleCommand method sendBungeeActivateMessage.
protected void sendBungeeActivateMessage(CommandSender invoker, String target, boolean activate) {
if (invoker instanceof PluginMessageRecipient) {
ChannelMessage message = new ChangePremiumMessage(target, activate, true);
plugin.getBungeeManager().sendPluginMessage((PluginMessageRecipient) invoker, message);
} else {
Optional<? extends Player> optPlayer = Bukkit.getServer().getOnlinePlayers().stream().findFirst();
if (!optPlayer.isPresent()) {
plugin.getLog().info("No player online to send a plugin message to the proxy");
return;
}
Player sender = optPlayer.get();
ChannelMessage message = new ChangePremiumMessage(target, activate, false);
plugin.getBungeeManager().sendPluginMessage(sender, message);
}
}
use of com.github.games647.fastlogin.core.message.ChannelMessage in project FastLogin by games647.
the class FastLoginBungee method sendPluginMessage.
public void sendPluginMessage(Server server, ChannelMessage message) {
if (server != null) {
ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput();
message.writeTo(dataOutput);
NamespaceKey channel = new NamespaceKey(getName(), message.getChannelName());
server.sendData(channel.getCombinedName(), dataOutput.toByteArray());
}
}
use of com.github.games647.fastlogin.core.message.ChannelMessage in project FastLogin by games647.
the class ForceLoginTask method onForceActionSuccess.
@Override
public void onForceActionSuccess(LoginSession session) {
// sub channel name
Type type = Type.LOGIN;
if (session.needsRegistration()) {
type = Type.REGISTER;
}
UUID proxyId = UUID.fromString(ProxyServer.getInstance().getConfig().getUuid());
ChannelMessage loginMessage = new LoginActionMessage(type, player.getName(), proxyId);
core.getPlugin().sendPluginMessage(server, loginMessage);
}
Aggregations