Attempt to migrate most of the codebase to newer versions of Java
This commit is contained in:
@@ -60,16 +60,15 @@ public class DhApi
|
||||
*
|
||||
* Note: Don't use this string in your code. It may change and is only for reference.
|
||||
*/
|
||||
public static final String READ_ME =
|
||||
"If you don't see Javadocs something is wrong. \n" +
|
||||
"If you are only using the full DH Mod in your build script, you won't have access to our javadocs and could potentially call into unsafe code. \n" +
|
||||
"\n" +
|
||||
"Please use the API jar in your build script as a compile time dependency " +
|
||||
"and the full DH jar as a runtime dependency. \n" +
|
||||
"\n" +
|
||||
"Please refer to the example API project or the DH Developer Wiki for additional information " +
|
||||
"and suggested setup. \n" + // DH Dev note: no links were included to prevent link rot.
|
||||
"";
|
||||
public static final String READ_ME =
|
||||
"""
|
||||
If you don't see Javadocs something is wrong.
|
||||
If you are only using the full DH Mod in your build script, you won't have access to our javadocs and could potentially call into unsafe code.
|
||||
|
||||
Please use the API jar in your build script as a compile time dependency and the full DH jar as a runtime dependency.
|
||||
|
||||
Please refer to the example API project or the DH Developer Wiki for additional information and suggested setup.
|
||||
"""; // DH Dev note: no links were included to prevent link rot.
|
||||
public static String readMe() { return READ_ME; }
|
||||
|
||||
/**
|
||||
|
||||
+13
-24
@@ -56,34 +56,23 @@ public enum EDhApiDebugRendering
|
||||
|
||||
public static EDhApiDebugRendering next(EDhApiDebugRendering type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case OFF:
|
||||
return SHOW_DETAIL;
|
||||
case SHOW_DETAIL:
|
||||
return SHOW_BLOCK_MATERIAL;
|
||||
case SHOW_BLOCK_MATERIAL:
|
||||
return SHOW_OVERLAPPING_QUADS;
|
||||
case SHOW_OVERLAPPING_QUADS:
|
||||
return SHOW_RENDER_SOURCE_FLAG;
|
||||
default:
|
||||
return OFF;
|
||||
}
|
||||
return switch (type) {
|
||||
case OFF -> SHOW_DETAIL;
|
||||
case SHOW_DETAIL -> SHOW_BLOCK_MATERIAL;
|
||||
case SHOW_BLOCK_MATERIAL -> SHOW_OVERLAPPING_QUADS;
|
||||
case SHOW_OVERLAPPING_QUADS -> SHOW_RENDER_SOURCE_FLAG;
|
||||
default -> OFF;
|
||||
};
|
||||
}
|
||||
|
||||
public static EDhApiDebugRendering previous(EDhApiDebugRendering type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case OFF:
|
||||
return SHOW_RENDER_SOURCE_FLAG;
|
||||
case SHOW_RENDER_SOURCE_FLAG:
|
||||
return SHOW_OVERLAPPING_QUADS;
|
||||
case SHOW_OVERLAPPING_QUADS:
|
||||
return SHOW_DETAIL;
|
||||
default:
|
||||
return OFF;
|
||||
}
|
||||
return switch (type) {
|
||||
case OFF -> SHOW_RENDER_SOURCE_FLAG;
|
||||
case SHOW_RENDER_SOURCE_FLAG -> SHOW_OVERLAPPING_QUADS;
|
||||
case SHOW_OVERLAPPING_QUADS -> SHOW_DETAIL;
|
||||
default -> OFF;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+10
-18
@@ -42,29 +42,21 @@ public enum EDhApiRendererMode
|
||||
/** Used by the config GUI to cycle through the available rendering options */
|
||||
public static EDhApiRendererMode next(EDhApiRendererMode type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DEFAULT:
|
||||
return DEBUG;
|
||||
case DEBUG:
|
||||
return DISABLED;
|
||||
default:
|
||||
return DEFAULT;
|
||||
}
|
||||
return switch (type) {
|
||||
case DEFAULT -> DEBUG;
|
||||
case DEBUG -> DISABLED;
|
||||
default -> DEFAULT;
|
||||
};
|
||||
}
|
||||
|
||||
/** Used by the config GUI to cycle through the available rendering options */
|
||||
public static EDhApiRendererMode previous(EDhApiRendererMode type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DEFAULT:
|
||||
return DISABLED;
|
||||
case DEBUG:
|
||||
return DEFAULT;
|
||||
default:
|
||||
return DEBUG;
|
||||
}
|
||||
return switch (type) {
|
||||
case DEFAULT -> DISABLED;
|
||||
case DEBUG -> DEFAULT;
|
||||
default -> DEBUG;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,12 +59,12 @@ public class DhApiResult<T>
|
||||
|
||||
|
||||
public static <Pt> DhApiResult<Pt> createSuccess() { return new DhApiResult<>(true, ""); }
|
||||
public static <Pt> DhApiResult<Pt> createSuccess(Pt payload) { return new DhApiResult<Pt>(true, "", payload); }
|
||||
public static <Pt> DhApiResult<Pt> createSuccess(Pt payload) { return new DhApiResult<>(true, "", payload); }
|
||||
// There is no createSuccess(String message) method because it would be too easy to confuse with createSuccess(Pt payload) when returning null
|
||||
public static <Pt> DhApiResult<Pt> createSuccess(String message, Pt payload) { return new DhApiResult<Pt>(true, message, payload); }
|
||||
public static <Pt> DhApiResult<Pt> createSuccess(String message, Pt payload) { return new DhApiResult<>(true, message, payload); }
|
||||
|
||||
// there is no createFail() since all fail results should give a reason for their failure
|
||||
public static <Pt> DhApiResult<Pt> createFail(String message) { return new DhApiResult<>(false, message); }
|
||||
public static <Pt> DhApiResult<Pt> createFail(String message, Pt payload) { return new DhApiResult<Pt>(false, message, payload); }
|
||||
public static <Pt> DhApiResult<Pt> createFail(String message, Pt payload) { return new DhApiResult<>(false, message, payload); }
|
||||
|
||||
}
|
||||
|
||||
+1
-2
@@ -163,9 +163,8 @@ public class ApiEventInjector extends DependencyInjector<IDhApiEvent> implements
|
||||
DhApiEventParam<T> eventParam = createEventParamWrapper(event, input);
|
||||
event.fireEvent(eventParam);
|
||||
|
||||
if (eventParam instanceof DhApiCancelableEventParam)
|
||||
if (eventParam instanceof DhApiCancelableEventParam<T> cancelableEventParam)
|
||||
{
|
||||
DhApiCancelableEventParam<T> cancelableEventParam = (DhApiCancelableEventParam<T>) eventParam;
|
||||
cancelEvent |= cancelableEventParam.isEventCanceled();
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -87,7 +87,7 @@ public class DependencyInjector<BindableType extends IBindable> implements IDepe
|
||||
// make sure the hashSet has an array to hold the dependency
|
||||
if (!this.dependencies.containsKey(dependencyInterface))
|
||||
{
|
||||
this.dependencies.put(dependencyInterface, new ArrayList<BindableType>());
|
||||
this.dependencies.put(dependencyInterface, new ArrayList<>());
|
||||
}
|
||||
|
||||
// add the dependency
|
||||
@@ -134,7 +134,7 @@ public class DependencyInjector<BindableType extends IBindable> implements IDepe
|
||||
@Override
|
||||
public <T extends BindableType> T get(Class<T> interfaceClass) throws ClassCastException
|
||||
{
|
||||
return (T) this.getInternalLogic(interfaceClass, false).get(0);
|
||||
return (T) this.getInternalLogic(interfaceClass, false).getFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -146,7 +146,7 @@ public class DependencyInjector<BindableType extends IBindable> implements IDepe
|
||||
@Override
|
||||
public <T extends BindableType> T get(Class<T> interfaceClass, boolean allowIncompleteDependencies) throws ClassCastException
|
||||
{
|
||||
return (T) this.getInternalLogic(interfaceClass, allowIncompleteDependencies).get(0);
|
||||
return (T) this.getInternalLogic(interfaceClass, allowIncompleteDependencies).getFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,7 +175,7 @@ public class DependencyInjector<BindableType extends IBindable> implements IDepe
|
||||
|
||||
|
||||
// return an empty list to prevent null pointers
|
||||
ArrayList<T> emptyList = new ArrayList<T>();
|
||||
ArrayList<T> emptyList = new ArrayList<>();
|
||||
emptyList.add(null);
|
||||
return emptyList;
|
||||
}
|
||||
|
||||
+2
-2
@@ -64,14 +64,14 @@ public class OverridePriorityListContainer implements IBindable
|
||||
else
|
||||
{
|
||||
// last item should have the highest priority
|
||||
return this.overridePairList.get(this.overridePairList.size() - 1).override;
|
||||
return this.overridePairList.getLast().override;
|
||||
}
|
||||
}
|
||||
public IDhApiOverrideable getOverrideWithHighestPriority()
|
||||
{
|
||||
if (this.overridePairList.size() != 0)
|
||||
{
|
||||
return this.overridePairList.get(0).override;
|
||||
return this.overridePairList.getFirst().override;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user