Skip to content

Commit

Permalink
chore: Change some commonly fired debug statements to be verbose, set…
Browse files Browse the repository at this point in the history
… default log level to Info

chore: Bump geary with fixes
  • Loading branch information
0ffz committed Mar 28, 2024
1 parent 8a00cb3 commit 79eafec
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GearyPaperConfig(
val mobTypeConversion: MobTypeConversion = MobTypeConversion.IGNORE,
@YamlComment("List of mob types to remove if they are not entities with Geary prefabs (i.e. vanilla entities)")
val removeVanillaMobTypes: Set<EntityType> = emptySet(),
val logLevel: Severity = Severity.Warn,
val logLevel: Severity = Severity.Info,
)

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fun GearyEntity.encodeComponentsTo(pdc: PersistentDataContainer) {

fun GearyEntity.encodeComponentsTo(holder: PersistentDataHolder) {
val bukkitHolder = holder as? BukkitEntity
geary.logger.d("Encoding components for bukkit entity $id (${bukkitHolder?.type} ${bukkitHolder?.uniqueId})")
geary.logger.v("Encoding components for bukkit entity $id (${bukkitHolder?.type} ${bukkitHolder?.uniqueId})")
encodeComponentsTo(holder.persistentDataContainer)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class EntityWorldEventTracker : Listener {
fun EntityAddToWorldEvent.onBukkitEntityAdd() {
// Only remove player from ECS on disconnect, not death
if (entity is Player) return
geary.logger.d("EntityAddToWorldEvent: Tracking bukkit entity ${entity.toGearyOrNull()?.id} (${entity.type} ${entity.uniqueId})")
geary.logger.v("EntityAddToWorldEvent: Tracking bukkit entity ${entity.toGearyOrNull()?.id} (${entity.type} ${entity.uniqueId})")
gearyMobs.bukkit2Geary.getOrCreate(entity)
}

Expand All @@ -35,15 +35,15 @@ class EntityWorldEventTracker : Listener {
// We remove the geary entity a bit later because paper has a bug where stored entities call load/unload/load
Bukkit.getScheduler().scheduleSyncDelayedTask(gearyPaper.plugin, {
if (entity.isValid) return@scheduleSyncDelayedTask // If the entity is still valid, it's the paper bug
geary.logger.d("EntityRemoveFromWorldEvent: Calling removeEntity for ${entity.toGearyOrNull()?.id} (${entity.type} ${entity.uniqueId})")
geary.logger.v("EntityRemoveFromWorldEvent: Calling removeEntity for ${entity.toGearyOrNull()?.id} (${entity.type} ${entity.uniqueId})")
entity.toGearyOrNull()?.removeEntity()
}, 10)
}

@EventHandler(priority = EventPriority.HIGHEST)
fun EntitiesUnloadEvent.onEntitiesUnload() {
if (entities.size != 0)
geary.logger.d("EntitiesUnloadEvent: Saving ${entities.size} entities in chunk...")
geary.logger.v("EntitiesUnloadEvent: Saving ${entities.size} entities in chunk...")
entities.forEach {
val gearyEntity = it.toGearyOrNull() ?: return@forEach
gearyEntity.encodeComponentsTo(it)
Expand All @@ -52,13 +52,13 @@ class EntityWorldEventTracker : Listener {

@EventHandler(priority = EventPriority.LOWEST)
fun PlayerJoinEvent.onPlayerLogin() {
geary.logger.d("PlayerJoinEvent: Track ${player.name}")
geary.logger.v("PlayerJoinEvent: Track ${player.name}")
gearyMobs.bukkit2Geary.getOrCreate(player)
}

@EventHandler(priority = EventPriority.HIGHEST)
fun PlayerQuitEvent.onPlayerLogout() {
geary.logger.d("PlayerQuitEvent: Untracking ${player.name}")
geary.logger.v("PlayerQuitEvent: Untracking ${player.name}")
val gearyEntity = player.toGearyOrNull() ?: return
gearyEntity.encodeComponentsTo(player)
gearyEntity.removeEntity()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract class PlayerItemCache<T>(

private fun removeEntity(slot: Int) {
val entity = entities[slot].takeIf { it != 0uL }?.toGeary() ?: return
logger.d("Removing ${entities[slot]} in slot $slot")
logger.v("Removing ${entities[slot]} in slot $slot")
val pdc = entity.get<ItemStack>()?.itemMeta?.persistentDataContainer
if (pdc != null) entity.encodeComponentsTo(pdc)
entity.removeEntity()
Expand Down Expand Up @@ -63,7 +63,7 @@ abstract class PlayerItemCache<T>(
entities[slot] = newEntity?.id ?: 0uL
if (holder != null) newEntity?.addParent(holder)
newEntity?.set<ItemStack>(convertToItemStack(item))
logger.d("Adding $newEntity (${newEntity?.prefabs?.map { it.get<PrefabKey>() }}) in slot $slot")
logger.v("Adding $newEntity (${newEntity?.prefabs?.map { it.get<PrefabKey>() }}) in slot $slot")
}

else -> removeEntity(slot)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ kotlin.code.style=official
group=com.mineinabyss
version=0.30
idofrontVersion=0.23.0
gearyVersion=0.26.0-dev.12
gearyVersion=0.26.0-dev.14

0 comments on commit 79eafec

Please sign in to comment.