Java Code Examples for net.minecraft.util.ChatAllowedCharacters

The following are top voted examples for showing how to use net.minecraft.util.ChatAllowedCharacters. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: RunicArcana   File: GuiPaperScrap.java   View source code 6 votes vote down vote up
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
    if (keyCode == 14 && !this.text.isEmpty())
    {
        this.text = this.text.substring(0, this.text.length() - 1);
    }

    if (ChatAllowedCharacters.isAllowedCharacter(typedChar) && this.fontRendererObj.getStringWidth(this.text + typedChar) <= 90)
    {
        this.text = this.text + typedChar;
    }


    if (keyCode == 1 || keyCode== Keyboard.KEY_RETURN)
    {
        this.actionPerformed(this.doneBtn);
    }
}
 
Example 2
Project: DecompiledMinecraft   File: GuiCreateWorld.java   View source code 6 votes vote down vote up
private void func_146314_g()
{
    this.field_146336_i = this.field_146333_g.getText().trim();

    for (char c0 : ChatAllowedCharacters.allowedCharactersArray)
    {
        this.field_146336_i = this.field_146336_i.replace(c0, '_');
    }

    if (StringUtils.isEmpty(this.field_146336_i))
    {
        this.field_146336_i = "World";
    }

    this.field_146336_i = func_146317_a(this.mc.getSaveLoader(), this.field_146336_i);
}
 
Example 3
Project: BaseClient   File: GuiCreateWorld.java   View source code 6 votes vote down vote up
private void func_146314_g()
{
    this.field_146336_i = this.field_146333_g.getText().trim();

    for (char c0 : ChatAllowedCharacters.allowedCharactersArray)
    {
        this.field_146336_i = this.field_146336_i.replace(c0, '_');
    }

    if (StringUtils.isEmpty(this.field_146336_i))
    {
        this.field_146336_i = "World";
    }

    this.field_146336_i = func_146317_a(this.mc.getSaveLoader(), this.field_146336_i);
}
 
Example 4
Project: BaseClient   File: GuiCreateWorld.java   View source code 6 votes vote down vote up
private void func_146314_g()
{
    this.field_146336_i = this.field_146333_g.getText().trim();

    for (char c0 : ChatAllowedCharacters.allowedCharactersArray)
    {
        this.field_146336_i = this.field_146336_i.replace(c0, '_');
    }

    if (StringUtils.isEmpty(this.field_146336_i))
    {
        this.field_146336_i = "World";
    }

    this.field_146336_i = func_146317_a(this.mc.getSaveLoader(), this.field_146336_i);
}
 
Example 5
Project: Backmemed   File: GuiCreateWorld.java   View source code 6 votes vote down vote up
/**
 * Determine a save-directory name from the world name
 */
private void calcSaveDirName()
{
    this.saveDirName = this.worldNameField.getText().trim();

    for (char c0 : ChatAllowedCharacters.ILLEGAL_FILE_CHARACTERS)
    {
        this.saveDirName = this.saveDirName.replace(c0, '_');
    }

    if (StringUtils.isEmpty(this.saveDirName))
    {
        this.saveDirName = "World";
    }

    this.saveDirName = getUncollidingSaveDirName(this.mc.getSaveLoader(), this.saveDirName);
}
 
Example 6
Project: Backmemed   File: GuiEditStructure.java   View source code 6 votes vote down vote up
private static boolean isValidCharacterForName(char p_190301_0_, int p_190301_1_)
{
    boolean flag = true;

    for (int i : LEGAL_KEY_CODES)
    {
        if (i == p_190301_1_)
        {
            return true;
        }
    }

    for (char c0 : ChatAllowedCharacters.ILLEGAL_STRUCTURE_CHARACTERS)
    {
        if (c0 == p_190301_0_)
        {
            flag = false;
            break;
        }
    }

    return flag;
}
 
Example 7
Project: CustomWorldGen   File: GuiCreateWorld.java   View source code 6 votes vote down vote up
/**
 * Determine a save-directory name from the world name
 */
