    001    package net.minecraft.util;
    002
    003    import java.io.BufferedReader;
    004    import java.io.InputStreamReader;
    005
    006    public class ChatAllowedCharacters
    007    {
    008        /**
    009         * This String have the characters allowed in any text drawing of minecraft.
    010         */
    011        public static final String allowedCharacters = getAllowedCharacters();
    012
    013        /**
    014         * Array of the special characters that are allowed in any text drawing of Minecraft.
    015         */
    016        public static final char[] allowedCharactersArray = new char[] {'/', '\n', '\r', '\t', '\u0000', '\f', '`', '?', '*', '\\', '<', '>', '|', '\"', ':'};
    017
    018        /**
    019         * Load the font.txt resource file, that is on UTF-8 format. This file contains the characters that minecraft can
    020         * render Strings on screen.
    021         */
    022        private static String getAllowedCharacters()
    023        {
    024            String var0 = "";
    025
    026            try
    027            {
    028                BufferedReader var1 = new BufferedReader(new InputStreamReader(ChatAllowedCharacters.class.getResourceAsStream("/font.txt"), "UTF-8"));
    029                String var2 = "";
    030
    031                while ((var2 = var1.readLine()) != null)
    032                {
    033                    if (!var2.startsWith("#"))
    034                    {
    035                        var0 = var0 + var2;
    036                    }
    037                }
    038
    039                var1.close();
    040            }
    041            catch (Exception var3)
    042            {
    043                ;
    044            }
    045
    046            return var0;
    047        }
    048
    049        public static final boolean isAllowedCharacter(char par0)
    050        {
    051            return par0 != 167 && (allowedCharacters.indexOf(par0) >= 0 || par0 > 32);
    052        }
    053
    054        /**
    055         * Filter string by only keeping those characters for which isAllowedCharacter() returns true.
    056         */
    057        public static String filerAllowedCharacters(String par0Str)
    058        {
    059            StringBuilder var1 = new StringBuilder();
    060            char[] var2 = par0Str.toCharArray();
    061            int var3 = var2.length;
    062
    063            for (int var4 = 0; var4 < var3; ++var4)
    064            {
    065                char var5 = var2[var4];
    066
    067                if (isAllowedCharacter(var5))
    068                {
    069                    var1.append(var5);
    070                }
    071            }
    072
    073            return var1.toString();
    074        }
    075    }