Exemplo n.º 1
0
 @Override
 public void execute(CommandSender sender, String[] args) {
   if (sender.hasPermission("serverutils.mute")) {
     if (!ServerUtils.mutelist.getBoolean(args[0].toLowerCase())) {
       ServerUtils.mutelist.set(args[0].toLowerCase(), true);
       try {
         ConfigurationProvider.getProvider(YamlConfiguration.class)
             .save(ServerUtils.mutelist, new File(ServerUtils.datafolder, "muteplayers.yml"));
       } catch (IOException e) {
       }
       sender.sendMessage(
           new ComponentBuilder("Muted " + args[0] + " sucessfully")
               .color(ChatColor.GREEN)
               .create());
     } else {
       sender.sendMessage(
           new ComponentBuilder("Command could not execute.").color(ChatColor.RED).create());
     }
   } else {
     sender.sendMessage(
         new ComponentBuilder("You do not have permission to execute this command.")
             .color(ChatColor.RED)
             .create());
   }
 }
 @Command(
     aliases = {"hub", "lobby", "main"},
     desc = "Teleport to the lobby",
     min = 0,
     max = 0)
 public static void hub(final CommandContext args, CommandSender sender) throws CommandException {
   if (sender instanceof ProxiedPlayer) {
     ((ProxiedPlayer) sender).connect(ProxyServer.getInstance().getServers().get("default"));
     sender.sendMessage(ChatColor.GREEN + "Teleporting you to the lobby...");
   } else {
     sender.sendMessage(ChatColor.RED + "Only players may use this command");
   }
 }
Exemplo n.º 3
0
  @Override
  public void execute(CommandSender sender, String[] args) {
    if (Tickets.getTickets(sender.getName(), "open").length != 0) {
      sender.sendMessage(ChatColor.RED + "Je hebt al een open ticket.");
      return;
    }

    if (Tickets.inTicket(sender.getName())) {
      sender.sendMessage(ChatColor.RED + "Je wordt al geholpen.");
      return;
    }

    boolean adminsOnline = false;
    for (ProxiedPlayer player : Main.instance.getProxy().getPlayers())
      if (Permissions.hasPermission(player.getName(), "bs.bungee.tickets.receive_broadcast"))
        adminsOnline = true;

    if (!adminsOnline) {
      sender.sendMessage(
          ChatColor.RED
              + "Er zijn op dit moment geen admins online om je te helpen. Probeer het later nog eens.");
      return;
    }

    String question = "";
    for (int i = 0; i < args.length; i++) {
      if (!args[i].equals("create")) question += ((question.equals("")) ? "" : " ") + args[i];
    }

    Ticket ticket = new Ticket();

    ticket.username = sender.getName();
    ticket.server =
        Main.instance.getProxy().getPlayer(sender.getName()).getServer().getInfo().getName();
    ticket.question = question;

    Tickets.createTicket(ticket);

    for (ProxiedPlayer player : Main.instance.getProxy().getPlayers())
      if (Permissions.hasPermission(player.getName(), "bs.bungee.tickets.receive_broadcast"))
        player.sendMessage(
            ChatColor.AQUA + ticket.username + " heeft een ticket aangemaakt: " + ticket.question);

    sender.sendMessage(
        ChatColor.GREEN + "Je ticket is aangemaakt. Je wordt zo snel mogelijk geholpen!");
  }
  @Command(
      aliases = {"delserver"},
      desc = "Remove a BungeeCord server",
      usage = "<name>",
      min = 1,
      max = 1)
  @CommandPermissions("bungeeutils.delserver")
  public static void delserver(final CommandContext args, CommandSender sender)
      throws CommandException {
    String name = args.getString(0);

    if (ProxyServer.getInstance().getServers().remove(name) == null) {
      sender.sendMessage(ChatColor.RED + "Could not find server " + ChatColor.GOLD + name);
    } else {
      sender.sendMessage(ChatColor.GREEN + "Removed server " + ChatColor.GOLD + name);
    }
  }
Exemplo n.º 5
0
  public static void sendMessageToTarget(CommandSender target, String message) {
    // Shouldnt need it. But let's be cautious.
    if (target == null) {
      return;
    }

    // Not exactly sure where we use the new line besides in the soon-to-be-removed MOTD...
    for (String line : Utilities.colorize(message).split("\n")) {
      target.sendMessage(line);
    }
  }
