This commit is contained in:
1e99 2024-11-17 18:44:20 +01:00
parent 004ab1e220
commit 9daf6158f7
5 changed files with 8 additions and 33 deletions

View file

@ -3,7 +3,6 @@
"package": "eu.e99.svc.client.fabric.mixin", "package": "eu.e99.svc.client.fabric.mixin",
"compatibilityLevel": "JAVA_21", "compatibilityLevel": "JAVA_21",
"mixins": [ "mixins": [
"PlayerEntityMixin"
], ],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1

View file

@ -1,30 +0,0 @@
package eu.e99.svc.client.fabric.mixin;
import com.mojang.authlib.GameProfile;
import dev.onvoid.webrtc.RTCPeerConnection;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(PlayerEntity.class)
public class PlayerEntityMixin {
@Shadow @Final private GameProfile gameProfile;
@Inject(method = "<init>", at = @At("RETURN"))
private void svc$init(World world, BlockPos pos, float yaw, GameProfile gameProfile, CallbackInfo ci) {
System.out.printf("Added %s.%n", gameProfile.getName());
}
@Inject(method = "remove", at = @At("HEAD"))
private void svc$remove(Entity.RemovalReason reason, CallbackInfo ci) {
System.out.printf("Removed %s.%n", this.gameProfile.getName());
}
}

View file

@ -16,3 +16,8 @@ sourceSets {
main.java.srcDirs = ['src'] main.java.srcDirs = ['src']
main.resources.srcDirs = ['resources'] main.resources.srcDirs = ['resources']
} }
tasks.register('run', JavaExec) {
mainClass = 'eu.e99.svc.server.Main'
classpath = sourceSets.main.runtimeClasspath
}

View file

@ -19,6 +19,7 @@ public class Main {
try (ServerSocket socket = socketFactory.createServerSocket()) { try (ServerSocket socket = socketFactory.createServerSocket()) {
socket.bind(new InetSocketAddress("0.0.0.0", 6969)); socket.bind(new InetSocketAddress("0.0.0.0", 6969));
System.out.printf("Server listening.%n");
Server server = new Server(socket); Server server = new Server(socket);
server.start(); server.start();

View file

@ -55,7 +55,7 @@ public class Server {
} }
private void handleConnection(Socket client) throws IOException { private void handleConnection(Socket client) throws IOException {
System.out.printf("Accepted client %s.%n", client.getInetAddress()); System.out.printf("Handling client %s.%n", client.getInetAddress());
Connection conn = new Connection(client); Connection conn = new Connection(client);
PlayerProfile profile = this.handleHandshake(conn); PlayerProfile profile = this.handleHandshake(conn);
@ -109,7 +109,7 @@ public class Server {
if (clientHello.version < SimplerVoiceChat.PROTOCOL_VERSION) { if (clientHello.version < SimplerVoiceChat.PROTOCOL_VERSION) {
System.out.printf("Refusing to accept client, outdated client.%n"); System.out.printf("Refusing to accept client, outdated client.%n");
conn.disconnect("Outdated client. Please update the mode."); conn.disconnect("Outdated client. Please update the mod.");
return null; return null;
} }