Skip to content

Commit 0d9419a

Browse files
committed
Refactor codebase to Java 25 language features
1 parent 1993077 commit 0d9419a

14 files changed

Lines changed: 34 additions & 97 deletions

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ enable_lwjglx = true
1919

2020
# Mod Information
2121
# HIGHLY RECOMMEND complying with SemVer for mod_version: https://semver.org/
22-
mod_version = 0.4.0-dev-J25
22+
mod_version = 0.4.0-dev2-J25
2323
root_package = jp.s12kuma01
2424
mod_id = celeritasextra
2525
mod_name = Celeritas Extra

src/main/java/jp/s12kuma01/celeritasextra/CeleritasExtraMixinConfigPlugin.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public class CeleritasExtraMixinConfigPlugin implements IMixinConfigPlugin {
1515

1616
@Override
1717
public void onLoad(String mixinPackage) {
18-
// No initialization needed
1918
}
2019

2120
@Override
@@ -25,14 +24,11 @@ public String getRefMapperConfig() {
2524

2625
@Override
2726
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
28-
// Add conditional mixin loading based on mod compatibility here
29-
// For example, only load certain mixins if specific mods are present
3027
return true;
3128
}
3229

3330
@Override
3431
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
35-
// No target filtering needed
3632
}
3733

3834
@Override
@@ -42,11 +38,9 @@ public List<String> getMixins() {
4238

4339
@Override
4440
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
45-
// No pre-apply logic needed
4641
}
4742

4843
@Override
4944
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
50-
// No post-apply logic needed
5145
}
5246
}

