This commit is contained in:
Izzel_Aliz
2018-05-09 13:11:59 +08:00
129 changed files with 7406 additions and 4399 deletions

View File

@@ -19,6 +19,7 @@ import java.util.regex.Pattern;
/**
* The NMS helper for all the Book-API
*/
@SuppressWarnings({"ALL", "AliControlFlowStatementWithoutBraces"})
public final class BookReflection {
private static final String version;
@@ -66,8 +67,10 @@ public final class BookReflection {
craftMetaBookField = craftMetaBookClass.getDeclaredField("pages");
craftMetaBookField.setAccessible(true);
Class<?> chatSerializer = getNmsClass("IChatBaseComponent$ChatSerializer", false);
if (chatSerializer == null)
//noinspection AliControlFlowStatementWithoutBraces
if (chatSerializer == null) {
chatSerializer = getNmsClass("ChatSerializer");
}
chatSerializerA = chatSerializer.getDeclaredMethod("a", String.class);
@@ -257,12 +260,15 @@ public final class BookReflection {
return craftItemStackAsNMSCopy.invoke(null, item);
}
@SuppressWarnings("AliControlFlowStatementWithoutBraces")
public static Class<?> getNmsClass(String className, boolean log) {
try {
return Class.forName("net.minecraft.server." + version + "." + className);
} catch (ClassNotFoundException e) {
if (log)
//noinspection AliControlFlowStatementWithoutBraces
if (log) {
e.printStackTrace();
}
return null;
}
}

View File

@@ -35,10 +35,11 @@ public interface ClickAction {
* @return a new ClickAction
*/
static ClickAction openUrl(String url) {
if (url.startsWith("http://") || url.startsWith("https://"))
if (url.startsWith("http://") || url.startsWith("https://")) {
return new SimpleClickAction(ClickEvent.Action.OPEN_URL, url);
else
} else {
throw new IllegalArgumentException("Invalid url: \"" + url + "\", it should start with http:// or https://");
}
}
/**

View File

@@ -107,8 +107,9 @@ public class PageBuilder {
*/
public static PageBuilder of(BaseComponent... text) {
PageBuilder res = new PageBuilder();
for(BaseComponent b : text)
for(BaseComponent b : text) {
res.add(b);
}
return res;
}
}