private static String removeColors(String source) {

    for (ChatColor cc : ChatColor.values()) {
      source = source.replace(cc.toString(), "");
    }
    return source;
  }
Exemplo n.º 2
0
 public JSONMessage color(final ChatColor color) {
   if (!color.isColor()) {
     throw new IllegalArgumentException(color.name() + " is not a color");
   }
   latest().color = color;
   return this;
 }
Exemplo n.º 3
0
  @Override
  public String getListName(String senderId) {
    if (senderId == null) return null;

    // Try Our Map
    String ret = this.idToListName.get(senderId);

    // Try Bukkit
    if (ret == null) {
      Player player = Bukkit.getPlayerExact(senderId);
      if (player != null) {
        ret = player.getPlayerListName();
      }
    }

    // Try Fixed Id
    if (ret == null) {
      ret = Mixin.tryFix(senderId);
    }

    // Ensure Colored
    if (ChatColor.stripColor(ret).equals(ret)) {
      ret = DEFAULT_COLOR.toString() + ret;
    }

    return ret;
  }
Exemplo n.º 4
0
 public static String parseColors(String str) {
   for (ChatColor color : ChatColor.values()) {
     String name = "\\[" + color.name().toUpperCase() + "]";
     str = str.replaceAll(name, color.toString());
   }
   return str;
 }
Exemplo n.º 5
0
 public static ChatColor getColor(String s) {
   ChatColor col = ChatColor.getByChar(s);
   if (col != null) return col;
   col = ChatColor.valueOf(s.toUpperCase());
   if (col != null) return col;
   return ChatColor.WHITE; // Didn't give us a proper color.
 }
