示例#1
0
 // Setup the irc <-> minecraft color mappings.
 static {
   ircToMinecraftColor.put(Colors.WHITE, ChatColor.WHITE.toString()); // black
   ircToMinecraftColor.put(Colors.BLACK, ChatColor.BLACK.toString()); // white
   ircToMinecraftColor.put(Colors.DARK_BLUE, ChatColor.DARK_BLUE.toString()); // dark_blue
   ircToMinecraftColor.put(Colors.DARK_GREEN, ChatColor.DARK_GREEN.toString()); // dark_green
   ircToMinecraftColor.put(Colors.RED, ChatColor.RED.toString()); // red
   ircToMinecraftColor.put(Colors.BROWN, ChatColor.DARK_RED.toString()); // brown
   ircToMinecraftColor.put(Colors.PURPLE, ChatColor.DARK_PURPLE.toString()); // purple
   ircToMinecraftColor.put(Colors.OLIVE, ChatColor.GOLD.toString()); // olive
   ircToMinecraftColor.put(Colors.YELLOW, ChatColor.YELLOW.toString()); // yellow
   ircToMinecraftColor.put(Colors.GREEN, ChatColor.GREEN.toString()); // green
   ircToMinecraftColor.put(Colors.TEAL, ChatColor.DARK_AQUA.toString()); // teal
   ircToMinecraftColor.put(Colors.CYAN, ChatColor.AQUA.toString()); // cyan
   ircToMinecraftColor.put(Colors.BLUE, ChatColor.BLUE.toString()); // blue
   ircToMinecraftColor.put(Colors.MAGENTA, ChatColor.LIGHT_PURPLE.toString()); // magenta
   ircToMinecraftColor.put(Colors.DARK_GRAY, ChatColor.DARK_GRAY.toString()); // dark_gray
   ircToMinecraftColor.put(Colors.LIGHT_GRAY, ChatColor.GRAY.toString()); // light_gray
   minecraftToIrcColor.put(ChatColor.WHITE.toString(), Colors.WHITE); // black
   minecraftToIrcColor.put(ChatColor.BLACK.toString(), Colors.BLACK); // white
   minecraftToIrcColor.put(ChatColor.DARK_BLUE.toString(), Colors.DARK_BLUE); // dark_blue
   minecraftToIrcColor.put(ChatColor.DARK_GREEN.toString(), Colors.DARK_GREEN); // dark_green
   minecraftToIrcColor.put(ChatColor.RED.toString(), Colors.RED); // red
   minecraftToIrcColor.put(ChatColor.DARK_RED.toString(), Colors.BROWN); // brown
   minecraftToIrcColor.put(ChatColor.DARK_PURPLE.toString(), Colors.PURPLE); // purple
   minecraftToIrcColor.put(ChatColor.GOLD.toString(), Colors.OLIVE); // olive
   minecraftToIrcColor.put(ChatColor.YELLOW.toString(), Colors.YELLOW); // yellow
   minecraftToIrcColor.put(ChatColor.GREEN.toString(), Colors.GREEN); // green
   minecraftToIrcColor.put(ChatColor.DARK_AQUA.toString(), Colors.TEAL); // teal
   minecraftToIrcColor.put(ChatColor.AQUA.toString(), Colors.CYAN); // cyan
   minecraftToIrcColor.put(ChatColor.BLUE.toString(), Colors.BLUE); // blue
   minecraftToIrcColor.put(ChatColor.LIGHT_PURPLE.toString(), Colors.MAGENTA); // magenta
   minecraftToIrcColor.put(ChatColor.DARK_GRAY.toString(), Colors.DARK_GRAY); // dark_gray
   minecraftToIrcColor.put(ChatColor.GRAY.toString(), Colors.LIGHT_GRAY); // light_gray
 }
示例#2
0
 private String colorize(String string) {
   if (string.indexOf(ChatColor.COLOR_CHAR) < 0) {
     return string; // no colors in the message
   } else if ((!jLine || !reader.getTerminal().isAnsiSupported()) && jTerminal == null) {
     return ChatColor.stripColor(string); // color not supported
   } else {
     return string
             .replace(ChatColor.RED.toString(), "\033[1;31m")
             .replace(ChatColor.YELLOW.toString(), "\033[1;33m")
             .replace(ChatColor.GREEN.toString(), "\033[1;32m")
             .replace(ChatColor.AQUA.toString(), "\033[1;36m")
             .replace(ChatColor.BLUE.toString(), "\033[1;34m")
             .replace(ChatColor.LIGHT_PURPLE.toString(), "\033[1;35m")
             .replace(ChatColor.BLACK.toString(), "\033[0;0m")
             .replace(ChatColor.DARK_GRAY.toString(), "\033[1;30m")
             .replace(ChatColor.DARK_RED.toString(), "\033[0;31m")
             .replace(ChatColor.GOLD.toString(), "\033[0;33m")
             .replace(ChatColor.DARK_GREEN.toString(), "\033[0;32m")
             .replace(ChatColor.DARK_AQUA.toString(), "\033[0;36m")
             .replace(ChatColor.DARK_BLUE.toString(), "\033[0;34m")
             .replace(ChatColor.DARK_PURPLE.toString(), "\033[0;35m")
             .replace(ChatColor.GRAY.toString(), "\033[0;37m")
             .replace(ChatColor.WHITE.toString(), "\033[1;37m")
         + "\033[0m";
   }
 }
