Compare commits

2 Commits

Author SHA1 Message Date
LiamSystems 7a6b52b883 Stubs instead 2026-06-10 00:24:46 +01:00
LiamSystems 2c508c6c51 Disable Vanish 2026-06-09 23:40:09 +01:00
2 changed files with 66 additions and 13 deletions
@@ -47,9 +47,10 @@ import net.kewwbec.networkcore.xp.XpSchemaBootstrap;
import net.kewwbec.networkcore.presence.PlayerPresenceService;
import net.kewwbec.networkcore.registry.RedisServerRegistry;
import net.kewwbec.networkcore.rpc.RpcClientImpl;
import net.kewwbec.networkcore.vanish.PlayerListVanishFilter;
import net.kewwbec.networkcore.vanish.VanishEnforcer;
import net.kewwbec.networkcore.vanish.VanishServiceImpl;
// import net.kewwbec.networkcore.vanish.PlayerListVanishFilter;
// import net.kewwbec.networkcore.vanish.VanishEnforcer;
// import net.kewwbec.networkcore.vanish.VanishServiceImpl;
import net.kewwbec.networkcore.vanish.NoopVanishService;
import com.hypixel.hytale.server.core.event.events.player.PlayerReadyEvent;
@@ -81,7 +82,8 @@ public final class NetworkCore extends JavaPlugin {
@Nullable private RefRequestService refRequestService;
@Nullable private LockService lockService;
@Nullable private ShutdownHandoff shutdownHandoff;
@Nullable private VanishServiceImpl vanishService;
// @Nullable private VanishServiceImpl vanishService;
@Nullable private VanishService vanishService;
public NetworkCore(@Nonnull JavaPluginInit init) {
super(init);
@@ -171,12 +173,16 @@ public final class NetworkCore extends JavaPlugin {
this.alertService = new AlertService(messageBus, serverId);
alertService.start();
this.vanishService = new VanishServiceImpl(messageBus, serverId);
vanishService.start();
// Vanish disabled — real impl + enforcement commented out. We still register a
// no-op stub so callers (GlistCommand, plugins via getVanishService()) get a
// non-null service that simply does nothing.
// this.vanishService = new VanishServiceImpl(messageBus, serverId);
// vanishService.start();
this.vanishService = new NoopVanishService();
services.register(VanishService.class, vanishService);
VanishEnforcer vanishEnforcer = new VanishEnforcer(vanishService);
getEventRegistry().registerGlobal(PlayerReadyEvent.class, vanishEnforcer::onPlayerReady);
new PlayerListVanishFilter(vanishService).register();
// VanishEnforcer vanishEnforcer = new VanishEnforcer(vanishService);
// getEventRegistry().registerGlobal(PlayerReadyEvent.class, vanishEnforcer::onPlayerReady);
// new PlayerListVanishFilter(vanishService).register();
this.refRequestService = new RefRequestService(messageBus, serverId);
refRequestService.start();
@@ -241,10 +247,8 @@ public final class NetworkCore extends JavaPlugin {
try { alertService.stop(); } catch (RuntimeException ignored) {}
alertService = null;
}
if (vanishService != null) {
try { vanishService.stop(); } catch (RuntimeException ignored) {}
vanishService = null;
}
// Stub vanish service holds no resources; nothing to stop.
vanishService = null;
if (presenceService != null) {
try { presenceService.stop(); } catch (RuntimeException ignored) {}
presenceService = null;
@@ -0,0 +1,49 @@
package net.kewwbec.networkcore.vanish;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import net.kewwbec.networkcore.api.VanishService;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.Set;
import java.util.UUID;
import java.util.function.BiConsumer;
/**
* No-op {@link VanishService}. Vanish is currently disabled, but callers (e.g.
* GlistCommand and consuming plugins via {@code getVanishService()}) still expect
* a non-null service. This stub satisfies the contract while doing nothing: nobody
* is ever vanished, toggles are ignored, and listeners are never fired.
*
* <p>To restore real behaviour, swap this back for {@link VanishServiceImpl} in
* NetworkCore and re-enable the VanishEnforcer / PlayerListVanishFilter wiring.</p>
*/
public final class NoopVanishService implements VanishService {
@Override
public boolean isVanished(@Nonnull UUID playerUuid) {
return false;
}
@Override
public void setVanished(@Nonnull UUID playerUuid, boolean vanished) {
// no-op: vanish disabled
}
@Override
@Nonnull
public Set<UUID> vanishedPlayers() {
return Collections.emptySet();
}
@Override
public boolean isHiddenFrom(@Nonnull UUID target, @Nullable PlayerRef viewer) {
return false;
}
@Override
public void addListener(@Nonnull BiConsumer<UUID, Boolean> listener) {
// no-op: state never changes, so listeners would never fire anyway
}
}