Exemplo n.º 6
0
 /*
  * Добавлене сообщения в список
  * Убираются цвета.
  * Параметры:
  * key - ключ сообщения
  * txt - текст сообщения
  */
 public void addMSG(String key, String txt) {
   msg.put(
       key,
       ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', lng.getString(key, txt))));
   if (msglist.isEmpty()) msglist = key;
   else msglist = msglist + "," + key;
 }
Exemplo n.º 7
0
  /**
   * Get a message from out I18n data file.
   *
   * @param message - message title. Such as 'noPlayer'
   * @return - What the set message really is
   */
  public String getColoredMessage(final String message) {

    if (messageCache.containsKey(message)) {
      return messageCache.get(message);
    }

    try {

      try {

        final String translatedMessage =
            ChatColor.translateAlternateColorCodes(colorCode, customMessages.getString(message));

        messageCache.put(message, translatedMessage);

        return translatedMessage;

      } catch (final MissingResourceException ex) {

        final String translatedMessage =
            ChatColor.translateAlternateColorCodes(colorCode, messages.getString(message));

        messageCache.put(message, translatedMessage);

        return translatedMessage;
      }

    } catch (final MissingResourceException ex) {
      return defaultBundle.getString(message);
    }
  }
Exemplo n.º 8
0
  @Override
  public void run() {

    String message =
        ChatColor.translateAlternateColorCodes('&', "&2Started buffered payment thread.");
    ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
    console.sendMessage(message);

    // Jobs.getPluginLogger().info("Started buffered payment thread");
    while (running) {
      try {
        sleep(sleep);
      } catch (InterruptedException e) {
        this.running = false;
        continue;
      }
      try {
        BufferedEconomy economy = Jobs.getEconomy();
        if (economy != null) economy.payAll();
      } catch (Throwable t) {
        t.printStackTrace();
        message =
            ChatColor.translateAlternateColorCodes(
                '&', "&cException in BufferedPaymentThread, stopping economy payments!");
        console.sendMessage(message);
        // Jobs.getPluginLogger().severe("Exception in BufferedPaymentThread, stopping economy
        // payments!");
        running = false;
      }
    }
    message = ChatColor.translateAlternateColorCodes('&', "&6Buffered payment thread shutdown.");
    console.sendMessage(message);
    // Jobs.getPluginLogger().info("Buffered payment thread shutdown");
  }
Exemplo n.º 9
0
 public String command(final CommandSender sender, Command command, String[] args) {
   try {
     BufferedWriter banlist = new BufferedWriter(new FileWriter("banned-players.txt", true));
     for (String p : plugin.cache.keySet()) {
       for (BanInfo info : plugin.cache.get(p)) {
         if (info.getType() == BanType.BAN.getId()) {
           banlist.newLine();
           banlist.write(g(p, info.getAdmin(), info.getReason()));
         }
       }
     }
     banlist.close();
     BufferedWriter iplist = new BufferedWriter(new FileWriter("banned-ips.txt", true));
     for (String p : plugin.cacheIP.keySet()) {
       for (BanInfo info : plugin.cacheIP.get(p)) {
         if (info.getType() == BanType.IPBAN.getId()) {
           iplist.newLine();
           iplist.write(g(p, info.getAdmin(), info.getReason()));
         }
       }
     }
     iplist.close();
   } catch (IOException e) {
     String msg = ChatColor.translateAlternateColorCodes('&', lang.getString("Export.Failed"));
     if (plugin.getLog()) plugin.getLogger().severe(ChatColor.stripColor(msg));
     e.printStackTrace();
     return msg;
   }
   String msg = ChatColor.translateAlternateColorCodes('&', lang.getString("Export.Completed"));
   if (plugin.getLog()) plugin.getLogger().info(ChatColor.stripColor(msg));
   return msg;
 }
Exemplo n.º 10
0
 @Override
 public void send(IProfile profile) {
   if (detail.equals("")) {
     new FancyMessage(ISettings.PREFIX + " ")
         .then(
             ChatColor.translateAlternateColorCodes(
                 '&',
                 profile.getBukkitPlayer().getDisplayName()
                     + "&7(&c"
                     + violation.getTotalVL()
                     + "&7)&r &7failed &9"
                     + violation.getCheck().getName()
                     + "&7[&c"
                     + violation.getVl()
                     + "&7]"))
         .send(profile.getBukkitPlayer());
   } else {
     new FancyMessage(ISettings.PREFIX + " ")
         .then(
             ChatColor.translateAlternateColorCodes(
                 '&',
                 profile.getBukkitPlayer().getDisplayName()
                     + "&7(&c"
                     + violation.getTotalVL()
                     + "&7)&r &7failed &9"
                     + violation.getCheck().getName()
                     + "&7(&c"
                     + detail
                     + "&7)[&c"
                     + violation.getVl()
                     + "&7]"))
         .send(profile.getBukkitPlayer());
   }
 }
Exemplo n.º 11
0
 public String getMessages(String playerName, String key) {
   String message = "null";
   try {
     if (!playerName.equalsIgnoreCase("console")) {
       message =
           ChatColor.translateAlternateColorCodes(
               '&',
               getYamlConfiguration(Language.getPlayerByName(playerName).getLanguage())
                   .getString(key));
     } else {
       message =
           ChatColor.translateAlternateColorCodes(
               '&',
               getYamlConfiguration(plugin.configFile.getString("language.default"))
                   .getString(key));
     }
   } catch (NullPointerException ex) {
     if (!playerName.equalsIgnoreCase("console")) {
       message =
           ChatColor.translateAlternateColorCodes(
               '&',
               getYamlConfiguration(plugin.configFile.getString("language.default"))
                   .getString(key));
       sendErrorMessages(playerName);
     }
   }
   return message;
 }
Exemplo n.º 12
0
 private void handleBlockChange(Player player, Block block, short entityID, String mobName) {
   if (!player.hasPermission("silkspawners.changetype." + mobName)) {
     su.sendMessage(
         player,
         ChatColor.translateAlternateColorCodes(
             '\u0026', plugin.localization.getString("noPermissionChangingSpawner")));
     return;
   }
   // Call the event and maybe change things!
   SilkSpawnersSpawnerChangeEvent changeEvent =
       new SilkSpawnersSpawnerChangeEvent(
           player, block, entityID, su.getSpawnerEntityID(block), 1);
   plugin.getServer().getPluginManager().callEvent(changeEvent);
   // See if we need to stop
   if (changeEvent.isCancelled()) {
     return;
   }
   // Get the new ID (might be changed)
   short newEntityID = changeEvent.getEntityID();
   String newMob = su.getCreatureName(entityID);
   if (su.setSpawnerType(
       block,
       newEntityID,
       player,
       ChatColor.translateAlternateColorCodes(
           '\u0026', plugin.localization.getString("changingDeniedWorldGuard")))) {
     su.sendMessage(
         player,
         ChatColor.translateAlternateColorCodes(
                 '\u0026', plugin.localization.getString("changedSpawner"))
             .replace("%creature%", newMob));
   }
 }
Exemplo n.º 13
0
  public void loadLocales() {
    Strings.clear();

    FileConfiguration locales = plugin.yml.getYMLConfig(Config.getLocale(), true);

    if (locales != null) {
      String value;
      for (String key : locales.getKeys(false)) {
        value = locales.getString(key);
        Strings.put(key, ChatColor.translateAlternateColorCodes('&', value));
      }
    }

    locales = plugin.yml.getYMLConfig("enUS.yml", true);

    if (locales != null) {
      String value;
      for (String key : locales.getKeys(false)) {
        if (!Strings.containsKey(key)) {
          value = locales.getString(key);
          Strings.put(key, ChatColor.translateAlternateColorCodes('&', value));
        }
      }
    }
  }
Exemplo n.º 14
0
 @Command(
     aliases = "npc",
     usage = "color [color-code]",
     desc = "set the name color of an NPC",
     modifiers = "color",
     min = 2,
     max = 2)
 @CommandPermissions("basic.modify.color")
 public static void color(CommandContext args, Player player, HumanNPC npc) {
   if (!args.getString(1).substring(0, 1).equals("&")) {
     player.sendMessage(ChatColor.RED + "Use an & to specify color.");
   } else if (args.getString(1).length() != 2) {
     player.sendMessage(ChatColor.GRAY + "Use the format &(code). Example - &f = white.");
   } else {
     char colour = args.getString(1).charAt(1);
     if (ChatColor.getByChar(colour) == null) {
       player.sendMessage(ChatColor.RED + "Color code not recognised.");
       return;
     }
     npc.getNPCData().setColour(ChatColor.getByChar(colour));
     NPCManager.setColour(npc.getUID(), npc.getOwner());
     player.sendMessage(
         StringUtils.wrapFull(
             "{"
                 + npc.getName()
                 + "}'s name color is now "
                 + args.getString(1).replace("&", "\u00A7")
                 + "this}."));
   }
 }
Exemplo n.º 15
0
  public Config(FileConfiguration fC) {
    Prefixes_Enabled = fC.getBoolean("prefixes.enabled");
    if (Prefixes_Enabled) {
      Prefixes_DefaultPrefix = fC.getString("prefixes.default-prefix");
      if (Prefixes_DefaultPrefix == null) {
        Prefixes_DefaultPrefix = "";
      } else if (Prefixes_DefaultPrefix.length() > 16) {
        Prefixes_DefaultPrefix = Prefixes_DefaultPrefix.substring(0, 16);
      }
    }

    RulesReminder_Enabled = fC.getBoolean("rules-reminder.enabled");
    if (RulesReminder_Enabled) {
      RulesReminder_Message =
          ChatColor.translateAlternateColorCodes('&', fC.getString("rules-reminder.message"));
      RulesReminder_Version = fC.getInt("rules-reminder.version");
    }

    MailboxReminder_Enabled = fC.getBoolean("mailbox-reminder.enabled");
    if (MailboxReminder_Enabled) {
      MailboxReminder_Message =
          ChatColor.translateAlternateColorCodes('&', fC.getString("mailbox-reminder.message"));
    }

    AfkKicker_MaxIdleSeconds = fC.getInt("afk-kicker.max-idle-seconds");

    Homes_Enabled = fC.getBoolean("homes.enabled");

    WebPw_Enabled = fC.getBoolean("webpw.enabled");
  }
Exemplo n.º 16
0
 public void sendTitle(
     Player player, int fadein, int stay, int fadeout, String title, String subtitle) {
   PlayerConnection pConn = ((CraftPlayer) player).getHandle().playerConnection;
   PacketPlayOutTitle pTitleInfo =
       new PacketPlayOutTitle(
           PacketPlayOutTitle.EnumTitleAction.TIMES,
           (IChatBaseComponent) null,
           (int) fadein,
           (int) stay,
           (int) fadeout);
   pConn.sendPacket(pTitleInfo);
   if (subtitle != null) {
     subtitle = subtitle.replaceAll("%player%", player.getDisplayName());
     subtitle = ChatColor.translateAlternateColorCodes('&', subtitle);
     IChatBaseComponent iComp =
         IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + subtitle + "\"}");
     PacketPlayOutTitle pSubtitle =
         new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.SUBTITLE, iComp);
     pConn.sendPacket(pSubtitle);
   }
   if (title != null) {
     title = title.replaceAll("%player%", player.getDisplayName());
     title = ChatColor.translateAlternateColorCodes('&', title);
     IChatBaseComponent iComp =
         IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + title + "\"}");
     PacketPlayOutTitle pTitle =
         new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TITLE, iComp);
     pConn.sendPacket(pTitle);
   }
 }
