mirror of
https://github.com/ViaVersion/ViaForge.git
synced 2024-09-29 04:47:34 +02:00
Update Via
This commit is contained in:
parent
e2bd4596a0
commit
62083a228b
@ -34,12 +34,12 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
version = "1.0.0.0"
|
version = "1.0.0.0"
|
||||||
group = "de.flori2007.viaforge"
|
group = "de.enzaxd.viaforge"
|
||||||
archivesBaseName = "ViaForge"
|
archivesBaseName = "ViaForge"
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
compileJava.options.encoding = 'windows-1252'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
version = "1.12.2-14.23.5.2768"
|
version = "1.12.2-14.23.5.2768"
|
||||||
@ -99,7 +99,7 @@ jar {
|
|||||||
"MixinConfigs": "mixins.viaforge.json",
|
"MixinConfigs": "mixins.viaforge.json",
|
||||||
"tweakClass": "org.spongepowered.asm.launch.MixinTweaker",
|
"tweakClass": "org.spongepowered.asm.launch.MixinTweaker",
|
||||||
"TweakOrder": 0,
|
"TweakOrder": 0,
|
||||||
"FMLCorePluginContainsFMLMod": "de.flori2007.viaforge.injection.MixinLoader"
|
"FMLCorePluginContainsFMLMod": "de.enzaxd.viaforge.injection.MixinLoader"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
BIN
libs/ViaBackwards-4.0.0-21w19a-SNAPSHOT.jar
Normal file
BIN
libs/ViaBackwards-4.0.0-21w19a-SNAPSHOT.jar
Normal file
Binary file not shown.
Binary file not shown.
BIN
libs/ViaRewind-2.0.0-SNAPSHOT.jar
Normal file
BIN
libs/ViaRewind-2.0.0-SNAPSHOT.jar
Normal file
Binary file not shown.
Binary file not shown.
BIN
libs/ViaVersion-4.0.0-21w19a-SNAPSHOT.jar
Normal file
BIN
libs/ViaVersion-4.0.0-21w19a-SNAPSHOT.jar
Normal file
Binary file not shown.
@ -1,88 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018- creeper123123321 <https://creeper123123321.keybase.pub/>
|
|
||||||
* Copyright (c) 2019- contributors <https://github.com/ViaVersion/ViaFabric/graphs/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;
|
|
||||||
|
|
||||||
import com.github.creeper123123321.viafabric.platform.VRInjector;
|
|
||||||
import com.github.creeper123123321.viafabric.platform.VRLoader;
|
|
||||||
import com.github.creeper123123321.viafabric.platform.VRPlatform;
|
|
||||||
import com.github.creeper123123321.viafabric.util.JLoggerToLog4j;
|
|
||||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
|
||||||
import de.flori2007.viaforge.platform.ViaBackwardsPlatformImplementation;
|
|
||||||
import de.flori2007.viaforge.platform.ViaRewindPlatformImplementation;
|
|
||||||
import io.netty.channel.EventLoop;
|
|
||||||
import io.netty.channel.local.LocalEventLoopGroup;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import us.myles.ViaVersion.ViaManager;
|
|
||||||
import us.myles.ViaVersion.api.Via;
|
|
||||||
import us.myles.ViaVersion.api.data.MappingDataLoader;
|
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
@Mod(modid = "viaforge")
|
|
||||||
public class ViaFabric {
|
|
||||||
|
|
||||||
public static int nativeVersion = 340;
|
|
||||||
public static int clientSideVersion;
|
|
||||||
public static String lastServer = "";
|
|
||||||
|
|
||||||
public static final Logger JLOGGER = new JLoggerToLog4j(LogManager.getLogger("ViaFabric"));
|
|
||||||
public static final ExecutorService ASYNC_EXECUTOR;
|
|
||||||
public static final EventLoop EVENT_LOOP;
|
|
||||||
public static CompletableFuture<Void> INIT_FUTURE = new CompletableFuture<>();
|
|
||||||
|
|
||||||
static {
|
|
||||||
ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat("ViaFabric-%d").build();
|
|
||||||
ASYNC_EXECUTOR = Executors.newFixedThreadPool(8, factory);
|
|
||||||
EVENT_LOOP = new LocalEventLoopGroup(1, factory).next(); // ugly code
|
|
||||||
EVENT_LOOP.submit(INIT_FUTURE::join); // https://github.com/ViaVersion/ViaFabric/issues/53 ugly workaround code but works tm
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getVersion() {
|
|
||||||
return "1.0";
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onInitialize() {
|
|
||||||
clientSideVersion = nativeVersion;
|
|
||||||
|
|
||||||
Via.init(ViaManager.builder()
|
|
||||||
.injector(new VRInjector())
|
|
||||||
.loader(new VRLoader())
|
|
||||||
.platform(new VRPlatform()).build());
|
|
||||||
|
|
||||||
MappingDataLoader.enableMappingsCache();
|
|
||||||
new ViaBackwardsPlatformImplementation();
|
|
||||||
new ViaRewindPlatformImplementation();
|
|
||||||
|
|
||||||
Via.getManager().init();
|
|
||||||
|
|
||||||
INIT_FUTURE.complete(null);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018- creeper123123321 <https://creeper123123321.keybase.pub/>
|
|
||||||
* Copyright (c) 2019- contributors <https://github.com/ViaVersion/ViaFabric/graphs/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.handler;
|
|
||||||
|
|
||||||
public class CommonTransformer {
|
|
||||||
public static final String HANDLER_DECODER_NAME = "via-decoder";
|
|
||||||
public static final String HANDLER_ENCODER_NAME = "via-encoder";
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018- creeper123123321 <https://creeper123123321.keybase.pub/>
|
|
||||||
* Copyright (c) 2019- contributors <https://github.com/ViaVersion/ViaFabric/graphs/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.handler.clientside;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
|
||||||
import io.netty.handler.codec.MessageToMessageDecoder;
|
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
|
||||||
import us.myles.ViaVersion.exception.CancelCodecException;
|
|
||||||
import us.myles.ViaVersion.exception.CancelDecoderException;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class VRDecodeHandler extends MessageToMessageDecoder<ByteBuf> {
|
|
||||||
private final UserConnection info;
|
|
||||||
|
|
||||||
public VRDecodeHandler(UserConnection info) {
|
|
||||||
this.info = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf bytebuf, List<Object> out) throws Exception {
|
|
||||||
info.checkOutgoingPacket();
|
|
||||||
if (!info.shouldTransformPacket()) {
|
|
||||||
out.add(bytebuf.retain());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ByteBuf transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf);
|
|
||||||
try {
|
|
||||||
info.transformOutgoing(transformedBuf, CancelDecoderException::generate);
|
|
||||||
out.add(transformedBuf.retain());
|
|
||||||
} finally {
|
|
||||||
transformedBuf.release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
|
||||||
if (cause instanceof CancelCodecException) return;
|
|
||||||
super.exceptionCaught(ctx, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserConnection getInfo() {
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018- creeper123123321 <https://creeper123123321.keybase.pub/>
|
|
||||||
* Copyright (c) 2019- contributors <https://github.com/ViaVersion/ViaFabric/graphs/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.handler.clientside;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
|
||||||
import io.netty.handler.codec.MessageToMessageEncoder;
|
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
|
||||||
import us.myles.ViaVersion.exception.CancelCodecException;
|
|
||||||
import us.myles.ViaVersion.exception.CancelEncoderException;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class VREncodeHandler extends MessageToMessageEncoder<ByteBuf> {
|
|
||||||
private final UserConnection info;
|
|
||||||
|
|
||||||
public VREncodeHandler(UserConnection info) {
|
|
||||||
this.info = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void encode(ChannelHandlerContext ctx, ByteBuf bytebuf, List<Object> out) throws Exception {
|
|
||||||
if (!info.checkIncomingPacket()) throw CancelEncoderException.generate(null);
|
|
||||||
if (!info.shouldTransformPacket()) {
|
|
||||||
out.add(bytebuf.retain());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ByteBuf transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf);
|
|
||||||
try {
|
|
||||||
info.transformIncoming(transformedBuf, CancelEncoderException::generate);
|
|
||||||
out.add(transformedBuf.retain());
|
|
||||||
} finally {
|
|
||||||
transformedBuf.release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
|
||||||
if (cause instanceof CancelCodecException) return;
|
|
||||||
super.exceptionCaught(ctx, cause);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018- creeper123123321 <https://creeper123123321.keybase.pub/>
|
|
||||||
* Copyright (c) 2019- contributors <https://github.com/ViaVersion/ViaFabric/graphs/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 us.myles.ViaVersion.api.boss.BossColor;
|
|
||||||
import us.myles.ViaVersion.api.boss.BossStyle;
|
|
||||||
import us.myles.ViaVersion.boss.CommonBoss;
|
|
||||||
|
|
||||||
public class VRBossBar extends CommonBoss<Void> {
|
|
||||||
public VRBossBar(String title, float health, BossColor color, BossStyle style) {
|
|
||||||
super(title, health, color, style);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018- creeper123123321 <https://creeper123123321.keybase.pub/>
|
|
||||||
* Copyright (c) 2019- contributors <https://github.com/ViaVersion/ViaFabric/graphs/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.handler.CommonTransformer;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.channel.Channel;
|
|
||||||
import io.netty.channel.ChannelFuture;
|
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
|
||||||
|
|
||||||
public class VRClientSideUserConnection extends UserConnection {
|
|
||||||
public VRClientSideUserConnection(Channel socketChannel) {
|
|
||||||
super(socketChannel);
|
|
||||||
}
|
|
||||||
// Based on https://github.com/Gerrygames/ClientViaVersion/blob/master/src/main/java/de/gerrygames/the5zig/clientviaversion/reflection/Injector.java
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRawPacket(final ByteBuf packet, boolean currentThread) {
|
|
||||||
Runnable act = () -> getChannel().pipeline().context(CommonTransformer.HANDLER_DECODER_NAME)
|
|
||||||
.fireChannelRead(packet);
|
|
||||||
if (currentThread) {
|
|
||||||
act.run();
|
|
||||||
} else {
|
|
||||||
getChannel().eventLoop().execute(act);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChannelFuture sendRawPacketFuture(ByteBuf packet) {
|
|
||||||
getChannel().pipeline().context(CommonTransformer.HANDLER_DECODER_NAME).fireChannelRead(packet);
|
|
||||||
return getChannel().newSucceededFuture();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRawPacketToServer(ByteBuf packet, boolean currentThread) {
|
|
||||||
if (currentThread) {
|
|
||||||
getChannel().pipeline().context(CommonTransformer.HANDLER_ENCODER_NAME).writeAndFlush(packet);
|
|
||||||
} else {
|
|
||||||
getChannel().eventLoop().submit(() -> {
|
|
||||||
getChannel().pipeline().context(CommonTransformer.HANDLER_ENCODER_NAME).writeAndFlush(packet);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018- creeper123123321 <https://creeper123123321.keybase.pub/>
|
|
||||||
* Copyright (c) 2019- contributors <https://github.com/ViaVersion/ViaFabric/graphs/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 us.myles.ViaVersion.api.data.UserConnection;
|
|
||||||
import us.myles.ViaVersion.api.platform.ViaConnectionManager;
|
|
||||||
|
|
||||||
public class VRConnectionManager extends ViaConnectionManager {
|
|
||||||
@Override
|
|
||||||
public boolean isFrontEnd(UserConnection connection) {
|
|
||||||
return !(connection instanceof VRClientSideUserConnection);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018- creeper123123321 <https://creeper123123321.keybase.pub/>
|
|
||||||
* Copyright (c) 2019- contributors <https://github.com/ViaVersion/ViaFabric/graphs/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.handler.CommonTransformer;
|
|
||||||
import us.myles.ViaVersion.api.platform.ViaInjector;
|
|
||||||
import us.myles.ViaVersion.util.GsonUtil;
|
|
||||||
import us.myles.viaversion.libs.gson.JsonObject;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class VRInjector implements ViaInjector {
|
|
||||||
@Override
|
|
||||||
public void inject() {
|
|
||||||
// *looks at Mixins*
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void uninject() {
|
|
||||||
// not possible *plays sad violin*
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getServerProtocolVersion() throws NoSuchFieldException, IllegalAccessException {
|
|
||||||
return getClientProtocol();
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getClientProtocol() throws NoSuchFieldException, IllegalAccessException {
|
|
||||||
return 47;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEncoderName() {
|
|
||||||
return CommonTransformer.HANDLER_ENCODER_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDecoderName() {
|
|
||||||
return CommonTransformer.HANDLER_DECODER_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonObject getDump() {
|
|
||||||
JsonObject obj = new JsonObject();
|
|
||||||
try {
|
|
||||||
obj.add("serverNetworkIOChInit", GsonUtil.getGson().toJsonTree(
|
|
||||||
Arrays.stream(Class.forName("net.minecraft.class_3242$1").getDeclaredMethods())
|
|
||||||
.map(Method::toString)
|
|
||||||
.toArray(String[]::new)));
|
|
||||||
} catch (ClassNotFoundException ignored) {
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
obj.add("clientConnectionChInit", GsonUtil.getGson().toJsonTree(
|
|
||||||
Arrays.stream(Class.forName("net.minecraft.class_2535$1").getDeclaredMethods())
|
|
||||||
.map(Method::toString)
|
|
||||||
.toArray(String[]::new)));
|
|
||||||
} catch (ClassNotFoundException ignored) {
|
|
||||||
}
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018- creeper123123321 <https://creeper123123321.keybase.pub/>
|
|
||||||
* Copyright (c) 2019- contributors <https://github.com/ViaVersion/ViaFabric/graphs/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.providers.VRVersionProvider;
|
|
||||||
import us.myles.ViaVersion.api.Via;
|
|
||||||
import us.myles.ViaVersion.api.platform.ViaPlatformLoader;
|
|
||||||
import us.myles.ViaVersion.bungee.providers.BungeeMovementTransmitter;
|
|
||||||
import us.myles.ViaVersion.protocols.base.VersionProvider;
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
|
||||||
|
|
||||||
public class VRLoader implements ViaPlatformLoader {
|
|
||||||
@Override
|
|
||||||
public void load() {
|
|
||||||
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter());
|
|
||||||
Via.getManager().getProviders().use(VersionProvider.class, new VRVersionProvider());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unload() {
|
|
||||||
// Nothing to do
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,237 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018- creeper123123321 <https://creeper123123321.keybase.pub/>
|
|
||||||
* Copyright (c) 2019- contributors <https://github.com/ViaVersion/ViaFabric/graphs/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 com.github.creeper123123321.viafabric.util.FutureTaskId;
|
|
||||||
import com.github.creeper123123321.viafabric.util.JLoggerToLog4j;
|
|
||||||
import io.netty.util.concurrent.Future;
|
|
||||||
import io.netty.util.concurrent.GenericFutureListener;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import us.myles.ViaVersion.api.ViaAPI;
|
|
||||||
import us.myles.ViaVersion.api.ViaVersionConfig;
|
|
||||||
import us.myles.ViaVersion.api.command.ViaCommandSender;
|
|
||||||
import us.myles.ViaVersion.api.configuration.ConfigurationProvider;
|
|
||||||
import us.myles.ViaVersion.api.platform.TaskId;
|
|
||||||
import us.myles.ViaVersion.api.platform.ViaConnectionManager;
|
|
||||||
import us.myles.ViaVersion.api.platform.ViaPlatform;
|
|
||||||
import us.myles.viaversion.libs.bungeecordchat.api.chat.TextComponent;
|
|
||||||
import us.myles.viaversion.libs.bungeecordchat.chat.ComponentSerializer;
|
|
||||||
import us.myles.viaversion.libs.gson.JsonObject;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
import java.util.concurrent.CancellationException;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public class VRPlatform implements ViaPlatform<UUID> {
|
|
||||||
private final Logger logger = new JLoggerToLog4j(LogManager.getLogger("ViaVersion"));
|
|
||||||
private final VRViaConfig config;
|
|
||||||
private final File dataFolder;
|
|
||||||
private final ViaConnectionManager connectionManager;
|
|
||||||
private final ViaAPI<UUID> api;
|
|
||||||
|
|
||||||
public VRPlatform() {
|
|
||||||
Path configDir = Minecraft.getMinecraft().gameDir.toPath().resolve("ViaFabric");
|
|
||||||
config = new VRViaConfig(configDir.resolve("viaversion.yml").toFile());
|
|
||||||
dataFolder = configDir.toFile();
|
|
||||||
connectionManager = new VRConnectionManager();
|
|
||||||
api = new VRViaAPI();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MinecraftServer getServer() {
|
|
||||||
// In 1.8.9 integrated server instance exists even if it's not running
|
|
||||||
if (!Minecraft.getMinecraft().isIntegratedServerRunning()) return null;
|
|
||||||
return Minecraft.getMinecraft().getIntegratedServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Logger getLogger() {
|
|
||||||
return logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPlatformName() {
|
|
||||||
return "ViaFabric";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPlatformVersion() {
|
|
||||||
return ViaFabric.getVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPluginVersion() {
|
|
||||||
return "3.3.0";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskId runAsync(Runnable runnable) {
|
|
||||||
return new FutureTaskId(CompletableFuture
|
|
||||||
.runAsync(runnable, ViaFabric.ASYNC_EXECUTOR)
|
|
||||||
.exceptionally(throwable -> {
|
|
||||||
if (!(throwable instanceof CancellationException)) {
|
|
||||||
throwable.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskId runSync(Runnable runnable) {
|
|
||||||
if (getServer() != null) {
|
|
||||||
return runServerSync(runnable);
|
|
||||||
} else {
|
|
||||||
return runEventLoop(runnable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private TaskId runServerSync(Runnable runnable) {
|
|
||||||
// Kick task needs to be on main thread, it does already have error logger
|
|
||||||
return new FutureTaskId(CompletableFuture.runAsync(runnable, it -> getServer().callFromMainThread((Callable
|
|
||||||
<Void>) () -> {
|
|
||||||
it.run();
|
|
||||||
return null;
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
|
|
||||||
private TaskId runEventLoop(Runnable runnable) {
|
|
||||||
return new FutureTaskId(
|
|
||||||
ViaFabric.EVENT_LOOP
|
|
||||||
.submit(runnable)
|
|
||||||
.addListener(errorLogger())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskId runSync(Runnable runnable, Long ticks) {
|
|
||||||
// ViaVersion seems to not need to run delayed tasks on main thread
|
|
||||||
return new FutureTaskId(
|
|
||||||
ViaFabric.EVENT_LOOP
|
|
||||||
.schedule(() -> runSync(runnable), ticks * 50, TimeUnit.MILLISECONDS)
|
|
||||||
.addListener(errorLogger())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskId runRepeatingSync(Runnable runnable, Long ticks) {
|
|
||||||
// ViaVersion seems to not need to run repeating tasks on main thread
|
|
||||||
return new FutureTaskId(
|
|
||||||
ViaFabric.EVENT_LOOP
|
|
||||||
.scheduleAtFixedRate(() -> runSync(runnable), 0, ticks * 50, TimeUnit.MILLISECONDS)
|
|
||||||
.addListener(errorLogger())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T extends Future<?>> GenericFutureListener<T> errorLogger() {
|
|
||||||
return future -> {
|
|
||||||
if (!future.isCancelled() && future.cause() != null) {
|
|
||||||
future.cause().printStackTrace();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cancelTask(TaskId taskId) {
|
|
||||||
if (taskId instanceof FutureTaskId) {
|
|
||||||
((FutureTaskId) taskId).getObject().cancel(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ViaCommandSender[] getOnlinePlayers() {
|
|
||||||
return new ViaCommandSender[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendMessage(UUID uuid, String s) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean kickPlayer(UUID uuid, String s) {
|
|
||||||
return kickServer(uuid, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean kickServer(UUID uuid, String s) {
|
|
||||||
return false; // Can't know if it worked
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPluginEnabled() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ViaAPI<UUID> getApi() {
|
|
||||||
return api;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ViaVersionConfig getConf() {
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConfigurationProvider getConfigurationProvider() {
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public File getDataFolder() {
|
|
||||||
return dataFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReload() {
|
|
||||||
// Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonObject getDump() {
|
|
||||||
return new JsonObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOldClientsAllowed() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ViaConnectionManager getConnectionManager() {
|
|
||||||
return connectionManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String legacyToJson(String legacy) {
|
|
||||||
return ComponentSerializer.toString(TextComponent.fromLegacyText(legacy));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,88 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018- creeper123123321 <https://creeper123123321.keybase.pub/>
|
|
||||||
* Copyright (c) 2019- contributors <https://github.com/ViaVersion/ViaFabric/graphs/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 io.netty.buffer.ByteBuf;
|
|
||||||
import us.myles.ViaVersion.api.Via;
|
|
||||||
import us.myles.ViaVersion.api.ViaAPI;
|
|
||||||
import us.myles.ViaVersion.api.boss.BossBar;
|
|
||||||
import us.myles.ViaVersion.api.boss.BossColor;
|
|
||||||
import us.myles.ViaVersion.api.boss.BossStyle;
|
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
|
||||||
|
|
||||||
import java.util.SortedSet;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class VRViaAPI implements ViaAPI<UUID> {
|
|
||||||
@Override
|
|
||||||
public int getPlayerVersion(UUID uuid) {
|
|
||||||
UserConnection con = Via.getManager().getConnection(uuid);
|
|
||||||
if (con != null) {
|
|
||||||
return con.getProtocolInfo().getProtocolVersion();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return Via.getManager().getInjector().getServerProtocolVersion();
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new AssertionError(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInjected(UUID uuid) {
|
|
||||||
return Via.getManager().isClientConnected(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getVersion() {
|
|
||||||
return Via.getPlatform().getPluginVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRawPacket(UUID uuid, ByteBuf byteBuf) throws IllegalArgumentException {
|
|
||||||
UserConnection ci = Via.getManager().getConnection(uuid);
|
|
||||||
ci.sendRawPacket(byteBuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BossBar<Void> createBossBar(String s, BossColor bossColor, BossStyle bossStyle) {
|
|
||||||
return new VRBossBar(s, 1f, bossColor, bossStyle);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BossBar<Void> createBossBar(String s, float v, BossColor bossColor, BossStyle bossStyle) {
|
|
||||||
return new VRBossBar(s, v, bossColor, bossStyle);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SortedSet<Integer> getSupportedVersions() {
|
|
||||||
SortedSet<Integer> outputSet = new TreeSet<>(ProtocolRegistry.getSupportedVersions());
|
|
||||||
outputSet.removeAll(Via.getPlatform().getConf().getBlockedProtocols());
|
|
||||||
|
|
||||||
return outputSet;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018- creeper123123321 <https://creeper123123321.keybase.pub/>
|
|
||||||
* Copyright (c) 2019- contributors <https://github.com/ViaVersion/ViaFabric/graphs/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 us.myles.ViaVersion.AbstractViaConfig;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class VRViaConfig extends AbstractViaConfig {
|
|
||||||
// Based on Sponge ViaVersion
|
|
||||||
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", "change-1_9-hitbox", "change-1_14-hitbox");
|
|
||||||
|
|
||||||
public VRViaConfig(File configFile) {
|
|
||||||
super(configFile);
|
|
||||||
// Load config
|
|
||||||
reloadConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public URL getDefaultConfigURL() {
|
|
||||||
return getClass().getClassLoader().getResource("assets/viaversion/config.yml");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void handleConfig(Map<String, Object> config) {
|
|
||||||
// Nothing Currently
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getUnsupportedOptions() {
|
|
||||||
return UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAntiXRay() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isItemCache() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isNMSPlayerTicking() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean is1_12QuickMoveActionFix() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getBlockConnectionMethod() {
|
|
||||||
return "packet";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean is1_9HitboxFix() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean is1_14HitboxFix() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package com.github.creeper123123321.viafabric.protocol;
|
|
||||||
|
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
|
||||||
import us.myles.ViaVersion.api.protocol.SimpleProtocol;
|
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
|
||||||
import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
|
||||||
import us.myles.ViaVersion.packets.State;
|
|
||||||
|
|
||||||
public class ViaFabricHostnameProtocol extends SimpleProtocol {
|
|
||||||
public static final ViaFabricHostnameProtocol INSTANCE = new ViaFabricHostnameProtocol();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void registerPackets() {
|
|
||||||
registerIncoming(State.HANDSHAKE, 0, 0, new PacketRemapper() {
|
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
map(Type.VAR_INT); // Protocol version
|
|
||||||
map(Type.STRING, new ValueTransformer<String, String>(Type.STRING) {
|
|
||||||
@Override
|
|
||||||
public String transform(PacketWrapper packetWrapper, String s) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018- creeper123123321 <https://creeper123123321.keybase.pub/>
|
|
||||||
* Copyright (c) 2019- contributors <https://github.com/ViaVersion/ViaFabric/graphs/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.providers;
|
|
||||||
|
|
||||||
import com.github.creeper123123321.viafabric.ViaFabric;
|
|
||||||
import com.github.creeper123123321.viafabric.platform.VRClientSideUserConnection;
|
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
|
||||||
import us.myles.ViaVersion.protocols.base.VersionProvider;
|
|
||||||
|
|
||||||
public class VRVersionProvider extends VersionProvider {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getServerProtocol(UserConnection connection) throws Exception {
|
|
||||||
if (connection instanceof VRClientSideUserConnection) {
|
|
||||||
return ViaFabric.clientSideVersion;
|
|
||||||
}
|
|
||||||
return super.getServerProtocol(connection);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018- creeper123123321 <https://creeper123123321.keybase.pub/>
|
|
||||||
* Copyright (c) 2019- contributors <https://github.com/ViaVersion/ViaFabric/graphs/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.util;
|
|
||||||
|
|
||||||
import us.myles.ViaVersion.api.platform.TaskId;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
public class FutureTaskId implements TaskId {
|
|
||||||
private final Future<?> object;
|
|
||||||
|
|
||||||
public FutureTaskId(Future<?> object) {
|
|
||||||
this.object = object;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Future<?> getObject() {
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018- creeper123123321 <https://creeper123123321.keybase.pub/>
|
|
||||||
* Copyright (c) 2019- contributors <https://github.com/ViaVersion/ViaFabric/graphs/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.util;
|
|
||||||
|
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
|
||||||
|
|
||||||
public class ProtocolUtils {
|
|
||||||
|
|
||||||
public static String getProtocolName(int id) {
|
|
||||||
if (!ProtocolVersion.isRegistered(id)) return Integer.toString(id);
|
|
||||||
return ProtocolVersion.getProtocol(id).getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
111
src/main/java/de/enzaxd/viaforge/ViaForge.java
Normal file
111
src/main/java/de/enzaxd/viaforge/ViaForge.java
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
package de.enzaxd.viaforge;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
|
import com.viaversion.viaversion.ViaManagerImpl;
|
||||||
|
import com.viaversion.viaversion.api.Via;
|
||||||
|
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||||
|
import de.enzaxd.viaforge.loader.VRBackwardsLoader;
|
||||||
|
import de.enzaxd.viaforge.loader.VRProviderLoader;
|
||||||
|
import de.enzaxd.viaforge.loader.VRRewindLoader;
|
||||||
|
import de.enzaxd.viaforge.platform.VRInjector;
|
||||||
|
import de.enzaxd.viaforge.platform.VRPlatform;
|
||||||
|
import de.enzaxd.viaforge.utils.JLoggerToLog4j;
|
||||||
|
import io.netty.channel.EventLoop;
|
||||||
|
import io.netty.channel.local.LocalEventLoopGroup;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class ViaForge {
|
||||||
|
|
||||||
|
public final static int SHARED_VERSION = 340;
|
||||||
|
|
||||||
|
private static final ViaForge instance = new ViaForge();
|
||||||
|
|
||||||
|
public static ViaForge getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Logger jLogger = new JLoggerToLog4j(LogManager.getLogger("ViaForge"));
|
||||||
|
private final CompletableFuture<Void> initFuture = new CompletableFuture<>();
|
||||||
|
|
||||||
|
private ExecutorService asyncExecutor;
|
||||||
|
private EventLoop eventLoop;
|
||||||
|
|
||||||
|
private File file;
|
||||||
|
private int version;
|
||||||
|
private String lastServer;
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat("ViaForge-%d").build();
|
||||||
|
asyncExecutor = Executors.newFixedThreadPool(8, factory);
|
||||||
|
|
||||||
|
eventLoop = new LocalEventLoopGroup(1, factory).next();
|
||||||
|
eventLoop.submit(initFuture::join);
|
||||||
|
|
||||||
|
setVersion(SHARED_VERSION);
|
||||||
|
this.file = new File("ViaForge");
|
||||||
|
if (this.file.mkdir())
|
||||||
|
this.getjLogger().info("Creating ViaForge Folder");
|
||||||
|
|
||||||
|
Via.init(
|
||||||
|
ViaManagerImpl.builder()
|
||||||
|
.injector(new VRInjector())
|
||||||
|
.loader(new VRProviderLoader())
|
||||||
|
.platform(new VRPlatform(file))
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
|
||||||
|
MappingDataLoader.enableMappingsCache();
|
||||||
|
((ViaManagerImpl) Via.getManager()).init();
|
||||||
|
|
||||||
|
new VRBackwardsLoader(file);
|
||||||
|
new VRRewindLoader(file);
|
||||||
|
|
||||||
|
initFuture.complete(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Logger getjLogger() {
|
||||||
|
return jLogger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompletableFuture<Void> getInitFuture() {
|
||||||
|
return initFuture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExecutorService getAsyncExecutor() {
|
||||||
|
return asyncExecutor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventLoop getEventLoop() {
|
||||||
|
return eventLoop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getFile() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastServer() {
|
||||||
|
return lastServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
public void setVersion(int version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFile(File file) {
|
||||||
|
this.file = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastServer(String lastServer) {
|
||||||
|
this.lastServer = lastServer;
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,8 @@
|
|||||||
package de.flori2007.viaforge.gui;
|
package de.enzaxd.viaforge.gui;
|
||||||
|
|
||||||
import com.github.creeper123123321.viafabric.ViaFabric;
|
|
||||||
import com.github.creeper123123321.viafabric.util.ProtocolUtils;
|
|
||||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||||
import de.flori2007.viaforge.utils.ProtocolSorter;
|
import de.enzaxd.viaforge.ViaForge;
|
||||||
|
import de.enzaxd.viaforge.protocols.ProtocolCollection;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
@ -70,12 +69,12 @@ public class GuiProtocolSelector extends GuiScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getSize() {
|
protected int getSize() {
|
||||||
return ProtocolSorter.getProtocolVersions().size();
|
return ProtocolCollection.values().length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void elementClicked(int i, boolean b, int i1, int i2) {
|
protected void elementClicked(int i, boolean b, int i1, int i2) {
|
||||||
ViaFabric.clientSideVersion = ProtocolSorter.getProtocolVersions().get(i).getVersion();
|
ViaForge.getInstance().setVersion(ProtocolCollection.values()[i].getVersion().getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -88,13 +87,13 @@ public class GuiProtocolSelector extends GuiScreen {
|
|||||||
drawDefaultBackground();
|
drawDefaultBackground();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawSlot(int i, int i1, int i2, int unknown, int i3, int i4, float i5) {
|
protected void drawSlot(int i, int i1, int i2, int i3, int i4, int i5, float v) {
|
||||||
drawCenteredString(mc.fontRenderer,(ViaFabric.clientSideVersion ==
|
drawCenteredString(mc.fontRenderer,(ViaForge.getInstance().getVersion() ==
|
||||||
ProtocolSorter.getProtocolVersions().get(i).getVersion() ? ChatFormatting.GREEN.toString() :
|
ProtocolCollection.values()[i].getVersion().getVersion() ? ChatFormatting.GREEN.toString() :
|
||||||
ChatFormatting.DARK_RED.toString()) + ProtocolUtils.getProtocolName(ProtocolSorter.
|
ChatFormatting.DARK_RED.toString()) + ProtocolCollection.getProtocolById(
|
||||||
getProtocolVersions().get(i).getVersion()), width / 2, i2 + 2, -1);
|
ProtocolCollection.values()[i].getVersion().getVersion()).getName(),
|
||||||
|
width / 2, i2 + 2, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package de.enzaxd.viaforge.handler;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.util.PipelineUtil;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.channel.ChannelHandler;
|
||||||
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||||
|
import io.netty.handler.codec.MessageToByteEncoder;
|
||||||
|
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
|
public class CommonTransformer {
|
||||||
|
public static final String HANDLER_DECODER_NAME = "via-decoder";
|
||||||
|
public static final String HANDLER_ENCODER_NAME = "via-encoder";
|
||||||
|
|
||||||
|
public static void decompress(ChannelHandlerContext ctx, ByteBuf buf) throws InvocationTargetException {
|
||||||
|
ChannelHandler handler = ctx.pipeline().get("decompress");
|
||||||
|
ByteBuf decompressed = handler instanceof MessageToMessageDecoder
|
||||||
|
? (ByteBuf) PipelineUtil.callDecode((MessageToMessageDecoder<?>) handler, ctx, buf).get(0)
|
||||||
|
: (ByteBuf) PipelineUtil.callDecode((ByteToMessageDecoder) handler, ctx, buf).get(0);
|
||||||
|
try {
|
||||||
|
buf.clear().writeBytes(decompressed);
|
||||||
|
} finally {
|
||||||
|
decompressed.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void compress(ChannelHandlerContext ctx, ByteBuf buf) throws Exception {
|
||||||
|
ByteBuf compressed = ctx.alloc().buffer();
|
||||||
|
try {
|
||||||
|
PipelineUtil.callEncode((MessageToByteEncoder<?>) ctx.pipeline().get("compress"), ctx, buf, compressed);
|
||||||
|
buf.clear().writeBytes(compressed);
|
||||||
|
} finally {
|
||||||
|
compressed.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
package de.enzaxd.viaforge.handler;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
|
import com.viaversion.viaversion.exception.CancelCodecException;
|
||||||
|
import com.viaversion.viaversion.exception.CancelDecoderException;
|
||||||
|
import com.viaversion.viaversion.util.PipelineUtil;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.channel.ChannelHandler;
|
||||||
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@ChannelHandler.Sharable
|
||||||
|
public class VRDecodeHandler extends MessageToMessageDecoder<ByteBuf> {
|
||||||
|
private final UserConnection info;
|
||||||
|
private boolean handledCompression;
|
||||||
|
private boolean skipDoubleTransform;
|
||||||
|
|
||||||
|
public VRDecodeHandler(UserConnection info) {
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserConnection getInfo() {
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://github.com/ViaVersion/ViaVersion/blob/master/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityDecodeHandler.java
|
||||||
|
@Override
|
||||||
|
protected void decode(ChannelHandlerContext ctx, ByteBuf bytebuf, List<Object> out) throws Exception {
|
||||||
|
if (skipDoubleTransform) {
|
||||||
|
skipDoubleTransform = false;
|
||||||
|
out.add(bytebuf.retain());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!info.checkIncomingPacket()) throw CancelDecoderException.generate(null);
|
||||||
|
if (!info.shouldTransformPacket()) {
|
||||||
|
out.add(bytebuf.retain());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteBuf transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf);
|
||||||
|
try {
|
||||||
|
boolean needsCompress = handleCompressionOrder(ctx, transformedBuf);
|
||||||
|
|
||||||
|
info.transformIncoming(transformedBuf, CancelDecoderException::generate);
|
||||||
|
|
||||||
|
if (needsCompress) {
|
||||||
|
CommonTransformer.compress(ctx, transformedBuf);
|
||||||
|
skipDoubleTransform = true;
|
||||||
|
}
|
||||||
|
out.add(transformedBuf.retain());
|
||||||
|
} finally {
|
||||||
|
transformedBuf.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean handleCompressionOrder(ChannelHandlerContext ctx, ByteBuf buf) throws InvocationTargetException {
|
||||||
|
if (handledCompression) return false;
|
||||||
|
|
||||||
|
int decoderIndex = ctx.pipeline().names().indexOf("decompress");
|
||||||
|
if (decoderIndex == -1) return false;
|
||||||
|
handledCompression = true;
|
||||||
|
if (decoderIndex > ctx.pipeline().names().indexOf("via-decoder")) {
|
||||||
|
// Need to decompress this packet due to bad order
|
||||||
|
CommonTransformer.decompress(ctx, buf);
|
||||||
|
ChannelHandler encoder = ctx.pipeline().get("via-encoder");
|
||||||
|
ChannelHandler decoder = ctx.pipeline().get("via-decoder");
|
||||||
|
ctx.pipeline().remove(encoder);
|
||||||
|
ctx.pipeline().remove(decoder);
|
||||||
|
ctx.pipeline().addAfter("compress", "via-encoder", encoder);
|
||||||
|
ctx.pipeline().addAfter("decompress", "via-decoder", decoder);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||||
|
if (PipelineUtil.containsCause(cause, CancelCodecException.class)) return;
|
||||||
|
super.exceptionCaught(ctx, cause);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
package de.enzaxd.viaforge.handler;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
|
import com.viaversion.viaversion.exception.CancelCodecException;
|
||||||
|
import com.viaversion.viaversion.exception.CancelEncoderException;
|
||||||
|
import com.viaversion.viaversion.util.PipelineUtil;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.channel.ChannelHandler;
|
||||||
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import io.netty.handler.codec.MessageToMessageEncoder;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@ChannelHandler.Sharable
|
||||||
|
public class VREncodeHandler extends MessageToMessageEncoder<ByteBuf> {
|
||||||
|
private final UserConnection info;
|
||||||
|
private boolean handledCompression;
|
||||||
|
|
||||||
|
public VREncodeHandler(UserConnection info) {
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void encode(final ChannelHandlerContext ctx, ByteBuf bytebuf, List<Object> out) throws Exception {
|
||||||
|
if (!info.checkOutgoingPacket()) throw CancelEncoderException.generate(null);
|
||||||
|
if (!info.shouldTransformPacket()) {
|
||||||
|
out.add(bytebuf.retain());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteBuf transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf);
|
||||||
|
try {
|
||||||
|
boolean needsCompress = handleCompressionOrder(ctx, transformedBuf);
|
||||||
|
|
||||||
|
info.transformOutgoing(transformedBuf, CancelEncoderException::generate);
|
||||||
|
|
||||||
|
if (needsCompress) {
|
||||||
|
CommonTransformer.compress(ctx, transformedBuf);
|
||||||
|
}
|
||||||
|
out.add(transformedBuf.retain());
|
||||||
|
} finally {
|
||||||
|
transformedBuf.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean handleCompressionOrder(ChannelHandlerContext ctx, ByteBuf buf) throws InvocationTargetException {
|
||||||
|
if (handledCompression) return false;
|
||||||
|
|
||||||
|
int encoderIndex = ctx.pipeline().names().indexOf("compress");
|
||||||
|
if (encoderIndex == -1) return false;
|
||||||
|
handledCompression = true;
|
||||||
|
if (encoderIndex > ctx.pipeline().names().indexOf("via-encoder")) {
|
||||||
|
// Need to decompress this packet due to bad order
|
||||||
|
CommonTransformer.decompress(ctx, buf);
|
||||||
|
ChannelHandler encoder = ctx.pipeline().get("via-encoder");
|
||||||
|
ChannelHandler decoder = ctx.pipeline().get("via-decoder");
|
||||||
|
ctx.pipeline().remove(encoder);
|
||||||
|
ctx.pipeline().remove(decoder);
|
||||||
|
ctx.pipeline().addAfter("compress", "via-encoder", encoder);
|
||||||
|
ctx.pipeline().addAfter("decompress", "via-decoder", decoder);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||||
|
if (PipelineUtil.containsCause(cause, CancelCodecException.class)) return;
|
||||||
|
super.exceptionCaught(ctx, cause);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package de.flori2007.viaforge.injection;
|
package de.enzaxd.viaforge.injection;
|
||||||
|
|
||||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
||||||
import org.spongepowered.asm.launch.MixinBootstrap;
|
import org.spongepowered.asm.launch.MixinBootstrap;
|
@ -1,6 +1,6 @@
|
|||||||
package de.flori2007.viaforge.injection.mixins;
|
package de.enzaxd.viaforge.injection.mixins;
|
||||||
|
|
||||||
import com.github.creeper123123321.viafabric.ViaFabric;
|
import de.enzaxd.viaforge.ViaForge;
|
||||||
import net.minecraft.client.multiplayer.GuiConnecting;
|
import net.minecraft.client.multiplayer.GuiConnecting;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@ -12,6 +12,6 @@ public abstract class MixinGuiConnecting {
|
|||||||
|
|
||||||
@Inject(method = "connect", at = @At("HEAD"))
|
@Inject(method = "connect", at = @At("HEAD"))
|
||||||
public void injectConnect(String ip, int port, CallbackInfo ci) {
|
public void injectConnect(String ip, int port, CallbackInfo ci) {
|
||||||
ViaFabric.lastServer = ip + ":" + port;
|
ViaForge.getInstance().setLastServer(ip + ":" + port);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
package de.flori2007.viaforge.injection.mixins;
|
package de.enzaxd.viaforge.injection.mixins;
|
||||||
|
|
||||||
import com.github.creeper123123321.viafabric.ViaFabric;
|
import de.enzaxd.viaforge.ViaForge;
|
||||||
import com.github.creeper123123321.viafabric.util.ProtocolUtils;
|
import de.enzaxd.viaforge.gui.GuiProtocolSelector;
|
||||||
import de.flori2007.viaforge.gui.GuiProtocolSelector;
|
import de.enzaxd.viaforge.protocols.ProtocolCollection;
|
||||||
import net.minecraft.client.gui.*;
|
import net.minecraft.client.gui.*;
|
||||||
import net.minecraft.client.multiplayer.GuiConnecting;
|
import net.minecraft.client.multiplayer.GuiConnecting;
|
||||||
import net.minecraft.client.multiplayer.ServerData;
|
import net.minecraft.client.multiplayer.ServerData;
|
||||||
@ -17,7 +17,7 @@ public abstract class MixinGuiDisconnected extends GuiScreen {
|
|||||||
@Inject(method = "initGui", at = @At("RETURN"))
|
@Inject(method = "initGui", at = @At("RETURN"))
|
||||||
public void injectInitGui(CallbackInfo ci) {
|
public void injectInitGui(CallbackInfo ci) {
|
||||||
buttonList.add(new GuiButton(1337, 5, 6, 98, 20,
|
buttonList.add(new GuiButton(1337, 5, 6, 98, 20,
|
||||||
ProtocolUtils.getProtocolName(ViaFabric.clientSideVersion)));
|
ProtocolCollection.getProtocolById(ViaForge.getInstance().getVersion()).getName()));
|
||||||
buttonList.add(new GuiButton(1338, 5, 28, 98, 20, "Reconnect"));
|
buttonList.add(new GuiButton(1338, 5, 28, 98, 20, "Reconnect"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +27,8 @@ public abstract class MixinGuiDisconnected extends GuiScreen {
|
|||||||
mc.displayGuiScreen(new GuiProtocolSelector(this));
|
mc.displayGuiScreen(new GuiProtocolSelector(this));
|
||||||
else if (p_actionPerformed_1_.id == 1338)
|
else if (p_actionPerformed_1_.id == 1338)
|
||||||
mc.displayGuiScreen(new GuiConnecting(new GuiMultiplayer(new GuiMainMenu()), mc,
|
mc.displayGuiScreen(new GuiConnecting(new GuiMultiplayer(new GuiMainMenu()), mc,
|
||||||
new ServerData(ViaFabric.lastServer, ViaFabric.lastServer, false)));
|
new ServerData(ViaForge.getInstance().getLastServer(), ViaForge.getInstance().getLastServer(),
|
||||||
|
false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "drawScreen", at = @At("RETURN"))
|
@Inject(method = "drawScreen", at = @At("RETURN"))
|
@ -1,8 +1,8 @@
|
|||||||
package de.flori2007.viaforge.injection.mixins;
|
package de.enzaxd.viaforge.injection.mixins;
|
||||||
|
|
||||||
import com.github.creeper123123321.viafabric.ViaFabric;
|
import de.enzaxd.viaforge.ViaForge;
|
||||||
import com.github.creeper123123321.viafabric.util.ProtocolUtils;
|
import de.enzaxd.viaforge.gui.GuiProtocolSelector;
|
||||||
import de.flori2007.viaforge.gui.GuiProtocolSelector;
|
import de.enzaxd.viaforge.protocols.ProtocolCollection;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiMainMenu;
|
import net.minecraft.client.gui.GuiMainMenu;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
@ -17,7 +17,7 @@ public abstract class MixinGuiMainMenu extends GuiScreen {
|
|||||||
@Inject(method = "initGui", at = @At("RETURN"))
|
@Inject(method = "initGui", at = @At("RETURN"))
|
||||||
public void injectInitGui(CallbackInfo ci) {
|
public void injectInitGui(CallbackInfo ci) {
|
||||||
buttonList.add(new GuiButton(1337, 5, 6, 98, 20,
|
buttonList.add(new GuiButton(1337, 5, 6, 98, 20,
|
||||||
ProtocolUtils.getProtocolName(ViaFabric.clientSideVersion)));
|
ProtocolCollection.getProtocolById(ViaForge.getInstance().getVersion()).getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "actionPerformed", at = @At("RETURN"))
|
@Inject(method = "actionPerformed", at = @At("RETURN"))
|
@ -1,8 +1,8 @@
|
|||||||
package de.flori2007.viaforge.injection.mixins;
|
package de.enzaxd.viaforge.injection.mixins;
|
||||||
|
|
||||||
import com.github.creeper123123321.viafabric.ViaFabric;
|
import de.enzaxd.viaforge.ViaForge;
|
||||||
import com.github.creeper123123321.viafabric.util.ProtocolUtils;
|
import de.enzaxd.viaforge.gui.GuiProtocolSelector;
|
||||||
import de.flori2007.viaforge.gui.GuiProtocolSelector;
|
import de.enzaxd.viaforge.protocols.ProtocolCollection;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiMultiplayer;
|
import net.minecraft.client.gui.GuiMultiplayer;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
@ -17,7 +17,7 @@ public abstract class MixinGuiMultiplayer extends GuiScreen {
|
|||||||
@Inject(method = "initGui", at = @At("RETURN"))
|
@Inject(method = "initGui", at = @At("RETURN"))
|
||||||
public void injectInitGui(CallbackInfo ci) {
|
public void injectInitGui(CallbackInfo ci) {
|
||||||
buttonList.add(new GuiButton(1337, 5, 38, 98, 20,
|
buttonList.add(new GuiButton(1337, 5, 38, 98, 20,
|
||||||
ProtocolUtils.getProtocolName(ViaFabric.clientSideVersion)));
|
ProtocolCollection.getProtocolById(ViaForge.getInstance().getVersion()).getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "actionPerformed", at = @At("RETURN"))
|
@Inject(method = "actionPerformed", at = @At("RETURN"))
|
@ -1,8 +1,8 @@
|
|||||||
package de.flori2007.viaforge.injection.mixins;
|
package de.enzaxd.viaforge.injection.mixins;
|
||||||
|
|
||||||
import com.github.creeper123123321.viafabric.ViaFabric;
|
import de.enzaxd.viaforge.ViaForge;
|
||||||
import com.github.creeper123123321.viafabric.util.ProtocolUtils;
|
import de.enzaxd.viaforge.gui.GuiProtocolSelector;
|
||||||
import de.flori2007.viaforge.gui.GuiProtocolSelector;
|
import de.enzaxd.viaforge.protocols.ProtocolCollection;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.client.gui.GuiScreenAddServer;
|
import net.minecraft.client.gui.GuiScreenAddServer;
|
||||||
@ -17,7 +17,7 @@ public abstract class MixinGuiScreenAddServer extends GuiScreen {
|
|||||||
@Inject(method = "initGui", at = @At("RETURN"))
|
@Inject(method = "initGui", at = @At("RETURN"))
|
||||||
public void injectInitGui(CallbackInfo ci) {
|
public void injectInitGui(CallbackInfo ci) {
|
||||||
buttonList.add(new GuiButton(1337, 5, 6, 98, 20,
|
buttonList.add(new GuiButton(1337, 5, 6, 98, 20,
|
||||||
ProtocolUtils.getProtocolName(ViaFabric.clientSideVersion)));
|
ProtocolCollection.getProtocolById(ViaForge.getInstance().getVersion()).getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "actionPerformed", at = @At("RETURN"))
|
@Inject(method = "actionPerformed", at = @At("RETURN"))
|
@ -1,8 +1,8 @@
|
|||||||
package de.flori2007.viaforge.injection.mixins;
|
package de.enzaxd.viaforge.injection.mixins;
|
||||||
|
|
||||||
import com.github.creeper123123321.viafabric.ViaFabric;
|
import de.enzaxd.viaforge.ViaForge;
|
||||||
import com.github.creeper123123321.viafabric.util.ProtocolUtils;
|
import de.enzaxd.viaforge.gui.GuiProtocolSelector;
|
||||||
import de.flori2007.viaforge.gui.GuiProtocolSelector;
|
import de.enzaxd.viaforge.protocols.ProtocolCollection;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.client.gui.GuiScreenServerList;
|
import net.minecraft.client.gui.GuiScreenServerList;
|
||||||
@ -17,7 +17,7 @@ public abstract class MixinGuiScreenServerList extends GuiScreen {
|
|||||||
@Inject(method = "initGui", at = @At("RETURN"))
|
@Inject(method = "initGui", at = @At("RETURN"))
|
||||||
public void injectInitGui(CallbackInfo ci) {
|
public void injectInitGui(CallbackInfo ci) {
|
||||||
buttonList.add(new GuiButton(1337, 5, 6, 98, 20,
|
buttonList.add(new GuiButton(1337, 5, 6, 98, 20,
|
||||||
ProtocolUtils.getProtocolName(ViaFabric.clientSideVersion)));
|
ProtocolCollection.getProtocolById(ViaForge.getInstance().getVersion()).getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "actionPerformed", at = @At("RETURN"))
|
@Inject(method = "actionPerformed", at = @At("RETURN"))
|
@ -1,6 +1,6 @@
|
|||||||
package de.flori2007.viaforge.injection.mixins;
|
package de.enzaxd.viaforge.injection.mixins;
|
||||||
|
|
||||||
import com.github.creeper123123321.viafabric.ViaFabric;
|
import de.enzaxd.viaforge.ViaForge;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.main.GameConfiguration;
|
import net.minecraft.client.main.GameConfiguration;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@ -14,7 +14,7 @@ public abstract class MixinMinecraft {
|
|||||||
@Inject(method = "<init>", at = @At("RETURN"))
|
@Inject(method = "<init>", at = @At("RETURN"))
|
||||||
public void injectConstructor(GameConfiguration p_i45547_1_, CallbackInfo ci) {
|
public void injectConstructor(GameConfiguration p_i45547_1_, CallbackInfo ci) {
|
||||||
try {
|
try {
|
||||||
new ViaFabric().onInitialize();
|
ViaForge.getInstance().start();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
@ -1,28 +1,28 @@
|
|||||||
package de.flori2007.viaforge.injection.mixins;
|
package de.enzaxd.viaforge.injection.mixins;
|
||||||
|
|
||||||
import com.github.creeper123123321.viafabric.handler.CommonTransformer;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.github.creeper123123321.viafabric.handler.clientside.VRDecodeHandler;
|
import com.viaversion.viaversion.connection.UserConnectionImpl;
|
||||||
import com.github.creeper123123321.viafabric.handler.clientside.VREncodeHandler;
|
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
|
||||||
import com.github.creeper123123321.viafabric.platform.VRClientSideUserConnection;
|
import de.enzaxd.viaforge.ViaForge;
|
||||||
import com.github.creeper123123321.viafabric.protocol.ViaFabricHostnameProtocol;
|
import de.enzaxd.viaforge.handler.CommonTransformer;
|
||||||
|
import de.enzaxd.viaforge.handler.VRDecodeHandler;
|
||||||
|
import de.enzaxd.viaforge.handler.VREncodeHandler;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.socket.SocketChannel;
|
import io.netty.channel.socket.SocketChannel;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
|
|
||||||
|
|
||||||
@Mixin(targets = "net.minecraft.network.NetworkManager$5")
|
@Mixin(targets = "net.minecraft.network.NetworkManager$5")
|
||||||
public abstract class MixinNetworkManagerChInit {
|
public abstract class MixinNetworkManagerChInit {
|
||||||
|
|
||||||
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
|
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
|
||||||
private void onInitChannel(Channel channel, CallbackInfo ci) {
|
private void onInitChannel(Channel channel, CallbackInfo ci) {
|
||||||
if (channel instanceof SocketChannel) {
|
if (channel instanceof SocketChannel && ViaForge.getInstance().getVersion() != ViaForge.SHARED_VERSION) {
|
||||||
|
|
||||||
UserConnection user = new VRClientSideUserConnection(channel);
|
UserConnection user = new UserConnectionImpl(channel, true);
|
||||||
new ProtocolPipeline(user).add(ViaFabricHostnameProtocol.INSTANCE);
|
new ProtocolPipelineImpl(user);
|
||||||
|
|
||||||
channel.pipeline()
|
channel.pipeline()
|
||||||
.addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new VREncodeHandler(user))
|
.addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new VREncodeHandler(user))
|
@ -0,0 +1,34 @@
|
|||||||
|
package de.enzaxd.viaforge.loader;
|
||||||
|
|
||||||
|
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
|
||||||
|
import de.enzaxd.viaforge.ViaForge;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class VRBackwardsLoader implements ViaBackwardsPlatform {
|
||||||
|
private final File file;
|
||||||
|
|
||||||
|
public VRBackwardsLoader(final File file) {
|
||||||
|
this.init(this.file = new File(file, "ViaBackwards"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Logger getLogger() {
|
||||||
|
return ViaForge.getInstance().getjLogger();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOutdated() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getDataFolder() {
|
||||||
|
return new File(this.file, "config.yml");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package de.enzaxd.viaforge.loader;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.Via;
|
||||||
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
|
import com.viaversion.viaversion.api.platform.ViaPlatformLoader;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
||||||
|
import com.viaversion.viaversion.bungee.providers.BungeeMovementTransmitter;
|
||||||
|
import com.viaversion.viaversion.protocols.base.BaseVersionProvider;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
||||||
|
import de.enzaxd.viaforge.ViaForge;
|
||||||
|
|
||||||
|
public class VRProviderLoader implements ViaPlatformLoader {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load() {
|
||||||
|
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter());
|
||||||
|
Via.getManager().getProviders().use(VersionProvider.class, new BaseVersionProvider() {
|
||||||
|
@Override
|
||||||
|
public int getClosestServerProtocol(UserConnection connection) throws Exception {
|
||||||
|
if (connection.isClientSide())
|
||||||
|
return ViaForge.getInstance().getVersion();
|
||||||
|
return super.getClosestServerProtocol(connection);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unload() {
|
||||||
|
}
|
||||||
|
}
|
22
src/main/java/de/enzaxd/viaforge/loader/VRRewindLoader.java
Normal file
22
src/main/java/de/enzaxd/viaforge/loader/VRRewindLoader.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package de.enzaxd.viaforge.loader;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.Via;
|
||||||
|
import de.gerrygames.viarewind.api.ViaRewindConfigImpl;
|
||||||
|
import de.gerrygames.viarewind.api.ViaRewindPlatform;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class VRRewindLoader implements ViaRewindPlatform {
|
||||||
|
|
||||||
|
public VRRewindLoader(final File file) {
|
||||||
|
final ViaRewindConfigImpl conf = new ViaRewindConfigImpl(file.toPath().resolve("ViaRewind").resolve("config.yml").toFile());
|
||||||
|
conf.reloadConfig();
|
||||||
|
this.init(conf);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Logger getLogger() {
|
||||||
|
return Via.getPlatform().getLogger();
|
||||||
|
}
|
||||||
|
}
|
38
src/main/java/de/enzaxd/viaforge/platform/VRInjector.java
Normal file
38
src/main/java/de/enzaxd/viaforge/platform/VRInjector.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package de.enzaxd.viaforge.platform;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.platform.ViaInjector;
|
||||||
|
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||||
|
import de.enzaxd.viaforge.ViaForge;
|
||||||
|
import de.enzaxd.viaforge.handler.CommonTransformer;
|
||||||
|
|
||||||
|
public class VRInjector implements ViaInjector {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void inject() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uninject() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getServerProtocolVersion() {
|
||||||
|
return ViaForge.SHARED_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEncoderName() {
|
||||||
|
return CommonTransformer.HANDLER_ENCODER_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDecoderName() {
|
||||||
|
return CommonTransformer.HANDLER_DECODER_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonObject getDump() {
|
||||||
|
JsonObject obj = new JsonObject();
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
161
src/main/java/de/enzaxd/viaforge/platform/VRPlatform.java
Normal file
161
src/main/java/de/enzaxd/viaforge/platform/VRPlatform.java
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
package de.enzaxd.viaforge.platform;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.ViaAPI;
|
||||||
|
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||||
|
import com.viaversion.viaversion.api.configuration.ConfigurationProvider;
|
||||||
|
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
|
||||||
|
import com.viaversion.viaversion.api.platform.PlatformTask;
|
||||||
|
import com.viaversion.viaversion.api.platform.ViaPlatform;
|
||||||
|
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||||
|
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import de.enzaxd.viaforge.ViaForge;
|
||||||
|
import de.enzaxd.viaforge.utils.FutureTaskId;
|
||||||
|
import de.enzaxd.viaforge.utils.JLoggerToLog4j;
|
||||||
|
import io.netty.util.concurrent.Future;
|
||||||
|
import io.netty.util.concurrent.GenericFutureListener;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CancellationException;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class VRPlatform implements ViaPlatform<UUID> {
|
||||||
|
|
||||||
|
private final Logger logger = new JLoggerToLog4j(LogManager.getLogger("ViaVersion"));
|
||||||
|
|
||||||
|
private final VRViaConfig config;
|
||||||
|
private final File dataFolder;
|
||||||
|
private final ViaAPI<UUID> api;
|
||||||
|
|
||||||
|
public VRPlatform(File dataFolder) {
|
||||||
|
Path configDir = dataFolder.toPath().resolve("ViaVersion");
|
||||||
|
config = new VRViaConfig(configDir.resolve("viaversion.yml").toFile());
|
||||||
|
this.dataFolder = configDir.toFile();
|
||||||
|
api = new VRViaAPI();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String legacyToJson(String legacy) {
|
||||||
|
return GsonComponentSerializer.gson().serialize(LegacyComponentSerializer.legacySection().deserialize(legacy));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Logger getLogger() {
|
||||||
|
return logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPlatformName() {
|
||||||
|
return "ViaForge";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPlatformVersion() {
|
||||||
|
return ViaForge.SHARED_VERSION+"";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPluginVersion() {
|
||||||
|
return "4.0.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FutureTaskId runAsync(Runnable runnable) {
|
||||||
|
return new FutureTaskId(CompletableFuture
|
||||||
|
.runAsync(runnable, ViaForge.getInstance().getAsyncExecutor())
|
||||||
|
.exceptionally(throwable -> {
|
||||||
|
if (!(throwable instanceof CancellationException)) {
|
||||||
|
throwable.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FutureTaskId runSync(Runnable runnable) {
|
||||||
|
return new FutureTaskId(ViaForge.getInstance().getEventLoop().submit(runnable).addListener(errorLogger()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlatformTask runSync(Runnable runnable, long ticks) {
|
||||||
|
return new FutureTaskId(ViaForge.getInstance().getEventLoop().schedule(() -> runSync(runnable), ticks *
|
||||||
|
50, TimeUnit.MILLISECONDS).addListener(errorLogger()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlatformTask runRepeatingSync(Runnable runnable, long ticks) {
|
||||||
|
return new FutureTaskId(ViaForge.getInstance().getEventLoop().scheduleAtFixedRate(() -> runSync(runnable),
|
||||||
|
0, ticks * 50, TimeUnit.MILLISECONDS).addListener(errorLogger()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T extends Future<?>> GenericFutureListener<T> errorLogger() {
|
||||||
|
return future -> {
|
||||||
|
if (!future.isCancelled() && future.cause() != null) {
|
||||||
|
future.cause().printStackTrace();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ViaCommandSender[] getOnlinePlayers() {
|
||||||
|
return new ViaCommandSender[1337];
|
||||||
|
}
|
||||||
|
|
||||||
|
private ViaCommandSender[] getServerPlayers() {
|
||||||
|
return new ViaCommandSender[1337];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(UUID uuid, String s) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean kickPlayer(UUID uuid, String s) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPluginEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ViaAPI<UUID> getApi() {
|
||||||
|
return api;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ViaVersionConfig getConf() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConfigurationProvider getConfigurationProvider() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getDataFolder() {
|
||||||
|
return dataFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReload() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonObject getDump() {
|
||||||
|
JsonObject platformSpecific = new JsonObject();
|
||||||
|
return platformSpecific;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOldClientsAllowed() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
8
src/main/java/de/enzaxd/viaforge/platform/VRViaAPI.java
Normal file
8
src/main/java/de/enzaxd/viaforge/platform/VRViaAPI.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package de.enzaxd.viaforge.platform;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.ViaAPIBase;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class VRViaAPI extends ViaAPIBase<UUID> {
|
||||||
|
}
|
68
src/main/java/de/enzaxd/viaforge/platform/VRViaConfig.java
Normal file
68
src/main/java/de/enzaxd/viaforge/platform/VRViaConfig.java
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package de.enzaxd.viaforge.platform;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.configuration.AbstractViaConfig;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class VRViaConfig extends AbstractViaConfig {
|
||||||
|
// Based on Sponge ViaVersion
|
||||||
|
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",
|
||||||
|
"velocity-ping-interval", "velocity-ping-save", "velocity-servers",
|
||||||
|
"blockconnection-method", "change-1_9-hitbox", "change-1_14-hitbox");
|
||||||
|
|
||||||
|
public VRViaConfig(File configFile) {
|
||||||
|
super(configFile);
|
||||||
|
// Load config
|
||||||
|
reloadConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public URL getDefaultConfigURL() {
|
||||||
|
return getClass().getClassLoader().getResource("assets/viaversion/config.yml");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleConfig(Map<String, Object> config) {
|
||||||
|
// Nothing Currently
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getUnsupportedOptions() {
|
||||||
|
return UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAntiXRay() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNMSPlayerTicking() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean is1_12QuickMoveActionFix() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBlockConnectionMethod() {
|
||||||
|
return "packet";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean is1_9HitboxFix() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean is1_14HitboxFix() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package de.enzaxd.viaforge.protocols;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
|
|
||||||
|
public enum ProtocolCollection {
|
||||||
|
|
||||||
|
R1_17(new ProtocolVersion(755, "21w19a")),
|
||||||
|
|
||||||
|
R1_16_5(new ProtocolVersion(754, "1.16.4-1.16.5")),
|
||||||
|
R1_16_3(new ProtocolVersion(753, "1.16.3")),
|
||||||
|
R1_16_2(new ProtocolVersion(751, "1.16.2")),
|
||||||
|
R1_16_1(new ProtocolVersion(736, "1.16.1")),
|
||||||
|
R1_16(new ProtocolVersion(735, "1.16")),
|
||||||
|
|
||||||
|
R1_15_2(new ProtocolVersion(578, "1.15.2")),
|
||||||
|
R1_15_1(new ProtocolVersion(575, "1.15.1")),
|
||||||
|
R1_15(new ProtocolVersion(573, "1.15")),
|
||||||
|
|
||||||
|
R1_14_4(new ProtocolVersion(498, "1.14.4")),
|
||||||
|
R1_14_3(new ProtocolVersion(490, "1.14.3")),
|
||||||
|
R1_14_2(new ProtocolVersion(485, "1.14.2")),
|
||||||
|
R1_14_1(new ProtocolVersion(480, "1.14.1")),
|
||||||
|
R1_14(new ProtocolVersion(477, "1.14")),
|
||||||
|
|
||||||
|
R1_13_2(new ProtocolVersion(404, "1.13.2")),
|
||||||
|
R1_13_1(new ProtocolVersion(401, "1.13.1")),
|
||||||
|
R1_13(new ProtocolVersion(393, "1.13")),
|
||||||
|
|
||||||
|
R1_12_2(new ProtocolVersion(340, "1.12.2")),
|
||||||
|
R1_12_1(new ProtocolVersion(338, "1.12.1")),
|
||||||
|
R1_12(new ProtocolVersion(335, "1.12")),
|
||||||
|
|
||||||
|
R1_11_1(new ProtocolVersion(316, "1.11.1-1.11.2")),
|
||||||
|
R1_11(new ProtocolVersion(315, "1.11")),
|
||||||
|
|
||||||
|
R1_10(new ProtocolVersion(210, "1.10.x")),
|
||||||
|
|
||||||
|
R1_9_4(new ProtocolVersion(110, "1.9.3-1.9.4")),
|
||||||
|
R1_9_2(new ProtocolVersion(109, "1.9.2")),
|
||||||
|
R1_9_1(new ProtocolVersion(108, "1.9.1")),
|
||||||
|
R1_9(new ProtocolVersion(107, "1.9")),
|
||||||
|
|
||||||
|
R1_8(new ProtocolVersion(47, "1.8.x"));
|
||||||
|
|
||||||
|
private ProtocolVersion version;
|
||||||
|
|
||||||
|
private ProtocolCollection(ProtocolVersion version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProtocolVersion getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProtocolVersion getProtocolById(int id) {
|
||||||
|
for (ProtocolCollection coll : values())
|
||||||
|
if (coll.getVersion().getVersion() == id)
|
||||||
|
return coll.getVersion();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
23
src/main/java/de/enzaxd/viaforge/utils/FutureTaskId.java
Normal file
23
src/main/java/de/enzaxd/viaforge/utils/FutureTaskId.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package de.enzaxd.viaforge.utils;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.platform.PlatformTask;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
public class FutureTaskId implements PlatformTask<Future<?>> {
|
||||||
|
private final Future<?> object;
|
||||||
|
|
||||||
|
public FutureTaskId(Future<?> object) {
|
||||||
|
this.object = object;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Future<?> getObject() {
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancel() {
|
||||||
|
object.cancel(false);
|
||||||
|
}
|
||||||
|
}
|
@ -1,29 +1,4 @@
|
|||||||
/*
|
package de.enzaxd.viaforge.utils;
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018- creeper123123321 <https://creeper123123321.keybase.pub/>
|
|
||||||
* Copyright (c) 2019- contributors <https://github.com/ViaVersion/ViaFabric/graphs/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.util;
|
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
@ -1,24 +0,0 @@
|
|||||||
package de.flori2007.viaforge.injection.mixins;
|
|
||||||
|
|
||||||
import com.github.creeper123123321.viafabric.ViaFabric;
|
|
||||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiIngameMenu;
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(GuiIngameMenu.class)
|
|
||||||
public abstract class MixinGuiIngameMenu extends GuiScreen {
|
|
||||||
|
|
||||||
@Inject(method = "drawScreen", at = @At("RETURN"))
|
|
||||||
public void injectDrawScreen(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) {
|
|
||||||
if (ViaFabric.clientSideVersion != ViaFabric.nativeVersion) {
|
|
||||||
String text = ChatFormatting.GOLD.toString() + ChatFormatting.BOLD.toString() + "ViaForge is active! Selected Version: " + ViaFabric.nativeVersion;
|
|
||||||
Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(text, width / 2 -
|
|
||||||
(Minecraft.getMinecraft().fontRenderer.getStringWidth(text) / 2), 1, -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
package de.flori2007.viaforge.injection.mixins;
|
|
||||||
|
|
||||||
import com.github.creeper123123321.viafabric.handler.CommonTransformer;
|
|
||||||
import io.netty.channel.ChannelHandler;
|
|
||||||
import io.netty.channel.ChannelPipeline;
|
|
||||||
import net.minecraft.network.NetworkManager;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
|
|
||||||
@Mixin(NetworkManager.class)
|
|
||||||
public abstract class MixinNetworkManager {
|
|
||||||
|
|
||||||
@Redirect(method = "setCompressionThreshold", at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
remap = false,
|
|
||||||
target = "Lio/netty/channel/ChannelPipeline;addBefore(Ljava/lang/String;Ljava/lang/String;Lio/netty/channel/ChannelHandler;)Lio/netty/channel/ChannelPipeline;"
|
|
||||||
))
|
|
||||||
private ChannelPipeline decodeEncodePlacement(ChannelPipeline instance, String base, String newHandler, ChannelHandler handler) {
|
|
||||||
// Fixes the handler order
|
|
||||||
switch (base) {
|
|
||||||
case "decoder": {
|
|
||||||
if (instance.get(CommonTransformer.HANDLER_DECODER_NAME) != null)
|
|
||||||
base = CommonTransformer.HANDLER_DECODER_NAME;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "encoder": {
|
|
||||||
if (instance.get(CommonTransformer.HANDLER_ENCODER_NAME) != null)
|
|
||||||
base = CommonTransformer.HANDLER_ENCODER_NAME;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return instance.addBefore(base, newHandler, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
package de.flori2007.viaforge.platform;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import nl.matsv.viabackwards.ViaBackwards;
|
|
||||||
import nl.matsv.viabackwards.api.ViaBackwardsConfig;
|
|
||||||
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
|
||||||
import us.myles.ViaVersion.api.Via;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public class ViaBackwardsPlatformImplementation implements ViaBackwardsPlatform {
|
|
||||||
|
|
||||||
public ViaBackwardsPlatformImplementation() {
|
|
||||||
ViaBackwards.init(this, new ViaBackwardsConfig() {
|
|
||||||
@Override
|
|
||||||
public boolean addCustomEnchantsToLore() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addTeamColorTo1_13Prefix() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isFix1_13FacePlayer() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean alwaysShowOriginalMobName() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
init(Minecraft.getMinecraft().gameDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Logger getLogger() {
|
|
||||||
return Via.getPlatform().getLogger();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void disable() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOutdated() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public File getDataFolder() {
|
|
||||||
return Minecraft.getMinecraft().gameDir;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
package de.flori2007.viaforge.platform;
|
|
||||||
|
|
||||||
import de.gerrygames.viarewind.api.ViaRewindConfig;
|
|
||||||
import de.gerrygames.viarewind.api.ViaRewindPlatform;
|
|
||||||
import us.myles.ViaVersion.api.Via;
|
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public class ViaRewindPlatformImplementation implements ViaRewindPlatform {
|
|
||||||
|
|
||||||
public ViaRewindPlatformImplementation() {
|
|
||||||
init(new ViaRewindConfig() {
|
|
||||||
@Override
|
|
||||||
public CooldownIndicator getCooldownIndicator() {
|
|
||||||
return CooldownIndicator.TITLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isReplaceAdventureMode() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isReplaceParticles() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Logger getLogger() {
|
|
||||||
return Via.getPlatform().getLogger();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
package de.flori2007.viaforge.utils;
|
|
||||||
|
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
|
|
||||||
public class ProtocolSorter {
|
|
||||||
|
|
||||||
private static final LinkedList<ProtocolVersion> protocolVersions = new LinkedList<>();
|
|
||||||
|
|
||||||
private static int count = 0;
|
|
||||||
|
|
||||||
static {
|
|
||||||
for (Field f : ProtocolVersion.class.getDeclaredFields()) {
|
|
||||||
if (f.getType().equals(ProtocolVersion.class)) {
|
|
||||||
count++;
|
|
||||||
try {
|
|
||||||
ProtocolVersion ver = (ProtocolVersion) f.get(null);
|
|
||||||
|
|
||||||
if (count >= 8 && !ver.getName().equals("UNKNOWN"))
|
|
||||||
getProtocolVersions().add(ver);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Collections.reverse(getProtocolVersions());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LinkedList<ProtocolVersion> getProtocolVersions() {
|
|
||||||
return protocolVersions;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
[{
|
|
||||||
"modid": "viaforge",
|
|
||||||
"name": "Via Forge",
|
|
||||||
"description": "Clientside Implemention of ViaVersion for Forge",
|
|
||||||
"version": "1.0.0.0",
|
|
||||||
"mcversion": "1.8.9",
|
|
||||||
"url": "github.com/FlorianMichael",
|
|
||||||
"authorList": ["EnZaXD", "Flori2007"],
|
|
||||||
"credits": "Ty to ViaVersion for making the Protocol Translator 'ViaVersion'"
|
|
||||||
}]
|
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"required": true,
|
"required": true,
|
||||||
"package": "de.flori2007.viaforge.injection.mixins",
|
"package": "de.enzaxd.viaforge.injection.mixins",
|
||||||
"refmap": "mixins.viaforge.refmap.json",
|
"refmap": "mixins.viaforge.refmap.json",
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
@ -11,10 +11,6 @@
|
|||||||
"MixinGuiScreenAddServer",
|
"MixinGuiScreenAddServer",
|
||||||
"MixinGuiScreenServerList",
|
"MixinGuiScreenServerList",
|
||||||
"MixinMinecraft",
|
"MixinMinecraft",
|
||||||
"MixinNetworkManager",
|
|
||||||
"MixinNetworkManagerChInit"
|
"MixinNetworkManagerChInit"
|
||||||
],
|
|
||||||
"client": [
|
|
||||||
"MixinGuiIngameMenu"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user