private void calcSaveDirName()
{
    this.saveDirName = this.worldNameField.getText().trim();

    for (char c0 : ChatAllowedCharacters.ILLEGAL_FILE_CHARACTERS)
    {
        this.saveDirName = this.saveDirName.replace(c0, '_');
    }

    if (StringUtils.isEmpty(this.saveDirName))
    {
        this.saveDirName = "World";
    }

    this.saveDirName = getUncollidingSaveDirName(this.mc.getSaveLoader(), this.saveDirName);
}
 
Example 8
Project: CustomWorldGen   File: GuiEditStructure.java   View source code 6 votes vote down vote up
private static boolean isValidCharacterForName(char p_190301_0_, int p_190301_1_)
{
    boolean flag = true;

    for (int i : LEGAL_KEY_CODES)
    {
        if (i == p_190301_1_)
        {
            return true;
        }
    }

    for (char c0 : ChatAllowedCharacters.ILLEGAL_STRUCTURE_CHARACTERS)
    {
        if (c0 == p_190301_0_)
        {
            flag = false;
            break;
        }
    }

    return flag;
}
 
Example 9
Project: 4Space-5   File: GuiLaunchController.java   View source code 6 votes vote down vote up
public boolean isValid(String string)
{
    if (string.length() > 0 && ChatAllowedCharacters.isAllowedCharacter(string.charAt(string.length() - 1)))
    {
        try
        {
            Integer.parseInt(string);
            return true;
        }
        catch (Exception e)
        {
            return false;
        }
    }
    else
    {
        return false;
    }
}
 
Example 10
Project: Simple-Dimensions   File: GuiCreateDimension.java   View source code 6 votes vote down vote up
private void func_146314_g()
{
	this.field_146336_i = this.dimensionNameTextField.getText().trim();
	char[] achar = ChatAllowedCharacters.ILLEGAL_FILE_CHARACTERS;
	int i = achar.length;

	for (int j = 0; j < i; ++j)
	{
		char c0 = achar[j];
		this.field_146336_i = this.field_146336_i.replace(c0, '_');
	}

	if (StringUtils.isEmpty(this.field_146336_i))
	{
		this.field_146336_i = "World";
	}

	this.field_146336_i = func_146317_a(this.mc.getSaveLoader(), this.field_146336_i);
}
 
Example 11
Project: jGui   File: AbstractGuiTextField.java   View source code 6 votes vote down vote up
@Override
public T writeChar(char c) {
    if (!ChatAllowedCharacters.isAllowedCharacter(c)) {
        return getThis();
    }

    deleteSelectedText();

    if (text.length() >= maxLength) {
        return getThis();
    }

    text = text.substring(0, cursorPos) + c + text.substring(cursorPos);
    selectionPos = ++cursorPos;

    return getThis();
}
 
Example 12
Project: FairyFactions   File: GuiName.java   View source code 6 votes vote down vote up
@Override
protected void keyTyped(char c, int i)
{
    if (i == 28)
    {
        mc.displayGuiScreen(null);
    }

    if (i == 14 && nameText.length() > 0)
    {
        nameText = nameText.substring(0, nameText.length() - 1);
    }

    if (ChatAllowedCharacters.isAllowedCharacter(c) && nameText.length() < 12)
    {
        nameText += c;
    }
}
 
Example 13
Project: NyaSamaRailway   File: GuiNGTablet.java   View source code 6 votes vote down vote up
private void keyTypedInngt(char p_keyTypedInngt_1_, int p_keyTypedInngt_2_) {
    switch(p_keyTypedInngt_1_) {
        case '\u0016':
            this.func_146459_b(GuiScreen.getClipboardString());
            return;
        default:
            switch(p_keyTypedInngt_2_) {
                case 14:
                    String var3 = this.func_146456_p();
                    if (var3.length() > 0) {
                        this.func_146457_a(var3.substring(0, var3.length() - 1));
                    }

                    return;
                case 28:
                case 156:
                    this.func_146459_b("\n");
                    return;
                default:
                    if (ChatAllowedCharacters.isAllowedCharacter(p_keyTypedInngt_1_)) {
                        this.func_146459_b(Character.toString(p_keyTypedInngt_1_));
                    }
            }
    }
}
 