Exemplo n.º 6
0
  @Override
  public void execute(CommandSender sender, String[] args) {
    if (sender instanceof ProxiedPlayer) {
      if (args == null || args.length < 1) {
        sender.sendMessage(Dictionary.format(Dictionary.ERROR_INVALID_ARGUMENTS));
        return;
      }

      ProxiedPlayer player = (ProxiedPlayer) sender;
      ProxiedPlayer join = ProxyServer.getInstance().getPlayer(args[0]);
      if (join == null || Messenger.isHidden(join)) {
        sender.sendMessage(Dictionary.format(Dictionary.ERROR_PLAYER_OFFLINE));
        return;
      }

      if (player.getUniqueId() == join.getUniqueId()) {
        sender.sendMessage(ChatColor.RED + "You cannot join yourself!");
        return;
      }

      ServerInfo info = join.getServer().getInfo();
      if (info.canAccess(player)) {
        sender.sendMessage(
            ChatColor.LIGHT_PURPLE + "Attempting to join " + join.getName() + "'s server..");
        player.connect(info);
      } else {
        sender.sendMessage(ProxyServer.getInstance().getTranslation("no_server_permission"));
      }
    } else {
      sender.sendMessage(ChatColor.RED + "Console cannot join servers");
    }
  }
Exemplo n.º 7
0
  @Override
  public void execute(CommandSender sender, String[] args) {
    if (args.length == 0) {
      sender.sendMessage(ChatColor.RED + "You must supply a message.");
    } else {
      String message = Joiner.on(' ').join(args);

      try {
        ProxyServer.getInstance().broadcast(ComponentSerializer.parse(message));
      } catch (Exception e) {
        sender.sendMessage(
            new ComponentBuilder(
                    "An error occurred while parsing your message. (Hover for details)")
                .color(ChatColor.RED)
                .underlined(true)
                .event(
                    new HoverEvent(
                        HoverEvent.Action.SHOW_TEXT,
                        new ComponentBuilder(e.getMessage()).color(ChatColor.RED).create()))
                .create());
      }
    }
  }
Exemplo n.º 8
0
 /**
  * Sends the message to a target.
  *
  * @param target The target that should receive the message.
  * @param args An optional array of arguments. If this is used they will be passed together with
  *     the message itself to the String.format() function, before the message gets send to the
  *     client. This can be used to add variable data into the message.
  */
 @Override
 public void send(@NotNull CommandSender target, @Nullable Object... args) {
   Validate.notNull(target, "The target that should receive the message should not be null!");
   if (getSendMethod() == SendMethod.DISABLED) return;
   if (target instanceof ProxiedPlayer) {
     method
         .getSender()
         .doSend(
             (ProxiedPlayer) target,
             (args != null && args.length > 0) ? String.format(json, quoteArgs(args)) : json,
             optionalParameters);
   } else {
     //noinspection deprecation
     target.sendMessage(
         (args != null && args.length > 0) ? String.format(fallback, args) : fallback);
   }
 }
  @Command(
      aliases = {"addserver"},
      desc = "Add a BungeeCord server",
      usage = "<name> <address> [port]",
      flags = "r",
      min = 2,
      max = 4)
  @CommandPermissions("bungeeutils.addserver")
  public static void addserver(final CommandContext args, CommandSender sender)
      throws CommandException {
    String name = args.getString(0);
    String address = args.getString(1);
    int port = args.argsLength() > 2 ? args.getInteger(2) : 25565;
    boolean restricted = args.hasFlag('r');

    ServerInfo serverInfo =
        ProxyServer.getInstance()
            .constructServerInfo(name, new InetSocketAddress(address, port), "", restricted);
    ProxyServer.getInstance().getServers().put(name, serverInfo);

    sender.sendMessage(ChatColor.GREEN + "Added server " + ChatColor.GOLD + name);
  }
