use of com.github.games647.changeskin.core.message.ForwardMessage in project ChangeSkin by games647.
the class MessageListener method onCommandForward.
private void onCommandForward(CommandSender invoker, ByteArrayDataInput dataInput) {
ForwardMessage message = new ForwardMessage();
message.readFrom(dataInput);
if (message.isOP() && message.isSource()) {
// bukkit op and it won't run as bungee console
invoker.addGroups(plugin.getName() + "-OP");
}
String line = message.getCommandName() + ' ' + message.getArgs();
if (message.isSource()) {
// the player is the actual invoker other it's the console
ProxyServer.getInstance().getPluginManager().dispatchCommand(invoker, line);
} else {
CommandSender console = ProxyServer.getInstance().getConsole();
ProxyServer.getInstance().getPluginManager().dispatchCommand(console, line);
}
}
use of com.github.games647.changeskin.core.message.ForwardMessage 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);
}
Aggregations