Skip to content

Commit

Permalink
refactor: change com.squareup.javapoet to com.palantir.javapoet
Browse files Browse the repository at this point in the history
  • Loading branch information
IWareQ committed Oct 22, 2024
1 parent e0e9c7a commit ca3baff
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 39 deletions.
2 changes: 0 additions & 2 deletions api/src/main/java/org/allaymc/api/world/biome/BiomeId.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ public enum BiomeId implements BiomeType {

CHERRY_GROVE(new Identifier("minecraft:cherry_grove"), 192, "DataDriven");

public static final BiomeId[] VALUES = values();

private static final BiomeId[] MAP1;

private static final HashMap<Identifier, BiomeType> MAP2;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.allaymc.codegen;

import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.TypeSpec;
import com.palantir.javapoet.ClassName;
import com.palantir.javapoet.JavaFile;
import com.palantir.javapoet.TypeSpec;

import javax.lang.model.element.Modifier;
import java.io.IOException;
Expand Down
9 changes: 2 additions & 7 deletions codegen/src/main/java/org/allaymc/codegen/BiomeIdEnumGen.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.allaymc.codegen;

import com.squareup.javapoet.*;
import com.palantir.javapoet.*;
import lombok.SneakyThrows;

import javax.lang.model.element.Modifier;
Expand Down Expand Up @@ -56,10 +56,6 @@ public static void generate() {
.endControlFlow()
.build()
)
.addField(FieldSpec
.builder(ClassNames.BIOME_ARRAY, "VALUES", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
.initializer("values()")
.build())
.addField(FieldSpec
.builder(ClassNames.BIOME_ARRAY, "MAP1", Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL)
.build())
Expand All @@ -85,8 +81,7 @@ public static void generate() {
.build()
);
for (var entry : BIOME_DATA.entrySet()) {
var identifier = """
new Identifier("minecraft:%s")""".formatted(entry.getKey());
var identifier = "new Identifier(\"minecraft:%s\")".formatted(entry.getKey());
var id = entry.getValue().id;
var type = entry.getValue().type;
codeBuilder.addEnumConstant(entry.getKey().toUpperCase(), TypeSpec.anonymousClassBuilder("$L, $L, $S", identifier, id, type).build());
Expand Down
4 changes: 2 additions & 2 deletions codegen/src/main/java/org/allaymc/codegen/BlockIdEnumGen.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.allaymc.codegen;

import com.squareup.javapoet.*;
import com.palantir.javapoet.*;
import lombok.SneakyThrows;
import org.allaymc.dependence.Identifier;
import org.cloudburstmc.nbt.NBTInputStream;
Expand Down Expand Up @@ -64,7 +64,7 @@ public static void generateToDependenceModule() {

@SneakyThrows
public static void generateToAPIModule() {
var blockTypeClass = ParameterizedTypeName.get(BLOCK_TYPE, WildcardTypeName.subtypeOf(TypeName.OBJECT));
var blockTypeClass = ParameterizedTypeName.get(BLOCK_TYPE, WildcardTypeName.subtypeOf(ClassName.OBJECT));
TypeSpec.Builder codeBuilder = commonBuilder(ClassNames.API_IDENTIFIER)
.addAnnotation(MINECRAFT_VERSION_SENSITIVE)
.addMethod(MethodSpec.methodBuilder("fromIdentifier")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.allaymc.codegen;

import com.squareup.javapoet.*;
import com.palantir.javapoet.*;
import lombok.SneakyThrows;
import org.allaymc.dependence.BlockId;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.allaymc.codegen;

import com.squareup.javapoet.*;
import com.palantir.javapoet.*;
import lombok.SneakyThrows;

import javax.lang.model.element.Modifier;
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/main/java/org/allaymc/codegen/ClassNames.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.allaymc.codegen;

import com.squareup.javapoet.ClassName;
import com.palantir.javapoet.ClassName;

/**
* @author daoge_cmd
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.allaymc.codegen;

import com.google.gson.JsonParser;
import com.squareup.javapoet.*;
import com.palantir.javapoet.*;
import lombok.SneakyThrows;
import org.allaymc.dependence.StringUtils;

Expand All @@ -12,8 +12,6 @@
import java.util.Map;
import java.util.TreeMap;

import static org.allaymc.codegen.ClassNames.MINECRAFT_VERSION_SENSITIVE;

/**
* @author daoge_cmd | Cool_Loong | IWareQ
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.allaymc.codegen;

import com.squareup.javapoet.*;
import com.palantir.javapoet.*;
import lombok.SneakyThrows;
import org.allaymc.dependence.EntityId;

Expand Down
4 changes: 2 additions & 2 deletions codegen/src/main/java/org/allaymc/codegen/ItemIdEnumGen.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.allaymc.codegen;

import com.google.gson.JsonParser;
import com.squareup.javapoet.*;
import com.palantir.javapoet.*;
import lombok.SneakyThrows;
import org.allaymc.dependence.StringUtils;

Expand Down Expand Up @@ -74,7 +74,7 @@ public static void generateToAPIModule() {
.addMethod(MethodSpec.methodBuilder("getItemType")
.addModifiers(Modifier.PUBLIC)
.addStatement("return $T.ITEMS.get(this.getIdentifier())", REGISTRIES)
.returns(ParameterizedTypeName.get(ITEM_TYPE, WildcardTypeName.subtypeOf(TypeName.OBJECT)))
.returns(ParameterizedTypeName.get(ITEM_TYPE, WildcardTypeName.subtypeOf(ClassName.OBJECT)))
.build()
);
addEnums(codeBuilder);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.allaymc.codegen;

import com.squareup.javapoet.*;
import com.palantir.javapoet.*;
import lombok.SneakyThrows;
import org.allaymc.dependence.ItemId;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.allaymc.codegen;

import com.squareup.javapoet.*;
import com.palantir.javapoet.*;

import javax.lang.model.element.Modifier;
import java.io.IOException;
Expand Down
10 changes: 5 additions & 5 deletions codegen/src/main/java/org/allaymc/codegen/SoundNameGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParser;
import com.squareup.javapoet.FieldSpec;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.TypeSpec;
import com.palantir.javapoet.FieldSpec;
import com.palantir.javapoet.JavaFile;
import com.palantir.javapoet.TypeSpec;
import lombok.SneakyThrows;

import javax.lang.model.element.Modifier;
Expand Down Expand Up @@ -49,7 +49,7 @@ public static void main(String[] args) {

@SneakyThrows
private static Set<String> getMusicNames() {
try(var reader = Files.newBufferedReader(Path.of("data/resources/unpacked/music_definitions.json"))) {
try (var reader = Files.newBufferedReader(Path.of("data/resources/unpacked/music_definitions.json"))) {
var musicNames = new HashSet<String>();
JsonParser.parseReader(reader).getAsJsonObject().asMap().values().forEach(v -> {
musicNames.add(v.getAsJsonObject().get("event_name").getAsString());
Expand All @@ -60,7 +60,7 @@ private static Set<String> getMusicNames() {

@SneakyThrows
private static Set<String> getSoundNames() {
try(var reader = Files.newBufferedReader(Path.of("data/resources/unpacked/sound_definitions.json"))) {
try (var reader = Files.newBufferedReader(Path.of("data/resources/unpacked/sound_definitions.json"))) {
return JsonParser.parseReader(reader)
.getAsJsonObject()
.getAsJsonObject("sound_definitions")
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/main/java/org/allaymc/codegen/TagGen.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.allaymc.codegen;

import com.squareup.javapoet.*;
import com.palantir.javapoet.*;

import javax.lang.model.element.Modifier;
import java.io.IOException;
Expand Down
10 changes: 4 additions & 6 deletions codegen/src/main/java/org/allaymc/codegen/TrKeysGen.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package org.allaymc.codegen;

import com.google.gson.JsonParser;
import com.squareup.javapoet.FieldSpec;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.TypeSpec;
import com.palantir.javapoet.FieldSpec;
import com.palantir.javapoet.JavaFile;
import com.palantir.javapoet.TypeSpec;
import lombok.SneakyThrows;
import org.allaymc.dependence.Identifier;

import javax.lang.model.element.Modifier;
import java.nio.file.Files;
import java.nio.file.Path;

import static org.allaymc.codegen.ClassNames.STRING;

/**
* @author daoge_cmd | IWareQ
*/
Expand All @@ -36,7 +34,7 @@ public static void main(String[] args) {
var fieldName = namespace + "_" + path;
codeBuilder.addField(
FieldSpec
.builder(STRING, fieldName, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
.builder(ClassNames.STRING, fieldName, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
.initializer("\"" + key + "\"")
.build()
);
Expand Down
3 changes: 1 addition & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ stateupdater = { group = "org.allaymc", name = "stateupdater", version = "1.21.3
# Collections
guava = { group = "com.google.guava", name = "guava", version = "33.3.1-jre" }
# Fastutil
#fastutil = { group = "it.unimi.dsi", name = "fastutil", version.ref = "fastutil" }
fastutil-object-int-maps = { group = "org.cloudburstmc.fastutil.maps", name = "object-int-maps", version.ref = "fastutil" }
fastutil-object-reference-maps = { group = "org.cloudburstmc.fastutil.maps", name = "object-reference-maps", version.ref = "fastutil" }
fastutil-object-object-maps = { group = "org.cloudburstmc.fastutil.maps", name = "object-object-maps", version.ref = "fastutil" }
Expand Down Expand Up @@ -60,7 +59,7 @@ log4j-core = { group = "org.apache.logging.log4j", name = "log4j-core", version.
# CLI dependencie
mcterminal = { group = "net.minecrell", name = "terminalconsoleappender", version = "1.3.0" }
# Code generating
javapoet = { group = "com.squareup", name = "javapoet", version = "1.13.0" }
javapoet = { module = "com.palantir.javapoet:javapoet", version = "0.5.0" }
# Reflections
reflections = { group = "org.reflections", name = "reflections", version = "0.10.2" }
fastreflect = { group = "com.github.AllayMC", name = "fast-reflection", version = "8733a599fa" }
Expand Down

0 comments on commit ca3baff

Please sign in to comment.