Exemplo n.º 17
0
 @Override
 public boolean equals(final Object object) {
   if (!(object instanceof User)) {
     return false;
   }
   return ChatColor.stripColor(this.getDisplayName())
       .equalsIgnoreCase(ChatColor.stripColor(((User) object).getDisplayName()));
 }
Exemplo n.º 18
0
  /**
   * Parse a ConfigurationSection representing a AlchemyPotion. Returns null if input cannot be
   * parsed.
   *
   * @param potion_section ConfigurationSection to be parsed.
   * @return Parsed AlchemyPotion.
   */
  private AlchemyPotion loadPotion(ConfigurationSection potion_section) {
    try {
      short dataValue = Short.parseShort(potion_section.getName());

      String name = potion_section.getString("Name");
      if (name != null) {
        name = ChatColor.translateAlternateColorCodes('&', name);
      }

      List<String> lore = new ArrayList<String>();
      if (potion_section.contains("Lore")) {
        for (String line : potion_section.getStringList("Lore")) {
          lore.add(ChatColor.translateAlternateColorCodes('&', line));
        }
      }

      List<PotionEffect> effects = new ArrayList<PotionEffect>();
      if (potion_section.contains("Effects")) {
        for (String effect : potion_section.getStringList("Effects")) {
          String[] parts = effect.split(" ");

          PotionEffectType type = parts.length > 0 ? PotionEffectType.getByName(parts[0]) : null;
          int amplifier = parts.length > 1 ? Integer.parseInt(parts[1]) : 0;
          int duration = parts.length > 2 ? Integer.parseInt(parts[2]) : 0;

          if (type != null) {
            effects.add(new PotionEffect(type, duration, amplifier));
          } else {
            mcMMO
                .p
                .getLogger()
                .warning("Failed to parse effect for potion " + name + ": " + effect);
          }
        }
      }

      Map<ItemStack, Short> children = new HashMap<ItemStack, Short>();
      if (potion_section.contains("Children")) {
        for (String child : potion_section.getConfigurationSection("Children").getKeys(false)) {
          ItemStack ingredient = loadIngredient(child);
          if (ingredient != null) {
            children.put(
                ingredient,
                Short.parseShort(
                    potion_section.getConfigurationSection("Children").getString(child)));
          } else {
            mcMMO.p.getLogger().warning("Failed to parse child for potion " + name + ": " + child);
          }
        }
      }

      return new AlchemyPotion(dataValue, name, lore, effects, children);
    } catch (Exception e) {
      mcMMO.p.getLogger().warning("Failed to load Alchemy potion: " + potion_section.getName());
      return null;
    }
  }
