Exemplo n.º 1
0
 /**
  * Kick a player from the proxy for a specified reason
  *
  * @param player
  * @param reason
  */
 public static void kick(final ProxiedPlayer player, final String reason) {
   if (reason == null || reason.equals("")) {
     player.disconnect(TextComponent.fromLegacyText("You have been disconnected of the server."));
   } else {
     player.disconnect(
         TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', reason)));
   }
 }
Exemplo n.º 2
0
 @Override
 public void sendMessage(String message) {
   sendMessage(TextComponent.fromLegacyText(message));
 }
Exemplo n.º 3
0
 @Override
 public void disconnect(String reason) {
   disconnect0(TextComponent.fromLegacyText(reason));
 }
Exemplo n.º 4
0
 public static BaseComponent[] __(final String message) {
   return TextComponent.fromLegacyText(
       ChatColor.translateAlternateColorCodes('&', prefix + message));
 }
 @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>"));
   }
 }