mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 08:45:11 +00:00
Proper Reformating
This commit is contained in:
1 parent
ce75880aba
commit
180d257024
1179 files changed
+59847
-61583
No files matched your search
@@ -11,72 +11,73 @@ import java.util.Arrays;
|
||||
|
||||
public class NoppesStringUtils {
|
||||
|
||||
final static int[] illegalChars = {34, 60, 62, 124, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 58, 42, 63, 92, 47};
|
||||
static {
|
||||
Arrays.sort(illegalChars);
|
||||
}
|
||||
public static String cleanFileName(String badFileName) {
|
||||
StringBuilder cleanName = new StringBuilder();
|
||||
for (int i = 0; i < badFileName.length(); i++) {
|
||||
int c = (int)badFileName.charAt(i);
|
||||
if (Arrays.binarySearch(illegalChars, c) < 0) {
|
||||
cleanName.append((char)c);
|
||||
}
|
||||
}
|
||||
return cleanName.toString();
|
||||
}
|
||||
|
||||
public static String formatText(String text, Object... obs) {
|
||||
for(Object ob : obs){
|
||||
if(ob instanceof EntityPlayer){
|
||||
String username = ((EntityPlayer)ob).getDisplayName();
|
||||
text = text.replace("{player}", username);
|
||||
text = text.replace("@p", username);
|
||||
}
|
||||
else if(ob instanceof EntityNPCInterface)
|
||||
text = text.replace("@npc", ((EntityNPCInterface)ob).getCommandSenderName());
|
||||
|
||||
}
|
||||
text = text.replace("&", Character.toChars(167)[0] + "");
|
||||
text = text.replace("%","%%");
|
||||
return text;
|
||||
}
|
||||
final static int[] illegalChars = {34, 60, 62, 124, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 58, 42, 63, 92, 47};
|
||||
|
||||
public static void setClipboardContents(String aString) {
|
||||
StringSelection stringSelection = new StringSelection(aString);
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
clipboard.setContents(stringSelection, new ClipboardOwner() {
|
||||
@Override
|
||||
public void lostOwnership(Clipboard arg0, Transferable arg1) {
|
||||
static {
|
||||
Arrays.sort(illegalChars);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
public static String cleanFileName(String badFileName) {
|
||||
StringBuilder cleanName = new StringBuilder();
|
||||
for (int i = 0; i < badFileName.length(); i++) {
|
||||
int c = (int) badFileName.charAt(i);
|
||||
if (Arrays.binarySearch(illegalChars, c) < 0) {
|
||||
cleanName.append((char) c);
|
||||
}
|
||||
}
|
||||
return cleanName.toString();
|
||||
}
|
||||
|
||||
public static String getClipboardContents() {
|
||||
String result = "";
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable contents = clipboard.getContents(null);
|
||||
boolean hasTransferableText = contents != null && contents.isDataFlavorSupported(DataFlavor.stringFlavor);
|
||||
if (hasTransferableText) {
|
||||
try {
|
||||
result = (String) contents.getTransferData(DataFlavor.stringFlavor);
|
||||
} catch (UnsupportedFlavorException ex) {
|
||||
System.err.println(ex);
|
||||
ex.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
System.err.println(ex);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static String formatText(String text, Object... obs) {
|
||||
for (Object ob : obs) {
|
||||
if (ob instanceof EntityPlayer) {
|
||||
String username = ((EntityPlayer) ob).getDisplayName();
|
||||
text = text.replace("{player}", username);
|
||||
text = text.replace("@p", username);
|
||||
} else if (ob instanceof EntityNPCInterface)
|
||||
text = text.replace("@npc", ((EntityNPCInterface) ob).getCommandSenderName());
|
||||
|
||||
public static String translate(Object... arr) {
|
||||
String s = "";
|
||||
for(Object str : arr){
|
||||
s += StatCollector.translateToLocal(str.toString());
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
text = text.replace("&", Character.toChars(167)[0] + "");
|
||||
text = text.replace("%", "%%");
|
||||
return text;
|
||||
}
|
||||
|
||||
public static void setClipboardContents(String aString) {
|
||||
StringSelection stringSelection = new StringSelection(aString);
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
clipboard.setContents(stringSelection, new ClipboardOwner() {
|
||||
@Override
|
||||
public void lostOwnership(Clipboard arg0, Transferable arg1) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static String getClipboardContents() {
|
||||
String result = "";
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable contents = clipboard.getContents(null);
|
||||
boolean hasTransferableText = contents != null && contents.isDataFlavorSupported(DataFlavor.stringFlavor);
|
||||
if (hasTransferableText) {
|
||||
try {
|
||||
result = (String) contents.getTransferData(DataFlavor.stringFlavor);
|
||||
} catch (UnsupportedFlavorException ex) {
|
||||
System.err.println(ex);
|
||||
ex.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
System.err.println(ex);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String translate(Object... arr) {
|
||||
String s = "";
|
||||
for (Object str : arr) {
|
||||
s += StatCollector.translateToLocal(str.toString());
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user