Exemplo n.º 19
0
 @Test
 public void testRemoveColor() {
   List<String[]> items = new LinkedList<String[]>();
   for (String[] item :
       new String[][] {
         {"", ""},
         {" ", " "},
         {"&", "&"},
         {"&&", "&&"},
         {"o3rg7cbo'!§)=?%V823rg7c", "o3rg7cbo'!§)=?%V823rg7c"},
       }) {
     items.add(item);
   }
   String[][] generic =
       new String[][] {
         {"&/&/&/", ""},
         {"&/&/", ""},
         {" &/&/ ", "  "},
         {" &/&/", " "},
         {"&/", ""},
         {"&/ ", " "},
         {" &/", " "},
         {"123&/123", "123123"},
       };
   for (ChatColor color : ChatColor.values()) {
     char c = color.getChar();
     for (String[] pattern : generic) {
       items.add(new String[] {pattern[0].replace('/', c), pattern[1]});
     }
   }
   int i = 0;
   for (String[] item : items) {
     String input = item[0];
     String expectedOutput = item[1];
     String detail = "no details.";
     String output = "(ERROR)";
     try {
       output = ColorUtil.removeColors(input);
     } catch (Throwable t) {
       detail = t.getClass().getSimpleName() + ": " + t.getMessage();
     }
     if (!expectedOutput.equals(output)) {
       fail(
           "Wrong output at index "
               + i
               + " for input '"
               + input
               + "', expected '"
               + expectedOutput
               + "', but got instead: '"
               + output
               + "', details: "
               + detail);
     }
     i++;
   }
 }