示例#3
0
  /**
   * Replace color macros in a string. The macros are in the form of `[char] where char represents
   * the color. R is for red, Y is for yellow, G is for green, C is for cyan, B is for blue, and P
   * is for purple. The uppercase versions of those are the darker shades, while the lowercase
   * versions are the lighter shades. For white, it's 'w', and 0-2 are black, dark grey, and grey,
   * respectively.
   *
   * @param str
   * @return color-coded string
   */
  public static String replaceColorMacros(String str) {
    str = str.replace("&r", ChatColor.RED.toString());
    str = str.replace("&R", ChatColor.DARK_RED.toString());

    str = str.replace("&y", ChatColor.YELLOW.toString());
    str = str.replace("&Y", ChatColor.GOLD.toString());

    str = str.replace("&g", ChatColor.GREEN.toString());
    str = str.replace("&G", ChatColor.DARK_GREEN.toString());

    str = str.replace("&c", ChatColor.AQUA.toString());
    str = str.replace("&C", ChatColor.DARK_AQUA.toString());

    str = str.replace("&b", ChatColor.BLUE.toString());
    str = str.replace("&B", ChatColor.DARK_BLUE.toString());

    str = str.replace("&p", ChatColor.LIGHT_PURPLE.toString());
    str = str.replace("&P", ChatColor.DARK_PURPLE.toString());

    str = str.replace("&0", ChatColor.BLACK.toString());
    str = str.replace("&1", ChatColor.DARK_GRAY.toString());
    str = str.replace("&2", ChatColor.GRAY.toString());
    str = str.replace("&w", ChatColor.WHITE.toString());

    return str;
  }
  @EventHandler
  public void onPlayerDeath(PlayerDiedEvent event) {
    if (event.getGame() != this.game) return;

    Player player = event.getPlayer();

    if (deadPlayers.containsKey(player)) return;

    DeadPlayer deadPlayer = new DeadPlayer(player, this.game);
    deadPlayers.put(player, deadPlayer);
    deadPlayer.spawn();

    for (PotionEffect effect : player.getActivePotionEffects()) {
      player.removePotionEffect(effect.getType());
    }

    game.broadcast(ChatColor.BOLD.toString() + ChatColor.DARK_RED + event.getDeathMessage());

    for (Player p : game.getPlayers()) {
      plugin.sendActionbarMessage(
          p,
          ChatColor.YELLOW.toString()
              + ChatColor.BOLD.toString()
              + player.getName()
              + " has been downed! Go revive them!");
    }

    if (deadPlayers.size() == game.getPlayers().size()) safelyEndGame();
  }
示例#5
0
 public String colorize(String string) {
   if (!string.contains("\u00A7")) {
     return string;
   } else if ((!jLine || !reader.getTerminal().isANSISupported()) && jTerminal == null) {
     return ChatColor.stripColor(string);
   } else {
     return string
             .replace(ChatColor.RED.toString(), "\033[1;31m")
             .replace(ChatColor.YELLOW.toString(), "\033[1;33m")
             .replace(ChatColor.GREEN.toString(), "\033[1;32m")
             .replace(ChatColor.AQUA.toString(), "\033[1;36m")
             .replace(ChatColor.BLUE.toString(), "\033[1;34m")
             .replace(ChatColor.LIGHT_PURPLE.toString(), "\033[1;35m")
             .replace(ChatColor.BLACK.toString(), "\033[0;0m")
             .replace(ChatColor.DARK_GRAY.toString(), "\033[1;30m")
             .replace(ChatColor.DARK_RED.toString(), "\033[0;31m")
             .replace(ChatColor.GOLD.toString(), "\033[0;33m")
             .replace(ChatColor.DARK_GREEN.toString(), "\033[0;32m")
             .replace(ChatColor.DARK_AQUA.toString(), "\033[0;36m")
             .replace(ChatColor.DARK_BLUE.toString(), "\033[0;34m")
             .replace(ChatColor.DARK_PURPLE.toString(), "\033[0;35m")
             .replace(ChatColor.GRAY.toString(), "\033[0;37m")
             .replace(ChatColor.WHITE.toString(), "\033[1;37m")
         + "\033[0m";
   }
 }