Example 14
Project: EvenWurse   File: GuiPasswordField.java   View source code 6 votes vote down vote up
public void func_146191_b(String p_146191_1_) {
    String var2 = "";
    String var3 = ChatAllowedCharacters.filterAllowedCharacters(p_146191_1_);
    int var4 = field_146224_r < field_146223_s ? field_146224_r : field_146223_s;
    int var5 = field_146224_r < field_146223_s ? field_146223_s : field_146224_r;
    int var6 = field_146217_k - field_146216_j.length() - (var4 - field_146223_s);
    if (field_146216_j.length() > 0) var2 = var2 + field_146216_j.substring(0, var4);

    int var8;

    if (var6 < var3.length()) {
        var2 = var2 + var3.substring(0, var6);
        var8 = var6;
    } else {
        var2 = var2 + var3;
        var8 = var3.length();
    }

    if (field_146216_j.length() > 0 && var5 < field_146216_j.length()) var2 = var2 + field_146216_j.substring(var5);

    field_146216_j = var2;
    func_146182_d(var4 - field_146223_s + var8);
}
 
Example 15
Project: Resilience-Client-Source   File: GuiCreateWorld.java   View source code 6 votes vote down vote up
private void func_146314_g()
{
    this.field_146336_i = this.field_146333_g.getText().trim();
    char[] var1 = ChatAllowedCharacters.allowedCharacters;
    int var2 = var1.length;

    for (int var3 = 0; var3 < var2; ++var3)
    {
        char var4 = var1[var3];
        this.field_146336_i = this.field_146336_i.replace(var4, '_');
    }

    if (MathHelper.stringNullOrLengthZero(this.field_146336_i))
    {
        this.field_146336_i = "World";
    }

    this.field_146336_i = func_146317_a(this.mc.getSaveLoader(), this.field_146336_i);
}
 
Example 16
Project: Progression   File: TextEditor.java   View source code 6 votes vote down vote up
public void keyTyped(char character, int key) {
    if (isTextEditing && editable != null) {
        ///Reset is just in case
        //setEditable(editable);
        if (key == 203) {
            cursorLeft(1);
        } else if (key == 205) {
            cursorRight(1);
        } else if (character == 22) {
            add(GuiScreen.getClipboardString());
        } else if (key == 14) {
            delete(-1);
        } else if (key == 211) {
            delete(0);
        } else if (key == 28 || key == 156) {
            add("\n");
        } else if (ChatAllowedCharacters.isAllowedCharacter(character)) {
            add(Character.toString(character));
        }
        
        //Update the cache
        cachedPosition.put(editable, position);
    }
}
 
Example 17
Project: Nuclear-Control   File: GuiTextArea.java   View source code 6 votes vote down vote up
public void writeText(String additionalText) {
	String newLine = "";
	String filteredText = ChatAllowedCharacters.filerAllowedCharacters(additionalText);
	int freeCharCount = this.maxStringLength - text[cursorLine].length();

	if (text[cursorLine].length() > 0)
		newLine = newLine + text[cursorLine].substring(0, cursorPosition);

	if (freeCharCount < filteredText.length())
		newLine = newLine + filteredText.substring(0, freeCharCount);
	else
		newLine = newLine + filteredText;

	if (text[cursorLine].length() > 0 && cursorPosition < text[cursorLine].length())
		newLine = newLine + text[cursorLine].substring(cursorPosition);

	text[cursorLine] = newLine;
	setCursorPosition(cursorPosition + filteredText.length(), cursorLine);
}
 
Example 18
Project: ExpandedRailsMod   File: GuiCreateWorld.java   View source code 6 votes vote down vote up
/**
 * Determine a save-directory name from the world name
 */
