Fixed some bugs

This commit is contained in:
RaphiMC 2023-01-04 03:33:44 +01:00
parent ffdfc86c59
commit 36e06d10f8
5 changed files with 24 additions and 8 deletions

View File

@ -1,6 +1,7 @@
plugins { plugins {
id "java-library" id "java-library"
id "maven-publish" id "maven-publish"
id "net.kyori.blossom" version "1.2.0"
} }
java.toolchain.languageVersion = JavaLanguageVersion.of(8) java.toolchain.languageVersion = JavaLanguageVersion.of(8)
@ -34,11 +35,21 @@ dependencies {
api "org.yaml:snakeyaml:1.33" api "org.yaml:snakeyaml:1.33"
} }
blossom {
replaceToken("\${version}", project.version, "src/main/java/net/raphimc/viaprotocolhack/ViaProtocolHack.java")
}
java { java {
withSourcesJar() withSourcesJar()
withJavadocJar() withJavadocJar()
} }
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
}
}
publishing { publishing {
repositories { repositories {
maven { maven {

View File

@ -6,4 +6,4 @@ org.gradle.configureondemand=true
# Project properties # Project properties
maven_name=ViaProtocolHack maven_name=ViaProtocolHack
maven_group=net.raphimc maven_group=net.raphimc
maven_version=2.0.0 maven_version=2.0.1

View File

@ -19,6 +19,8 @@ import java.util.logging.Logger;
public class ViaProtocolHack { public class ViaProtocolHack {
public static final String VERSION = "${version}";
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaProtocolHack")); private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaProtocolHack"));
@SuppressWarnings("ReassignedVariable") @SuppressWarnings("ReassignedVariable")
@ -44,7 +46,7 @@ public class ViaProtocolHack {
try { try {
finalViaBackwardsPlatformSupplier.get(); finalViaBackwardsPlatformSupplier.get();
} catch (Throwable e) { } catch (Throwable e) {
LOGGER.warning("ViaBackwards failed to load: " + e.getMessage()); LOGGER.severe("ViaBackwards failed to load: " + e.getMessage());
} }
} else { } else {
LOGGER.info("ViaBackwards is not loaded."); LOGGER.info("ViaBackwards is not loaded.");
@ -53,7 +55,7 @@ public class ViaProtocolHack {
try { try {
finalViaRewindPlatformSupplier.get(); finalViaRewindPlatformSupplier.get();
} catch (Throwable e) { } catch (Throwable e) {
LOGGER.warning("ViaRewind failed to load: " + e.getMessage()); LOGGER.severe("ViaRewind failed to load: " + e.getMessage());
} }
} else { } else {
LOGGER.info("ViaRewind is not loaded."); LOGGER.info("ViaRewind is not loaded.");
@ -62,7 +64,7 @@ public class ViaProtocolHack {
try { try {
finalViaLegacyPlatformSupplier.get(); finalViaLegacyPlatformSupplier.get();
} catch (Throwable e) { } catch (Throwable e) {
LOGGER.warning("ViaLegacy failed to load: " + e.getMessage()); LOGGER.severe("ViaLegacy failed to load: " + e.getMessage());
} }
} else { } else {
LOGGER.info("ViaLegacy is not loaded."); LOGGER.info("ViaLegacy is not loaded.");

View File

@ -12,6 +12,7 @@ import com.viaversion.viaversion.configuration.AbstractViaConfig;
import com.viaversion.viaversion.libs.gson.JsonObject; import com.viaversion.viaversion.libs.gson.JsonObject;
import com.viaversion.viaversion.util.VersionInfo; import com.viaversion.viaversion.util.VersionInfo;
import io.netty.channel.EventLoop; import io.netty.channel.EventLoop;
import net.raphimc.viaprotocolhack.ViaProtocolHack;
import net.raphimc.viaprotocolhack.commands.UserCommandSender; import net.raphimc.viaprotocolhack.commands.UserCommandSender;
import net.raphimc.viaprotocolhack.impl.viaversion.VPApiBase; import net.raphimc.viaprotocolhack.impl.viaversion.VPApiBase;
import net.raphimc.viaprotocolhack.impl.viaversion.VPViaConfig; import net.raphimc.viaprotocolhack.impl.viaversion.VPViaConfig;
@ -57,7 +58,7 @@ public class ViaVersionPlatformImpl implements ViaPlatform<UUID> {
@Override @Override
public String getPlatformVersion() { public String getPlatformVersion() {
return "1.3.3.7"; return ViaProtocolHack.VERSION;
} }
@Override @Override

View File

@ -1,10 +1,10 @@
package net.raphimc.viaprotocolhack.impl.viaversion; package net.raphimc.viaprotocolhack.impl.viaversion;
import com.viaversion.viaversion.api.platform.ViaInjector; import com.viaversion.viaversion.api.platform.ViaInjector;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.libs.fastutil.ints.IntLinkedOpenHashSet; import com.viaversion.viaversion.libs.fastutil.ints.IntLinkedOpenHashSet;
import com.viaversion.viaversion.libs.fastutil.ints.IntSortedSet; import com.viaversion.viaversion.libs.fastutil.ints.IntSortedSet;
import com.viaversion.viaversion.libs.gson.JsonObject; import com.viaversion.viaversion.libs.gson.JsonObject;
import net.raphimc.vialegacy.util.VersionEnum;
import net.raphimc.viaprotocolhack.netty.ViaPipeline; import net.raphimc.viaprotocolhack.netty.ViaPipeline;
public class VPInjector implements ViaInjector { public class VPInjector implements ViaInjector {
@ -25,8 +25,10 @@ public class VPInjector implements ViaInjector {
@Override @Override
public IntSortedSet getServerProtocolVersions() { public IntSortedSet getServerProtocolVersions() {
final IntSortedSet versions = new IntLinkedOpenHashSet(); final IntSortedSet versions = new IntLinkedOpenHashSet();
for (VersionEnum version : VersionEnum.OFFICIAL_SUPPORTED_PROTOCOLS) { for (ProtocolVersion protocol : ProtocolVersion.getProtocols()) {
versions.add(version.getOriginalVersion()); if (protocol.getOriginalVersion() >= 4) { // >=1.7.2
versions.add(protocol.getOriginalVersion());
}
} }
return versions; return versions;
} }