use of net.md_5.bungee.api.CommandSender in project CloudNet by Dytanic.
the class CommandHub method execute.
@Override
public void execute(CommandSender commandSender, String[] args) {
if (!(commandSender instanceof ProxiedPlayer))
return;
ServerInfo serverInfo = CloudProxy.getInstance().getCachedServers().get(((ProxiedPlayer) commandSender).getServer().getInfo().getName());
if (serverInfo != null)
if (CloudProxy.getInstance().getProxyGroup().getProxyConfig().getDynamicFallback().getNamedFallbackes().contains(serverInfo.getServiceId().getGroup())) {
commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', CloudAPI.getInstance().getCloudNetwork().getMessages().getString("hub-already")));
return;
}
String fallback = CloudProxy.getInstance().fallbackOnEnabledKick((((ProxiedPlayer) commandSender)), CloudAPI.getInstance().getGroup(), ((ProxiedPlayer) commandSender).getServer().getInfo().getName());
ProxiedPlayerFallbackEvent proxiedPlayerFallbackEvent = new ProxiedPlayerFallbackEvent((ProxiedPlayer) commandSender, CloudAPI.getInstance().getOnlinePlayer(((ProxiedPlayer) commandSender).getUniqueId()), ProxiedPlayerFallbackEvent.FallbackType.HUB_COMMAND, fallback);
ProxyServer.getInstance().getPluginManager().callEvent(proxiedPlayerFallbackEvent);
fallback = proxiedPlayerFallbackEvent.getFallback();
ProxyServer.getInstance().getPluginManager().callEvent(proxiedPlayerFallbackEvent);
if (fallback == null)
commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', CloudAPI.getInstance().getCloudNetwork().getMessages().getString("hubCommandNoServerFound")));
else
((ProxiedPlayer) commandSender).connect(ProxyServer.getInstance().getServerInfo(fallback));
}
use of net.md_5.bungee.api.CommandSender in project ChangeSkin by games647.
the class InfoCommand method execute.
@Override
public void execute(CommandSender sender, String[] strings) {
if (!(sender instanceof ProxiedPlayer)) {
plugin.sendMessage(sender, "no-console");
return;
}
ProxiedPlayer player = (ProxiedPlayer) sender;
UserPreference preference = plugin.getLoginSession((PendingConnection) player);
Optional<SkinModel> optSkin = preference.getTargetSkin();
if (optSkin.isPresent()) {
String template = plugin.getCore().getMessage("skin-info");
sender.sendMessage(TextComponent.fromLegacyText(formatter.apply(template, optSkin.get())));
} else {
plugin.sendMessage(sender, "skin-not-found");
}
}
use of net.md_5.bungee.api.CommandSender 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 net.md_5.bungee.api.CommandSender in project ChangeSkin by games647.
the class InvalidateCommand method execute.
@Override
public void execute(CommandSender sender, String[] args) {
boolean isOp = sender.getGroups().contains(plugin.getName() + "-OP");
if (sender instanceof ProxiedPlayer) {
sender.removeGroups(plugin.getName() + "-OP");
}
if (args.length > 0) {
ProxiedPlayer targetPlayer = ProxyServer.getInstance().getPlayer(args[0]);
if (targetPlayer == null) {
plugin.sendMessage(sender, "not-online");
return;
}
String permPrefix = plugin.getName().toLowerCase() + ".command.skinupdate.other.";
if (!sender.hasPermission(permPrefix + targetPlayer.getUniqueId()) && !sender.hasPermission(permPrefix + '*')) {
plugin.sendMessage(sender, "no-permission-other");
return;
}
Runnable skinInvalidate = new SkinInvalidator(plugin, sender, targetPlayer, isOp);
ProxyServer.getInstance().getScheduler().runAsync(plugin, skinInvalidate);
return;
}
if (!(sender instanceof ProxiedPlayer)) {
plugin.sendMessage(sender, "no-console");
return;
}
ProxiedPlayer receiver = (ProxiedPlayer) sender;
Runnable skinInvalidate = new SkinInvalidator(plugin, sender, receiver, isOp);
ProxyServer.getInstance().getScheduler().runAsync(plugin, skinInvalidate);
}
use of net.md_5.bungee.api.CommandSender in project CitizensAPI by CitizensDev.
the class Messaging method parseAndSendComponents.
private static void parseAndSendComponents(CommandSender sender, String message) {
ComponentBuilder builder = new ComponentBuilder("");
Matcher m = COMPONENT_MATCHER.matcher(message);
int end = 0;
while (m.find()) {
String text = m.group(1);
String type = m.group(2);
String command = m.group(3);
ClickEvent.Action action = null;
switch(type) {
case "url":
action = ClickEvent.Action.OPEN_URL;
break;
case "command":
action = ClickEvent.Action.RUN_COMMAND;
break;
case "suggest":
action = ClickEvent.Action.SUGGEST_COMMAND;
break;
}
builder.append(text);
end = m.end();
if (action != null) {
builder.underlined(true);
builder.event(new ClickEvent(action, command));
}
if (m.groupCount() > 3) {
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(m.group(4).substring(1))));
} else {
builder.event((HoverEvent) null);
}
}
if (end - 1 < message.length()) {
builder.append(message.substring(end));
builder.event((ClickEvent) null);
builder.event((HoverEvent) null);
builder.underlined(false);
}
sender.spigot().sendMessage(builder.create());
}
Aggregations