Removed unused ProtocolLib initialization

- Updated FakeEntity class
- Updated FakeImage class
- Updated YamipaPlugin class
This commit is contained in:
José Miguel Moreno committed 2025-07-29 20:57:28 +02:00
1 parent 641e7532bf
commit c78a51ee07
3 files changed
+1 -36

No files matched your search

@@ -123,11 +123,6 @@ public class YamipaPlugin extends JavaPlugin {
scheduler = Executors.newScheduledThreadPool(6);
// Warm-up plugin dependencies
LOGGER.fine("Waiting for ProtocolLib to be ready...");
scheduler.execute(() -> {
FakeEntity.waitForProtocolLib();
LOGGER.fine("ProtocolLib is now ready");
});
LOGGER.fine("Triggered map color cache warm-up");
FakeMap.pixelToIndex(Color.RED.getRGB()); // Ask for a color index to force cache generation
@@ -5,7 +5,6 @@ import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.injector.netty.manager.NetworkManagerInjector;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import io.josemmo.bukkit.plugin.YamipaPlugin;
import io.josemmo.bukkit.plugin.utils.Internals;
import io.josemmo.bukkit.plugin.utils.Logger;
@@ -13,13 +12,11 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
public abstract class FakeEntity {
private static final Logger LOGGER = Logger.getLogger("FakeEntity");
private static final ProtocolManager CONNECTION = ProtocolLibrary.getProtocolManager();
private static @Nullable NetworkManagerInjector NETWORK_MANAGER_INJECTOR;
private static boolean READY = false;
static {
try {
@@ -38,39 +35,13 @@ public abstract class FakeEntity {
}
}
/**
* Wait for ProtocolLib to be ready
* <p>
* NOTE: Will wait synchronously, blocking the invoker thread
*/
public static synchronized void waitForProtocolLib() {
if (READY) {
// ProtocolLib is ready
return;
}
int retry = 0;
while (true) {
try {
WrappedDataWatcher.Registry.get((Type) Byte.class);
READY = true;
break;
} catch (Exception e) {
if (++retry > 20) {
// Exhausted max. retries
throw e;
}
tryToSleep(200);
}
}
}
/**
* Try to sleep
* <p>
* NOTE: Will wait synchronously, blocking the invoker thread
* @param ms Delay in milliseconds
*/
@SuppressWarnings("SameParameterValue")
protected static void tryToSleep(long ms) {
try {
Thread.sleep(ms);
@@ -432,7 +432,6 @@ public class FakeImage extends FakeEntity {
// Instance needs to be loaded
loading = true;
tryToRunAsyncTask(() -> {
waitForProtocolLib();
load();
loading = false;
spawnOnceLoaded(player);