use of com.laytonsmith.abstraction.enums.MCChatColor in project CommandHelper by EngineHub.
the class SyntaxHighlighters method macro.
private static String macro(String macroName) {
String[] split = macroName.split(":");
String type = split[0];
String datalist = split[1];
List<String> params = new ArrayList<>();
for (int i = 2; i < split.length; i++) {
params.add(split[i].toLowerCase());
}
List<String> base = new ArrayList<>();
if (datalist.equalsIgnoreCase("colors")) {
for (MCChatColor c : MCChatColor.values()) {
base.add(c.name());
}
} else if (datalist.equalsIgnoreCase("keywords")) {
for (String keyword : SimpleSyntaxHighlighter.KEYWORDS) {
base.add(keyword);
}
} else if (datalist.equalsIgnoreCase("functions")) {
for (Function f : GetFunctions()) {
if (SimpleSyntaxHighlighter.KEYWORDS.contains(f.getName())) {
// Keywords override functions
continue;
}
if (!f.appearInDocumentation()) {
continue;
}
if (params.contains("restricted") || params.contains("unrestricted")) {
if (params.contains("restricted") && f.isRestricted()) {
base.add(f.getName());
} else if (params.contains("unrestricted") && !f.isRestricted()) {
base.add(f.getName());
}
} else {
base.add(f.getName());
}
}
} else if (datalist.equalsIgnoreCase("events")) {
for (Documentation d : GetEvents()) {
base.add(d.getName());
}
} else if (datalist.equalsIgnoreCase("exceptions")) {
for (Class<? extends CREThrowable> c : ClassDiscovery.getDefaultInstance().loadClassesWithAnnotationThatExtend(typeof.class, CREThrowable.class)) {
base.add(c.getAnnotation(typeof.class).value());
}
} else if (datalist.equalsIgnoreCase("types")) {
base.addAll(NativeTypeList.getNativeTypeList());
// Null is technically in the list, but it shouldn't be added.
base.remove("null");
} else if (datalist.equalsIgnoreCase("enums")) {
Set<String> set = new HashSet<>();
Set<Class<? extends Enum>> enums = ClassDiscovery.getDefaultInstance().loadClassesWithAnnotationThatExtend(MEnum.class, Enum.class);
for (Class<? extends Enum> e : enums) {
Enum[] es = e.getEnumConstants();
for (Enum ee : es) {
set.add(ee.name());
}
}
base.addAll(set);
} else if (datalist.equalsIgnoreCase("fileOptions")) {
for (Field f : FileOptions.class.getDeclaredFields()) {
base.add(f.getName());
}
}
String header = "";
String spliter = "IMPROPER FORMATTING";
String footer = "";
if (type.equalsIgnoreCase("space")) {
if (params.contains("quoted")) {
header = "'";
spliter = "' '";
footer = "'";
} else {
spliter = " ";
}
} else if (type.equalsIgnoreCase("comma")) {
if (params.contains("quoted")) {
header = "'";
spliter = "', '";
footer = "'";
} else {
spliter = ", ";
}
} else if (type.equalsIgnoreCase("pipe")) {
if (params.contains("quoted")) {
header = "'";
spliter = "|";
footer = "'";
} else {
spliter = "|";
}
} else if (type.equalsIgnoreCase("xml")) {
String tag = "PLEASE INCLUDE THE TAG NAME USING tag=tagname AS A PARAMETER";
for (String param : params) {
// Find the tag name
if (param.matches("tag=.*")) {
tag = param.substring(4);
break;
}
}
if (params.contains("quoted")) {
header = "<" + tag + ">'";
spliter = "'</" + tag + "><" + tag + ">'";
footer = "'</" + tag + ">";
} else {
header = "<" + tag + ">";
spliter = "</" + tag + "><" + tag + ">";
footer = "</" + tag + ">";
}
}
return header + Join(base, spliter) + footer;
}
Aggregations