Skip to content

Commit 93602f6

Browse files
committed
Updated formatter api.
1 parent 8e842d8 commit 93602f6

20 files changed

+987
-633
lines changed

.run/Publish to Local Maven.run.xml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Publish to Local Maven" type="GradleRunConfiguration" factoryName="Gradle">
3+
<ExternalSystemSettings>
4+
<option name="executionName"/>
5+
<option name="externalProjectPath" value="$PROJECT_DIR$"/>
6+
<option name="externalSystemIdString" value="GRADLE"/>
7+
<option name="scriptParameters" value=""/>
8+
<option name="taskDescriptions">
9+
<list/>
10+
</option>
11+
<option name="taskNames">
12+
<list>
13+
<option value="publishAllPublicationsToMavenLocalRepository"/>
14+
</list>
15+
</option>
16+
<option name="vmOptions"/>
17+
</ExternalSystemSettings>
18+
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
19+
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
20+
<DebugAllEnabled>false</DebugAllEnabled>
21+
<method v="2"/>
22+
</configuration>
23+
</component>

build.gradle

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ buildscript {
88
}
99
dependencies {
1010
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
11+
classpath group: 'org.parchmentmc', name: 'librarian', version: '1.+', changing: true
1112
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
1213
}
1314
}
@@ -18,6 +19,7 @@ plugins {
1819

1920
apply plugin: 'net.minecraftforge.gradle'
2021
apply plugin: 'org.spongepowered.mixin'
22+
apply plugin: 'org.parchmentmc.librarian.forgegradle'
2123
apply plugin: 'eclipse'
2224
apply plugin: 'maven-publish'
2325

@@ -205,7 +207,7 @@ dependencies {
205207
// Specify the version of Minecraft to use. If this is any group other than 'net.minecraft' it is assumed
206208
// that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
207209
// The user-dev artifact is a special name and will get all sorts of transformations applied to it.
208-
minecraft 'net.minecraftforge:forge:1.18.1-39.1.0'
210+
minecraft 'net.minecraftforge:forge:1.18.2-40.1.0'
209211

210212
// Real mod deobf dependency examples - these get remapped to your current mappings
211213
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package com.ultreon.mods.advanceddebug.api.client.formatter;
2+
3+
@SuppressWarnings("UnusedReturnValue")
4+
public interface IFormatterContext {
5+
IFormatterContext keyword(String text);
6+
7+
IFormatterContext number(String text);
8+
9+
IFormatterContext number(Number number);
10+
11+
IFormatterContext string(String text);
12+
13+
IFormatterContext stringEscape(String text);
14+
15+
IFormatterContext operator(String text);
16+
17+
IFormatterContext identifier(String text);
18+
19+
IFormatterContext parameter(String text);
20+
21+
IFormatterContext parameter(String text, Object value);
22+
23+
IFormatterContext comment(String text);
24+
25+
IFormatterContext error(String text);
26+
27+
IFormatterContext className(String text);
28+
29+
IFormatterContext enumConstant(Enum<?> enumValue);
30+
31+
IFormatterContext enumConstant(String text);
32+
33+
IFormatterContext packageName(String text);
34+
35+
IFormatterContext methodName(String text);
36+
37+
IFormatterContext functionName(String text);
38+
39+
IFormatterContext callName(String text);
40+
41+
IFormatterContext field(String text);
42+
43+
IFormatterContext annotation(String text);
44+
45+
IFormatterContext normal(String text);
46+
47+
IFormatterContext classValue(Class<?> clazz);
48+
49+
IFormatterContext space();
50+
51+
IFormatterContext separator();
52+
53+
IFormatterContext hex(String hexString);
54+
55+
IFormatterContext hexValue(int number);
56+
57+
IFormatterContext intValue(int number);
58+
59+
IFormatterContext longValue(long number);
60+
61+
IFormatterContext floatValue(float number);
62+
63+
IFormatterContext doubleValue(double number);
64+
65+
IFormatterContext stringEscaped(String text);
66+
67+
IFormatterContext charsEscaped(String text);
68+
69+
IFormatterContext other(Object e);
70+
}

src/api/java/com/ultreon/mods/advanceddebug/api/client/menu/Formatter.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
package com.ultreon.mods.advanceddebug.api.client.menu;
22

33
import com.ultreon.mods.advanceddebug.api.IAdvancedDebug;
4+
import com.ultreon.mods.advanceddebug.api.client.formatter.IFormatterContext;
45
import com.ultreon.mods.advanceddebug.api.common.IFormatter;
56
import net.minecraft.resources.ResourceLocation;
67
import net.minecraftforge.registries.ForgeRegistryEntry;
78

8-
public abstract class Formatter<T> extends ForgeRegistryEntry<Formatter<T>> implements IFormatter {
9+
public abstract class Formatter<T> extends ForgeRegistryEntry<Formatter<T>> implements IFormatter<T> {
910
private final Class<T> clazz;
1011

1112
public Formatter(Class<T> clazz, ResourceLocation name) {
1213
this.clazz = clazz;
1314
this.setRegistryName(name);
1415
}
1516

16-
public abstract void format(T obj, StringBuilder sb);
17-
1817
@Override
19-
public final String format(Object obj) {
20-
return IAdvancedDebug.get().getGui().format(obj);
18+
public abstract void format(T obj, IFormatterContext context);
19+
20+
public final void formatOther(Object obj, IFormatterContext context) {
21+
IAdvancedDebug.get().getGui().format(obj, context);
2122
}
2223

2324
public Class<T> clazz() {

src/api/java/com/ultreon/mods/advanceddebug/api/client/menu/IDebugGui.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package com.ultreon.mods.advanceddebug.api.client.menu;
22

3+
import com.ultreon.mods.advanceddebug.api.client.formatter.IFormatterContext;
34
import com.ultreon.mods.advanceddebug.api.common.IFormatter;
45

56
import javax.annotation.Nullable;
67

7-
public interface IDebugGui extends IFormatter {
8+
public interface IDebugGui extends IFormatter<Object> {
89
<T extends DebugPage> T registerPage(T page);
910

1011
@Nullable
@@ -20,7 +21,7 @@ public interface IDebugGui extends IFormatter {
2021

2122
void prev();
2223

23-
String format(Object obj);
24+
void format(Object obj, IFormatterContext context);
2425

2526
Formatter<Object> getDefault();
2627
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.ultreon.mods.advanceddebug.api.common;
22

3-
public interface IFormatter {
4-
String format(Object obj);
3+
import com.ultreon.mods.advanceddebug.api.client.formatter.IFormatterContext;
4+
5+
public interface IFormatter<T> {
6+
void format(T obj, IFormatterContext context);
57
}

0 commit comments

Comments
 (0)