private void calcSaveDirName()
{
    this.saveDirName = this.worldNameField.getText().trim();

    for (char c0 : ChatAllowedCharacters.ILLEGAL_FILE_CHARACTERS)
    {
        this.saveDirName = this.saveDirName.replace(c0, '_');
    }

    if (StringUtils.isEmpty(this.saveDirName))
    {
        this.saveDirName = "World";
    }

    this.saveDirName = getUncollidingSaveDirName(this.mc.getSaveLoader(), this.saveDirName);
}
 
Example 19
Project: ExpandedRailsMod   File: GuiEditStructure.java   View source code 6 votes vote down vote up
private static boolean func_190301_b(char p_190301_0_, int p_190301_1_)
{
    boolean flag = true;

    for (int i : field_190302_a)
    {
        if (i == p_190301_1_)
        {
            return true;
        }
    }

    for (char c0 : ChatAllowedCharacters.field_189861_b)
    {
        if (c0 == p_190301_0_)
        {
            flag = false;
            break;
        }
    }

    return flag;
}
 
Example 20
Project: MoarPeripherals   File: ChatUtil.java   View source code 6 votes vote down vote up
public static void sendChatToPlayer(String[] to, String message) {
    // remove illegal characters
    message = ChatAllowedCharacters.filerAllowedCharacters(message);

    // allow color, bold, italic, and underline formatting
    for (EnumChatFormatting formatting : EnumChatFormatting.values()) {
        message = message.replace(PREFIX + formatting.getFormattingCode(), formatting.toString());
    }

    final ChatComponentText msg = new ChatComponentText(message);
    for (String user : to) {
        final EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(user);
        if (player != null) {
            player.addChatComponentMessage(msg);
        }
    }
}
 
Example 21
Project: Cauldron   File: GuiCreateWorld.java   View source code 6 votes vote down vote up
private void func_146314_g()
{
    this.field_146336_i = this.field_146333_g.getText().trim();
    char[] achar = ChatAllowedCharacters.allowedCharacters;
    int i = achar.length;

    for (int j = 0; j < i; ++j)
    {
        char c0 = achar[j];
        this.field_146336_i = this.field_146336_i.replace(c0, '_');
    }

    if (MathHelper.stringNullOrLengthZero(this.field_146336_i))
    {
        this.field_146336_i = "World";
    }

    this.field_146336_i = func_146317_a(this.mc.getSaveLoader(), this.field_146336_i);
}
 
Example 22
Project: Cauldron   File: GuiCreateWorld.java   View source code 6 votes vote down vote up
private void func_146314_g()
{
    this.field_146336_i = this.field_146333_g.getText().trim();
    char[] achar = ChatAllowedCharacters.allowedCharacters;
    int i = achar.length;

    for (int j = 0; j < i; ++j)
    {
        char c0 = achar[j];
        this.field_146336_i = this.field_146336_i.replace(c0, '_');
    }

    if (MathHelper.stringNullOrLengthZero(this.field_146336_i))
    {
        this.field_146336_i = "World";
    }

    this.field_146336_i = func_146317_a(this.mc.getSaveLoader(), this.field_146336_i);
}
 
Example 23
Project: projectzulu1.7.10-pre-1.3a   File: GuiTombstone.java   View source code 6 votes vote down vote up
/**
 * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
 */
@Override
protected void keyTyped(char keyChar, int keyID) {
    if (keyID == Keyboard.KEY_UP) {
        editLine = editLine - 1 >= 0 ? editLine - 1 : entitySign.signText.length - 1;
    }

    if (keyID == Keyboard.KEY_DOWN || keyID == Keyboard.KEY_RETURN) {
        editLine = editLine + 1 < entitySign.signText.length ? editLine + 1 : 0;
    }

    if (keyID == Keyboard.KEY_BACK && entitySign.signText[editLine].length() > 0) {
        entitySign.signText[editLine] = entitySign.signText[editLine].substring(0,
                entitySign.signText[editLine].length() - 1);
    }

    if (ChatAllowedCharacters.isAllowedCharacter(keyChar) && entitySign.signText[editLine].length() < entitySign.maxcharPerLine) {
        entitySign.signText[editLine] = entitySign.signText[editLine] + keyChar;
    }
}
 