Exemplo n.º 10
0
		@Override
		public void onCommand(final CommandSender sender, final String[] args, final boolean confirmedCmd) throws IllegalArgumentException {
			if (args[0].equals("help")) {
				try {
					FormatUtils.showFormattedHelp(BAT.getInstance().getModules().getModule("comment").getCommands(),
							sender, "COMMENT");
				} catch (final InvalidModuleException e) {
					e.printStackTrace();
				}
				return;
			}
			if(args.length < 2){
				throw new IllegalArgumentException();
			}
			if(!confirmedCmd && Core.getPlayerIP(args[0]).equals("0.0.0.0")){
				mustConfirmCommand(sender, "bat " + getName() + " " + Joiner.on(' ').join(args),
						_("operationUnknownPlayer", new String[] {args[0]}));
				return;
			}
			
			checkArgument(comment.hasLastcommentCooledDown(args[0]), _("cooldownUnfinished"));
			comment.insertComment(args[0], Utils.getFinalArg(args, 1), Type.NOTE, sender.getName());
			sender.sendMessage(__("commentAdded"));
		}
Exemplo n.º 11
0
		@Override
		public void onCommand(final CommandSender sender, final String[] args, final boolean confirmedCmd) throws IllegalArgumentException {
			sender.sendMessage(BAT.__(comment.clearComments(args[0], ((args.length == 2) ? Integer.parseInt(args[1]) : -1) )));
		}
