mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2024-11-22 11:45:47 +01:00
/viaver, fix scheduler, do not add clientsidereference to server
This commit is contained in:
parent
04d5ec9d46
commit
f1c5c32a0e
@ -36,7 +36,6 @@ import net.fabricmc.api.EnvType;
|
|||||||
import net.fabricmc.fabric.api.registry.CommandRegistry;
|
import net.fabricmc.fabric.api.registry.CommandRegistry;
|
||||||
import net.fabricmc.loader.FabricLoader;
|
import net.fabricmc.loader.FabricLoader;
|
||||||
import net.minecraft.server.command.CommandSource;
|
import net.minecraft.server.command.CommandSource;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
|
||||||
import us.myles.ViaVersion.ViaManager;
|
import us.myles.ViaVersion.ViaManager;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||||
@ -64,17 +63,8 @@ public class VRViaVersionInitializer {
|
|||||||
Class.forName("io.github.cottonmc.clientcommands.ClientCommands")
|
Class.forName("io.github.cottonmc.clientcommands.ClientCommands")
|
||||||
.getMethod("registerCommand", Consumer.class)
|
.getMethod("registerCommand", Consumer.class)
|
||||||
.invoke(null,
|
.invoke(null,
|
||||||
(Consumer<CommandDispatcher<CommandSource>>) command -> command
|
(Consumer<CommandDispatcher<CommandSource>>) c ->
|
||||||
.register(
|
c.register(command("viafabricclient"))
|
||||||
LiteralArgumentBuilder.<CommandSource>literal("viafabricclient")
|
|
||||||
.then(
|
|
||||||
RequiredArgumentBuilder
|
|
||||||
.<CommandSource, String>argument("args", StringArgumentType.greedyString())
|
|
||||||
.executes(((VRCommandHandler) Via.getManager().getCommandHandler())::execute)
|
|
||||||
.suggests(((VRCommandHandler) Via.getManager().getCommandHandler())::suggestion)
|
|
||||||
)
|
|
||||||
.executes(((VRCommandHandler) Via.getManager().getCommandHandler())::execute)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||||
Via.getPlatform().getLogger().warning("ClientCommands isn't installed");
|
Via.getPlatform().getLogger().warning("ClientCommands isn't installed");
|
||||||
@ -83,20 +73,22 @@ public class VRViaVersionInitializer {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Class.forName("net.fabricmc.fabric.api.registry.CommandRegistry");
|
Class.forName("net.fabricmc.fabric.api.registry.CommandRegistry");
|
||||||
CommandRegistry.INSTANCE.register(false, command -> command
|
CommandRegistry.INSTANCE.register(false, c -> c.register(command("viaversion")));
|
||||||
.register(
|
CommandRegistry.INSTANCE.register(false, c -> c.register(command("viaver")));
|
||||||
LiteralArgumentBuilder.<ServerCommandSource>literal("viafabric")
|
CommandRegistry.INSTANCE.register(false, c -> c.register(command("vvfabric")));
|
||||||
.then(
|
|
||||||
RequiredArgumentBuilder
|
|
||||||
.<ServerCommandSource, String>argument("args", StringArgumentType.greedyString())
|
|
||||||
.executes(((VRCommandHandler) Via.getManager().getCommandHandler())::execute)
|
|
||||||
.suggests(((VRCommandHandler) Via.getManager().getCommandHandler())::suggestion)
|
|
||||||
)
|
|
||||||
.executes(((VRCommandHandler) Via.getManager().getCommandHandler())::execute)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
Via.getPlatform().getLogger().warning("Fabric API isn't installed");
|
Via.getPlatform().getLogger().warning("Fabric API isn't installed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static <S extends CommandSource> LiteralArgumentBuilder<S> command(String commandName) {
|
||||||
|
return LiteralArgumentBuilder.<S>literal(commandName)
|
||||||
|
.then(
|
||||||
|
RequiredArgumentBuilder
|
||||||
|
.<S, String>argument("args", StringArgumentType.greedyString())
|
||||||
|
.executes(((VRCommandHandler) Via.getManager().getCommandHandler())::execute)
|
||||||
|
.suggests(((VRCommandHandler) Via.getManager().getCommandHandler())::suggestion)
|
||||||
|
)
|
||||||
|
.executes(((VRCommandHandler) Via.getManager().getCommandHandler())::execute);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,17 +67,14 @@ public class ViaFabric implements ModInitializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getVersion() {
|
public static String getVersion() {
|
||||||
return FabricLoader.INSTANCE.getModContainers()
|
return FabricLoader.INSTANCE.getModContainer("viafabric")
|
||||||
.stream()
|
.get().getMetadata().getVersion().getFriendlyString();
|
||||||
.filter(container -> container.getInfo().getId().equals("viafabric"))
|
|
||||||
.findFirst()
|
|
||||||
.get().getInfo().getVersion().getFriendlyString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForUpdates(File jar, String artifactName, String groupIdPath, String depName) throws Exception {
|
private void checkForUpdates(File jar, String artifactName, String groupIdPath, String depName) throws Exception {
|
||||||
int timeDivisor = 1000 * 60 * 60 * 24;
|
int timeDivisor = 1000 * 60 * 60 * 24;
|
||||||
long cachedTime = System.currentTimeMillis() / timeDivisor;
|
long cachedTime = System.currentTimeMillis() / timeDivisor;
|
||||||
if (!(jar.exists() && jar.lastModified() / timeDivisor == cachedTime)) {
|
if (!(jar.exists() && jar.lastModified() / timeDivisor >= cachedTime)) {
|
||||||
String localMd5 = null;
|
String localMd5 = null;
|
||||||
if (jar.exists()) {
|
if (jar.exists()) {
|
||||||
try (InputStream is = Files.newInputStream(jar.toPath())) {
|
try (InputStream is = Files.newInputStream(jar.toPath())) {
|
||||||
@ -131,19 +128,11 @@ public class ViaFabric implements ModInitializer {
|
|||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
File viaVersionJar = FabricLoader.INSTANCE.getConfigDirectory().toPath().resolve("ViaFabric").resolve("viaversion.jar").toFile();
|
File viaVersionJar = FabricLoader.INSTANCE.getConfigDirectory().toPath().resolve("ViaFabric").resolve("viaversion.jar").toFile();
|
||||||
try {
|
|
||||||
checkForUpdates(viaVersionJar, "viaversion", "us/myles", "ViaVersion");
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
File viaRewindJar = FabricLoader.INSTANCE.getConfigDirectory().toPath().resolve("ViaFabric").resolve("viarewind.jar").toFile();
|
File viaRewindJar = FabricLoader.INSTANCE.getConfigDirectory().toPath().resolve("ViaFabric").resolve("viarewind.jar").toFile();
|
||||||
try {
|
|
||||||
checkForUpdates(viaRewindJar, "viarewind-core", "de/gerrygames", "ViaRewind");
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
File viaBackwardsJar = FabricLoader.INSTANCE.getConfigDirectory().toPath().resolve("ViaFabric").resolve("viabackwards.jar").toFile();
|
File viaBackwardsJar = FabricLoader.INSTANCE.getConfigDirectory().toPath().resolve("ViaFabric").resolve("viabackwards.jar").toFile();
|
||||||
try {
|
try {
|
||||||
|
checkForUpdates(viaVersionJar, "viaversion", "us/myles", "ViaVersion");
|
||||||
|
checkForUpdates(viaRewindJar, "viarewind-core", "de/gerrygames", "ViaRewind");
|
||||||
checkForUpdates(viaBackwardsJar, "viabackwards-core", "nl/matsv", "ViaBackwards");
|
checkForUpdates(viaBackwardsJar, "viabackwards-core", "nl/matsv", "ViaBackwards");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -26,7 +26,6 @@ package com.github.creeper123123321.viafabric.mixin;
|
|||||||
|
|
||||||
import com.github.creeper123123321.viafabric.handler.serverside.FabricDecodeHandler;
|
import com.github.creeper123123321.viafabric.handler.serverside.FabricDecodeHandler;
|
||||||
import com.github.creeper123123321.viafabric.handler.serverside.FabricEncodeHandler;
|
import com.github.creeper123123321.viafabric.handler.serverside.FabricEncodeHandler;
|
||||||
import com.github.creeper123123321.viafabric.protocol.ClientSideReference;
|
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.socket.SocketChannel;
|
import io.netty.channel.socket.SocketChannel;
|
||||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||||
@ -44,7 +43,7 @@ public class MixinClientConnectionServerChInit {
|
|||||||
private void onInitChannel(Channel channel, CallbackInfo ci) {
|
private void onInitChannel(Channel channel, CallbackInfo ci) {
|
||||||
if (channel instanceof SocketChannel) {
|
if (channel instanceof SocketChannel) {
|
||||||
UserConnection user = new UserConnection(channel);
|
UserConnection user = new UserConnection(channel);
|
||||||
new ProtocolPipeline(user).add(new ClientSideReference());
|
new ProtocolPipeline(user);
|
||||||
|
|
||||||
MessageToByteEncoder oldEncoder = (MessageToByteEncoder) channel.pipeline().get("encoder");
|
MessageToByteEncoder oldEncoder = (MessageToByteEncoder) channel.pipeline().get("encoder");
|
||||||
ByteToMessageDecoder oldDecoder = (ByteToMessageDecoder) channel.pipeline().get("decoder");
|
ByteToMessageDecoder oldDecoder = (ByteToMessageDecoder) channel.pipeline().get("decoder");
|
||||||
|
@ -57,6 +57,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -82,7 +83,7 @@ public class VRPlatform implements ViaPlatform {
|
|||||||
@Override
|
@Override
|
||||||
public String getPluginVersion() {
|
public String getPluginVersion() {
|
||||||
try {
|
try {
|
||||||
return VersionInfo.class.getField("VERSION").get(null) + "-ViaFabric";
|
return VersionInfo.class.getField("VERSION").get(null).toString();
|
||||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -102,21 +103,33 @@ public class VRPlatform implements ViaPlatform {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskId runSync(Runnable runnable) {
|
public TaskId runSync(Runnable runnable) {
|
||||||
return new FutureTaskId(ViaFabric.EVENT_LOOP
|
// Kick task needs to be on main thread
|
||||||
.submit(runnable)
|
Executor executor = ViaFabric.EVENT_LOOP;
|
||||||
.addListener(future -> {
|
boolean alreadyLogged;
|
||||||
if (!future.isSuccess()) {
|
MinecraftServer server = FabricLoader.INSTANCE.getEnvironmentHandler().getServerInstance();
|
||||||
future.cause().printStackTrace();
|
if (server != null) {
|
||||||
}
|
alreadyLogged = true;
|
||||||
})
|
executor = server;
|
||||||
|
} else {
|
||||||
|
alreadyLogged = false;
|
||||||
|
}
|
||||||
|
return new FutureTaskId(
|
||||||
|
CompletableFuture.runAsync(runnable, executor)
|
||||||
|
.exceptionally(throwable -> {
|
||||||
|
if (!alreadyLogged) {
|
||||||
|
throwable.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskId runSync(Runnable runnable, Long ticks) {
|
public TaskId runSync(Runnable runnable, Long ticks) {
|
||||||
|
// ViaVersion seems to not need to run delayed tasks on main thread
|
||||||
return new FutureTaskId(
|
return new FutureTaskId(
|
||||||
ViaFabric.EVENT_LOOP
|
ViaFabric.EVENT_LOOP
|
||||||
.schedule(runnable, ticks * 50, TimeUnit.SECONDS)
|
.schedule(runnable, ticks * 50, TimeUnit.MILLISECONDS)
|
||||||
.addListener(future -> {
|
.addListener(future -> {
|
||||||
if (!future.isSuccess()) {
|
if (!future.isSuccess()) {
|
||||||
future.cause().printStackTrace();
|
future.cause().printStackTrace();
|
||||||
@ -127,9 +140,10 @@ public class VRPlatform implements ViaPlatform {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskId runRepeatingSync(Runnable runnable, Long ticks) {
|
public TaskId runRepeatingSync(Runnable runnable, Long ticks) {
|
||||||
|
// ViaVersion seems to not need to run repeating tasks on main thread
|
||||||
return new FutureTaskId(
|
return new FutureTaskId(
|
||||||
ViaFabric.EVENT_LOOP
|
ViaFabric.EVENT_LOOP
|
||||||
.scheduleAtFixedRate(runnable, 0, ticks * 50, TimeUnit.SECONDS)
|
.scheduleAtFixedRate(runnable, 0, ticks * 50, TimeUnit.MILLISECONDS)
|
||||||
.addListener(future -> {
|
.addListener(future -> {
|
||||||
if (!future.isSuccess()) {
|
if (!future.isSuccess()) {
|
||||||
future.cause().printStackTrace();
|
future.cause().printStackTrace();
|
||||||
@ -148,7 +162,8 @@ public class VRPlatform implements ViaPlatform {
|
|||||||
@Override
|
@Override
|
||||||
public ViaCommandSender[] getOnlinePlayers() {
|
public ViaCommandSender[] getOnlinePlayers() {
|
||||||
MinecraftServer server = FabricLoader.INSTANCE.getEnvironmentHandler().getServerInstance();
|
MinecraftServer server = FabricLoader.INSTANCE.getEnvironmentHandler().getServerInstance();
|
||||||
if (server != null) {
|
if (server != null && server.isMainThread()) {
|
||||||
|
// Not thread safe
|
||||||
return server.getPlayerManager().getPlayerList().stream()
|
return server.getPlayerManager().getPlayerList().stream()
|
||||||
.map(Entity::getCommandSource)
|
.map(Entity::getCommandSource)
|
||||||
.map(NMSCommandSender::new)
|
.map(NMSCommandSender::new)
|
||||||
@ -174,11 +189,13 @@ public class VRPlatform implements ViaPlatform {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MinecraftServer server = FabricLoader.INSTANCE.getEnvironmentHandler().getServerInstance();
|
runSync(() -> {
|
||||||
if (server == null) return;
|
MinecraftServer server = FabricLoader.INSTANCE.getEnvironmentHandler().getServerInstance();
|
||||||
ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid);
|
if (server == null) return;
|
||||||
if (player == null) return;
|
ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid);
|
||||||
player.sendChatMessage(TextComponent.Serializer.fromJsonString(ChatRewriter.legacyTextToJson(s)), ChatMessageType.SYSTEM);
|
if (player == null) return;
|
||||||
|
player.sendChatMessage(TextComponent.Serializer.fromJsonString(ChatRewriter.legacyTextToJson(s)), ChatMessageType.SYSTEM);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,18 +207,19 @@ public class VRPlatform implements ViaPlatform {
|
|||||||
chat.write(Type.STRING, ChatRewriter.legacyTextToJson(s));
|
chat.write(Type.STRING, ChatRewriter.legacyTextToJson(s));
|
||||||
try {
|
try {
|
||||||
chat.sendFuture(ClientSideReference.class).addListener(future -> user.getChannel().close());
|
chat.sendFuture(ClientSideReference.class).addListener(future -> user.getChannel().close());
|
||||||
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MinecraftServer server = FabricLoader.INSTANCE.getEnvironmentHandler().getServerInstance();
|
MinecraftServer server = FabricLoader.INSTANCE.getEnvironmentHandler().getServerInstance();
|
||||||
if (server == null) return false;
|
if (server != null && server.isMainThread()) {
|
||||||
ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid);
|
ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid);
|
||||||
if (player == null) return false;
|
if (player == null) return false;
|
||||||
player.networkHandler.disconnect(TextComponent.Serializer.fromJsonString(ChatRewriter.legacyTextToJson(s)));
|
player.networkHandler.disconnect(TextComponent.Serializer.fromJsonString(ChatRewriter.legacyTextToJson(s)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -235,11 +253,11 @@ public class VRPlatform implements ViaPlatform {
|
|||||||
List<PluginInfo> mods = new ArrayList<>();
|
List<PluginInfo> mods = new ArrayList<>();
|
||||||
for (ModContainer mod : FabricLoader.INSTANCE.getModContainers()) {
|
for (ModContainer mod : FabricLoader.INSTANCE.getModContainers()) {
|
||||||
mods.add(new PluginInfo(true,
|
mods.add(new PluginInfo(true,
|
||||||
mod.getInfo().getName(),
|
mod.getMetadata().getName(),
|
||||||
mod.getInfo().getVersionString(),
|
mod.getMetadata().getVersion().getFriendlyString(),
|
||||||
String.join(", ", mod.getInfo().getInitializers()),
|
String.join(", ", mod.getInfo().getInitializers()),
|
||||||
mod.getInfo().getAuthors().stream()
|
mod.getInfo().getAuthors().stream()
|
||||||
.map(info -> info.getName() + " <" + info.getEmail() + "> " + "[" + info.getWebsite() + "]")
|
.map(info -> info.getName() + " <" + info.getEmail() + "> (" + info.getWebsite() + ")")
|
||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList())
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ import us.myles.ViaVersion.api.type.types.VoidType;
|
|||||||
import us.myles.ViaVersion.api.type.types.version.Types1_8;
|
import us.myles.ViaVersion.api.type.types.version.Types1_8;
|
||||||
import us.myles.ViaVersion.packets.State;
|
import us.myles.ViaVersion.packets.State;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -278,14 +279,11 @@ public class Protocol1_8TO1_7_6_10 extends Protocol {
|
|||||||
delayedPacket.write(Type.SHORT, item);
|
delayedPacket.write(Type.SHORT, item);
|
||||||
delayedPacket.write(Types1_8.METADATA_LIST, metadata);
|
delayedPacket.write(Types1_8.METADATA_LIST, metadata);
|
||||||
|
|
||||||
Via.getPlatform().runSync(new Runnable() {
|
Via.getPlatform().runSync(() -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
delayedPacket.send(Protocol1_8TO1_7_6_10.class);
|
||||||
try {
|
} catch (Exception ex) {
|
||||||
delayedPacket.send(Protocol1_8TO1_7_6_10.class);
|
ex.printStackTrace();
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, 1L);
|
}, 1L);
|
||||||
} else {
|
} else {
|
||||||
@ -925,14 +923,11 @@ public class Protocol1_8TO1_7_6_10 extends Protocol {
|
|||||||
this.registerOutgoing(State.PLAY, 0x33, 0x33, new PacketRemapper() {
|
this.registerOutgoing(State.PLAY, 0x33, 0x33, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
map(new ValueReader<Position>() {
|
map(packetWrapper -> {
|
||||||
@Override
|
long x = packetWrapper.read(Type.INT);
|
||||||
public Position read(PacketWrapper packetWrapper) throws Exception {
|
long y = packetWrapper.read(Type.SHORT);
|
||||||
long x = packetWrapper.read(Type.INT);
|
long z = packetWrapper.read(Type.INT);
|
||||||
long y = packetWrapper.read(Type.SHORT);
|
return new Position(x, y, z);
|
||||||
long z = packetWrapper.read(Type.INT);
|
|
||||||
return new Position(x, y, z);
|
|
||||||
}
|
|
||||||
}, new TypeRemapper<>(Type.POSITION)); //Position
|
}, new TypeRemapper<>(Type.POSITION)); //Position
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -1008,14 +1003,11 @@ public class Protocol1_8TO1_7_6_10 extends Protocol {
|
|||||||
this.registerOutgoing(State.PLAY, 0x35, 0x35, new PacketRemapper() {
|
this.registerOutgoing(State.PLAY, 0x35, 0x35, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
map(new ValueReader<Position>() {
|
map(packetWrapper -> {
|
||||||
@Override
|
long x = packetWrapper.read(Type.INT);
|
||||||
public Position read(PacketWrapper packetWrapper) throws Exception {
|
long y = packetWrapper.read(Type.SHORT);
|
||||||
long x = packetWrapper.read(Type.INT);
|
long z = packetWrapper.read(Type.INT);
|
||||||
long y = packetWrapper.read(Type.SHORT);
|
return new Position(x, y, z);
|
||||||
long z = packetWrapper.read(Type.INT);
|
|
||||||
return new Position(x, y, z);
|
|
||||||
}
|
|
||||||
}, new TypeRemapper<>(Type.POSITION)); //Position
|
}, new TypeRemapper<>(Type.POSITION)); //Position
|
||||||
map(Type.UNSIGNED_BYTE); //Action
|
map(Type.UNSIGNED_BYTE); //Action
|
||||||
map(Types1_7_6_10.COMPRESSED_NBT, Type.NBT);
|
map(Types1_7_6_10.COMPRESSED_NBT, Type.NBT);
|
||||||
@ -1180,7 +1172,7 @@ public class Protocol1_8TO1_7_6_10 extends Protocol {
|
|||||||
short length = packetWrapper.read(Type.SHORT);
|
short length = packetWrapper.read(Type.SHORT);
|
||||||
if (channel.equals("MC|Brand")) {
|
if (channel.equals("MC|Brand")) {
|
||||||
byte[] data = packetWrapper.read(new CustomByteType((int) length));
|
byte[] data = packetWrapper.read(new CustomByteType((int) length));
|
||||||
String brand = new String(data, "UTF-8");
|
String brand = new String(data, StandardCharsets.UTF_8);
|
||||||
packetWrapper.write(Type.STRING, brand);
|
packetWrapper.write(Type.STRING, brand);
|
||||||
} else if (channel.equals("MC|AdvCdm")) {
|
} else if (channel.equals("MC|AdvCdm")) {
|
||||||
byte type = packetWrapper.passthrough(Type.BYTE);
|
byte type = packetWrapper.passthrough(Type.BYTE);
|
||||||
@ -1690,7 +1682,7 @@ public class Protocol1_8TO1_7_6_10 extends Protocol {
|
|||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
public final int extra;
|
public final int extra;
|
||||||
private static final HashMap<String, Particle> particleMap = new HashMap();
|
private static final HashMap<String, Particle> particleMap = new HashMap<>();
|
||||||
|
|
||||||
Particle(String name) {
|
Particle(String name) {
|
||||||
this(name, 0);
|
this(name, 0);
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018 creeper123123321 and contributors
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.github.creeper123123321.viafabric.util;
|
|
||||||
|
|
||||||
import java.util.concurrent.ForkJoinPool;
|
|
||||||
|
|
||||||
public class ManagedBlockerRunnable implements ForkJoinPool.ManagedBlocker {
|
|
||||||
private final Runnable runnable;
|
|
||||||
private boolean release;
|
|
||||||
|
|
||||||
public ManagedBlockerRunnable(Runnable runnable) {
|
|
||||||
this.runnable = runnable;
|
|
||||||
release = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean block() {
|
|
||||||
runnable.run();
|
|
||||||
release = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isReleasable() {
|
|
||||||
return release;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user