Exemplo n.º 20
0
  public String getNick(final boolean longnick) {
    final StringBuilder prefix = new StringBuilder();
    String nickname;
    String suffix = "";
    final String nick = getNickname();
    if (ess.getSettings().isCommandDisabled("nick")
        || nick == null
        || nick.isEmpty()
        || nick.equals(getName())) {
      nickname = getName();
    } else if (nick.equalsIgnoreCase(getName())) {
      nickname = nick;
    } else {
      nickname = ess.getSettings().getNicknamePrefix() + nick;
      suffix = "§r";
    }

    if (this.getBase().isOp()) {
      try {
        final ChatColor opPrefix = ess.getSettings().getOperatorColor();
        if (opPrefix != null && opPrefix.toString().length() > 0) {
          prefix.insert(0, opPrefix.toString());
          suffix = "§r";
        }
      } catch (Exception e) {
      }
    }

    if (ess.getSettings().addPrefixSuffix()) {
      // These two extra toggles are not documented, because they are mostly redundant #EasterEgg
      if (!ess.getSettings().disablePrefix()) {
        final String ptext = ess.getPermissionsHandler().getPrefix(base).replace('&', '§');
        prefix.insert(0, ptext);
        suffix = "§r";
      }
      if (!ess.getSettings().disableSuffix()) {
        final String stext = ess.getPermissionsHandler().getSuffix(base).replace('&', '§');
        suffix = stext + "§r";
        suffix = suffix.replace("§f§f", "§f").replace("§f§r", "§r").replace("§r§r", "§r");
      }
    }
    final String strPrefix = prefix.toString();
    String output = strPrefix + nickname + suffix;
    if (!longnick && output.length() > 16) {
      output = strPrefix + nickname;
    }
    if (!longnick && output.length() > 16) {
      output = FormatUtil.lastCode(strPrefix) + nickname;
    }
    if (!longnick && output.length() > 16) {
      output = FormatUtil.lastCode(strPrefix) + nickname.substring(0, 14);
    }
    if (output.charAt(output.length() - 1) == '§') {
      output = output.substring(0, output.length() - 1);
    }
    return output;
  }
Exemplo n.º 21
0
 public JSONMessage style(final ChatColor... styles) {
   for (final ChatColor style : styles) {
     if (!style.isFormat()) {
       throw new IllegalArgumentException(style.name() + " is not a style");
     }
   }
   latest().styles = styles;
   return this;
 }
Exemplo n.º 22
0
 /**
  * Sets the stylization of the current editing component.
  *
  * @param styles The array of styles to apply to the editing component.
  * @return This builder instance.
  * @exception IllegalArgumentException If any of the enumeration values in the array do not
  *     represent formatters.
  */
 public FancyMessage style(ChatColor... styles) {
   for (final ChatColor style : styles) {
     if (!style.isFormat()) {
       throw new IllegalArgumentException(style.name() + " is not a style");
     }
   }
   latest().styles.addAll(Arrays.asList(styles));
   dirty = true;
   return this;
 }
