Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgazul committed Apr 27, 2024
1 parent 24398f4 commit 4629ff7
Show file tree
Hide file tree
Showing 24 changed files with 94 additions and 92 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ dependencies {
implementation "org.apache.maven:maven-model-builder:3.8.5"
implementation "org.apache.maven:maven-repository-metadata:3.8.5"
compileOnly "org.jetbrains:annotations:21.0.1"
implementation(include("com.mohistmc:i18n:0.2"))
implementation(include("com.mohistmc:i18n:0.6"))
implementation(include("com.mohistmc:dynamicenum:0.3"))

// craftbukkit
implementation "org.fusesource.jansi:jansi:1.18"
Expand All @@ -81,7 +82,6 @@ dependencies {
// spigot
implementation "net.md-5:bungeecord-chat:1.16-R0.4"
implementation "io.izzel:tools:1.3.0"
implementation "com.mohistmc:dynamicenum:0.1"

implementation "com.google.guava:failureaccess:1.0.1"
implementation "com.google.guava:guava:31.0.1-jre"
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/mohistmc/banner/BannerMCStart.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void run() throws Exception {
LOGGER.info("| _ { / / | | | |\\ | | |\\ | | __| | _ / ");
LOGGER.info("| |_| | / / | | | | \\ | | | \\ | | |___ | | \\ \\ ");
LOGGER.info("|_____/ /_/ |_| |_| \\_| |_| \\_| |_____| |_| \\_\\ ");
LOGGER.info(I18N.get("banner.launch.welcomemessage") + " - " + getVersion() + ", Java " + javaVersion);
LOGGER.info(I18N.as("banner.launch.welcomemessage") + " - " + getVersion() + ", Java " + javaVersion);
}
if (System.getProperty("log4j.configurationFile") == null) {
System.setProperty("log4j.configurationFile", "log4j2_banner.xml");
Expand All @@ -45,7 +45,7 @@ public static void run() throws Exception {
CustomLibraries.loadCustomLibs();
injectDeobfStack();
if (!EulaUtil.hasAcceptedEULA()) {
System.out.println(I18N.get("eula"));
System.out.println(I18N.as("eula"));
while (!"true".equals(new Scanner(System.in).next()));
EulaUtil.writeInfos();
}
Expand All @@ -61,7 +61,7 @@ public static String getVersion() {
}

private static void injectDeobfStack() {
CompatUtil.LOGGER.info(BannerMCStart.I18N.get("stackdeobf.inject.logger"));
CompatUtil.LOGGER.info(BannerMCStart.I18N.as("stackdeobf.inject.logger"));
RemappingRewritePolicy policy = new RemappingRewritePolicy();
policy.inject((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger());
CachedMappings.init(new MojangMappingProvider());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ private void fixPackage(Manifest manifest, URL url, String name) {
if (attributes != null) {
try {
try {
/*
Object versionInfo = MohistDynamEnum.getField(pkg, Package.class.getDeclaredField("versionInfo"));
if (versionInfo != null) {
Class<?> Package$VersionInfo = Class.forName("java.lang.Package$VersionInfo");
Expand All @@ -147,6 +148,7 @@ private void fixPackage(Manifest manifest, URL url, String name) {
MohistDynamEnum.setField(versionInfo, attributes.getValue(Attributes.Name.SPECIFICATION_VERSION), Package$VersionInfo.getDeclaredField("specVersion"));
MohistDynamEnum.setField(versionInfo, attributes.getValue(Attributes.Name.SPECIFICATION_VENDOR), Package$VersionInfo.getDeclaredField("specVendor"));
}
*/
} catch (Exception ignored) {
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ public static void save() {

public static void i18n() {
String banner_lang = yml.getString("banner.lang", "xx_XX");
String l = banner_lang.split("_")[0];
String c = banner_lang.split("_")[1];
BannerMCStart.I18N = new i18n(BannerMCStart.class.getClassLoader(), new Locale(l, c));
BannerMCStart.I18N = new i18n(BannerMCStart.class.getClassLoader(), banner_lang);
}

public static String lang() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class BannerEventDispatcherRegistry {

public static void registerEventDispatchers() {
BannerServer.LOGGER.info(BannerMCStart.I18N.get("banner.event_handler.register"));
BannerServer.LOGGER.info(BannerMCStart.I18N.as("banner.event_handler.register"));
LevelEventDispatcher.dispatchLevel();
PlayerEventDispatcher.dispatcherPlayer();
EntityEventDispatcher.dispatchEntity();
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/mohistmc/banner/fabric/FabricInjectBukkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static void addEnumEnvironment() {
if (environment1 == null) {
String name = normalizeName(key.location().toString());
int id = i - 1;
environment1 = MohistDynamEnum.addEnum(World.Environment.class, name, new Class[]{Integer.TYPE}, new Object[]{id});
environment1 = MohistDynamEnum.addEnum(World.Environment.class, name, List.of(Integer.TYPE), List.of(id));
DIM_MAP.put(key, environment1);
BannerServer.LOGGER.debug("Registered fabric DimensionType as environment {}", environment1);
i++;
Expand Down Expand Up @@ -145,7 +145,7 @@ public static void addEnumEffectAndPotion() {
if (CraftPotionUtil.toBukkit(resourceLocation.toString()).getType() == PotionType.UNCRAFTABLE && potion != Potions.EMPTY) {
String name = normalizeName(resourceLocation.toString());
MobEffectInstance effectInstance = potion.getEffects().isEmpty() ? null : potion.getEffects().get(0);
PotionType potionType = MohistDynamEnum.addEnum0(PotionType.class, name, new Class[]{PotionEffectType.class, Boolean.TYPE, Boolean.TYPE}, effectInstance == null ? null : PotionEffectType.getById(MobEffect.getId(effectInstance.getEffect())), false, false);
PotionType potionType = MohistDynamEnum.addEnum(PotionType.class, name, List.of(PotionEffectType.class, Boolean.TYPE, Boolean.TYPE), List.of(effectInstance == null ? null : PotionEffectType.getById(MobEffect.getId(effectInstance.getEffect())), false, false));
if (potionType != null) {
BannerServer.LOGGER.debug("Save-PotionType:" + name + " - " + potionType.name());
}
Expand All @@ -159,7 +159,7 @@ public static void addEnumParticle() {
ResourceLocation resourceLocation = registry.getKey(particleType);
String name = normalizeName(resourceLocation.toString());
if (!resourceLocation.getNamespace().equals(NamespacedKey.MINECRAFT)) {
Particle particle = MohistDynamEnum.addEnum0(Particle.class, name, new Class[0]);
Particle particle = MohistDynamEnum.addEnum(Particle.class, name, List.of(), List.of());
if (particle != null) {
org.bukkit.craftbukkit.v1_19_R3.CraftParticle.putParticles(particle, resourceLocation);
BannerServer.LOGGER.debug("Save-ParticleType:" + name + " - " + particle.name());
Expand All @@ -176,7 +176,7 @@ public static void addEnumBiome() {
String biomeName = normalizeName(resourceLocation.toString());
if (!isMINECRAFT(resourceLocation) && !map.contains(biomeName)) {
map.add(biomeName);
org.bukkit.block.Biome biomeCB = MohistDynamEnum.addEnum0(org.bukkit.block.Biome.class, biomeName, new Class[0]);
org.bukkit.block.Biome biomeCB = MohistDynamEnum.addEnum(org.bukkit.block.Biome.class, biomeName, List.of(), List.of());
BannerServer.LOGGER.debug("Save-BIOME:" + biomeCB.name() + " - " + biomeName);
}
}
Expand All @@ -190,7 +190,7 @@ public static void addEnumEntity() {
if (!isMINECRAFT(resourceLocation)) {
String entityType = normalizeName(resourceLocation.toString());
int typeId = entityType.hashCode();
EntityType bukkitType = MohistDynamEnum.addEnum0(EntityType.class, entityType, new Class[]{String.class, Class.class, Integer.TYPE, Boolean.TYPE}, entityType.toLowerCase(), MohistModsEntity.class, typeId, false);
EntityType bukkitType = MohistDynamEnum.addEnum(EntityType.class, entityType, List.of(String.class, Class.class, Integer.TYPE, Boolean.TYPE), List.of(entityType.toLowerCase(), MohistModsEntity.class, typeId, false));
EntityType.NAME_MAP.put(entityType.toLowerCase(), bukkitType);
EntityType.ID_MAP.put((short) typeId, bukkitType);
ServerAPI.entityTypeMap.put(entity, entityType);
Expand All @@ -204,7 +204,7 @@ public static void addEnumVillagerProfession() {
ResourceLocation resourceLocation = registry.getKey(villagerProfession);
if (!isMINECRAFT(resourceLocation)) {
String name = normalizeName(resourceLocation.toString());
Villager.Profession vp = MohistDynamEnum.addEnum0(Villager.Profession.class, name, new Class[0]);
Villager.Profession vp = MohistDynamEnum.addEnum(Villager.Profession.class, name, List.of(), List.of());
profession.put(vp, resourceLocation);
BannerServer.LOGGER.debug("Registered fabric VillagerProfession as Profession {}", vp.name());
}
Expand All @@ -217,7 +217,7 @@ public static void addFluid() {
ResourceLocation resourceLocation = registry.getKey(fluidType);
String name = normalizeName(resourceLocation.getPath());
if (!isMINECRAFT(resourceLocation)) {
Fluid fluid = MohistDynamEnum.addEnum0(Fluid.class, name, new Class[0]);
Fluid fluid = MohistDynamEnum.addEnum(Fluid.class, name, List.of(), List.of());
CraftMagicNumbers.FLUIDTYPE_FLUID.put(fluidType, fluid);
BannerServer.LOGGER.debug("Registered fabric Fluid as Fluid(Bukkit) {}", fluid.name());
}
Expand All @@ -230,7 +230,7 @@ public static void addStatistic() {
ResourceLocation resourceLocation = registry.getKey(statType);
String name = normalizeName(resourceLocation.getPath());
if (!isMINECRAFT(resourceLocation)) {
Statistic statistic = MohistDynamEnum.addEnum0(Statistic.class, name, new Class[0]);
Statistic statistic = MohistDynamEnum.addEnum(Statistic.class, name, List.of(), List.of());
statisticMap.put(statType, statistic);
BannerServer.LOGGER.debug("Registered fabric StatType as Statistic(Bukkit) {}", statistic.name());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static String libUrl(File lib) {
}

public static void run() throws Exception {
System.out.println(BannerMCStart.I18N.get("libraries.checking.start"));
System.out.println(BannerMCStart.I18N.as("libraries.checking.start"));
LinkedHashMap<File, String> libs = getDefaultLibs();
AtomicLong currentSize = new AtomicLong();
Set<File> defaultLibs = new LinkedHashSet<>();
Expand All @@ -52,14 +52,14 @@ public static void run() throws Exception {
lib.getParentFile().mkdirs();

String u = libUrl(lib);
System.out.println(BannerMCStart.I18N.get("libraries.global.percentage") + Math.round((float) (currentSize.get() * 100) / allSize.get()) + "%"); //Global percentage
System.out.println(BannerMCStart.I18N.as("libraries.global.percentage") + Math.round((float) (currentSize.get() * 100) / allSize.get()) + "%"); //Global percentage
try {
UpdateUtils.downloadFile(u, lib, libs.get(lib));
currentSize.addAndGet(lib.length());
fail.remove(u.replace(MAVENURL, ""));
} catch (Exception e) {
if (e.getMessage() != null && !"md5".equals(e.getMessage())) {
System.out.println(BannerMCStart.I18N.get("file.download.nook", u));
System.out.println(BannerMCStart.I18N.as("file.download.nook", u));
lib.delete();
}
fail.put(u.replace(MAVENURL, ""), lib.getAbsolutePath());
Expand All @@ -69,7 +69,7 @@ public static void run() throws Exception {
if (!fail.isEmpty()) {
run();
} else {
System.out.println(BannerMCStart.I18N.get("libraries.check.end"));
System.out.println(BannerMCStart.I18N.as("libraries.check.end"));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public final void prepareLevels(ChunkProgressListener listener) {
ServerLevel banner$serverLevel = this.prepareLevels$serverlevel.getAndSet(this.overworld());
banner$serverLevel = banner$serverLevel == null ? this.overworld() : banner$serverLevel;
ServerLevel serverLevel = banner$serverLevel;
LOGGER.info(BannerMCStart.I18N.get("server.region.prepare"), serverLevel.dimension().location());
LOGGER.info(BannerMCStart.I18N.as("server.region.prepare"), serverLevel.dimension().location());
BlockPos blockPos = serverLevel.getSharedSpawnPos();
listener.updateSpawnPos(new ChunkPos(blockPos));
ServerChunkCache serverChunkCache = serverLevel.getChunkSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public MixinDedicatedServer(Thread thread, LevelStorageSource.LevelStorageAccess

@Inject(method = "initServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/dedicated/DedicatedServer;usesAuthentication()Z", ordinal = 1))
private void banner$initServer(CallbackInfoReturnable<Boolean> cir) {
BannerServer.LOGGER.info(BannerMCStart.I18N.get("bukkit.plugin.loading.info"));
BannerServer.LOGGER.info(BannerMCStart.I18N.as("bukkit.plugin.loading.info"));
// CraftBukkit start
this.bridge$server().loadPlugins();
this.bridge$server().enablePlugins(PluginLoadOrder.STARTUP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class UpdateUtils {
private static int percentage = 0;

public static void versionCheck() {
System.out.println(BannerMCStart.I18N.get("update.check"));
System.out.println(BannerMCStart.I18N.get("update.stopcheck"));
System.out.println(BannerMCStart.I18N.as("update.check"));
System.out.println(BannerMCStart.I18N.as("update.stopcheck"));

try {
JsonElement root = JsonParser.parseReader(new InputStreamReader(getInput("https://ci.codemc.io/job/MohistMC/job/Banner-1.19.4/lastSuccessfulBuild/api/json")));
Expand All @@ -40,12 +40,12 @@ public static void versionCheck() {
String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(Long.parseLong(root.getAsJsonObject().get("timestamp").toString())));

if (jar_sha.equals(build_number))
System.out.println(BannerMCStart.I18N.get("update.latest", jar_sha, build_number));
System.out.println(BannerMCStart.I18N.as("update.latest", jar_sha, build_number));
else {
System.out.println(BannerMCStart.I18N.get("update.detect", build_number, jar_sha, time));
System.out.println(BannerMCStart.I18N.as("update.detect", build_number, jar_sha, time));
}
} catch (Throwable e) {
System.out.println(BannerMCStart.I18N.get("check.update.noci"));
System.out.println(BannerMCStart.I18N.as("check.update.noci"));
}
}

Expand All @@ -55,7 +55,7 @@ public static void downloadFile(String URL, File f) throws Exception {

public static void downloadFile(String URL, File f, String md5) throws Exception {
URLConnection conn = getConn(URL);
System.out.println(BannerMCStart.I18N.get("download.file", f.getName(), getSize(conn.getContentLength())));
System.out.println(BannerMCStart.I18N.as("download.file", f.getName(), getSize(conn.getContentLength())));
ReadableByteChannel rbc = Channels.newChannel(conn.getInputStream());
FileChannel fc = FileChannel.open(f.toPath(), StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING);
int fS = conn.getContentLength();
Expand All @@ -65,7 +65,7 @@ public static void downloadFile(String URL, File f, String md5) throws Exception
() -> {
if (rbc.isOpen()) {
if (percentage != Math.round((float) f.length() / fS * 100) && percentage < 100) {
System.out.println(BannerMCStart.I18N.get("file.download.percentage", f.getName(), percentage));
System.out.println(BannerMCStart.I18N.as("file.download.percentage", f.getName(), percentage));
}
percentage = Math.round((float) f.length() / fS * 100);
}
Expand All @@ -77,10 +77,10 @@ public static void downloadFile(String URL, File f, String md5) throws Exception
String MD5 = MD5Util.getMd5(f);
if (f.getName().endsWith(".jar") && md5 != null && MD5 != null && !MD5.equals(md5.toLowerCase())) {
f.delete();
System.out.println(BannerMCStart.I18N.get("file.download.nook.md5", URL, MD5, md5.toLowerCase()));
System.out.println(BannerMCStart.I18N.as("file.download.nook.md5", URL, MD5, md5.toLowerCase()));
throw new Exception("md5");
}
System.out.println(BannerMCStart.I18N.get("download.file.ok", f.getName()));
System.out.println(BannerMCStart.I18N.as("download.file.ok", f.getName()));
}

public static String getSize(long size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public static CompletableFuture<byte[]> getAsync(URI uri, Executor executor) {
HttpRequest request = HttpRequest.newBuilder(uri).build();
HttpResponse.BodyHandler<byte[]> handler = HttpResponse.BodyHandlers.ofByteArray();

CompatUtil.LOGGER.info(BannerMCStart.I18N.get("stackdeobf.requesting"), uri);
CompatUtil.LOGGER.info(BannerMCStart.I18N.as("stackdeobf.requesting"), uri);
long start = System.currentTimeMillis();

return getHttpClient(executor).sendAsync(request, handler).thenApplyAsync(resp -> {
long timeDiff = System.currentTimeMillis() - start;
byte[] bodyBytes = resp.body();

String message = BannerMCStart.I18N.get("stackdeobf.received");
String message = BannerMCStart.I18N.as("stackdeobf.received");
Object[] args = {bodyBytes.length, FileUtils.byteCountToDisplaySize(bodyBytes.length),
resp.statusCode(), uri, timeDiff};

Expand Down
Loading

0 comments on commit 4629ff7

Please sign in to comment.