示例#6
0
  public static String getColor(Player player, LivingEntity target) {
    if ((target instanceof Player)) {
      for (String arg : default_colours.keySet()) {
        if (((arg.equals("op")) && (((Player) target).isOp()))
            || (arg.equals("default"))
            || (((Player) target).hasPermission(arg))) {
          String color = (String) default_colours.get(arg);
          if (color.matches("[0-9a-f]")) {
            return new StringBuilder().append("§").append(color).toString();
          }
          return ChatColor.valueOf(color.toUpperCase()).toString();
        }
      }
      return ((Player) target).isOp() ? ChatColor.GOLD.toString() : ChatColor.YELLOW.toString();
    }
    if ((target instanceof Monster)) {
      if ((player != null) && (player.equals(((Monster) target).getTarget()))) {
        return ChatColor.RED.toString();
      }
      return ChatColor.YELLOW.toString();
    }
    if ((target instanceof WaterMob)) return ChatColor.GREEN.toString();
    if ((target instanceof Flying)) return ChatColor.YELLOW.toString();
    if ((target instanceof Animals)) {
      if ((player != null) && (player.equals(((Animals) target).getTarget())))
        return ChatColor.RED.toString();
      if ((target instanceof Tameable)) {
        Tameable pet = (Tameable) target;
        if (pet.isTamed()) {
          return ChatColor.GREEN.toString();
        }
        return ChatColor.YELLOW.toString();
      }

      return ChatColor.GRAY.toString();
    }

    return ChatColor.GRAY.toString();
  }
示例#7
0
 public boolean handleCommand(String command) {
   try {
     if (command.equals("/?") || command.startsWith("/client help")) {
       SpoutClient.getHandle()
           .ingameGUI
           .addChatMessage(ChatColor.YELLOW.toString() + "Spoutcraft Client Debug Commands:");
       SpoutClient.getHandle().ingameGUI.addChatMessage("/client gc - run the garbage collector");
       return true;
     } else if (command.startsWith("/client gc")) {
       SpoutClient.getHandle()
           .ingameGUI
           .addChatMessage(ChatColor.YELLOW.toString() + "Starting Garbage Collection...");
       long start = System.currentTimeMillis();
       long mem = Runtime.getRuntime().freeMemory();
       long time = 250;
       if (command.split(" ").length > 2) {
         try {
           time = Long.parseLong(command.split(" ")[2]);
         } catch (Exception ignore) {
         }
       }
       while ((System.currentTimeMillis() - start) < time) {
         System.gc();
       }
       SpoutClient.getHandle()
           .ingameGUI
           .addChatMessage(ChatColor.GREEN.toString() + "Garbage Collection Complete!");
       SpoutClient.getHandle()
           .ingameGUI
           .addChatMessage(
               ChatColor.GREEN.toString()
                   + (Runtime.getRuntime().freeMemory() - mem) / (1024D * 1024D)
                   + " mb of memory freed");
       return true;
     }
   } catch (Exception e) {
   }
   return false;
 }
示例#8
0
public class Messaging {

  public static void configure(String messageColour, String highlightColour) {
    MESSAGE_COLOUR = messageColour;
    HIGHLIGHT_COLOUR = highlightColour;
  }

  private static String prettify(String message) {
    String trimmed = message.trim();
    String messageColor = Colorizer.parseColors(MESSAGE_COLOUR);
    if (!trimmed.isEmpty()) {
      if (trimmed.charAt(0) == ChatColor.COLOR_CHAR) {
        ChatColor test = ChatColor.getByChar(trimmed.substring(1, 2));
        if (test == null) {
          message = messageColor + message;
        }
      } else message = messageColor + message;
    }
    return message;
  }

  public static void send(CommandSender sender, String msg) {
    sendMessageTo(sender, msg);
  }

  public static void sendInfo(CommandSender sender, String msg) {
    send(sender, ChatColor.YELLOW.toString() + msg);
  }

  public static void sendError(CommandSender sender, String msg) {
    send(sender, ChatColor.RED.toString() + msg);
  }

  private static void sendMessageTo(CommandSender sender, String rawMessage) {
    if (sender instanceof Player) {
      Player player = (Player) sender;
      rawMessage = rawMessage.replace("<player>", player.getName());
      rawMessage = rawMessage.replace("<world>", player.getWorld().getName());
    }
    rawMessage = Colorizer.parseColors(rawMessage);
    for (String message : rawMessage.split("<br>|<n>|\\n")) {
      sender.sendMessage(prettify(message));
    }
  }