Exemplo n.º 12
0
 public void execute(CommandSender sender, String[] args) {
   if (this.testPermission(sender) == false) {
     return;
   }
   if (args.length != 2) {
     sender.sendMessage(
         ChatColor.RED + "Not enough arguments, usage: /send <player|all|current> <target>");
     return;
   }
   String serverInfo = args[1];
   int serverId = -1;
   String[] split = serverInfo.split("\\.");
   if (split.length == 2) {
     try {
       serverId = Integer.parseInt(split[1]);
     } catch (Exception ex) {
       sender.sendMessage(ChatColor.RED + "Target must be server type or serverType.id");
       return;
     }
   }
   ServerInfo target = null;
   ArrayList<ServerInfo> servers = new ArrayList<>();
   for (ExtendedServerInfo extendedServerInfo : ExtendedServerInfo.getExtendedInfos().values()) {
     if (extendedServerInfo.getServerName().equalsIgnoreCase(split[0]) == false) {
       continue;
     }
     if (extendedServerInfo.getServerId() != serverId && serverId != -1) {
       continue;
     }
     servers.add(extendedServerInfo.getServerInfo());
   }
   if (servers.isEmpty() == false) {
     int random = (int) (Math.random() * servers.size());
     target = servers.get(random);
   }
   if (target == null) {
     sender.sendMessage(ProxyServer.getInstance().getTranslation("no_server", new Object[0]));
     return;
   }
   if (args[0].equalsIgnoreCase("all")) {
     for (ProxiedPlayer p : ProxyServer.getInstance().getPlayers()) {
       summon(p, target, sender);
     }
   } else if (args[0].equalsIgnoreCase("current")) {
     if (!(sender instanceof ProxiedPlayer)) {
       sender.sendMessage(ChatColor.RED + "Only in game players can use this command");
       return;
     }
     ProxiedPlayer player = (ProxiedPlayer) sender;
     for (ProxiedPlayer p : player.getServer().getInfo().getPlayers()) {
       summon(p, target, sender);
     }
   } else {
     ProxiedPlayer player = ProxyServer.getInstance().getPlayer(args[0]);
     if (player == null) {
       sender.sendMessage(ChatColor.RED + "That player is not online");
       return;
     }
     summon(player, target, sender);
   }
   sender.sendMessage(ChatColor.GREEN + "Successfully summoned player(s)");
 }
 @Override
 public void execute(CommandSender commandSender, String[] strings) {
   if (strings.length < 1) {
     strings = new String[] {"help"};
   }
   switch (strings[0]) {
     case "about":
       commandSender.sendMessage(
           TextComponent.fromLegacyText(
               ChatColor.GOLD
                   + "AdvancedBungeeAnnouncer "
                   + AdvancedBungeeAnnouncer.getPlugin().getDescription().getVersion()
                   + " by tuxed"));
       commandSender.sendMessage(
           TextComponent.fromLegacyText(
               ChatColor.GOLD
                   + "This plugin is freely redistributable under the terms of the WTFPL, see http://www.wtfpl.net for more details."));
       break;
     case "reload":
       AdvancedBungeeAnnouncer.getConfiguration().reloadAnnouncements();
       AdvancedBungeeAnnouncer.getConfiguration().reloadConfiguration();
       commandSender.sendMessage(
           TextComponent.fromLegacyText(
               ChatColor.GREEN + "The plugin was reloaded successfully."));
       break;
     case "create":
       if (strings.length < 4) {
         commandSender.sendMessage(
             TextComponent.fromLegacyText(ChatColor.RED + "Not enough arguments specified."));
         commandSender.sendMessage(
             TextComponent.fromLegacyText(
                 ChatColor.RED + "/announcer create <id> <server(s)> <line 1>"));
         commandSender.sendMessage(
             TextComponent.fromLegacyText(
                 ChatColor.RED
                     + "<server(s)> may be 'global' if the message is going to be sent to all servers."));
         commandSender.sendMessage(
             TextComponent.fromLegacyText(
                 ChatColor.RED
                     + "<server(s)> may have semicolons to separate server names, like hub;pvp."));
         return;
       }
       if (AdvancedBungeeAnnouncer.getConfiguration().getAnnouncements().containsKey(strings[1])) {
         commandSender.sendMessage(
             TextComponent.fromLegacyText(
                 ChatColor.RED + "An announcement with this ID already exists."));
         return;
       }
       String message = Joiner.on(" ").join(Arrays.copyOfRange(strings, 3, strings.length));
       List<String> servers;
       if (strings[2].contains(";")) {
         servers = ImmutableList.copyOf(Splitter.on(";").omitEmptyStrings().split(strings[2]));
       } else {
         servers = Collections.singletonList(strings[2]);
       }
       Announcement announcement = new Announcement(message);
       announcement.getServers().addAll(servers);
       AdvancedBungeeAnnouncer.getConfiguration().getAnnouncements().put(strings[1], announcement);
       commandSender.sendMessage(
           TextComponent.fromLegacyText(ChatColor.GREEN + "New announcement added."));
       break;
     case "remove":
       if (strings.length < 2) {
         commandSender.sendMessage(
             TextComponent.fromLegacyText(ChatColor.RED + "Not enough arguments specified."));
         commandSender.sendMessage(
             TextComponent.fromLegacyText(ChatColor.RED + "/announcer remove <id>"));
         return;
       }
       if (!AdvancedBungeeAnnouncer.getConfiguration()
           .getAnnouncements()
           .containsKey(strings[1])) {
         commandSender.sendMessage(
             TextComponent.fromLegacyText(
                 ChatColor.RED + "An announcement with this ID does not exist."));
         return;
       }
       AdvancedBungeeAnnouncer.getConfiguration().getAnnouncements().remove(strings[1]);
       commandSender.sendMessage(
           TextComponent.fromLegacyText(ChatColor.GREEN + "Announcement removed."));
       break;
     case "list":
       commandSender.sendMessage(
           TextComponent.fromLegacyText(
               ChatColor.YELLOW
                   + "Announcements: "
                   + Joiner.on(", ")
                       .join(
                           AdvancedBungeeAnnouncer.getConfiguration()
                               .getAnnouncements()
                               .keySet())));
       break;
     case "info":
       if (strings.length < 2) {
         commandSender.sendMessage(
             TextComponent.fromLegacyText(ChatColor.RED + "Not enough arguments specified."));
         commandSender.sendMessage(
             TextComponent.fromLegacyText(ChatColor.RED + "/announcer info <id>"));
         return;
       }
       Announcement a =
           AdvancedBungeeAnnouncer.getConfiguration().getAnnouncements().get(strings[1]);
       commandSender.sendMessage(
           TextComponent.fromLegacyText("-------------------------------------"));
       commandSender.sendMessage(
           TextComponent.fromLegacyText(ChatColor.AQUA + "Announcement ID: " + strings[1]));
       commandSender.sendMessage(
           TextComponent.fromLegacyText(ChatColor.AQUA + "Announcement Text:"));
       for (String s : a.getText().split("\n")) {
         commandSender.sendMessage(
             TextComponent.fromLegacyText(
                 ChatColor.AQUA
                     + "-"
                     + ChatColor.RESET
                     + ChatColor.translateAlternateColorCodes('&', s)));
       }
       commandSender.sendMessage(
           TextComponent.fromLegacyText(
               ChatColor.AQUA + "Sent To: " + Joiner.on(", ").join(a.getServers())));
       commandSender.sendMessage(
           TextComponent.fromLegacyText("-------------------------------------"));
       break;
     default:
       commandSender.sendMessage(
           TextComponent.fromLegacyText(
               ChatColor.RED
                   + "/announcer <about|reload|create|remove|{set,add,remove}line|list|info>"));
   }
 }