Example 24
Project: RuneCraftery   File: GuiScreenBook.java   View source code 6 votes vote down vote up
private void func_74164_b(char p_74164_1_, int p_74164_2_) {
   switch(p_74164_1_) {
   case 22:
      this.func_74160_b(GuiScreen.func_73870_l());
      return;
   default:
      switch(p_74164_2_) {
      case 14:
         String var3 = this.func_74158_i();
         if(var3.length() > 0) {
            this.func_74159_a(var3.substring(0, var3.length() - 1));
         }

         return;
      case 28:
      case 156:
         this.func_74160_b("\n");
         return;
      default:
         if(ChatAllowedCharacters.func_71566_a(p_74164_1_)) {
            this.func_74160_b(Character.toString(p_74164_1_));
         }
      }
   }
}
 
Example 25
Project: RuneCraftery   File: GuiScreenBook.java   View source code 6 votes vote down vote up
private void func_74162_c(char p_74162_1_, int p_74162_2_) {
   switch(p_74162_2_) {
   case 14:
      if(!this.field_74176_t.isEmpty()) {
         this.field_74176_t = this.field_74176_t.substring(0, this.field_74176_t.length() - 1);
         this.func_74161_g();
      }

      return;
   case 28:
   case 156:
      if(!this.field_74176_t.isEmpty()) {
         this.func_74163_a(true);
         this.field_73882_e.func_71373_a((GuiScreen)null);
      }

      return;
   default:
      if(this.field_74176_t.length() < 16 && ChatAllowedCharacters.func_71566_a(p_74162_1_)) {
         this.field_74176_t = this.field_74176_t + Character.toString(p_74162_1_);
         this.func_74161_g();
         this.field_74166_d = true;
      }

   }
}
 
Example 26
Project: RuneCraftery   File: GuiCreateWorld.java   View source code 6 votes vote down vote up
private void func_73912_g() {
   this.field_73918_d = this.field_73919_b.func_73781_b().trim();
   char[] var1 = ChatAllowedCharacters.field_71567_b;
   int var2 = var1.length;

   for(int var3 = 0; var3 < var2; ++var3) {
      char var4 = var1[var3];
      this.field_73918_d = this.field_73918_d.replace(var4, '_');
   }

   if(MathHelper.func_76139_a(this.field_73918_d)) {
      this.field_73918_d = "World";
   }

   this.field_73918_d = func_73913_a(this.field_73882_e.func_71359_d(), this.field_73918_d);
}
 
Example 27
Project: RuneCraftery   File: FontRenderer.java   View source code 6 votes vote down vote up
public int func_78263_a(char p_78263_1_) {
   if(p_78263_1_ == 167) {
      return -1;
   } else if(p_78263_1_ == 32) {
      return 4;
   } else {
      int var2 = ChatAllowedCharacters.field_71568_a.indexOf(p_78263_1_);
      if(var2 >= 0 && !this.field_78293_l) {
         return this.field_78286_d[var2 + 32];
      } else if(this.field_78287_e[p_78263_1_] != 0) {
         int var3 = this.field_78287_e[p_78263_1_] >>> 4;
         int var4 = this.field_78287_e[p_78263_1_] & 15;
         if(var4 > 7) {
            var4 = 15;
            var3 = 0;
         }

         ++var4;
         return (var4 - var3) / 2 + 1;
      } else {
         return 0;
      }
   }
}
 
Example 28
Project: RuneCraftery   File: GuiCreateWorld.java   View source code 6 votes vote down vote up
/**
 * Makes a the name for a world save folder based on your world name, replacing specific characters for _s and
 * appending -s to the end until a free name is available.
 */