src/main/java/jp/s12kuma01/celeritasextra/CeleritasExtraMod.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ public void construct(FMLConstructionEvent event) {
2929
OptionGroupConstructionEvent.BUS.addListener(jp.s12kuma01.celeritasextra.client.gui.CeleritasExtraOptionsListener::onOptionGroupConstruct);
3030
LOGGER.info("Successfully registered Celeritas Extra with Celeritas GUI");
3131
} catch (Throwable t) {
32-
if (t instanceof NoClassDefFoundError) {
33-
LOGGER.error("Celeritas version is too old, use 2.4.0 or newer");
34-
} else {
35-
LOGGER.error("Unable to check if Celeritas is up-to-date", t);
32+
switch (t) {
33+
case NoClassDefFoundError _ -> LOGGER.error("Celeritas version is too old, use 2.4.0 or newer");
34+
default -> LOGGER.error("Unable to check if Celeritas is up-to-date", t);
3635
}
3736
}
3837
} else {

src/main/java/jp/s12kuma01/celeritasextra/client/CeleritasExtraClientMod.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ private static CeleritasExtraGameOptions loadConfig() {
3232
public static void onClientInit() {
3333
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
3434
CeleritasExtraMod.LOGGER.info("Initializing Celeritas Extra client...");
35-
// Load configuration
3635
options();
3736
}
3837
}

src/main/java/jp/s12kuma01/celeritasextra/client/ClientTickHandler.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,11 @@ public static void onClientTick(TickEvent.ClientTickEvent event) {
3333

3434
int currentFPS = Minecraft.getDebugFPS();
3535

36-
// Add current FPS to queue
3736
if (fpsQueue.size() >= QUEUE_SIZE) {
3837
fpsQueue.pollFirst();
3938
}
4039
fpsQueue.addLast(currentFPS);
4140

42-
// Calculate statistics
4341
if (!fpsQueue.isEmpty()) {
4442
int sum = 0;
4543
int min = Integer.MAX_VALUE;

src/main/java/jp/s12kuma01/celeritasextra/client/gui/CeleritasExtraGameOptionPages.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ public static OptionPage particle() {
131131
ParticleClassRegistry.getInstance().scanModJars();
132132

133133
// Dynamic particle class controls - grouped by mod name
134-
Map<String, String> discovered = ParticleClassRegistry.getInstance().getDiscoveredClasses();
134+
var discovered = ParticleClassRegistry.getInstance().getDiscoveredClasses();
135135
if (!discovered.isEmpty()) {
136-
Map<String, List<Map.Entry<String, String>>> byMod = new TreeMap<>();
137-
for (Map.Entry<String, String> entry : discovered.entrySet()) {
136+
var byMod = new TreeMap<String, List<Map.Entry<String, String>>>();
137+
for (var entry : discovered.entrySet()) {
138138
String fullName = entry.getKey();
139139
String modId = ParticleClassRegistry.getInstance().getModName(fullName);
140140
if (modId == null) {
@@ -143,15 +143,15 @@ public static OptionPage particle() {
143143
byMod.computeIfAbsent(modId, k -> new ArrayList<>()).add(entry);
144144
}
145145

146-
for (Map.Entry<String, List<Map.Entry<String, String>>> modEntry : byMod.entrySet()) {
147-
String modId = modEntry.getKey();
148-
OptionGroup.Builder groupBuilder = OptionGroup.createBuilder();
149-
List<Map.Entry<String, String>> classEntries = modEntry.getValue();
146+
for (var modEntry : byMod.entrySet()) {
147+
var modId = modEntry.getKey();
148+
var groupBuilder = OptionGroup.createBuilder();
149+
var classEntries = modEntry.getValue();
150150
classEntries.sort(Comparator.comparing(Map.Entry::getValue));
151151

152-
for (Map.Entry<String, String> classEntry : classEntries) {
153-
String fullClassName = classEntry.getKey();
154-
String simpleClassName = classEntry.getValue();
152+
for (var classEntry : classEntries) {
153+
var fullClassName = classEntry.getKey();
154+
var simpleClassName = classEntry.getValue();
155155
String displayName = simpleClassName + " (" + modId + ")";
156156

157157
groupBuilder.add(OptionImpl.createBuilder(boolean.class, celeritasExtraOpts)

src/main/java/jp/s12kuma01/celeritasextra/client/gui/CeleritasExtraGameOptions.java

Lines changed: 10 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
*/
2222
public class CeleritasExtraGameOptions {
2323

24-
// Category names
2524
private static final String CAT_ANIMATION = "animation";
2625
private static final String CAT_PARTICLE = "particle";
2726
private static final String CAT_PARTICLE_CLASSES = "particle_classes";
@@ -269,18 +268,18 @@ public static VerticalSyncOption getVerticalSyncOption(CeleritasExtraGameOptions
269268
public static void setVerticalSyncOption(CeleritasExtraGameOptions opts, VerticalSyncOption value) {
270269
Minecraft mc = Minecraft.getMinecraft();
271270
switch (value) {
272-
case OFF:
271+
case OFF -> {
273272
opts.extraSettings.useAdaptiveSync = false;
274273
mc.gameSettings.enableVsync = false;
275-
break;
276-
case ON:
274+
}
275+
case ON -> {
277276
opts.extraSettings.useAdaptiveSync = false;
278277
mc.gameSettings.enableVsync = true;
279-
break;
280-
case ADAPTIVE:
278+
}
279+
case ADAPTIVE -> {
281280
opts.extraSettings.useAdaptiveSync = true;
282281
mc.gameSettings.enableVsync = true;
283-
break;
282+
}
284283
}
285284
// Trigger VSync update - our mixin intercepts this when adaptive is enabled
286285
Display.setVSyncEnabled(mc.gameSettings.enableVsync);
@@ -305,7 +304,6 @@ public String getLocalizedName() {
305304
}
306305
}
307306

308-
// Settings classes
309307
public static class AnimationSettings {
310308
public boolean animation = true;
311309
public boolean water = true;
@@ -363,24 +361,8 @@ public static class ExtraSettings {
363361
public int steadyDebugHudRefreshInterval = 20;
364362
}
365363

366-
private static class BooleanProperty {
367-
final String category;
368-
final String key;
369-
final boolean defaultValue;
370-
final String comment;
371-
final Consumer<Boolean> setter;
372-
final Supplier<Boolean> getter;
373-
374-
BooleanProperty(String category, String key, boolean defaultValue, String comment,
375-
Consumer<Boolean> setter, Supplier<Boolean> getter) {
376-
this.category = category;
377-
this.key = key;
378-
this.defaultValue = defaultValue;
379-
this.comment = comment;
380-
this.setter = setter;
381-
this.getter = getter;
382-
}
383-
364+
private record BooleanProperty(String category, String key, boolean defaultValue, String comment,
365+
Consumer<Boolean> setter, Supplier<Boolean> getter) {
384366
void load(Configuration config) {
385367
setter.accept(config.getBoolean(key, category, defaultValue, comment));
386368
}
@@ -390,28 +372,8 @@ void save(Configuration config) {
390372
}
391373
}
392374

393-
private static class IntProperty {
394-
final String category;
395-
final String key;
396-
final int defaultValue;
397-
final int min;
398-
final int max;
399-
final String comment;
400-
final Consumer<Integer> setter;
401-
final Supplier<Integer> getter;
402-
403-
IntProperty(String category, String key, int defaultValue, int min, int max, String comment,
404-
Consumer<Integer> setter, Supplier<Integer> getter) {
405-
this.category = category;
406-
this.key = key;
407-
this.defaultValue = defaultValue;
408-
this.min = min;
409-
this.max = max;
410-
this.comment = comment;
411-
this.setter = setter;
412-
this.getter = getter;
413-
}
414-
375+
private record IntProperty(String category, String key, int defaultValue, int min, int max, String comment,
376+
Consumer<Integer> setter, Supplier<Integer> getter) {
415377
void load(Configuration config) {
416378
setter.accept(config.getInt(key, category, defaultValue, min, max, comment));
417379
}

src/main/java/jp/s12kuma01/celeritasextra/client/gui/CeleritasExtraHud.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class CeleritasExtraHud {
2929
@SubscribeEvent
3030
public static void onRenderOverlay(RenderGameOverlayEvent.Text event) {
3131
if (mc.gameSettings.showDebugInfo || mc.gameSettings.hideGUI) {
32-
return; // Don't render when F3 debug screen is open or GUI is hidden
32+
return;
3333
}
3434

3535
List<String> lines = new ArrayList<>();
@@ -113,21 +113,13 @@ private static void drawString(FontRenderer fontRenderer, String text, int x, in
113113
int textColor = 0xFFFFFF;
114114

115115
switch (textContrast) {
116-
case BACKGROUND:
117-
// Draw semi-transparent background
116+
case BACKGROUND -> {
118117
int textWidth = fontRenderer.getStringWidth(text);
119118
Gui.drawRect(x - 1, y - 1, x + textWidth + 1, y + fontRenderer.FONT_HEIGHT + 1, 0x90505050);
120119
fontRenderer.drawString(text, x, y, textColor);
121-
break;
122-
case SHADOW:
123-
// Draw with shadow (default Minecraft style)
124-
fontRenderer.drawStringWithShadow(text, x, y, textColor);
125-
break;
126-
case NONE:
127-
default:
128-
// Draw without any contrast enhancement
129-
fontRenderer.drawString(text, x, y, textColor);
130-
break;
120+
}
121+
case SHADOW -> fontRenderer.drawStringWithShadow(text, x, y, textColor);
122+
default -> fontRenderer.drawString(text, x, y, textColor);
131123
}
132124
}
133125
}

src/main/java/jp/s12kuma01/celeritasextra/client/particle/ParticleClassRegistry.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public void scanModJars() {
166166
boolean changed = true;
167167
while (changed) {
168168
changed = false;
169-
for (Map.Entry<String, String> entry : superMap.entrySet()) {
169+
for (var entry : superMap.entrySet()) {
170170
String className = entry.getKey();
171171
String superName = entry.getValue();
172172
if (knownParticleNames.contains(className)) continue;
@@ -197,10 +197,10 @@ private void scanJarForSuperclasses(File jarFile, Map<String, String> superMap,
197197
String className = cr.getClassName();
198198
superMap.put(className, cr.getSuperName());
199199
classToModName.put(className, modName);
200-
} catch (Throwable ignored) {
200+
} catch (Throwable _) {
201201
}
202202
}
203-
} catch (Throwable ignored) {
203+
} catch (Throwable _) {
204204
}
205205
}
206206

@@ -217,7 +217,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
217217
String className = cr.getClassName();
218218
superMap.put(className, cr.getSuperName());
219219
classToModName.put(className, modName);
220-
} catch (Throwable ignored) {
220+
} catch (Throwable _) {
221221
}
222222
}
223223
return FileVisitResult.CONTINUE;

src/main/java/jp/s12kuma01/celeritasextra/core/CeleritasExtraCore.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public String getSetupClass() {
3434

3535
@Override
3636
public void injectData(Map<String, Object> data) {
37-
// No data injection needed
3837
}
3938

4039
@Override

0 commit comments

Comments
 (0)