package com.hypixel.hytale.server.spawning.local; import com.hypixel.hytale.component.AddReason; import com.hypixel.hytale.component.CommandBuffer; import com.hypixel.hytale.component.ComponentType; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.RemoveReason; import com.hypixel.hytale.component.ResourceType; import com.hypixel.hytale.component.Store; import com.hypixel.hytale.component.query.Query; import com.hypixel.hytale.component.system.RefSystem; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import com.hypixel.hytale.server.spawning.SpawningPlugin; import java.util.logging.Level; import javax.annotation.Nonnull; public class LocalSpawnBeaconSystem extends RefSystem { private final ComponentType componentType; private final ResourceType localSpawnStateResourceType; public LocalSpawnBeaconSystem( ComponentType componentType, ResourceType localSpawnStateResourceType ) { this.componentType = componentType; this.localSpawnStateResourceType = localSpawnStateResourceType; } @Override public void onEntityAdded( @Nonnull Ref reference, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { } @Override public void onEntityRemove( @Nonnull Ref reference, @Nonnull RemoveReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { SpawningPlugin.get().getLogger().at(Level.FINE).log("Triggering forced rerun of local spawn controllers"); store.getResource(this.localSpawnStateResourceType).forceTriggerControllers(); } @Override public Query getQuery() { return this.componentType; } }