  private static String HIGHLIGHT_COLOUR = ChatColor.YELLOW.toString();

  private static String MESSAGE_COLOUR = ChatColor.GREEN.toString();
}
示例#9
0
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    Player p = null;

    if (sender instanceof Player) {
      p = (Player) sender;
    }

    if (p != null) {
      if (!(p.isOp())) {
        return true;
      }
    }

    if (args.length == 0) {
      if (p != null) {
        if (!(p.isOp())) {
          return true;
        }
        p.sendMessage(
            ChatColor.RED
                + "Invalid Syntax. Please use /isay <msg> to send a local world messsage.");
        return true;
      }
    }

    String msg = "";
    for (String s : args) {
      msg += s + " ";
    }
    msg = msg.substring(0, msg.lastIndexOf(" "));

    msg = msg.replaceAll("&0", ChatColor.BLACK.toString());
    msg = msg.replaceAll("&1", ChatColor.DARK_BLUE.toString());
    msg = msg.replaceAll("&2", ChatColor.DARK_GREEN.toString());
    msg = msg.replaceAll("&3", ChatColor.DARK_AQUA.toString());
    msg = msg.replaceAll("&4", ChatColor.DARK_RED.toString());
    msg = msg.replaceAll("&5", ChatColor.DARK_PURPLE.toString());
    msg = msg.replaceAll("&6", ChatColor.GOLD.toString());
    msg = msg.replaceAll("&7", ChatColor.GRAY.toString());
    msg = msg.replaceAll("&8", ChatColor.DARK_GRAY.toString());
    msg = msg.replaceAll("&9", ChatColor.BLUE.toString());
    msg = msg.replaceAll("&a", ChatColor.GREEN.toString());
    msg = msg.replaceAll("&b", ChatColor.AQUA.toString());
    msg = msg.replaceAll("&c", ChatColor.RED.toString());
    msg = msg.replaceAll("&d", ChatColor.LIGHT_PURPLE.toString());
    msg = msg.replaceAll("&e", ChatColor.YELLOW.toString());
    msg = msg.replaceAll("&f", ChatColor.WHITE.toString());

    msg = msg.replaceAll("&u", ChatColor.UNDERLINE.toString());
    msg = msg.replaceAll("&s", ChatColor.BOLD.toString());
    msg = msg.replaceAll("&i", ChatColor.ITALIC.toString());
    msg = msg.replaceAll("&m", ChatColor.MAGIC.toString());

    if (sender instanceof BlockCommandSender) {
      BlockCommandSender cb = (BlockCommandSender) sender;
      for (Player pl : cb.getBlock().getWorld().getPlayers()) {
        pl.sendMessage(msg);
      }
    } else if (sender instanceof Player) {
      for (Player pl : p.getWorld().getPlayers()) {
        pl.sendMessage(msg);
      }
    }
    return true;
  }
示例#10
0
 public static void sendInfo(CommandSender sender, String msg) {
   send(sender, ChatColor.YELLOW.toString() + msg);
 }
