code cleanup

This commit is contained in:
FalsePattern committed 2022-08-17 20:10:51 +02:00
1 parent c440524bdd
commit de6a7e5080
22 files changed
+86 -108

No files matched your search

@@ -12,6 +12,5 @@ import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
@StableAPI(since = "0.10.0")
public @interface DeprecationDetails {
@StableAPI.Expose
String deprecatedSince();
@StableAPI.Expose String deprecatedSince();
}
@@ -55,8 +55,7 @@ public @interface StableAPI {
/**
* The version this API was introduced/stabilized in. Used for library version tracking.
*/
@StableAPI.Expose
String since();
@StableAPI.Expose String since();
/**
* You may use this annotation if you want a member to have an equal effective {@link #since()} value as its owner
@@ -73,8 +72,7 @@ public @interface StableAPI {
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
@StableAPI(since = "0.10.0")
@interface Expose {
@StableAPI.Expose
String since() default "__PARENT__";
@StableAPI.Expose String since() default "__PARENT__";
}
/**
@@ -87,5 +85,6 @@ public @interface StableAPI {
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
@StableAPI(since = "0.10.0")
@interface Internal {}
@interface Internal {
}
}
@@ -105,9 +105,11 @@ public class BlockPos extends Vec3i {
* In situations where it is usable, prefer
* {@link #getAllInBoxMutable(BlockPos, BlockPos) instead as it has better performance (fewer allocations)
* <p>
*
* @param from One corner of the box
* @param to Another corner of the box
* <p>
* <p>
*
* @see #getAllInBox(int, int, int, int, int, int)
* @see #getAllInBoxMutable(BlockPos, BlockPos)
*/
@@ -125,13 +127,15 @@ public class BlockPos extends Vec3i {
* In situations where it is usable, prefer
* {@link #getAllInBoxMutable(BlockPos, BlockPos) instead as it has better performance (fewer allocations)
* <p>
*
* @param x0 The lower x coordinate
* @param y0 The lower y coordinate
* @param z0 The lower z coordinate
* @param x1 The upper x coordinate
* @param y1 The upper y coordinate
* @param z1 The upper z coordinate
* <p>
* <p>
*
* @see #getAllInBox(BlockPos, BlockPos)
* @see #getAllInBoxMutable(BlockPos, BlockPos)
*/
@@ -440,6 +444,7 @@ public class BlockPos extends Vec3i {
return super.rotate(rotation).toImmutable();
}
@Override
@StableAPI.Expose
public BlockPos toImmutable() {
return new BlockPos(this);
@@ -28,14 +28,10 @@ import net.minecraft.util.EnumFacing;
@StableAPI(since = "0.6.0")
public enum Rotation {
@StableAPI.Expose
NONE,
@StableAPI.Expose
CLOCKWISE_90,
@StableAPI.Expose
CLOCKWISE_180,
@StableAPI.Expose
COUNTERCLOCKWISE_90;
@StableAPI.Expose NONE,
@StableAPI.Expose CLOCKWISE_90,
@StableAPI.Expose CLOCKWISE_180,
@StableAPI.Expose COUNTERCLOCKWISE_90;
@StableAPI.Expose
public Rotation add(@NonNull Rotation rotation) {
@@ -44,14 +44,12 @@ public @interface Config {
/**
* The mod id that this configuration is associated with.
*/
@StableAPI.Expose
String modid();
@StableAPI.Expose String modid();
/**
* Root element category, defaults to "general". You must not specify an empty string.
*/
@StableAPI.Expose
String category() default "general";
@StableAPI.Expose String category() default "general";
/**
* The lang file key of this configuration. Used in config GUIs.
@@ -61,8 +59,7 @@ public @interface Config {
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.TYPE})
@interface LangKey {
@StableAPI.Expose
String value();
@StableAPI.Expose String value();
}
/**
@@ -73,8 +70,7 @@ public @interface Config {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface Comment {
@StableAPI.Expose
String[] value();
@StableAPI.Expose String[] value();
}
/**
@@ -97,8 +93,7 @@ public @interface Config {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface DefaultBoolean {
@StableAPI.Expose
boolean value();
@StableAPI.Expose boolean value();
}
/**
@@ -109,10 +104,9 @@ public @interface Config {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface RangeInt {
@StableAPI.Expose
int min() default Integer.MIN_VALUE;
@StableAPI.Expose
int max() default Integer.MAX_VALUE;
@StableAPI.Expose int min() default Integer.MIN_VALUE;
@StableAPI.Expose int max() default Integer.MAX_VALUE;
}
/**
@@ -124,8 +118,7 @@ public @interface Config {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface DefaultInt {
@StableAPI.Expose
int value();
@StableAPI.Expose int value();
}
/**
@@ -139,10 +132,9 @@ public @interface Config {
@Target(ElementType.FIELD)
@StableAPI(since = "0.6.0")
@interface RangeFloat {
@StableAPI.Expose
float min() default -Float.MAX_VALUE;
@StableAPI.Expose
float max() default Float.MAX_VALUE;
@StableAPI.Expose float min() default -Float.MAX_VALUE;
@StableAPI.Expose float max() default Float.MAX_VALUE;
}
/**
@@ -157,8 +149,7 @@ public @interface Config {
@Target(ElementType.FIELD)
@StableAPI(since = "0.6.0")
@interface DefaultFloat {
@StableAPI.Expose
float value();
@StableAPI.Expose float value();
}
/**
@@ -169,10 +160,9 @@ public @interface Config {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface RangeDouble {
@StableAPI.Expose
double min() default -Double.MAX_VALUE;
@StableAPI.Expose
double max() default Double.MAX_VALUE;
@StableAPI.Expose double min() default -Double.MAX_VALUE;
@StableAPI.Expose double max() default Double.MAX_VALUE;
}
/**
@@ -184,8 +174,7 @@ public @interface Config {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface DefaultDouble {
@StableAPI.Expose
double value();
@StableAPI.Expose double value();
}
/**
@@ -197,8 +186,7 @@ public @interface Config {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface DefaultString {
@StableAPI.Expose
String value();
@StableAPI.Expose String value();
}
@@ -215,8 +203,7 @@ public @interface Config {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface StringMaxLength {
@StableAPI.Expose
int value();
@StableAPI.Expose int value();
}
/**
@@ -227,8 +214,7 @@ public @interface Config {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface Pattern {
@StableAPI.Expose
String value();
@StableAPI.Expose String value();
}
/**
@@ -240,8 +226,7 @@ public @interface Config {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface DefaultEnum {
@StableAPI.Expose
String value();
@StableAPI.Expose String value();
}
/**
@@ -253,8 +238,7 @@ public @interface Config {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface DefaultStringList {
@StableAPI.Expose
String[] value();
@StableAPI.Expose String[] value();
}
/**
@@ -266,8 +250,7 @@ public @interface Config {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface DefaultDoubleList {
@StableAPI.Expose
double[] value();
@StableAPI.Expose double[] value();
}
/**
@@ -279,8 +262,7 @@ public @interface Config {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface DefaultIntList {
@StableAPI.Expose
int[] value();
@StableAPI.Expose int[] value();
}
/**
@@ -292,8 +274,7 @@ public @interface Config {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface DefaultBooleanList {
@StableAPI.Expose
boolean[] value();
@StableAPI.Expose boolean[] value();
}
/**
@@ -319,8 +300,7 @@ public @interface Config {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface ListMaxLength {
@StableAPI.Expose
int value();
@StableAPI.Expose int value();
}
@@ -332,8 +312,7 @@ public @interface Config {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface Name {
@StableAPI.Expose
String value();
@StableAPI.Expose String value();
}
/**
@@ -51,7 +51,9 @@ public class DependencyLoader {
@DeprecationDetails(deprecatedSince = "0.10.0")
@StableAPI.Expose
public static void loadLibrary(@NonNull String loadingModId, @NonNull String groupId, @NonNull String artifactId, @NonNull Version minVersion, Version maxVersion, @NonNull Version preferredVersion, String regularSuffix, String devSuffix) {
FalsePatternLib.getLog().warn(DependencyLoader.class.getName() + ".loadLibrary is deprecated and will be removed in FalsePatternLib 0.11! Use loadLibraries instead!");
FalsePatternLib.getLog()
.warn(DependencyLoader.class.getName() +
".loadLibrary is deprecated and will be removed in FalsePatternLib 0.11! Use loadLibraries instead!");
DependencyLoaderImpl.loadLibrary(loadingModId, groupId, artifactId, minVersion, maxVersion, preferredVersion,
regularSuffix, devSuffix);
}
@@ -6,17 +6,22 @@ import lombok.NonNull;
@StableAPI(since = "0.10.0")
public class Library {
@StableAPI.Expose
@NonNull public final String loadingModId;
@NonNull
public final String loadingModId;
@StableAPI.Expose
@NonNull public final String groupId;
@NonNull
public final String groupId;
@StableAPI.Expose
@NonNull public final String artifactId;
@NonNull
public final String artifactId;
@StableAPI.Expose
@NonNull public final Version minVersion;
@NonNull
public final Version minVersion;
@StableAPI.Expose
public final Version maxVersion;
@StableAPI.Expose
@NonNull public final Version preferredVersion;
@NonNull
public final Version preferredVersion;
@StableAPI.Expose
public final String regularSuffix;
@StableAPI.Expose
@@ -111,7 +111,8 @@ public class SemanticVersion extends Version {
@Override
public String toString() {
return majorVersion + (minorVersion < 0 ? "" : "." + minorVersion) + (patchVersion < 0 ? "" : "." + patchVersion) + (preRelease == null ? "" : "-" + preRelease) +
return majorVersion + (minorVersion < 0 ? "" : "." + minorVersion) +
(patchVersion < 0 ? "" : "." + patchVersion) + (preRelease == null ? "" : "-" + preRelease) +
(build == null ? "" : "+" + build);
}
@@ -46,11 +46,8 @@ public class LibraryConfig {
public static ValidationLogging CONFIG_ERROR_LOUDNESS;
public enum ValidationLogging {
@StableAPI.Expose(since = "__INTERNAL__")
None,
@StableAPI.Expose(since = "__INTERNAL__")
Log,
@StableAPI.Expose(since = "__INTERNAL__")
LogAndToast
@StableAPI.Expose(since = "__INTERNAL__") None,
@StableAPI.Expose(since = "__INTERNAL__") Log,
@StableAPI.Expose(since = "__INTERNAL__") LogAndToast
}
}
@@ -55,9 +55,7 @@ public class ToastConfig {
}
public enum Side {
@StableAPI.Expose(since = "__INTERNAL__")
Left,
@StableAPI.Expose(since = "__INTERNAL__")
Right
@StableAPI.Expose(since = "__INTERNAL__") Left,
@StableAPI.Expose(since = "__INTERNAL__") Right
}
}
@@ -197,7 +197,8 @@ public class ConfigurationManagerImpl {
val opt = serializedNames.keySet().stream().filter((key) -> key.equals(serializedName)).findFirst();
if (!opt.isPresent()) {
input.skipBytes(dataSize);
FalsePatternLib.getLog().warn("Server tried to sync config not registered on our side: " + serializedName);
FalsePatternLib.getLog()
.warn("Server tried to sync config not registered on our side: " + serializedName);
continue;
}
val clazz = serializedNames.get(opt.get());
@@ -22,6 +22,7 @@ package com.falsepattern.lib.internal.impl.config;
import com.falsepattern.lib.config.Config;
import com.falsepattern.lib.config.ConfigException;
import com.falsepattern.lib.internal.ReflectionUtil;
import com.falsepattern.lib.internal.impl.config.fields.AConfigField;
import com.falsepattern.lib.internal.impl.config.fields.BooleanConfigField;
import com.falsepattern.lib.internal.impl.config.fields.BooleanListConfigField;
@@ -33,7 +34,6 @@ import com.falsepattern.lib.internal.impl.config.fields.IntConfigField;
import com.falsepattern.lib.internal.impl.config.fields.IntListConfigField;
import com.falsepattern.lib.internal.impl.config.fields.StringConfigField;
import com.falsepattern.lib.internal.impl.config.fields.StringListConfigField;
import com.falsepattern.lib.internal.ReflectionUtil;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.val;
@@ -154,7 +154,7 @@ public class DependencyLoaderImpl {
public static CompletableFuture<Void> loadLibrariesAsync(Library... libraries) {
val futures = new ArrayList<CompletableFuture<Void>>();
for (val library: libraries) {
for (val library : libraries) {
val task = new DependencyLoadTask(library.loadingModId, library.groupId, library.artifactId,
library.minVersion, library.maxVersion, library.preferredVersion,
library.regularSuffix, library.devSuffix);
@@ -15,7 +15,6 @@ import lombok.val;
import net.minecraft.client.resources.I18n;
import net.minecraft.event.ClickEvent;
import net.minecraft.util.IChatComponent;
import cpw.mods.fml.common.Loader;
import java.net.MalformedURLException;
@@ -85,7 +84,9 @@ public final class UpdateCheckerImpl {
.groupId("com.falsepattern")
.artifactId("json")
.minVersion(new SemanticVersion(0, 4, 0))
.maxVersion(new SemanticVersion(0, Integer.MAX_VALUE, Integer.MAX_VALUE))
.maxVersion(new SemanticVersion(0,
Integer.MAX_VALUE,
Integer.MAX_VALUE))
.preferredVersion(new SemanticVersion(0, 4, 1))
.build());
} catch (Exception e) {
@@ -71,7 +71,8 @@ public class MappingManager {
.patchVersion(-1)
.build())
.build());
val input = new DataInputStream(new LZMA2Options(6).getInputStream(ResourceUtil.getResourceFromJar("/mappings.lzma2", CoreLoadingPlugin.class)));
val input = new DataInputStream(new LZMA2Options(6).getInputStream(
ResourceUtil.getResourceFromJar("/mappings.lzma2", CoreLoadingPlugin.class)));
{
var classBytes = new byte[input.readInt()];
input.readFully(classBytes);
@@ -86,7 +87,7 @@ public class MappingManager {
{
var fieldBytes = new byte[input.readInt()];
input.readFully(fieldBytes);
var fieldMappings = new String(fieldBytes).split( "\n");
var fieldMappings = new String(fieldBytes).split("\n");
for (int i = 1; i < fieldMappings.length; i++) {
val line = fieldMappings[i].split(",");
val clazz = internalLookup.get(MappingType.Notch, line[0].substring(0, line[0].lastIndexOf('/')));
@@ -24,10 +24,7 @@ import com.falsepattern.lib.StableAPI;
@StableAPI(since = "0.10.0")
public enum MappingType {
@StableAPI.Expose
Notch,
@StableAPI.Expose
SRG,
@StableAPI.Expose
MCP
@StableAPI.Expose Notch,
@StableAPI.Expose SRG,
@StableAPI.Expose MCP
}
@@ -24,8 +24,6 @@ import com.falsepattern.lib.StableAPI;
@StableAPI(since = "0.10.0")
public enum NameType {
@StableAPI.Expose
Internal,
@StableAPI.Expose
Regular
@StableAPI.Expose Internal,
@StableAPI.Expose Regular
}
@@ -21,8 +21,8 @@
package com.falsepattern.lib.mapping.types;
import com.falsepattern.lib.StableAPI;
import com.falsepattern.lib.mapping.storage.MappedString;
import com.falsepattern.lib.internal.ReflectionUtil;
import com.falsepattern.lib.mapping.storage.MappedString;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
@@ -21,8 +21,8 @@
package com.falsepattern.lib.mapping.types;
import com.falsepattern.lib.StableAPI;
import com.falsepattern.lib.mapping.storage.MappedString;
import com.falsepattern.lib.internal.ReflectionUtil;
import com.falsepattern.lib.mapping.storage.MappedString;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
@@ -49,12 +49,9 @@ public interface IMixin {
@StableAPI(since = "0.10.0")
enum Side {
@StableAPI.Expose
COMMON,
@StableAPI.Expose
CLIENT,
@StableAPI.Expose
SERVER
@StableAPI.Expose COMMON,
@StableAPI.Expose CLIENT,
@StableAPI.Expose SERVER
}
@StableAPI(since = "0.10.0")
@@ -44,6 +44,7 @@ public interface ITargetedMod {
return "jar".equals(fileExtension) && getCondition().test(nameLowerCase);
}
@StableAPI.Expose
Predicate<String> getCondition();