ngl ts pmo

This commit is contained in:
2026-06-04 16:48:47 -04:00
parent 9fc011fc1b
commit e0f55b9ac7
3 changed files with 19 additions and 6 deletions
+2 -1
View File
@@ -92,7 +92,8 @@ public final class HubPlugin extends JavaPlugin {
protected void start() { protected void start() {
this.worldService = new HubWorldService(config); this.worldService = new HubWorldService(config);
HubJoinListener joinListener = new HubJoinListener(config, filter); HubJoinListener joinListener = new HubJoinListener(config, filter);
HubMessageListener messageListener = new HubMessageListener(config, filter); HubMessageListener messageListener = new HubMessageListener(config, filter,
net.kewwbec.networkcore.NetworkCore.getInstance().getVanishService());
this.hudVisibility = new HubHudVisibility(config.inventory.hidden_hud_components); this.hudVisibility = new HubHudVisibility(config.inventory.hidden_hud_components);
hudVisibility.setChangeListener(this::onHudVisibilityChange); hudVisibility.setChangeListener(this::onHudVisibilityChange);
HubInventoryListener inventoryListener = new HubInventoryListener(config.inventory, filter, hudVisibility); HubInventoryListener inventoryListener = new HubInventoryListener(config.inventory, filter, hudVisibility);
@@ -9,10 +9,12 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import net.kewwbec.hub.config.HubConfig; import net.kewwbec.hub.config.HubConfig;
import net.kewwbec.hub.protection.HubWorldFilter; import net.kewwbec.hub.protection.HubWorldFilter;
import net.kewwbec.hub.util.HubMessageFormatter; import net.kewwbec.hub.util.HubMessageFormatter;
import net.kewwbec.networkcore.api.VanishService;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.UUID; import java.util.UUID;
// Nullable already imported above
/** /**
* Replaces (or suppresses) Hytale's default join/leave broadcasts on hub worlds. * Replaces (or suppresses) Hytale's default join/leave broadcasts on hub worlds.
@@ -26,32 +28,44 @@ public final class HubMessageListener {
private final HubConfig config; private final HubConfig config;
private final HubWorldFilter filter; private final HubWorldFilter filter;
@Nullable private final VanishService vanish;
public HubMessageListener(@Nonnull HubConfig config, @Nonnull HubWorldFilter filter) { public HubMessageListener(@Nonnull HubConfig config,
@Nonnull HubWorldFilter filter,
@Nullable VanishService vanish) {
this.config = config; this.config = config;
this.filter = filter; this.filter = filter;
this.vanish = vanish;
} }
public void onAdd(@Nonnull AddPlayerToWorldEvent event) { public void onAdd(@Nonnull AddPlayerToWorldEvent event) {
if (!filter.isHub(event.getWorld())) return; if (!filter.isHub(event.getWorld())) return;
Subject s = resolveSubject(event.getHolder());
if (vanish != null && vanish.isVanished(s.uuid)) {
event.setBroadcastJoinMessage(false);
return;
}
String template = config.messages.join_announcement; String template = config.messages.join_announcement;
if (template == null || template.isBlank()) { if (template == null || template.isBlank()) {
event.setBroadcastJoinMessage(false); event.setBroadcastJoinMessage(false);
return; return;
} }
Subject s = resolveSubject(event.getHolder());
event.setJoinMessage(HubMessageFormatter.format(template, s.name, s.uuid)); event.setJoinMessage(HubMessageFormatter.format(template, s.name, s.uuid));
event.setBroadcastJoinMessage(true); event.setBroadcastJoinMessage(true);
} }
public void onRemove(@Nonnull RemovedPlayerFromWorldEvent event) { public void onRemove(@Nonnull RemovedPlayerFromWorldEvent event) {
if (!filter.isHub(event.getWorld())) return; if (!filter.isHub(event.getWorld())) return;
Subject s = resolveSubject(event.getHolder());
if (vanish != null && vanish.isVanished(s.uuid)) {
event.setBroadcastLeaveMessage(false);
return;
}
String template = config.messages.leave_announcement; String template = config.messages.leave_announcement;
if (template == null || template.isBlank()) { if (template == null || template.isBlank()) {
event.setBroadcastLeaveMessage(false); event.setBroadcastLeaveMessage(false);
return; return;
} }
Subject s = resolveSubject(event.getHolder());
event.setLeaveMessage(HubMessageFormatter.format(template, s.name, s.uuid)); event.setLeaveMessage(HubMessageFormatter.format(template, s.name, s.uuid));
event.setBroadcastLeaveMessage(true); event.setBroadcastLeaveMessage(true);
} }
@@ -43,7 +43,5 @@ public final class CancelBreakBlockSystem extends EntityEventSystem<EntityStore,
PlayerRef player = chunk.getComponent(chunkSlot, PlayerRef.getComponentType()); PlayerRef player = chunk.getComponent(chunkSlot, PlayerRef.getComponentType());
if (player != null && buildMode.isOn(player.getUuid())) return; if (player != null && buildMode.isOn(player.getUuid())) return;
event.setCancelled(true); event.setCancelled(true);
player.sendMessage(Message.raw("you broke " + event.getBlockType().getId()));
} }
} }