示例#11
0
  public List<String> getTooltipLines(String locale) {
    ArrayList<String> output = new ArrayList<String>();
    int width = 150;
    output.add(encodedID + quality.colour + ChatColor.BOLD + displayName);
    int dWidth = getStringWidthBold(ChatColor.stripColor(displayName));
    if (dWidth > width) width = dWidth;

    dWidth = getStringWidth(ChatColor.stripColor(hand + "     " + type));
    if (dWidth > width) width = dWidth;
    String damageStr;
    if (damageMin == 0 && damageMax == 0 && armour != 0) {
      damageStr = armour + "% " + Plugin.plugin.getConfig().getString("defaults.armour", "Armour");
    } else if (armour == 0 && damageMin == 0 && damageMax == 0) {
      damageStr = null;
    } else if (damageMin == damageMax) {
      damageStr =
          damageMin + " " + Plugin.plugin.getConfig().getString("defaults.damage", "Damage");
    } else {
      damageStr =
          damageMin
              + "-"
              + damageMax
              + " "
              + Plugin.plugin.getConfig().getString("defaults.damage", "Damage");
    }
    if (damageMin != 0 || damageMax != 0 || armour != 0) {
      dWidth = getStringWidth(damageStr);
      if (dWidth > width) width = dWidth;
    }

    for (Power p : powers) {
      dWidth = getStringWidth(ChatColor.stripColor(p.displayText(locale)));
      if (dWidth > width) width = dWidth;
    }

    for (String s : description) {
      dWidth = getStringWidth(ChatColor.stripColor(s));
      if (dWidth > width) width = dWidth;
    }

    tooltipWidth = width;

    output.add(
        ChatColor.WHITE
            + hand
            + StringUtils.repeat(
                " ", (width - getStringWidth(ChatColor.stripColor(hand + type))) / 4)
            + type);
    if (damageStr != null) {
      output.add(ChatColor.WHITE + damageStr);
    }

    for (Power p : powers) {
      output.add(p.displayText(locale));
    }
    if (loreText.length() != 0) {
      int cWidth = 0;
      int tWidth = 0;
      StringBuilder out = new StringBuilder();
      StringBuilder temp = new StringBuilder();
      out.append(ChatColor.YELLOW);
      out.append(ChatColor.ITALIC);
      String currentColour = ChatColor.YELLOW.toString();
      String dMsg = "\"" + loreText + "\"";
      for (int i = 0; i < dMsg.length(); i++) {
        char c = dMsg.charAt(i);
        temp.append(c);
        if (c == ChatColor.COLOR_CHAR || c == '&') {
          i += 1;
          temp.append(dMsg.charAt(i));
          currentColour = ChatColor.COLOR_CHAR + "" + dMsg.charAt(i);
          continue;
        }
        if (c == ' ') tWidth += 4;
        else tWidth += Font.widths[c] + 1;
        if (c == ' ' || i == dMsg.length() - 1) {
          if (cWidth + tWidth > width) {
            cWidth = 0;
            cWidth += tWidth;
            tWidth = 0;
            output.add(out.toString());
            out = new StringBuilder();
            out.append(currentColour);
            out.append(ChatColor.ITALIC);
            out.append(temp);
            temp = new StringBuilder();
          } else {
            out.append(temp);
            temp = new StringBuilder();
            cWidth += tWidth;
            tWidth = 0;
          }
        }
      }
      out.append(temp);
      output.add(out.toString());
    }

    for (String s : description) {
      output.add(s);
    }
    return output;
  }
