From 7a33e30de7f740144eb0d51aa6eff83dec7f5ac5 Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Tue, 7 Mar 2023 19:20:21 -0600 Subject: [PATCH] setURL for the player when null --- .../java/net/montoyo/wd/miniserv/SyncPlugin.java | 12 ++---------- .../net/montoyo/wd/net/server/SMessageGetUrl.java | 3 +-- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/main/java/net/montoyo/wd/miniserv/SyncPlugin.java b/src/main/java/net/montoyo/wd/miniserv/SyncPlugin.java index b2e246c..cd2c33c 100644 --- a/src/main/java/net/montoyo/wd/miniserv/SyncPlugin.java +++ b/src/main/java/net/montoyo/wd/miniserv/SyncPlugin.java @@ -1,17 +1,9 @@ package net.montoyo.wd.miniserv; -import com.mojang.math.Vector3d; -import net.minecraft.core.RegistryAccess; -import net.minecraft.network.Connection; -import net.minecraft.network.protocol.Packet; -import net.minecraft.network.protocol.PacketFlow; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.player.Player; -import net.minecraftforge.network.NetworkDirection; -import net.minecraftforge.network.PacketDistributor; -import net.montoyo.wd.WebDisplays; import net.montoyo.wd.net.Messages; import net.montoyo.wd.net.server.SMessageGetUrl; +import net.montoyo.wd.net.server.URLMessage; import java.util.ArrayList; import java.util.HashMap; @@ -32,7 +24,7 @@ public class SyncPlugin { public static String getPlayerString(ServerPlayer player) { if(URL.get(player) == null) { - return "https://www.google.com"; + setPlayerString(player, new URLMessage().getURL()); } return URL.get(player); } diff --git a/src/main/java/net/montoyo/wd/net/server/SMessageGetUrl.java b/src/main/java/net/montoyo/wd/net/server/SMessageGetUrl.java index ae6149a..3de051c 100644 --- a/src/main/java/net/montoyo/wd/net/server/SMessageGetUrl.java +++ b/src/main/java/net/montoyo/wd/net/server/SMessageGetUrl.java @@ -30,8 +30,7 @@ public class SMessageGetUrl { public void handle(Supplier contextSupplier) { contextSupplier.get().enqueueWork(() -> { - int connectTime = Objects.requireNonNull(Objects.requireNonNull(contextSupplier.get().getSender()).getServer()).getTickCount() - Objects.requireNonNull(contextSupplier.get().getSender()).connection.player.tickCount; - if(Objects.requireNonNull(contextSupplier.get().getSender()).connection.getConnection().isConnected() && connectTime > 20) { + if(Objects.requireNonNull(contextSupplier.get().getSender()).connection.getConnection().isConnected()) { Messages.INSTANCE.send(PacketDistributor.PLAYER.with(() -> contextSupplier.get().getSender()), new URLMessage(url)); } Messages.INSTANCE.send(PacketDistributor.ALL.noArg(), new URLMessage(url));