Exemplo n.º 23
0
  private void handleChange(CommandSender sender, String newMob) {
    if (sender instanceof Player) {
      if (su.isUnkown(newMob)) {
        su.sendMessage(
            sender,
            ChatColor.translateAlternateColorCodes(
                    '\u0026', plugin.localization.getString("unknownCreature"))
                .replace("%creature%", newMob));
        return;
      }

      // entityID
      short entityID = su.name2Eid.get(newMob);
      String creature = su.getCreatureName(entityID);
      // Filter spaces (like Zombie Pigman)
      String mobName = creature.toLowerCase().replace(" ", "");

      Player player = (Player) sender;

      int distance = plugin.config.getInt("spawnerCommandReachDistance", 6);
      // If the distance is -1, return
      if (distance != -1) {
        // Get the block
        Block block = su.nmsProvider.getSpawnerFacing(player, distance);
        if (block != null) {
          handleBlockChange(player, block, entityID, mobName);
          return;
        }
      }

      ItemStack itemInHand = su.nmsProvider.getSpawnerItemInHand(player);
      Material itemMaterial;
      try {
        itemMaterial = itemInHand.getType();
      } catch (NullPointerException e) {
        itemMaterial = null;
      }

      if (itemMaterial != null && itemMaterial == Material.MOB_SPAWNER) {
        handleChangeSpawner(player, entityID, mobName, itemInHand);
      } else if (itemMaterial != null && itemMaterial == SilkUtil.SPAWN_EGG) {
        handleChangeEgg(player, entityID, mobName, itemInHand);
      } else {
        su.sendMessage(
            player,
            ChatColor.translateAlternateColorCodes(
                '\u0026', plugin.localization.getString("spawnerNotDeterminable")));
      }
    } else {
      su.sendMessage(
          sender,
          ChatColor.translateAlternateColorCodes(
              '\u0026', plugin.localization.getString("noConsole")));
    }
  }
  @Override
  public boolean run(
      CommandSender sender,
      Player sender_p,
      Command cmd,
      String commandLabel,
      String[] args,
      boolean senderIsConsole) {
    if (args.length != 1) {
      return false;
    }

    if ("off".equals(args[0])) {
      TFM_EssentialsBridge.setNickname(sender.getName(), null);
      playerMsg("Nickname cleared.");
      return true;
    }

    final String nickPlain = ChatColor.stripColor(TFM_Util.colorize(args[0].trim()));

    if (!nickPlain.matches("^[a-zA-Z_0-9\u00a7]+$")) {
      playerMsg("That nickname contains invalid characters.");
      return true;
    } else if (nickPlain.length() < 4 || nickPlain.length() > 30) {
      playerMsg("Your nickname must be between 4 and 30 characters long.");
      return true;
    }

    final Player[] onlinePlayers = server.getOnlinePlayers();
    for (final Player player : onlinePlayers) {
      if (player == sender_p) {
        continue;
      }
      if (player.getName().equalsIgnoreCase(nickPlain)
          || ChatColor.stripColor(player.getDisplayName()).trim().equalsIgnoreCase(nickPlain)) {
        playerMsg("That nickname is already in use.");
        return true;
      }
    }

    final StringBuilder newNick = new StringBuilder();

    final char[] chars = nickPlain.toCharArray();
    for (char c : chars) {
      newNick.append(TFM_Util.randomChatColor()).append(c);
    }

    newNick.append(ChatColor.WHITE);

    TFM_EssentialsBridge.setNickname(sender.getName(), newNick.toString());

    playerMsg("Your nickname is now: " + newNick.toString());

    return true;
  }
Exemplo n.º 25
0
 @Override
 protected void loadFromConfig(ConfigurationSection config) {
   title = config.getString("title", title);
   if (title != null) title = ChatColor.translateAlternateColorCodes('&', title);
   subtitle = config.getString("subtitle", subtitle);
   if (subtitle != null) subtitle = ChatColor.translateAlternateColorCodes('&', subtitle);
   fadeIn = config.getInt("fade-in", fadeIn);
   stay = config.getInt("stay", stay);
   fadeOut = config.getInt("fade-out", fadeOut);
   broadcast = config.getBoolean("broadcast", broadcast);
 }
