Java Code Examples for net.minecraft.util.ChatAllowedCharacters#isAllowedCharacter()
The following examples show how to use
net.minecraft.util.ChatAllowedCharacters#isAllowedCharacter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MixinGuiEditSign.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
/** * @author CCBlueX */ @Overwrite protected void keyTyped(char typedChar, int keyCode) throws IOException { this.signCommand1.textboxKeyTyped(typedChar, keyCode); this.signCommand2.textboxKeyTyped(typedChar, keyCode); this.signCommand3.textboxKeyTyped(typedChar, keyCode); this.signCommand4.textboxKeyTyped(typedChar, keyCode); if(signCommand1.isFocused() || signCommand2.isFocused() || signCommand3.isFocused() || signCommand4.isFocused()) return; 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) || (enabled && 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 2
Source File: MixinGuiEditSign.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
/** * @author CCBlueX */ @Overwrite protected void keyTyped(char typedChar, int keyCode) throws IOException { this.signCommand1.textboxKeyTyped(typedChar, keyCode); this.signCommand2.textboxKeyTyped(typedChar, keyCode); this.signCommand3.textboxKeyTyped(typedChar, keyCode); this.signCommand4.textboxKeyTyped(typedChar, keyCode); if(signCommand1.isFocused() || signCommand2.isFocused() || signCommand3.isFocused() || signCommand4.isFocused()) return; 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) || (enabled && 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 3
Source File: MaterialTextField.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
public void keyTyped(char typedChar, int keyCode) { if (focused) { if (keyCode == 28) { focused = false; } else if (keyCode == 14) { if (!text.isEmpty()) { text = text.substring(0, text.length() - 1); } } else if (ChatAllowedCharacters.isAllowedCharacter(typedChar)) { text += typedChar; } } }
Example 4
Source File: CharacterFilter.java From ehacks-pro with GNU General Public License v3.0 | 5 votes |
public static String filerAllowedCharacters(String str, boolean section) { StringBuilder sb = new StringBuilder(); for (char c : str.toCharArray()) { if (!ChatAllowedCharacters.isAllowedCharacter((char) c) && (!section || c != '\u00a7' && c != '\n')) { continue; } sb.append(c); } return sb.toString(); }
Example 5
Source File: SaveLoadButton.java From NotEnoughItems with MIT License | 5 votes |
@Override public boolean handleKeyPress(int keyID, char keyChar) { if (!focused) { return false; } if (keyID == Keyboard.KEY_BACK) { if (label.length() > 0) { label = label.substring(0, label.length() - 1); onTextChange(); backdowntime = System.currentTimeMillis(); } } else if (keyID == Keyboard.KEY_RETURN) { focused = false; } else if (keyChar == 22)//paste { String pastestring = GuiScreen.getClipboardString(); if (pastestring == null) { pastestring = ""; } label = label + pastestring; onTextChange(); } else if (ChatAllowedCharacters.isAllowedCharacter(keyChar)) { label = label + keyChar; onTextChange(); } return true; }
Example 6
Source File: SaveLoadButton.java From NotEnoughItems with MIT License | 5 votes |
@Override public boolean handleKeyPress(int keyID, char keyChar) { if(!focused) return false; if(keyID == Keyboard.KEY_BACK) { if(label.length() > 0) { label = label.substring(0, label.length() - 1); onTextChange(); backdowntime = System.currentTimeMillis(); } } else if(keyID == Keyboard.KEY_RETURN) { focused = false; } else if(keyChar == 22)//paste { String pastestring = GuiScreen.getClipboardString(); if(pastestring == null) pastestring = ""; label = label + pastestring; onTextChange(); } else if(ChatAllowedCharacters.isAllowedCharacter(keyChar)) { label = label + keyChar; onTextChange(); } return true; }
Example 7
Source File: CharacterFilter.java From NBTEdit with GNU General Public License v3.0 | 5 votes |
public static String filerAllowedCharacters(String str, boolean section) { StringBuilder sb = new StringBuilder(); char[] arr = str.toCharArray(); int length = arr.length; for (int i = 0; i < length; ++i) { char c = arr[i]; if (ChatAllowedCharacters.isAllowedCharacter(c) || (section && (c == NBTStringHelper.SECTION_SIGN || c == '\n'))) sb.append(c); } return sb.toString(); }
Example 8
Source File: GuiAphorismTile.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override protected void keyTyped(char par1, int par2){ if(par2 == 1) { NetworkHandler.sendToServer(new PacketAphorismTileUpdate(tile)); } else if(par2 == 200) { cursorY--; if(cursorY < 0) cursorY = textLines.length - 1; } else if(par2 == 208 || par2 == 156) { cursorY++; if(cursorY >= textLines.length) cursorY = 0; } else if(par2 == 28) { cursorY++; textLines = ArrayUtils.add(textLines, cursorY, ""); } else if(par2 == 14) { if(textLines[cursorY].length() > 0) { textLines[cursorY] = textLines[cursorY].substring(0, textLines[cursorY].length() - 1); } else if(textLines.length > 1) { textLines = ArrayUtils.remove(textLines, cursorY); cursorY--; if(cursorY < 0) cursorY = 0; } } else if(ChatAllowedCharacters.isAllowedCharacter(par1)) { textLines[cursorY] = textLines[cursorY] + par1; } tile.setTextLines(textLines); super.keyTyped(par1, par2); }
Example 9
Source File: GuiTextField.java From ehacks-pro with GNU General Public License v3.0 | 4 votes |
public boolean textboxKeyTyped(char par1, int par2) { if (this.isEnabled && this.isFocused) { switch (par1) { case '\u0001': { this.setCursorPositionEnd(); this.setSelectionPos(0); return true; } case '\u0003': { GuiScreen.setClipboardString(this.getSelectedtext()); return true; } case '\u0016': { this.writeText(GuiScreen.getClipboardString()); return true; } case '\u0018': { GuiScreen.setClipboardString(this.getSelectedtext()); this.writeText(""); return true; } } switch (par2) { case 14: { if (GuiScreen.isCtrlKeyDown()) { this.deleteWords(-1); } else { this.deleteFromCursor(-1); } return true; } case 199: { if (GuiScreen.isShiftKeyDown()) { this.setSelectionPos(0); } else { this.setCursorPositionZero(); } return true; } case 203: { if (GuiScreen.isShiftKeyDown()) { if (GuiScreen.isCtrlKeyDown()) { this.setSelectionPos(this.getNthWordFromPos(-1, this.getSelectionEnd())); } else { this.setSelectionPos(this.getSelectionEnd() - 1); } } else if (GuiScreen.isCtrlKeyDown()) { this.setCursorPosition(this.getNthWordFromCursor(-1)); } else { this.moveCursorBy(-1); } return true; } case 205: { if (GuiScreen.isShiftKeyDown()) { if (GuiScreen.isCtrlKeyDown()) { this.setSelectionPos(this.getNthWordFromPos(1, this.getSelectionEnd())); } else { this.setSelectionPos(this.getSelectionEnd() + 1); } } else if (GuiScreen.isCtrlKeyDown()) { this.setCursorPosition(this.getNthWordFromCursor(1)); } else { this.moveCursorBy(1); } return true; } case 207: { if (GuiScreen.isShiftKeyDown()) { this.setSelectionPos(this.text.length()); } else { this.setCursorPositionEnd(); } return true; } case 211: { if (GuiScreen.isCtrlKeyDown()) { this.deleteWords(1); } else { this.deleteFromCursor(1); } return true; } } if (ChatAllowedCharacters.isAllowedCharacter((char) par1)) { this.writeText(Character.toString(par1)); return true; } return false; } return false; }
Example 10
Source File: TextField.java From NotEnoughItems with MIT License | 4 votes |
public boolean isValid(String string) { // Solve the problem that Minecraft can't post Chinese characters return ChatAllowedCharacters.isAllowedCharacter(string.charAt(string.length() - 1)); }
Example 11
Source File: TextField.java From NotEnoughItems with MIT License | 4 votes |
public boolean isValid(String string) { // Solve the problem that Minecraft can't post Chinese characters return ChatAllowedCharacters.isAllowedCharacter(string.charAt(string.length() - 1)); }
Example 12
Source File: GuiCCTextField.java From CodeChickenCore with MIT License | 4 votes |
public boolean canAddChar(char c) { return allowedCharacters == null ? ChatAllowedCharacters.isAllowedCharacter(c) : allowedCharacters.indexOf(c) >= 0; }