private void makeUseableName()
{
    this.folderName = this.textboxWorldName.getText().trim();
    char[] achar = ChatAllowedCharacters.allowedCharactersArray;
    int i = achar.length;

    for (int j = 0; j < i; ++j)
    {
        char c0 = achar[j];
        this.folderName = this.folderName.replace(c0, '_');
    }

    if (MathHelper.stringNullOrLengthZero(this.folderName))
    {
        this.folderName = "World";
    }

    this.folderName = func_73913_a(this.mc.getSaveLoader(), this.folderName);
}
 
Example 29
Project: projectzulu1.7.10   File: GuiTombstone.java   View source code 6 votes vote down vote up
/**
 * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
 */
@Override
protected void keyTyped(char keyChar, int keyID) {
    if (keyID == Keyboard.KEY_UP) {
        editLine = editLine - 1 >= 0 ? editLine - 1 : entitySign.signText.length - 1;
    }

    if (keyID == Keyboard.KEY_DOWN || keyID == Keyboard.KEY_RETURN) {
        editLine = editLine + 1 < entitySign.signText.length ? editLine + 1 : 0;
    }

    if (keyID == Keyboard.KEY_BACK && entitySign.signText[editLine].length() > 0) {
        entitySign.signText[editLine] = entitySign.signText[editLine].substring(0,
                entitySign.signText[editLine].length() - 1);
    }

    if (ChatAllowedCharacters.isAllowedCharacter(keyChar) && entitySign.signText[editLine].length() < entitySign.maxcharPerLine) {
        entitySign.signText[editLine] = entitySign.signText[editLine] + keyChar;
    }
}
 
Example 30
Project: BetterNutritionMod   File: GuiCreateWorld.java   View source code 6 votes vote down vote up
/**
 * Makes a the name for a world save folder based on your world name, replacing specific characters for _s and
 * appending -s to the end until a free name is available.
 */
private void makeUseableName()
{
    this.folderName = this.textboxWorldName.getText().trim();
    char[] achar = ChatAllowedCharacters.allowedCharactersArray;
    int i = achar.length;

    for (int j = 0; j < i; ++j)
    {
        char c0 = achar[j];
        this.folderName = this.folderName.replace(c0, '_');
    }

    if (MathHelper.stringNullOrLengthZero(this.folderName))
    {
        this.folderName = "World";
    }

    this.folderName = func_73913_a(this.mc.getSaveLoader(), this.folderName);
}
 
Example 31
Project: Modjam-3   File: HackedCreateWorld.java   View source code 6 votes vote down vote up
/**
 * Makes a the name for a world save folder based on your world name, replacing specific characters for _s and
 * appending -s to the end until a free name is available.
 */
private void makeUseableName()
{
	this.folderName = this.textboxWorldName.getText().trim();

	for (char c0 : ChatAllowedCharacters.allowedCharactersArray)
	{
		this.folderName = this.folderName.replace(c0, '_');
	}

	if (MathHelper.stringNullOrLengthZero(this.folderName))
	{
		this.folderName = "World";
	}

	this.folderName = func_73913_a(this.mc.getSaveLoader(), this.folderName);
}
 
Example 32
Project: MineDonate   File: GuiGradientTextField.java   View source code 5 votes vote down vote up
/**
 * replaces selected text, or inserts text at the position on the cursor
 */
public void writeText(String p_146191_1_)
{
    String s1 = "";
    String s2 = ChatAllowedCharacters.filerAllowedCharacters(p_146191_1_);
    int i = this.cursorPosition < this.selectionEnd ? this.cursorPosition : this.selectionEnd;
    int j = this.cursorPosition < this.selectionEnd ? this.selectionEnd : this.cursorPosition;
    int k = this.maxStringLength - this.text.length() - (i - this.selectionEnd);

    if (this.text.length() > 0)
    {
        s1 = s1 + this.text.substring(0, i);
    }

    int l;

    if (k < s2.length())
    {
        s1 = s1 + s2.substring(0, k);
        l = k;
    }
    else
    {
        s1 = s1 + s2;
        l = s2.length();
    }

    if (this.text.length() > 0 && j < this.text.length())
    {
        s1 = s1 + this.text.substring(j);
    }

    this.text = s1;
    this.moveCursorBy(i - this.selectionEnd + l);
}
 