示例#12
0
  /** Server Selector Listener */
  @EventHandler
  public void onInventoryClick(final InventoryClickEvent event) {
    if (event
        .getInventory()
        .getName()
        .contains(
            ChatColor.DARK_GREEN
                + SubPlugin.lang.get("Lang.GUI.Server-List-Title").replace("$Int$", ""))) {
      Player player = (Player) event.getWhoClicked();
      if (event.getCurrentItem() != null
          && event.getCurrentItem().getType() != Material.AIR
          && event.getCurrentItem().hasItemMeta()) {
        if (event
            .getCurrentItem()
            .getItemMeta()
            .getDisplayName()
            .equals(ChatColor.DARK_RED.toString() + SubPlugin.lang.get("Lang.GUI.Exit"))) {
          player.closeInventory();
        } else if (event
            .getCurrentItem()
            .getItemMeta()
            .getDisplayName()
            .equals(ChatColor.YELLOW.toString() + SubPlugin.lang.get("Lang.GUI.Back"))) {
          new SubGUI(
              player,
              (Integer.parseInt(
                      event
                          .getClickedInventory()
                          .getName()
                          .replace(
                              ChatColor.DARK_GREEN.toString()
                                  + SubPlugin.lang
                                      .get("Lang.GUI.Server-List-Title")
                                      .replace("$Int$", ""),
                              ""))
                  - 2),
              null,
              SubPlugin);
        } else if (event
            .getCurrentItem()
            .getItemMeta()
            .getDisplayName()
            .equals(ChatColor.YELLOW.toString() + SubPlugin.lang.get("Lang.GUI.Next"))) {
          new SubGUI(
              player,
              Integer.parseInt(
                  event
                      .getClickedInventory()
                      .getName()
                      .replace(
                          ChatColor.DARK_GREEN.toString()
                              + SubPlugin.lang
                                  .get("Lang.GUI.Server-List-Title")
                                  .replace("$Int$", ""),
                          "")),
              null,
              SubPlugin);
        } else if (!event
            .getCurrentItem()
            .getItemMeta()
            .getDisplayName()
            .equals(
                ChatColor.GRAY
                    + SubPlugin.Plugin.getDescription().getName()
                    + " v"
                    + SubPlugin.Plugin.getDescription().getVersion())) {
          new SubGUI(
              player,
              0,
              event
                  .getCurrentItem()
                  .getItemMeta()
                  .getDisplayName()
                  .replace(ChatColor.YELLOW.toString(), ""),
              SubPlugin);
        }
      }
      event.setCancelled(true);
    }

    /** Server Editor Listener */
    if (event
        .getInventory()
        .getName()
        .contains(ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title"))) {
      final Player player = (Player) event.getWhoClicked();
      if (event.getCurrentItem() != null
          && event.getCurrentItem().getType() != Material.AIR
          && event.getCurrentItem().hasItemMeta()) {
        String displayName = event.getCurrentItem().getItemMeta().getDisplayName();
        if ((ChatColor.DARK_GREEN.toString() + SubPlugin.lang.get("Lang.GUI.Start"))
            .equals(displayName)) {
          if (player.hasPermission("SubServer.Command.start.*")
              || player.hasPermission(
                  "SubServer.Command.start."
                      + event
                          .getClickedInventory()
                          .getName()
                          .replace(
                              ChatColor.DARK_GREEN
                                  + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                  + ChatColor.YELLOW,
                              ""))) {
            SubAPI.getSubServer(
                    event
                        .getClickedInventory()
                        .getName()
                        .replace(
                            ChatColor.DARK_GREEN
                                + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                + ChatColor.YELLOW,
                            ""))
                .start((Player) event.getWhoClicked());
            final SubGUI SubGUI;
            (SubGUI = new SubGUI(SubPlugin))
                .openLoader(
                    player,
                    event
                        .getClickedInventory()
                        .getName()
                        .replace(
                            ChatColor.DARK_GREEN
                                + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                + ChatColor.YELLOW,
                            ""),
                    "openServerWindow");
            new BukkitRunnable() {
              @Override
              public void run() {
                try {
                  Thread.sleep(1500);
                } catch (InterruptedException e) {
                  e.printStackTrace();
                }
                SubAPI.getSubServer(
                            event
                                .getClickedInventory()
                                .getName()
                                .replace(
                                    ChatColor.DARK_GREEN
                                        + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                        + ChatColor.YELLOW,
                                    ""))
                        .Running =
                    true;
                SubGUI.stopLoader = true;
              }
            }.runTaskAsynchronously(SubPlugin.Plugin);
          }
        } else if ((ChatColor.RED.toString() + SubPlugin.lang.get("Lang.GUI.Stop"))
            .equals(displayName)) {
          if (player.hasPermission("SubServer.Command.stop.*")
              || player.hasPermission(
                  "SubServer.Command.stop."
                      + event
                          .getClickedInventory()
                          .getName()
                          .replace(
                              ChatColor.DARK_GREEN
                                  + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                  + ChatColor.YELLOW,
                              ""))) {
            SubAPI.getSubServer(
                    event
                        .getClickedInventory()
                        .getName()
                        .replace(
                            ChatColor.DARK_GREEN
                                + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                + ChatColor.YELLOW,
                            ""))
                .stop((Player) event.getWhoClicked());
            final SubGUI SubGUI;
            (SubGUI = new SubGUI(SubPlugin))
                .openLoader(
                    player,
                    event
                        .getClickedInventory()
                        .getName()
                        .replace(
                            ChatColor.DARK_GREEN
                                + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                + ChatColor.YELLOW,
                            ""),
                    "openServerWindow");
            new BukkitRunnable() {
              @Override
              public void run() {
                try {
                  Thread.sleep(1500);
                } catch (InterruptedException e) {
                  e.printStackTrace();
                }
                SubAPI.getSubServer(
                            event
                                .getClickedInventory()
                                .getName()
                                .replace(
                                    ChatColor.DARK_GREEN
                                        + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                        + ChatColor.YELLOW,
                                    ""))
                        .Running =
                    false;
                SubGUI.stopLoader = true;
              }
            }.runTaskAsynchronously(SubPlugin.Plugin);
          }
        } else if ((ChatColor.DARK_RED.toString() + SubPlugin.lang.get("Lang.GUI.Terminate"))
            .equals(displayName)) {
          if (player.hasPermission("SubServer.Command.kill.*")
              || player.hasPermission(
                  "SubServer.Command.kill."
                      + event
                          .getClickedInventory()
                          .getName()
                          .replace(
                              ChatColor.DARK_GREEN
                                  + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                  + ChatColor.YELLOW,
                              ""))) {
            SubAPI.getSubServer(
                    event
                        .getClickedInventory()
                        .getName()
                        .replace(
                            ChatColor.DARK_GREEN
                                + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                + ChatColor.YELLOW,
                            ""))
                .terminate((Player) event.getWhoClicked());
            final SubGUI SubGUI;
            (SubGUI = new SubGUI(SubPlugin))
                .openLoader(
                    player,
                    event
                        .getClickedInventory()
                        .getName()
                        .replace(
                            ChatColor.DARK_GREEN
                                + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                + ChatColor.YELLOW,
                            ""),
                    "openServerWindow");
            new BukkitRunnable() {
              @Override
              public void run() {
                try {
                  Thread.sleep(500);
                } catch (InterruptedException e) {
                  e.printStackTrace();
                }
                SubGUI.stopLoader = true;
                SubAPI.getSubServer(
                            event
                                .getClickedInventory()
                                .getName()
                                .replace(
                                    ChatColor.DARK_GREEN
                                        + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                        + ChatColor.YELLOW,
                                    ""))
                        .Running =
                    false;
                new SubGUI(
                    player,
                    0,
                    event
                        .getClickedInventory()
                        .getName()
                        .replace(
                            ChatColor.DARK_GREEN
                                + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                + ChatColor.YELLOW,
                            ""),
                    SubPlugin);
              }
            }.runTaskAsynchronously(SubPlugin.Plugin);
          }
        } else if ((ChatColor.RED.toString() + SubPlugin.lang.get("Lang.GUI.Back"))
            .equals(displayName)) {
          player.closeInventory();
          int i =
              (int)
                  Math.floor(
                      SubPlugin.SubServers.indexOf(
                              event
                                  .getClickedInventory()
                                  .getName()
                                  .replace(
                                      ChatColor.DARK_GREEN
                                          + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                          + ChatColor.YELLOW,
                                      ""))
                          / 18);
          new SubGUI(player, i, null, SubPlugin);
        } else if ((ChatColor.DARK_RED.toString() + SubPlugin.lang.get("Lang.GUI.Exit"))
            .equals(displayName)) {
          player.closeInventory();
        } else if ((ChatColor.AQUA.toString() + SubPlugin.lang.get("Lang.GUI.Send-CMD"))
            .equals(displayName)) {
          if (player.hasPermission("SubServer.Command.send.*")
              || player.hasPermission(
                  "SubServer.Command.send."
                      + event
                          .getClickedInventory()
                          .getName()
                          .replace(
                              ChatColor.DARK_GREEN
                                  + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                  + ChatColor.YELLOW,
                              ""))) {
            player.closeInventory();
            final SubGUIChat chat = new SubGUIChat(player, SubPlugin);
            chat.chatEnabled = false;
            player.sendMessage(
                ChatColor.AQUA + SubPlugin.lprefix + SubPlugin.lang.get("Lang.GUI.Enter-CMD"));
            new BukkitRunnable() {
              @Override
              public void run() {
                try {
                  do {
                    Thread.sleep(25);
                  } while (chat.chatEnabled == false);
                } catch (InterruptedException e) {
                  e.printStackTrace();
                }

                SubAPI.getSubServer(
                        event
                            .getClickedInventory()
                            .getName()
                            .replace(
                                ChatColor.DARK_GREEN
                                    + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                    + ChatColor.YELLOW,
                                ""))
                    .sendCommand((Player) event.getWhoClicked(), chat.chatText);
                chat.chatText = "";
                new SubGUI(SubPlugin)
                    .openSentCommand(
                        player,
                        event
                            .getClickedInventory()
                            .getName()
                            .replace(
                                ChatColor.DARK_GREEN
                                    + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                    + ChatColor.YELLOW,
                                ""));
              }
            }.runTaskAsynchronously(SubPlugin.Plugin);
          }
        } else if ((ChatColor.DARK_GREEN.toString() + SubPlugin.lang.get("Lang.GUI.Online"))
            .equals(displayName)) {
          String server =
              event
                  .getClickedInventory()
                  .getName()
                  .replace(
                      ChatColor.DARK_GREEN
                          + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                          + ChatColor.YELLOW,
                      "");
          if ((player.hasPermission("SubServer.Command.teleport." + server)
                  || player.hasPermission("SubServer.Command.teleport.*"))
              && !server.equalsIgnoreCase("~Proxy")) {
            player.closeInventory();
            SubAPI.getSubServer(server).sendPlayer(player);
          }
        }
      }
      event.setCancelled(true);
    }

    /** Other Listeners */
    if (event
        .getInventory()
        .getName()
        .contains(ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Success"))) {
      final Player player = (Player) event.getWhoClicked();
      if (event.getCurrentItem() != null
          && event.getCurrentItem().getType() != Material.AIR
          && event.getCurrentItem().hasItemMeta()) {
        player.closeInventory();
        new SubGUI(
            player,
            0,
            event
                .getClickedInventory()
                .getName()
                .replace(
                    ChatColor.DARK_GREEN
                        + SubPlugin.lang.get("Lang.GUI.Success")
                        + ChatColor.YELLOW,
                    ""),
            SubPlugin);
      }
      event.setCancelled(true);
    }
    if (event.getInventory().getName().equals(SubPlugin.lang.get("Lang.GUI.Loading"))) {
      event.setCancelled(true);
    }

    /** Seecret Listener */
    if (event.getInventory().getName().contains(":S:")) {
      if (event.getCurrentItem() != null
          && event.getCurrentItem().getType() != Material.AIR
          && event.getClickedInventory().contains(event.getCurrentItem())) {
        new SubGUI(SubPlugin).openSeecretWindow((Player) event.getWhoClicked());
        event.setCancelled(true);
      }
    }
  }
示例#13
0
  /**
   * Converts color codes into the simoleon code. Sort of a HTML format color code tag and `[code]
   *
   * <p>Color codes allowed: black, navy, green, teal, red, purple, gold, silver, gray, blue, lime,
   * aqua, rose, pink, yellow, white. Example:
   *
   * <blockquote
   *
   * <pre>
   *
   * Messaging.colorize(&quot;Hello &lt;green&gt;world!&quot;); // returns: Hello $world! </pre>
   *
   * </blockquote>
   *
   * @param string Original string to be parsed against group of color names.
   * @return <code>String</code> - The parsed string after conversion.
   */
  public static String colorize(String string) {
    if (iConomy.TerminalSupport)
      if (!(sender instanceof Player))
        string =
            string
                    .replace("`r", "\033[1;31m")
                    .replace("`R", "\033[0;31m")
                    .replace("`y", "\033[1;33m")
                    .replace("`Y", "\033[0;33m")
                    .replace("`g", "\033[1;32m")
                    .replace("`G", "\033[0;32m")
                    .replace("`a", "\033[1;36m")
                    .replace("`A", "\033[0;36m")
                    .replace("`b", "\033[1;34m")
                    .replace("`B", "\033[0;34m")
                    .replace("`p", "\033[1;35m")
                    .replace("`P", "\033[0;35m")
                    .replace("`k", "\033[0;0m")
                    .replace("`s", "\033[0;37m")
                    .replace("`S", "\033[1;30m")
                    .replace("`w", "\033[1;37m")
                    .replace("<r>", "\033[0m")
                    .replace("`e", "\033[0m")
                    .replace("<silver>", "\033[0;37m")
                    .replace("<gray>", "\033[1;30m")
                    .replace("<rose>", "\033[1;31m")
                    .replace("<lime>", "\033[1;32m")
                    .replace("<aqua>", "\033[1;36m")
                    .replace("<pink>", "\033[1;35m")
                    .replace("<yellow>", "\033[1;33m")
                    .replace("<blue>", "\033[1;34m")
                    .replace("<black>", "\033[0;0m")
                    .replace("<red>", "\033[0;31m")
                    .replace("<green>", "\033[0;32m")
                    .replace("<teal>", "\033[0;36m")
                    .replace("<navy>", "\033[0;34m")
                    .replace("<purple>", "\033[0;35m")
                    .replace("<gold>", "\033[0;33m")
                    .replace("<white>", "\033[1;37m")
                + "\033[0m";

    string =
        string
            .replace("`e", "")
            .replace("`r", ChatColor.RED.toString())
            .replace("`R", ChatColor.DARK_RED.toString())
            .replace("`y", ChatColor.YELLOW.toString())
            .replace("`Y", ChatColor.GOLD.toString())
            .replace("`g", ChatColor.GREEN.toString())
            .replace("`G", ChatColor.DARK_GREEN.toString())
            .replace("`a", ChatColor.AQUA.toString())
            .replace("`A", ChatColor.DARK_AQUA.toString())
            .replace("`b", ChatColor.BLUE.toString())
            .replace("`B", ChatColor.DARK_BLUE.toString())
            .replace("`p", ChatColor.LIGHT_PURPLE.toString())
            .replace("`P", ChatColor.DARK_PURPLE.toString())
            .replace("`k", ChatColor.BLACK.toString())
            .replace("`s", ChatColor.GRAY.toString())
            .replace("`S", ChatColor.DARK_GRAY.toString())
            .replace("`w", ChatColor.WHITE.toString());

    string =
        string
            .replace("<r>", "")
            .replace("<black>", "\u00A70")
            .replace("<navy>", "\u00A71")
            .replace("<green>", "\u00A72")
            .replace("<teal>", "\u00A73")
            .replace("<red>", "\u00A74")
            .replace("<purple>", "\u00A75")
            .replace("<gold>", "\u00A76")
            .replace("<silver>", "\u00A77")
            .replace("<gray>", "\u00A78")
            .replace("<blue>", "\u00A79")
            .replace("<lime>", "\u00A7a")
            .replace("<aqua>", "\u00A7b")
            .replace("<rose>", "\u00A7c")
            .replace("<pink>", "\u00A7d")
            .replace("<yellow>", "\u00A7e")
            .replace("<white>", "\u00A7f");

    return string;
  }