Exemplo n.º 26
0
 @Override
 public boolean isExplosionsEnabled(Location loc) {
   Faction faction = Board.getFactionAt(new FLocation(loc));
   if (ChatColor.stripColor(faction.getTag()).equalsIgnoreCase("safezone")
       || ChatColor.stripColor(faction.getTag()).equalsIgnoreCase("warzone")) {
     // ObsidianDestroyer.debug("Factions18x.isExplosionsEnabled: false");
     return false;
   }
   // ObsidianDestroyer.debug("Factions18x.isExplosionsEnabled: " +
   // faction.getFlag(FFlag.EXPLOSIONS));
   return faction.getFlag(FFlag.EXPLOSIONS);
 }
Exemplo n.º 27
0
 @Override
 @Localized("CRAZYCHATS.COMMAND.COLORHELP $ColorHelp$")
 public void command(final CommandSender sender, final String[] args) throws CrazyException {
   final StringBuilder builder = new StringBuilder();
   for (final ChatColor color : ChatColor.values())
     builder
         .append(color.toString())
         .append(Character.toUpperCase(color.getChar()))
         .append(color.getChar())
         .append(ChatColor.RESET);
   plugin.sendLocaleMessage("COMMAND.COLORHELP", sender, builder.toString());
 }
Exemplo n.º 28
0
 public static void sendTranslatedMessage(CommandSender player, String message) {
   if (messagePrefix != null) {
     if (player != null) {
       player.sendMessage(
           ChatColor.translateAlternateColorCodes('&', messagePrefix + " " + message));
     }
   } else {
     if (player != null) {
       player.sendMessage(ChatColor.translateAlternateColorCodes('&', message));
     }
   }
 }
Exemplo n.º 29
0
  @Override
  protected void run(Player player, String[] args) {
    if (args.length > 0) {

      String realName = Bukkit.getPlayer(args[0]).getName();
      String primGroup = XeChat.chat.getPrimaryGroup("world", realName);
      String primGroupPrefix = XeChat.chat.getGroupPrefix("world", primGroup);
      String prefix = ChatColor.translateAlternateColorCodes('&', primGroupPrefix);
      player.sendMessage(
          ChatColor.AQUA
              + "[XeChat]: "
              + prefix
              + realName
              + ChatColor.AQUA
              + " is in "
              + prefix
              + primGroup
              + ChatColor.AQUA
              + ".");

    } else {

      HashMap<String, ArrayList<Player>> ranks = new HashMap<String, ArrayList<Player>>();
      for (Player player1 : Bukkit.getOnlinePlayers()) {
        String realName = player1.getName();
        String primGroup = XeChat.chat.getPrimaryGroup("world", realName);
        if (ranks.containsKey(primGroup)) {
          ArrayList<Player> players = ranks.get(primGroup);
          players.add(player1);
          ranks.put(primGroup, players);
        } else {
          ArrayList<Player> players = new ArrayList<Player>();
          players.add(player1);
          ranks.put(primGroup, players);
        }
      }

      for (Map.Entry<String, ArrayList<Player>> entry : ranks.entrySet()) {
        String s = "";
        for (Player player1 : entry.getValue()) {
          s += player1.getName() + ", ";
        }
        s = s.substring(0, s.length() - 2);
        String primGroupPrefix = XeChat.chat.getGroupPrefix("world", entry.getKey());
        String prefix = ChatColor.translateAlternateColorCodes('&', primGroupPrefix);
        player.sendMessage(prefix + entry.getKey() + " [" + entry.getValue().size() + "] : " + s);
      }

      //            player.sendMessage(ChatColor.RED + "[XeChat]: SYNTAX ERROR, Type /rank [name] To
      // get the rank of a player.");
    }
  }
  public static String replaceColorCodes(String message) {
    ChatColor arr$[] = ChatColor.values();
    int len$ = arr$.length;
    for (int i$ = 0; i$ < len$; i$++) {
      ChatColor color = arr$[i$];
      message =
          message.replaceAll(
              String.format("&%c", new Object[] {Character.valueOf(color.getChar())}),
              color.toString());
    }

    return message;
  }