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

View File

@ -6,4 +6,4 @@ org.gradle.configureondemand=true
# Project properties
maven_name=ViaProtocolHack
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 static final String VERSION = "${version}";
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaProtocolHack"));
@SuppressWarnings("ReassignedVariable")
@ -44,7 +46,7 @@ public class ViaProtocolHack {
try {
finalViaBackwardsPlatformSupplier.get();
} catch (Throwable e) {
LOGGER.warning("ViaBackwards failed to load: " + e.getMessage());
LOGGER.severe("ViaBackwards failed to load: " + e.getMessage());
}
} else {
LOGGER.info("ViaBackwards is not loaded.");
@ -53,7 +55,7 @@ public class ViaProtocolHack {
try {
finalViaRewindPlatformSupplier.get();
} catch (Throwable e) {
LOGGER.warning("ViaRewind failed to load: " + e.getMessage());
LOGGER.severe("ViaRewind failed to load: " + e.getMessage());
}
} else {
LOGGER.info("ViaRewind is not loaded.");
@ -62,7 +64,7 @@ public class ViaProtocolHack {
try {
finalViaLegacyPlatformSupplier.get();
} catch (Throwable e) {
LOGGER.warning("ViaLegacy failed to load: " + e.getMessage());
LOGGER.severe("ViaLegacy failed to load: " + e.getMessage());
}
} else {
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.util.VersionInfo;
import io.netty.channel.EventLoop;
import net.raphimc.viaprotocolhack.ViaProtocolHack;
import net.raphimc.viaprotocolhack.commands.UserCommandSender;
import net.raphimc.viaprotocolhack.impl.viaversion.VPApiBase;
import net.raphimc.viaprotocolhack.impl.viaversion.VPViaConfig;
@ -57,7 +58,7 @@ public class ViaVersionPlatformImpl implements ViaPlatform<UUID> {
@Override
public String getPlatformVersion() {
return "1.3.3.7";
return ViaProtocolHack.VERSION;
}
@Override

View File

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