Example 33
Project: DecompiledMinecraft   File: GuiScreenBook.java   View source code 5 votes vote down vote up
/**
 * Processes keystrokes when editing the text of a book
 */
private void keyTypedInBook(char typedChar, int keyCode)
{
    if (GuiScreen.isKeyComboCtrlV(keyCode))
    {
        this.pageInsertIntoCurrent(GuiScreen.getClipboardString());
    }
    else
    {
        switch (keyCode)
        {
            case 14:
                String s = this.pageGetCurrent();

                if (s.length() > 0)
                {
                    this.pageSetCurrent(s.substring(0, s.length() - 1));
                }

                return;

            case 28:
            case 156:
                this.pageInsertIntoCurrent("\n");
                return;

            default:
                if (ChatAllowedCharacters.isAllowedCharacter(typedChar))
                {
                    this.pageInsertIntoCurrent(Character.toString(typedChar));
                }
        }
    }
}
 
Example 34
Project: DecompiledMinecraft   File: GuiScreenBook.java   View source code 5 votes vote down vote up
/**
 * Processes keystrokes when editing the title of a book
 */
private void keyTypedInTitle(char p_146460_1_, int p_146460_2_) throws IOException
{
    switch (p_146460_2_)
    {
        case 14:
            if (!this.bookTitle.isEmpty())
            {
                this.bookTitle = this.bookTitle.substring(0, this.bookTitle.length() - 1);
                this.updateButtons();
            }

            return;

        case 28:
        case 156:
            if (!this.bookTitle.isEmpty())
            {
                this.sendBookToServer(true);
                this.mc.displayGuiScreen((GuiScreen)null);
            }

            return;

        default:
            if (this.bookTitle.length() < 16 && ChatAllowedCharacters.isAllowedCharacter(p_146460_1_))
            {
                this.bookTitle = this.bookTitle + Character.toString(p_146460_1_);
                this.updateButtons();
                this.bookIsModified = true;
            }
    }
}
 
Example 35
Project: DecompiledMinecraft   File: GuiEditSign.java   View source code 5 votes vote down vote up
/**
 * Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
 * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
 */
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
    if (keyCode == 200)
    {
        this.editLine = this.editLine - 1 & 3;
    }

    if (keyCode == 208 || keyCode == 28 || keyCode == 156)
    {
        this.editLine = this.editLine + 1 & 3;
    }

    String s = this.tileSign.signText[this.editLine].getUnformattedText();

    if (keyCode == 14 && s.length() > 0)
    {
        s = s.substring(0, s.length() - 1);
    }

    if (ChatAllowedCharacters.isAllowedCharacter(typedChar) && this.fontRendererObj.getStringWidth(s + typedChar) <= 90)
    {
        s = s + typedChar;
    }

    this.tileSign.signText[this.editLine] = new ChatComponentText(s);

    if (keyCode == 1)
    {
        this.actionPerformed(this.doneBtn);
    }
}
 
Example 36
Project: Wurst-MC-1.12-OF   File: PasswordField.java   View source code 5 votes vote down vote up
/**
 * Adds the given text after the cursor, or replaces the currently selected
 * text if there is a selection.
 */
public void writeText(String textToWrite)
{
	String s = "";
	String s1 = ChatAllowedCharacters.filterAllowedCharacters(textToWrite);
	int i = cursorPosition < selectionEnd ? cursorPosition : selectionEnd;
	int j = cursorPosition < selectionEnd ? selectionEnd : cursorPosition;
	int k = maxStringLength - text.length() - (i - j);
	
	if(!text.isEmpty())
		s = s + text.substring(0, i);
	
	int l;
	
	if(k < s1.length())
	{
		s = s + s1.substring(0, k);
		l = k;
	}else
	{
		s = s + s1;
		l = s1.length();
	}
	
	if(!text.isEmpty() && j < text.length())
		s = s + text.substring(j);
	
	if(validator.apply(s))
	{
		text = s;
		moveCursorBy(i - selectionEnd + l);
		func_190516_a(id, text);
	}
}
 
