net.minestom.server.network.NetworkBufferTemplate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minestom-snapshots Show documentation
Show all versions of minestom-snapshots Show documentation
1.20.4 Lightweight Minecraft server
package net.minestom.server.network;
import net.minestom.server.network.NetworkBuffer.Type;
import org.jetbrains.annotations.NotNull;
import java.util.function.Function;
import java.util.function.Supplier;
public final class NetworkBufferTemplate {
@FunctionalInterface
public interface F1 {
R apply(P1 p1);
}
@FunctionalInterface
public interface F2 {
R apply(P1 p1, P2 p2);
}
@FunctionalInterface
public interface F3 {
R apply(P1 p1, P2 p2, P3 p3);
}
@FunctionalInterface
public interface F4 {
R apply(P1 p1, P2 p2, P3 p3, P4 p4);
}
@FunctionalInterface
public interface F5 {
R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5);
}
@FunctionalInterface
public interface F6 {
R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6);
}
@FunctionalInterface
public interface F7 {
R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7);
}
@FunctionalInterface
public interface F8 {
R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8);
}
@FunctionalInterface
public interface F9 {
R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9);
}
@FunctionalInterface
public interface F10 {
R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10);
}
@FunctionalInterface
public interface F11 {
R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, P11 p11);
}
@FunctionalInterface
public interface F12 {
R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, P11 p11, P12 p12);
}
@FunctionalInterface
public interface F13 {
R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, P11 p11, P12 p12, P13 p13);
}
@FunctionalInterface
public interface F14 {
R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, P11 p11, P12 p12, P13 p13, P14 p14);
}
@FunctionalInterface
public interface F15 {
R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, P11 p11, P12 p12, P13 p13, P14 p14, P15 p15);
}
@FunctionalInterface
public interface F16 {
R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, P11 p11, P12 p12, P13 p13, P14 p14, P15 p15, P16 p16);
}
@FunctionalInterface
public interface F17 {
R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, P11 p11, P12 p12, P13 p13, P14 p14, P15 p15, P16 p16, P17 p17);
}
@FunctionalInterface
public interface F18 {
R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, P11 p11, P12 p12, P13 p13, P14 p14, P15 p15, P16 p16, P17 p17, P18 p18);
}
@FunctionalInterface
public interface F19 {
R apply(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, P11 p11, P12 p12, P13 p13, P14 p14, P15 p15, P16 p16, P17 p17, P18 p18, P19 p19);
}
public static Type template(Supplier supplier) {
return new NetworkBufferTypeImpl<>() {
@Override
public void write(@NotNull NetworkBuffer buffer, R value) {
}
@Override
public R read(@NotNull NetworkBuffer buffer) {
return supplier.get();
}
};
}
public static Type template(Type p1, Function g1, F1 reader) {
return new NetworkBufferTypeImpl<>() {
@Override
public void write(@NotNull NetworkBuffer buffer, R value) {
p1.write(buffer, g1.apply(value));
}
@Override
public R read(@NotNull NetworkBuffer buffer) {
return reader.apply(p1.read(buffer));
}
};
}
public static Type template(
Type p1, Function g1, Type p2, Function g2,
F2 reader
) {
return new NetworkBufferTypeImpl<>() {
@Override
public void write(@NotNull NetworkBuffer buffer, R value) {
p1.write(buffer, g1.apply(value));
p2.write(buffer, g2.apply(value));
}
@Override
public R read(@NotNull NetworkBuffer buffer) {
return reader.apply(p1.read(buffer), p2.read(buffer));
}
};
}
public static Type template(
Type p1, Function g1, Type p2, Function g2,
Type p3, Function g3, F3 reader
) {
return new NetworkBufferTypeImpl<>() {
@Override
public void write(@NotNull NetworkBuffer buffer, R value) {
p1.write(buffer, g1.apply(value));
p2.write(buffer, g2.apply(value));
p3.write(buffer, g3.apply(value));
}
@Override
public R read(@NotNull NetworkBuffer buffer) {
return reader.apply(p1.read(buffer), p2.read(buffer), p3.read(buffer));
}
};
}
public static Type template(
Type p1, Function g1, Type p2, Function g2,
Type p3, Function g3, Type p4, Function g4,
F4 reader
) {
return new NetworkBufferTypeImpl<>() {
@Override
public void write(@NotNull NetworkBuffer buffer, R value) {
p1.write(buffer, g1.apply(value));
p2.write(buffer, g2.apply(value));
p3.write(buffer, g3.apply(value));
p4.write(buffer, g4.apply(value));
}
@Override
public R read(@NotNull NetworkBuffer buffer) {
return reader.apply(
p1.read(buffer), p2.read(buffer),
p3.read(buffer), p4.read(buffer)
);
}
};
}
public static Type template(
Type p1, Function g1, Type p2, Function g2,
Type p3, Function g3, Type p4, Function g4,
Type p5, Function g5, F5 reader
) {
return new NetworkBufferTypeImpl<>() {
@Override
public void write(@NotNull NetworkBuffer buffer, R value) {
p1.write(buffer, g1.apply(value));
p2.write(buffer, g2.apply(value));
p3.write(buffer, g3.apply(value));
p4.write(buffer, g4.apply(value));
p5.write(buffer, g5.apply(value));
}
@Override
public R read(@NotNull NetworkBuffer buffer) {
return reader.apply(
p1.read(buffer), p2.read(buffer),
p3.read(buffer), p4.read(buffer),
p5.read(buffer)
);
}
};
}
public static Type template(
Type p1, Function g1, Type p2, Function g2,
Type p3, Function g3, Type p4, Function g4,
Type p5, Function g5, Type p6, Function g6,
F6 reader
) {
return new NetworkBufferTypeImpl<>() {
@Override
public void write(@NotNull NetworkBuffer buffer, R value) {
p1.write(buffer, g1.apply(value));
p2.write(buffer, g2.apply(value));
p3.write(buffer, g3.apply(value));
p4.write(buffer, g4.apply(value));
p5.write(buffer, g5.apply(value));
p6.write(buffer, g6.apply(value));
}
@Override
public R read(@NotNull NetworkBuffer buffer) {
return reader.apply(
p1.read(buffer), p2.read(buffer),
p3.read(buffer), p4.read(buffer),
p5.read(buffer), p6.read(buffer)
);
}
};
}
public static Type template(
Type p1, Function g1, Type p2, Function g2,
Type p3, Function g3, Type p4, Function g4,
Type p5, Function g5, Type p6, Function g6,
Type p7, Function g7, F7 reader
) {
return new NetworkBufferTypeImpl<>() {
@Override
public void write(@NotNull NetworkBuffer buffer, R value) {
p1.write(buffer, g1.apply(value));
p2.write(buffer, g2.apply(value));
p3.write(buffer, g3.apply(value));
p4.write(buffer, g4.apply(value));
p5.write(buffer, g5.apply(value));
p6.write(buffer, g6.apply(value));
p7.write(buffer, g7.apply(value));
}
@Override
public R read(@NotNull NetworkBuffer buffer) {
return reader.apply(
p1.read(buffer), p2.read(buffer),
p3.read(buffer), p4.read(buffer),
p5.read(buffer), p6.read(buffer),
p7.read(buffer)
);
}
};
}
public static Type template(
Type p1, Function g1, Type p2, Function g2,
Type p3, Function g3, Type p4, Function g4,
Type p5, Function g5, Type p6, Function g6,
Type p7, Function g7, Type p8, Function g8,
F8 reader
) {
return new NetworkBufferTypeImpl<>() {
@Override
public void write(@NotNull NetworkBuffer buffer, R value) {
p1.write(buffer, g1.apply(value));
p2.write(buffer, g2.apply(value));
p3.write(buffer, g3.apply(value));
p4.write(buffer, g4.apply(value));
p5.write(buffer, g5.apply(value));
p6.write(buffer, g6.apply(value));
p7.write(buffer, g7.apply(value));
p8.write(buffer, g8.apply(value));
}
@Override
public R read(@NotNull NetworkBuffer buffer) {
return reader.apply(
p1.read(buffer), p2.read(buffer),
p3.read(buffer), p4.read(buffer),
p5.read(buffer), p6.read(buffer),
p7.read(buffer), p8.read(buffer)
);
}
};
}
public static Type template(
Type p1, Function g1, Type p2, Function g2,
Type p3, Function g3, Type p4, Function g4,
Type p5, Function g5, Type p6, Function g6,
Type p7, Function g7, Type p8, Function g8,
Type p9, Function g9, F9 reader
) {
return new NetworkBufferTypeImpl<>() {
@Override
public void write(@NotNull NetworkBuffer buffer, R value) {
p1.write(buffer, g1.apply(value));
p2.write(buffer, g2.apply(value));
p3.write(buffer, g3.apply(value));
p4.write(buffer, g4.apply(value));
p5.write(buffer, g5.apply(value));
p6.write(buffer, g6.apply(value));
p7.write(buffer, g7.apply(value));
p8.write(buffer, g8.apply(value));
p9.write(buffer, g9.apply(value));
}
@Override
public R read(@NotNull NetworkBuffer buffer) {
return reader.apply(
p1.read(buffer), p2.read(buffer),
p3.read(buffer), p4.read(buffer),
p5.read(buffer), p6.read(buffer),
p7.read(buffer), p8.read(buffer),
p9.read(buffer)
);
}
};
}
public static Type template(
Type p1, Function g1, Type p2, Function g2,
Type p3, Function g3, Type p4, Function g4,
Type p5, Function g5, Type p6, Function g6,
Type p7, Function g7, Type p8, Function g8,
Type p9, Function g9, Type p10, Function g10,
F10 reader
) {
return new NetworkBufferTypeImpl<>() {
@Override
public void write(@NotNull NetworkBuffer buffer, R value) {
p1.write(buffer, g1.apply(value));
p2.write(buffer, g2.apply(value));
p3.write(buffer, g3.apply(value));
p4.write(buffer, g4.apply(value));
p5.write(buffer, g5.apply(value));
p6.write(buffer, g6.apply(value));
p7.write(buffer, g7.apply(value));
p8.write(buffer, g8.apply(value));
p9.write(buffer, g9.apply(value));
p10.write(buffer, g10.apply(value));
}
@Override
public R read(@NotNull NetworkBuffer buffer) {
return reader.apply(
p1.read(buffer), p2.read(buffer),
p3.read(buffer), p4.read(buffer),
p5.read(buffer), p6.read(buffer),
p7.read(buffer), p8.read(buffer),
p9.read(buffer), p10.read(buffer)
);
}
};
}
public static Type template(
Type p1, Function g1, Type p2, Function g2,
Type p3, Function g3, Type p4, Function g4,
Type p5, Function g5, Type p6, Function g6,
Type p7, Function g7, Type p8, Function g8,
Type p9, Function g9, Type p10, Function g10,
Type p11, Function g11, F11 reader
) {
return new NetworkBufferTypeImpl<>() {
@Override
public void write(@NotNull NetworkBuffer buffer, R value) {
p1.write(buffer, g1.apply(value));
p2.write(buffer, g2.apply(value));
p3.write(buffer, g3.apply(value));
p4.write(buffer, g4.apply(value));
p5.write(buffer, g5.apply(value));
p6.write(buffer, g6.apply(value));
p7.write(buffer, g7.apply(value));
p8.write(buffer, g8.apply(value));
p9.write(buffer, g9.apply(value));
p10.write(buffer, g10.apply(value));
p11.write(buffer, g11.apply(value));
}
@Override
public R read(@NotNull NetworkBuffer buffer) {
return reader.apply(
p1.read(buffer), p2.read(buffer),
p3.read(buffer), p4.read(buffer),
p5.read(buffer), p6.read(buffer),
p7.read(buffer), p8.read(buffer),
p9.read(buffer), p10.read(buffer),
p11.read(buffer)
);
}
};
}
public static Type template(
Type p1, Function g1, Type p2, Function g2,
Type p3, Function g3, Type p4, Function g4,
Type p5, Function g5, Type p6, Function g6,
Type p7, Function g7, Type p8, Function g8,
Type p9, Function g9, Type p10, Function g10,
Type p11, Function g11, Type p12, Function g12, F12 reader
) {
return new NetworkBufferTypeImpl<>() {
@Override
public void write(@NotNull NetworkBuffer buffer, R value) {
p1.write(buffer, g1.apply(value));
p2.write(buffer, g2.apply(value));
p3.write(buffer, g3.apply(value));
p4.write(buffer, g4.apply(value));
p5.write(buffer, g5.apply(value));
p6.write(buffer, g6.apply(value));
p7.write(buffer, g7.apply(value));
p8.write(buffer, g8.apply(value));
p9.write(buffer, g9.apply(value));
p10.write(buffer, g10.apply(value));
p11.write(buffer, g11.apply(value));
p12.write(buffer, g12.apply(value));
}
@Override
public R read(@NotNull NetworkBuffer buffer) {
return reader.apply(
p1.read(buffer), p2.read(buffer),
p3.read(buffer), p4.read(buffer),
p5.read(buffer), p6.read(buffer),
p7.read(buffer), p8.read(buffer),
p9.read(buffer), p10.read(buffer),
p11.read(buffer), p12.read(buffer)
);
}
};
}
public static Type template(
Type p1, Function g1, Type p2, Function g2,
Type p3, Function g3, Type p4, Function g4,
Type p5, Function g5, Type p6, Function g6,
Type p7, Function g7, Type p8, Function g8,
Type p9, Function g9, Type p10, Function g10,
Type p11, Function g11, Type p12, Function g12,
Type p13, Function g13,
F13 reader
) {
return new NetworkBufferTypeImpl<>() {
@Override
public void write(@NotNull NetworkBuffer buffer, R value) {
p1.write(buffer, g1.apply(value));
p2.write(buffer, g2.apply(value));
p3.write(buffer, g3.apply(value));
p4.write(buffer, g4.apply(value));
p5.write(buffer, g5.apply(value));
p6.write(buffer, g6.apply(value));
p7.write(buffer, g7.apply(value));
p8.write(buffer, g8.apply(value));
p9.write(buffer, g9.apply(value));
p10.write(buffer, g10.apply(value));
p11.write(buffer, g11.apply(value));
p12.write(buffer, g12.apply(value));
p13.write(buffer, g13.apply(value));
}
@Override
public R read(@NotNull NetworkBuffer buffer) {
return reader.apply(
p1.read(buffer), p2.read(buffer),
p3.read(buffer), p4.read(buffer),
p5.read(buffer), p6.read(buffer),
p7.read(buffer), p8.read(buffer),
p9.read(buffer), p10.read(buffer),
p11.read(buffer), p12.read(buffer),
p13.read(buffer)
);
}
};
}
public static Type template(
Type p1, Function g1, Type p2, Function g2,
Type p3, Function g3, Type