Skip to content

Commit dfba569

Browse files
committed
cleanup code
1 parent 6868e1f commit dfba569

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+637
-373
lines changed

src/main/java/com/falsepattern/lib/DeprecationDetails.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
@StableAPI(since = "0.10.0")
3535
public @interface DeprecationDetails {
3636
@StableAPI.Expose String deprecatedSince();
37+
3738
@StableAPI.Expose(since = "0.11.0") String replacement() default "";
3839

3940
/**

src/main/java/com/falsepattern/lib/StableAPI.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,5 @@
8585
@Retention(RetentionPolicy.RUNTIME)
8686
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
8787
@StableAPI(since = "0.10.0")
88-
@interface Internal {
89-
}
88+
@interface Internal {}
9089
}

src/main/java/com/falsepattern/lib/asm/ASMUtil.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,16 @@ public static FieldNode findFieldStandard(ClassNode cn, String name, boolean opt
6363
public static FieldNode findFieldFromMCP(ClassNode cn, String fieldName, boolean optional) {
6464
val classMapping = discoverClassMappingType(cn);
6565
if (classMapping == null) {
66-
throw new AsmClassNotFoundException("The class " + cn + " is not from Minecraft, or the mapping manager" +
67-
"doesn't have it, cannot use findFieldFromMCP! Use findFieldStandard instead!");
66+
throw new AsmClassNotFoundException("The class "
67+
+ cn
68+
+ " is not from Minecraft, or the mapping manager"
69+
+ "doesn't have it, cannot use findFieldFromMCP! Use findFieldStandard instead!");
6870
}
69-
return findFieldStandard(cn, MappingManager.classForName(NameType.Internal, classMapping, cn.name)
70-
.getField(MappingType.MCP, fieldName)
71-
.getName(classMapping), optional);
71+
return findFieldStandard(cn,
72+
MappingManager.classForName(NameType.Internal, classMapping, cn.name)
73+
.getField(MappingType.MCP, fieldName)
74+
.getName(classMapping),
75+
optional);
7276
}
7377

7478
@StableAPI.Expose
@@ -106,8 +110,10 @@ public static MethodNode findMethodStandard(ClassNode cn, String name, String de
106110
public static MethodNode findMethodFromMCP(ClassNode cn, String mcpName, String mcpDescriptor, boolean optional) {
107111
val classMapping = discoverClassMappingType(cn);
108112
if (classMapping == null) {
109-
throw new AsmClassNotFoundException("The class " + cn + " is not from Minecraft, or the mapping manager" +
110-
"doesn't have it, cannot use findMethodFromMCP! Use findFieldStandard instead!");
113+
throw new AsmClassNotFoundException("The class "
114+
+ cn
115+
+ " is not from Minecraft, or the mapping manager"
116+
+ "doesn't have it, cannot use findMethodFromMCP! Use findFieldStandard instead!");
111117
}
112118
val method = MappingManager.classForName(NameType.Internal, classMapping, cn.name)
113119
.getMethod(MappingType.MCP, mcpName, mcpDescriptor);

src/main/java/com/falsepattern/lib/compat/BlockPos.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,12 @@ public static BlockPos fromLong(long serialized) {
115115
*/
116116
@StableAPI.Expose
117117
public static Iterable<BlockPos> getAllInBox(@NonNull BlockPos from, @NonNull BlockPos to) {
118-
return getAllInBox(Math.min(from.getX(), to.getX()), Math.min(from.getY(), to.getY()),
119-
Math.min(from.getZ(), to.getZ()), Math.max(from.getX(), to.getX()),
120-
Math.max(from.getY(), to.getY()), Math.max(from.getZ(), to.getZ()));
118+
return getAllInBox(Math.min(from.getX(), to.getX()),
119+
Math.min(from.getY(), to.getY()),
120+
Math.min(from.getZ(), to.getZ()),
121+
Math.max(from.getX(), to.getX()),
122+
Math.max(from.getY(), to.getY()),
123+
Math.max(from.getZ(), to.getZ()));
121124
}
122125

123126
/**
@@ -192,9 +195,12 @@ protected BlockPos computeNext() {
192195
*/
193196
@StableAPI.Expose
194197
public static Iterable<BlockPos.MutableBlockPos> getAllInBoxMutable(@NonNull BlockPos from, @NonNull BlockPos to) {
195-
return getAllInBoxMutable(Math.min(from.getX(), to.getX()), Math.min(from.getY(), to.getY()),
196-
Math.min(from.getZ(), to.getZ()), Math.max(from.getX(), to.getX()),
197-
Math.max(from.getY(), to.getY()), Math.max(from.getZ(), to.getZ()));
198+
return getAllInBoxMutable(Math.min(from.getX(), to.getX()),
199+
Math.min(from.getY(), to.getY()),
200+
Math.min(from.getZ(), to.getZ()),
201+
Math.max(from.getX(), to.getX()),
202+
Math.max(from.getY(), to.getY()),
203+
Math.max(from.getZ(), to.getZ()));
198204
}
199205

200206
/**
@@ -304,7 +310,8 @@ public BlockPos offset(@NonNull EnumFacing facing, int blocks) {
304310
if (blocks == 0) {
305311
return this;
306312
}
307-
return new BlockPos(x + facing.getFrontOffsetX() * blocks, y + facing.getFrontOffsetY() * blocks,
313+
return new BlockPos(x + facing.getFrontOffsetX() * blocks,
314+
y + facing.getFrontOffsetY() * blocks,
308315
z + facing.getFrontOffsetZ() * blocks);
309316
}
310317

@@ -380,7 +387,8 @@ public BlockPos rotate(@NonNull Rotation rotation) {
380387

381388
@Override
382389
public BlockPos crossProduct(@NonNull Vec3i vec) {
383-
return new BlockPos(y * vec.getZ() - z * vec.getY(), z * vec.getX() - x * vec.getZ(),
390+
return new BlockPos(y * vec.getZ() - z * vec.getY(),
391+
z * vec.getX() - x * vec.getZ(),
384392
x * vec.getY() - y * vec.getX());
385393
}
386394

@@ -479,7 +487,8 @@ public BlockPos.MutableBlockPos move(@NonNull EnumFacing facing) {
479487

480488
@StableAPI.Expose
481489
public BlockPos.MutableBlockPos move(@NonNull EnumFacing facing, int blocks) {
482-
return this.setPos(x + facing.getFrontOffsetX() * blocks, y + facing.getFrontOffsetY() * blocks,
490+
return this.setPos(x + facing.getFrontOffsetX() * blocks,
491+
y + facing.getFrontOffsetY() * blocks,
483492
z + facing.getFrontOffsetZ() * blocks);
484493
}
485494
}

src/main/java/com/falsepattern/lib/compat/Vec3i.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public int compareTo(@NonNull Vec3i vec) {
7878
*/
7979
@StableAPI.Expose
8080
public Vec3i crossProduct(@NonNull Vec3i vec) {
81-
return new Vec3i(y * vec.getZ() - z * vec.getY(), z * vec.getX() - x * vec.getZ(),
81+
return new Vec3i(y * vec.getZ() - z * vec.getY(),
82+
z * vec.getX() - x * vec.getZ(),
8283
x * vec.getY() - y * vec.getX());
8384
}
8485

src/main/java/com/falsepattern/lib/config/Config.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@
8080
@Documented
8181
@Retention(RetentionPolicy.RUNTIME)
8282
@Target(ElementType.FIELD)
83-
@interface Ignore {
84-
}
83+
@interface Ignore {}
8584

8685
/**
8786
* The default value for a boolean field. Not having a default is deprecated since 0.10, and will be strongly
@@ -253,8 +252,7 @@
253252
@Documented
254253
@Retention(RetentionPolicy.RUNTIME)
255254
@Target(ElementType.FIELD)
256-
@interface ListFixedLength {
257-
}
255+
@interface ListFixedLength {}
258256

259257
/**
260258
* This annotation limits the maximum number of elements present in an array configuration. Only effective if
@@ -290,8 +288,7 @@
290288
@Documented
291289
@Retention(RetentionPolicy.RUNTIME)
292290
@Target({ElementType.FIELD, ElementType.TYPE})
293-
@interface RequiresMcRestart {
294-
}
291+
@interface RequiresMcRestart {}
295292

296293
/**
297294
* Whether the specific configuration needs a world/server rejoin to be applied.
@@ -300,8 +297,7 @@
300297
@Documented
301298
@Retention(RetentionPolicy.RUNTIME)
302299
@Target({ElementType.FIELD, ElementType.TYPE})
303-
@interface RequiresWorldRestart {
304-
}
300+
@interface RequiresWorldRestart {}
305301

306302
/**
307303
* Signals that this configuration class should be synchronized between the client and the server when
@@ -314,8 +310,7 @@
314310
@Documented
315311
@Retention(RetentionPolicy.RUNTIME)
316312
@Target(ElementType.TYPE)
317-
@interface Synchronize {
318-
}
313+
@interface Synchronize {}
319314

320315
/**
321316
* Use this to mark config fields you don't want to synchronize in a class marked with {@link Synchronize}.
@@ -324,6 +319,5 @@
324319
@Documented
325320
@Retention(RetentionPolicy.RUNTIME)
326321
@Target(ElementType.FIELD)
327-
@interface NoSync {
328-
}
322+
@interface NoSync {}
329323
}

src/main/java/com/falsepattern/lib/config/SimpleGuiConfig.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ public SimpleGuiConfig(GuiScreen parent, Class<?> configClass, String modID, Str
4040
@StableAPI.Expose(since = "0.10.0")
4141
public SimpleGuiConfig(GuiScreen parent, String modID, String modName, Class<?>... configClasses)
4242
throws ConfigException {
43-
super(parent, ConfigurationManager.getConfigElementsMulti(configClasses), modID, false, false,
44-
modName + " Configuration", I18n.format("falsepatternlib.gui.config.description"));
43+
super(parent,
44+
ConfigurationManager.getConfigElementsMulti(configClasses),
45+
modID,
46+
false,
47+
false,
48+
modName + " Configuration",
49+
I18n.format("falsepatternlib.gui.config.description"));
4550
}
4651
}

src/main/java/com/falsepattern/lib/config/event/ConfigValidationFailureEvent.java

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,34 @@ protected ConfigValidationFailureEvent(String reason, Class<?> configClass, Stri
6363
public static void postNumericRangeOutOfBounds(Field field, int listIndex, String value, String min, String max) {
6464
FMLCommonHandler.instance()
6565
.bus()
66-
.post(new NumericRangeOutOfBounds(field.getDeclaringClass(), field.getName(), listIndex, value,
67-
min, max));
66+
.post(new NumericRangeOutOfBounds(field.getDeclaringClass(),
67+
field.getName(),
68+
listIndex,
69+
value,
70+
min,
71+
max));
6872
}
6973

7074
@StableAPI.Internal
7175
public static void postSize(Field field, int requestedSize, boolean fixedSize, int maxSize, int defaultSize) {
7276
FMLCommonHandler.instance()
7377
.bus()
74-
.post(new ListSizeOutOfBounds(field.getDeclaringClass(), field.getName(), requestedSize,
75-
fixedSize, maxSize, defaultSize));
78+
.post(new ListSizeOutOfBounds(field.getDeclaringClass(),
79+
field.getName(),
80+
requestedSize,
81+
fixedSize,
82+
maxSize,
83+
defaultSize));
7684
}
7785

7886
@StableAPI.Internal
7987
public static void postStringSizeOutOfBounds(Field field, int listIndex, String text, int maxSize) {
8088
FMLCommonHandler.instance()
8189
.bus()
82-
.post(new StringSizeOutOfBounds(field.getDeclaringClass(), field.getName(), listIndex, text,
90+
.post(new StringSizeOutOfBounds(field.getDeclaringClass(),
91+
field.getName(),
92+
listIndex,
93+
text,
8394
maxSize));
8495
}
8596

@@ -92,19 +103,24 @@ public static void fieldIsNull(Field field, int listIndex) {
92103
public static void postStringPatternMismatch(Field field, int listIndex, String text, String pattern) {
93104
FMLCommonHandler.instance()
94105
.bus()
95-
.post(new StringPatternMismatch(field.getDeclaringClass(), field.getName(), listIndex, text,
106+
.post(new StringPatternMismatch(field.getDeclaringClass(),
107+
field.getName(),
108+
listIndex,
109+
text,
96110
pattern));
97111
}
98112

99113
@SideOnly(Side.CLIENT)
100114
@StableAPI.Internal
101115
public void toast() {
102116
val ann = configClass.getAnnotation(Config.class);
103-
val toast = new SimpleToast(ToastBG.TOAST_DARK, null,
117+
val toast = new SimpleToast(ToastBG.TOAST_DARK,
118+
null,
104119
FormattedText.parse(EnumChatFormatting.RED + "Config validation failed")
105120
.toChatText()
106121
.get(0),
107-
FormattedText.parse(ann.modid() + ":" + ann.category()).toChatText().get(0), false,
122+
FormattedText.parse(ann.modid() + ":" + ann.category()).toChatText().get(0),
123+
false,
108124
2000);
109125
GuiToast.add(toast);
110126
}
@@ -122,7 +138,7 @@ public void logWarn() {
122138
errorString.append("\nArray index: ").append(listIndex);
123139
}
124140
customText(errorString);
125-
for (val line: errorString.toString().split("\n")) {
141+
for (val line : errorString.toString().split("\n")) {
126142
Share.LOG.error(line);
127143
}
128144
}

src/main/java/com/falsepattern/lib/dependencies/Library.java

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,35 @@ public LibraryBuilder devSuffix(String devSuffix) {
130130

131131
@StableAPI.Expose
132132
public Library build() {
133-
return new Library(loadingModId, groupId, artifactId, minVersion, maxVersion, preferredVersion,
134-
regularSuffix, devSuffix);
133+
return new Library(loadingModId,
134+
groupId,
135+
artifactId,
136+
minVersion,
137+
maxVersion,
138+
preferredVersion,
139+
regularSuffix,
140+
devSuffix);
135141
}
136142

137143
@Override
138144
public String toString() {
139-
return "Library.LibraryBuilder(loadingModId=" + this.loadingModId + ", groupId=" + this.groupId +
140-
", artifactId=" + this.artifactId + ", minVersion=" + this.minVersion + ", maxVersion=" +
141-
this.maxVersion + ", preferredVersion=" + this.preferredVersion + ", regularSuffix=" +
142-
this.regularSuffix + ", devSuffix=" + this.devSuffix + ")";
145+
return "Library.LibraryBuilder(loadingModId="
146+
+ this.loadingModId
147+
+ ", groupId="
148+
+ this.groupId
149+
+ ", artifactId="
150+
+ this.artifactId
151+
+ ", minVersion="
152+
+ this.minVersion
153+
+ ", maxVersion="
154+
+ this.maxVersion
155+
+ ", preferredVersion="
156+
+ this.preferredVersion
157+
+ ", regularSuffix="
158+
+ this.regularSuffix
159+
+ ", devSuffix="
160+
+ this.devSuffix
161+
+ ")";
143162
}
144163
}
145164
}

src/main/java/com/falsepattern/lib/dependencies/SemanticVersion.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,11 @@ public int compareTo(@NonNull Version o) {
111111

112112
@Override
113113
public String toString() {
114+
// @formatter:off
114115
return majorVersion + (minorVersion < 0 ? "" : "." + minorVersion) +
115116
(patchVersion < 0 ? "" : "." + patchVersion) + (preRelease == null ? "" : "-" + preRelease) +
116117
(build == null ? "" : "+" + build);
118+
// @formatter:on
117119
}
118120

119121
@StableAPI(since = "0.10.0")
@@ -165,9 +167,17 @@ public SemanticVersion build() {
165167

166168
@Override
167169
public String toString() {
168-
return "SemanticVersion.SemanticVersionBuilder(majorVersion=" + this.majorVersion + ", minorVersion=" +
169-
this.minorVersion + ", patchVersion=" + this.patchVersion + ", preRelease=" + this.preRelease +
170-
", build=" + this.build + ")";
170+
return "SemanticVersion.SemanticVersionBuilder(majorVersion="
171+
+ this.majorVersion
172+
+ ", minorVersion="
173+
+ this.minorVersion
174+
+ ", patchVersion="
175+
+ this.patchVersion
176+
+ ", preRelease="
177+
+ this.preRelease
178+
+ ", build="
179+
+ this.build
180+
+ ")";
171181
}
172182
}
173183
}

0 commit comments

Comments
 (0)