Example 37
Project: Wurst-MC-1.12   File: PasswordField.java   View source code 5 votes vote down vote up
/**
 * Adds the given text after the cursor, or replaces the currently selected
 * text if there is a selection.
 */
public void writeText(String textToWrite)
{
	String s = "";
	String s1 = ChatAllowedCharacters.filterAllowedCharacters(textToWrite);
	int i = cursorPosition < selectionEnd ? cursorPosition : selectionEnd;
	int j = cursorPosition < selectionEnd ? selectionEnd : cursorPosition;
	int k = maxStringLength - text.length() - (i - j);
	
	if(!text.isEmpty())
		s = s + text.substring(0, i);
	
	int l;
	
	if(k < s1.length())
	{
		s = s + s1.substring(0, k);
		l = k;
	}else
	{
		s = s + s1;
		l = s1.length();
	}
	
	if(!text.isEmpty() && j < text.length())
		s = s + text.substring(j);
	
	if(validator.apply(s))
	{
		text = s;
		moveCursorBy(i - selectionEnd + l);
		func_190516_a(id, text);
	}
}
 
Example 38
Project: Wurst-MC-1.12   File: WurstFontRenderer.java   View source code 5 votes vote down vote up
/**
 * Make dis
 */
private String toRandom(final WurstFont font, final String text)
{
	String newText = "";
	final String allowedCharacters =
		"\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>[email protected][\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000";
	for(final char c : text.toCharArray())
		if(ChatAllowedCharacters.isAllowedCharacter(c))
		{
			final int index =
				fontRandom.nextInt(allowedCharacters.length());
			newText += allowedCharacters.toCharArray()[index];
		}
	return newText;
}
 
Example 39
Project: BaseClient   File: GuiScreenBook.java   View source code 5 votes vote down vote up
/**
 * Processes keystrokes when editing the text of a book
 */
private void keyTypedInBook(char typedChar, int keyCode)
{
    if (GuiScreen.isKeyComboCtrlV(keyCode))
    {
        this.pageInsertIntoCurrent(GuiScreen.getClipboardString());
    }
    else
    {
        switch (keyCode)
        {
            case 14:
                String s = this.pageGetCurrent();

                if (s.length() > 0)
                {
                    this.pageSetCurrent(s.substring(0, s.length() - 1));
                }

                return;

            case 28:
            case 156:
                this.pageInsertIntoCurrent("\n");
                return;

            default:
                if (ChatAllowedCharacters.isAllowedCharacter(typedChar))
                {
                    this.pageInsertIntoCurrent(Character.toString(typedChar));
                }
        }
    }
}
 
Example 40
Project: BaseClient   File: GuiScreenBook.java   View source code 5 votes vote down vote up
/**
 * Processes keystrokes when editing the title of a book
 */
private void keyTypedInTitle(char p_146460_1_, int p_146460_2_) throws IOException
{
    switch (p_146460_2_)
    {
        case 14:
            if (!this.bookTitle.isEmpty())
            {
                this.bookTitle = this.bookTitle.substring(0, this.bookTitle.length() - 1);
                this.updateButtons();
            }

            return;

        case 28:
        case 156:
            if (!this.bookTitle.isEmpty())
            {
                this.sendBookToServer(true);
                this.mc.displayGuiScreen((GuiScreen)null);
            }

            return;

        default:
            if (this.bookTitle.length() < 16 && ChatAllowedCharacters.isAllowedCharacter(p_146460_1_))
            {
                this.bookTitle = this.bookTitle + Character.toString(p_146460_1_);
                this.updateButtons();
                this.bookIsModified = true;
            }
    }
}