Fix runClient, ViaBackwards and ViaRewind platform, 19w09a

This commit is contained in:
creeper123123321 2019-03-01 17:09:33 -03:00
parent 922b3ec219
commit 40cafaf103
No known key found for this signature in database
GPG Key ID: 0AC57D54786721D1
9 changed files with 133 additions and 41 deletions

View File

@ -1,4 +1,4 @@
import org.apache.tools.ant.filters.* import org.apache.tools.ant.filters.ReplaceTokens
plugins { plugins {
id 'java' id 'java'
@ -21,7 +21,6 @@ repositories {
maven { url 'https://repo.viaversion.com/' } maven { url 'https://repo.viaversion.com/' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url 'https://maven.fabricmc.net/' } maven { url 'https://maven.fabricmc.net/' }
maven { url "http://server.bbkr.space:8081/artifactory/libs-snapshot" }
} }
processResources { processResources {
@ -32,17 +31,16 @@ processResources {
dependencies { dependencies {
compile "us.myles:viaversion:2.0.0-19w08b" // transitive = false, viabackwards-core because Guava is conflicting on runClient
compile "de.gerrygames:viarewind-all:1.4.0" compile("us.myles:viaversion:2.0.0-19w09a") { transitive = false }
compile("de.gerrygames:viarewind-core:1.4.0") { transitive = false }
minecraft "com.mojang:minecraft:19w08b" compile("nl.matsv:viabackwards-core:2.4.0-SNAPSHOT") { transitive = false }
mappings "net.fabricmc:yarn:19w08b.6"
minecraft "com.mojang:minecraft:19w09a"
mappings "net.fabricmc:yarn:19w09a.2"
modCompile "net.fabricmc:fabric-loader:0.3.7.109" modCompile "net.fabricmc:fabric-loader:0.3.7.109"
modCompile "net.fabricmc:fabric:0.2.3.104" modCompile "net.fabricmc:fabric:0.2.3.108"
modCompile "io.github.cottonmc:client-commands:0.1.0+19w05a-SNAPSHOT"
} }

View File

@ -25,15 +25,13 @@
package com.github.creeper123123321.viafabric; package com.github.creeper123123321.viafabric;
import com.github.creeper123123321.viafabric.commands.VRCommandHandler; import com.github.creeper123123321.viafabric.commands.VRCommandHandler;
import com.github.creeper123123321.viafabric.platform.VRInjector; import com.github.creeper123123321.viafabric.platform.*;
import com.github.creeper123123321.viafabric.platform.VRLoader;
import com.github.creeper123123321.viafabric.platform.VRPlatform;
import com.github.creeper123123321.viafabric.protocol.protocol1_7_6_10to1_7_1_5.Protocol1_7_6_10to1_7_1_5; import com.github.creeper123123321.viafabric.protocol.protocol1_7_6_10to1_7_1_5.Protocol1_7_6_10to1_7_1_5;
import com.github.creeper123123321.viafabric.protocol.protocol1_8to1_7_6_10.Protocol1_8TO1_7_6_10; import com.github.creeper123123321.viafabric.protocol.protocol1_8to1_7_6_10.Protocol1_8TO1_7_6_10;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder; import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import io.github.cottonmc.clientcommands.ClientCommands;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.fabric.api.registry.CommandRegistry; import net.fabricmc.fabric.api.registry.CommandRegistry;
import net.fabricmc.loader.FabricLoader; import net.fabricmc.loader.FabricLoader;
@ -44,7 +42,9 @@ import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion.api.protocol.ProtocolVersion; import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import java.lang.reflect.InvocationTargetException;
import java.util.Collections; import java.util.Collections;
import java.util.function.Consumer;
public class VRViaVersionInitializer { public class VRViaVersionInitializer {
public static void init() { public static void init() {
@ -56,11 +56,15 @@ public class VRViaVersionInitializer {
Via.getManager().init(); Via.getManager().init();
ProtocolRegistry.registerProtocol(new Protocol1_7_6_10to1_7_1_5(), Collections.singletonList(ProtocolVersion.v1_7_6.getId()), ProtocolVersion.v1_7_1.getId()); ProtocolRegistry.registerProtocol(new Protocol1_7_6_10to1_7_1_5(), Collections.singletonList(ProtocolVersion.v1_7_6.getId()), ProtocolVersion.v1_7_1.getId());
ProtocolRegistry.registerProtocol(new Protocol1_8TO1_7_6_10(), Collections.singletonList(ProtocolVersion.v1_8.getId()), ProtocolVersion.v1_7_6.getId()); ProtocolRegistry.registerProtocol(new Protocol1_8TO1_7_6_10(), Collections.singletonList(ProtocolVersion.v1_8.getId()), ProtocolVersion.v1_7_6.getId());
new VRRewindPlatform().init();
new VRBackwardsPlatform().init();
if (FabricLoader.INSTANCE.getEnvironmentType() == EnvType.CLIENT) { if (FabricLoader.INSTANCE.getEnvironmentType() == EnvType.CLIENT) {
try { try {
Class.forName("io.github.cottonmc.clientcommands.ClientCommands"); Class.forName("io.github.cottonmc.clientcommands.ClientCommands")
ClientCommands.registerCommand(command -> command .getMethod("registerCommand", Consumer.class)
.invoke(null,
(Consumer<CommandDispatcher<CommandSource>>) command -> command
.register( .register(
LiteralArgumentBuilder.<CommandSource>literal("viafabricclient") LiteralArgumentBuilder.<CommandSource>literal("viafabricclient")
.then( .then(
@ -72,7 +76,7 @@ public class VRViaVersionInitializer {
.executes(((VRCommandHandler) Via.getManager().getCommandHandler())::execute) .executes(((VRCommandHandler) Via.getManager().getCommandHandler())::execute)
) )
); );
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
Via.getPlatform().getLogger().warning("ClientCommands isn't installed"); Via.getPlatform().getLogger().warning("ClientCommands isn't installed");
} }
} }

View File

@ -71,7 +71,7 @@ public class ViaFabric implements ModInitializer {
.stream() .stream()
.filter(container -> container.getInfo().getId().equals("viafabric")) .filter(container -> container.getInfo().getId().equals("viafabric"))
.findFirst() .findFirst()
.get().getInfo().getVersionString(); .get().getInfo().getVersion().getFriendlyString();
} }
private void checkForUpdates(File jar, String artifactName, String groupIdPath, String depName) throws Exception { private void checkForUpdates(File jar, String artifactName, String groupIdPath, String depName) throws Exception {
@ -138,7 +138,13 @@ public class ViaFabric implements ModInitializer {
} }
File viaRewindJar = FabricLoader.INSTANCE.getConfigDirectory().toPath().resolve("ViaFabric").resolve("viarewind.jar").toFile(); File viaRewindJar = FabricLoader.INSTANCE.getConfigDirectory().toPath().resolve("ViaFabric").resolve("viarewind.jar").toFile();
try { try {
checkForUpdates(viaRewindJar, "viarewind-all", "de/gerrygames", "ViaRewind"); checkForUpdates(viaRewindJar, "viarewind-core", "de/gerrygames", "ViaRewind");
} catch (Exception e) {
e.printStackTrace();
}
File viaBackwardsJar = FabricLoader.INSTANCE.getConfigDirectory().toPath().resolve("ViaFabric").resolve("viabackwards.jar").toFile();
try {
checkForUpdates(viaBackwardsJar, "viabackwards-core", "nl/matsv", "ViaBackwards");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -147,6 +153,8 @@ public class ViaFabric implements ModInitializer {
addUrl.setAccessible(true); addUrl.setAccessible(true);
addUrl.invoke(ViaFabric.class.getClassLoader(), viaVersionJar.toURI().toURL()); addUrl.invoke(ViaFabric.class.getClassLoader(), viaVersionJar.toURI().toURL());
addUrl.invoke(ViaFabric.class.getClassLoader(), viaRewindJar.toURI().toURL()); addUrl.invoke(ViaFabric.class.getClassLoader(), viaRewindJar.toURI().toURL());
addUrl.invoke(ViaFabric.class.getClassLoader(), viaBackwardsJar.toURI().toURL());
// Need reflection because Fabric was loading the class before the jars were added to classpath
Class.forName("com.github.creeper123123321.viafabric.VRViaVersionInitializer") Class.forName("com.github.creeper123123321.viafabric.VRViaVersionInitializer")
.getMethod("init") .getMethod("init")
.invoke(null); .invoke(null);

View File

@ -47,10 +47,8 @@ public class SaveProtocolButton extends ButtonWidget {
try { try {
newVersion = Integer.parseInt(textField.getText()); newVersion = Integer.parseInt(textField.getText());
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
try { ProtocolVersion closest = ProtocolVersion.getClosest(textField.getText());
newVersion = ProtocolVersion.getClosest(textField.getText()).getId(); if (closest != null) newVersion = closest.getId();
} catch (NullPointerException ignored) {
}
} }
((VRVersionProvider) Via.getManager().getProviders().get(VersionProvider.class)).clientSideModeVersion = newVersion; ((VRVersionProvider) Via.getManager().getProviders().get(VersionProvider.class)).clientSideModeVersion = newVersion;
textField.setText(ProtocolVersion.isRegistered(newVersion) textField.setText(ProtocolVersion.isRegistered(newVersion)

View File

@ -47,20 +47,20 @@ public abstract class MixinMultiplayerGui extends Screen {
@Inject(method = "onInitialized", at = @At("TAIL")) @Inject(method = "onInitialized", at = @At("TAIL"))
private void onOnInitialized(CallbackInfo ci) { private void onOnInitialized(CallbackInfo ci) {
protocolVersion = new TextFieldWidget(fontRenderer, this.width / 2 + 55, 8, 45, 20); protocolVersion = new TextFieldWidget(fontRenderer, this.screenWidth / 2 + 55, 8, 45, 20);
int clientSideVersion = ((VRVersionProvider) Via.getManager().getProviders().get(VersionProvider.class)).clientSideModeVersion; int clientSideVersion = ((VRVersionProvider) Via.getManager().getProviders().get(VersionProvider.class)).clientSideModeVersion;
protocolVersion.setText(ProtocolVersion.isRegistered(clientSideVersion) protocolVersion.setText(ProtocolVersion.isRegistered(clientSideVersion)
? ProtocolVersion.getProtocol(clientSideVersion).getName() ? ProtocolVersion.getProtocol(clientSideVersion).getName()
: Integer.toString(clientSideVersion)); : Integer.toString(clientSideVersion));
protocolVersion.method_1890(new VersionFormatFilter()); protocolVersion.method_1890(new VersionFormatFilter());
this.listeners.add(protocolVersion); this.listeners.add(protocolVersion);
addButton(new SaveProtocolButton(width / 2 + 100, 8, 50, 20, addButton(new SaveProtocolButton(screenWidth / 2 + 100, 8, 50, 20,
I18n.translate("selectWorld.edit.save"), protocolVersion)); I18n.translate("selectWorld.edit.save"), protocolVersion));
} }
@Inject(method = "draw", at = @At("TAIL")) @Inject(method = "draw", at = @At("TAIL"))
private void onDraw(int p_1, int p_2, float p_3, CallbackInfo ci) { private void onDraw(int p_1, int p_2, float p_3, CallbackInfo ci) {
drawStringCentered(fontRenderer, "Protocol Version:", this.width / 2, 12, 0xFFFFFF); drawStringCentered(fontRenderer, "Protocol Version:", this.screenWidth / 2, 12, 0xFFFFFF);
protocolVersion.draw(p_1, p_2, p_3); protocolVersion.draw(p_1, p_2, p_3);
} }

View File

@ -0,0 +1,41 @@
/*
* MIT License
*
* Copyright (c) 2018 creeper123123321 and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.creeper123123321.viafabric.platform;
import com.github.creeper123123321.viafabric.ViaFabric;
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
import java.util.logging.Logger;
public class VRBackwardsPlatform implements ViaBackwardsPlatform {
@Override
public Logger getLogger() {
return ViaFabric.JLOGGER;
}
@Override
public void disable() {
}
}

View File

@ -53,7 +53,6 @@ import us.myles.ViaVersion.sponge.VersionInfo;
import us.myles.ViaVersion.util.GsonUtil; import us.myles.ViaVersion.util.GsonUtil;
import us.myles.viaversion.libs.gson.JsonObject; import us.myles.viaversion.libs.gson.JsonObject;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -63,7 +62,7 @@ import java.util.logging.Logger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class VRPlatform implements ViaPlatform { public class VRPlatform implements ViaPlatform {
private VRViaConfig config = new VRViaConfig(new File(FabricLoader.INSTANCE.getConfigDirectory(), "ViaFabric")); private VRViaConfig config = new VRViaConfig(FabricLoader.INSTANCE.getConfigDirectory().toPath().resolve("ViaFabric").resolve("viaversion.yml").toFile());
@Override @Override
public Logger getLogger() { public Logger getLogger() {
@ -84,9 +83,7 @@ public class VRPlatform implements ViaPlatform {
public String getPluginVersion() { public String getPluginVersion() {
try { try {
return VersionInfo.class.getField("VERSION").get(null) + "-ViaFabric"; return VersionInfo.class.getField("VERSION").get(null) + "-ViaFabric";
} catch (IllegalAccessException e) { } catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace(); e.printStackTrace();
} }
return "?"; return "?";

View File

@ -0,0 +1,46 @@
/*
* MIT License
*
* Copyright (c) 2018 creeper123123321 and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.creeper123123321.viafabric.platform;
import com.github.creeper123123321.viafabric.ViaFabric;
import de.gerrygames.viarewind.api.ViaRewindConfig;
import de.gerrygames.viarewind.api.ViaRewindConfigImpl;
import de.gerrygames.viarewind.api.ViaRewindPlatform;
import net.fabricmc.loader.FabricLoader;
import java.util.logging.Logger;
public class VRRewindPlatform implements ViaRewindPlatform {
private static ViaRewindConfig config = new ViaRewindConfigImpl(FabricLoader.INSTANCE.getConfigDirectory().toPath().resolve("ViaFabric").resolve("viarewind.yml").toFile());
public void init() {
init(config);
}
@Override
public Logger getLogger() {
return ViaFabric.JLOGGER;
}
}

View File

@ -38,7 +38,7 @@ public class VRViaConfig extends Config implements ViaVersionConfig {
private static List<String> UNSUPPORTED = Arrays.asList("anti-xray-patch", "bungee-ping-interval", "bungee-ping-save", "bungee-servers", "quick-move-action-fix", "nms-player-ticking", "item-cache", "velocity-ping-interval", "velocity-ping-save", "velocity-servers", "blockconnection-method"); private static List<String> UNSUPPORTED = Arrays.asList("anti-xray-patch", "bungee-ping-interval", "bungee-ping-save", "bungee-servers", "quick-move-action-fix", "nms-player-ticking", "item-cache", "velocity-ping-interval", "velocity-ping-save", "velocity-servers", "blockconnection-method");
public VRViaConfig(File configFile) { public VRViaConfig(File configFile) {
super(new File(configFile, "config.yml")); super(configFile);
// Load config // Load config
reloadConfig(); reloadConfig();
} }