Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions run-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ cat > "$SERVER_DIR/plugins/Atlas/config.yml" << EOF
# Atlas Plugin Configuration (auto-generated for testing)
# Resource pack is disabled because Nexo handles resource pack generation and hosting

logging: false

resource-pack:
enabled: false
url: ""
Expand Down
12 changes: 7 additions & 5 deletions src/main/kotlin/com/coderjoe/atlas/Atlas.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ class Atlas : JavaPlugin() {
dataFolder.mkdirs()
}

AtlasConfig.load(this)

nexoIntegration = NexoIntegration(this)
nexoIntegration.initialize()

resourcePackManager = ResourcePackManager(this)
resourcePackManager.load()

if (resourcePackManager.isConfigured()) {
logger.info("Resource pack is configured and will be sent to players on join")
logger.atlasInfo("Resource pack is configured and will be sent to players on join")
server.pluginManager.registerEvents(PlayerJoinListener(resourcePackManager), this)
}

Expand Down Expand Up @@ -76,7 +78,7 @@ class Atlas : JavaPlugin() {
fluidBlockPersistence.save(fluidBlockRegistry)
}, 6000L, 6000L)

logger.info("Atlas plugin enabled!")
logger.atlasInfo("Atlas plugin enabled!")
}

override fun onDisable() {
Expand All @@ -101,7 +103,7 @@ class Atlas : JavaPlugin() {
fluidBlockRegistry.stopAll()
}

logger.info("Atlas plugin has been disabled!")
logger.atlasInfo("Atlas plugin has been disabled!")
}

fun initPowerSystem() {
Expand All @@ -110,7 +112,7 @@ class Atlas : JavaPlugin() {
powerBlockPersistence = PowerBlockPersistence(this)
powerBlockPersistence.load(powerBlockRegistry)

logger.info("Power system initialized with ${PowerBlockFactory.getRegisteredBlockIds().size} block types")
logger.atlasInfo("Power system initialized with ${PowerBlockFactory.getRegisteredBlockIds().size} block types")
}

fun initFluidSystem() {
Expand All @@ -119,7 +121,7 @@ class Atlas : JavaPlugin() {
fluidBlockPersistence = FluidBlockPersistence(this)
fluidBlockPersistence.load(fluidBlockRegistry)

logger.info("Fluid system initialized with ${FluidBlockFactory.getRegisteredBlockIds().size} block types")
logger.atlasInfo("Fluid system initialized with ${FluidBlockFactory.getRegisteredBlockIds().size} block types")
}

private fun powerDescriptors(): Map<String, com.coderjoe.atlas.core.BlockDescriptor> {
Expand Down
20 changes: 20 additions & 0 deletions src/main/kotlin/com/coderjoe/atlas/AtlasConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.coderjoe.atlas

import org.bukkit.plugin.java.JavaPlugin
import java.util.logging.Logger

object AtlasConfig {
var loggingEnabled: Boolean = true
private set

fun load(plugin: JavaPlugin) {
plugin.saveDefaultConfig()
loggingEnabled = plugin.config.getBoolean("logging", true)
}
}

fun Logger.atlasInfo(message: String) {
if (AtlasConfig.loggingEnabled) {
info(message)
}
}
8 changes: 4 additions & 4 deletions src/main/kotlin/com/coderjoe/atlas/NexoIntegration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class NexoIntegration(private val plugin: JavaPlugin) {
copyItemConfigurations()
copyTextures()
copyRecipes()
plugin.logger.info("Atlas Nexo integration initialized")
plugin.logger.atlasInfo("Atlas Nexo integration initialized")
}

private fun copyItemConfigurations() {
Expand All @@ -29,7 +29,7 @@ class NexoIntegration(private val plugin: JavaPlugin) {
if (sourceFile.exists()) {
sourceFile.copyTo(targetFile, overwrite = true)
sourceFile.delete()
plugin.logger.info("Copied Atlas block configurations to Nexo")
plugin.logger.atlasInfo("Copied Atlas block configurations to Nexo")
}
}

Expand All @@ -50,7 +50,7 @@ class NexoIntegration(private val plugin: JavaPlugin) {
if (sourceFile.exists()) {
sourceFile.copyTo(textureFile, overwrite = true)
sourceFile.delete()
plugin.logger.info("Copied ${fileName.removeSuffix(".png")} texture to Nexo")
plugin.logger.atlasInfo("Copied ${fileName.removeSuffix(".png")} texture to Nexo")
}
}
}
Expand Down Expand Up @@ -90,7 +90,7 @@ class NexoIntegration(private val plugin: JavaPlugin) {
if (sourceFile.exists()) {
sourceFile.copyTo(targetFile, overwrite = true)
sourceFile.delete()
plugin.logger.info("Copied Atlas recipes to Nexo")
plugin.logger.atlasInfo("Copied Atlas recipes to Nexo")
}
}
}
6 changes: 3 additions & 3 deletions src/main/kotlin/com/coderjoe/atlas/ResourcePackManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ResourcePackManager(private val plugin: JavaPlugin) {

val enabled = config.getBoolean("resource-pack.enabled", false)
if (!enabled) {
plugin.logger.info("Resource pack is disabled in config")
plugin.logger.atlasInfo("Resource pack is disabled in config")
return
}

Expand Down Expand Up @@ -49,7 +49,7 @@ class ResourcePackManager(private val plugin: JavaPlugin) {
promptMessage = Component.text(prompt)
}

plugin.logger.info("Resource pack configured: $url")
plugin.logger.atlasInfo("Resource pack configured: $url")
} catch (e: Exception) {
plugin.logger.severe("Failed to configure resource pack: ${e.message}")
}
Expand All @@ -69,7 +69,7 @@ class ResourcePackManager(private val plugin: JavaPlugin) {

player.sendResourcePacks(request)

plugin.logger.info("Sent resource pack to ${player.name}")
plugin.logger.atlasInfo("Sent resource pack to ${player.name}")
}

fun isConfigured(): Boolean = packInfo != null
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/com/coderjoe/atlas/core/AtlasBlock.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.coderjoe.atlas.core

import com.coderjoe.atlas.Atlas
import com.coderjoe.atlas.atlasInfo
import com.nexomc.nexo.api.NexoBlocks
import org.bukkit.Location
import org.bukkit.Material
Expand Down Expand Up @@ -60,12 +61,12 @@ abstract class AtlasBlock(
}
}, updateIntervalTicks, updateIntervalTicks)

plugin.logger.info("${this::class.simpleName} at ${location.blockX},${location.blockY},${location.blockZ} started")
plugin.logger.atlasInfo("${this::class.simpleName} at ${location.blockX},${location.blockY},${location.blockZ} started")
}

fun stop() {
updateTask?.cancel()
updateTask = null
plugin.logger.info("${this::class.simpleName} at ${location.blockX},${location.blockY},${location.blockZ} stopped")
plugin.logger.atlasInfo("${this::class.simpleName} at ${location.blockX},${location.blockY},${location.blockZ} stopped")
}
}
11 changes: 6 additions & 5 deletions src/main/kotlin/com/coderjoe/atlas/core/BlockPersistence.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.coderjoe.atlas.core

import com.coderjoe.atlas.atlasInfo
import org.bukkit.Location
import org.bukkit.block.BlockFace
import org.bukkit.configuration.file.YamlConfiguration
Expand All @@ -20,7 +21,7 @@ class BlockPersistence<T : AtlasBlock>(
val config = YamlConfiguration()
val blocksWithIds = registry.getAllBlocksWithIds()

plugin.logger.info("Saving ${blocksWithIds.size} blocks to $fileName...")
plugin.logger.atlasInfo("Saving ${blocksWithIds.size} blocks to $fileName...")

val blockDataList = mutableListOf<Map<String, Any>>()

Expand All @@ -44,7 +45,7 @@ class BlockPersistence<T : AtlasBlock>(

try {
config.save(dataFile)
plugin.logger.info("Successfully saved ${blockDataList.size} blocks to $fileName")
plugin.logger.atlasInfo("Successfully saved ${blockDataList.size} blocks to $fileName")
} catch (e: Exception) {
plugin.logger.severe("Failed to save blocks to $fileName: ${e.message}")
e.printStackTrace()
Expand All @@ -53,14 +54,14 @@ class BlockPersistence<T : AtlasBlock>(

fun load(registry: BlockRegistry<T>) {
if (!dataFile.exists()) {
plugin.logger.info("No $fileName data file found, starting fresh")
plugin.logger.atlasInfo("No $fileName data file found, starting fresh")
return
}

val config = YamlConfiguration.loadConfiguration(dataFile)
val blockDataList = config.getMapList(yamlKey)

plugin.logger.info("Loading ${blockDataList.size} blocks from $fileName...")
plugin.logger.atlasInfo("Loading ${blockDataList.size} blocks from $fileName...")

var loadedCount = 0
var failedCount = 0
Expand Down Expand Up @@ -104,6 +105,6 @@ class BlockPersistence<T : AtlasBlock>(
}
}

plugin.logger.info("Loaded $loadedCount blocks from $fileName, $failedCount failed")
plugin.logger.atlasInfo("Loaded $loadedCount blocks from $fileName, $failedCount failed")
}
}
7 changes: 4 additions & 3 deletions src/main/kotlin/com/coderjoe/atlas/core/BlockRegistry.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.coderjoe.atlas.core

import com.coderjoe.atlas.atlasInfo
import org.bukkit.Location
import org.bukkit.block.BlockFace
import org.bukkit.plugin.java.JavaPlugin
Expand All @@ -21,7 +22,7 @@ open class BlockRegistry<T : AtlasBlock>(protected val plugin: JavaPlugin) {
blocks[key] = block
blockIds[key] = blockId
block.start()
plugin.logger.info("Registered ${block::class.simpleName} at ${block.location.blockX},${block.location.blockY},${block.location.blockZ}")
plugin.logger.atlasInfo("Registered ${block::class.simpleName} at ${block.location.blockX},${block.location.blockY},${block.location.blockZ}")
}

fun unregister(location: Location): T? {
Expand All @@ -30,7 +31,7 @@ open class BlockRegistry<T : AtlasBlock>(protected val plugin: JavaPlugin) {
blockIds.remove(key)
block?.stop()
if (block != null) {
plugin.logger.info("Unregistered ${block::class.simpleName} at ${location.blockX},${location.blockY},${location.blockZ}")
plugin.logger.atlasInfo("Unregistered ${block::class.simpleName} at ${location.blockX},${location.blockY},${location.blockZ}")
}
return block
}
Expand Down Expand Up @@ -71,7 +72,7 @@ open class BlockRegistry<T : AtlasBlock>(protected val plugin: JavaPlugin) {
}

fun stopAll() {
plugin.logger.info("Stopping ${blocks.size} blocks...")
plugin.logger.atlasInfo("Stopping ${blocks.size} blocks...")
blocks.values.forEach { it.stop() }
blocks.clear()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.coderjoe.atlas.fluid.block

import com.coderjoe.atlas.atlasInfo
import com.coderjoe.atlas.core.BlockDescriptor
import com.coderjoe.atlas.core.PlacementType
import com.coderjoe.atlas.fluid.FluidBlock
Expand Down Expand Up @@ -133,7 +134,7 @@ class FluidContainer(location: Location, override val facing: BlockFace) : Fluid
if (source.canRemoveFluidFrom(facing)) {
val fluid = source.removeFluid()
if (storeFluid(fluid)) {
plugin.logger.info("FluidContainer at ${location.blockX},${location.blockY},${location.blockZ} pulled ${fluid.name} from FluidPump")
plugin.logger.atlasInfo("FluidContainer at ${location.blockX},${location.blockY},${location.blockZ} pulled ${fluid.name} from FluidPump")
} else {
source.storeFluid(fluid)
}
Expand All @@ -143,7 +144,7 @@ class FluidContainer(location: Location, override val facing: BlockFace) : Fluid
if (source.hasFluid()) {
val fluid = source.removeFluid()
if (storeFluid(fluid)) {
plugin.logger.info("FluidContainer at ${location.blockX},${location.blockY},${location.blockZ} pulled ${fluid.name} from FluidPipe")
plugin.logger.atlasInfo("FluidContainer at ${location.blockX},${location.blockY},${location.blockZ} pulled ${fluid.name} from FluidPipe")
} else {
source.storeFluid(fluid)
}
Expand All @@ -153,7 +154,7 @@ class FluidContainer(location: Location, override val facing: BlockFace) : Fluid
if (source.canRemoveFluidFrom(facing)) {
val fluid = source.removeFluid()
if (storeFluid(fluid)) {
plugin.logger.info("FluidContainer at ${location.blockX},${location.blockY},${location.blockZ} pulled ${fluid.name} from FluidContainer")
plugin.logger.atlasInfo("FluidContainer at ${location.blockX},${location.blockY},${location.blockZ} pulled ${fluid.name} from FluidContainer")
} else {
source.storeFluid(fluid)
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/kotlin/com/coderjoe/atlas/fluid/block/FluidPipe.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.coderjoe.atlas.fluid.block

import com.coderjoe.atlas.atlasInfo
import com.coderjoe.atlas.core.BlockDescriptor
import com.coderjoe.atlas.core.PlacementType
import com.coderjoe.atlas.fluid.FluidBlock
Expand Down Expand Up @@ -77,21 +78,21 @@ class FluidPipe(location: Location, override val facing: BlockFace) : FluidBlock
if (source.canRemoveFluidFrom(facing)) {
val fluid = source.removeFluid()
storeFluid(fluid)
plugin.logger.info("FluidPipe at ${location.blockX},${location.blockY},${location.blockZ} pulled ${fluid.name} from FluidPump")
plugin.logger.atlasInfo("FluidPipe at ${location.blockX},${location.blockY},${location.blockZ} pulled ${fluid.name} from FluidPump")
}
}
is FluidPipe -> {
if (source.hasFluid()) {
val fluid = source.removeFluid()
storeFluid(fluid)
plugin.logger.info("FluidPipe at ${location.blockX},${location.blockY},${location.blockZ} pulled ${fluid.name} from FluidPipe")
plugin.logger.atlasInfo("FluidPipe at ${location.blockX},${location.blockY},${location.blockZ} pulled ${fluid.name} from FluidPipe")
}
}
is FluidContainer -> {
if (source.canRemoveFluidFrom(facing)) {
val fluid = source.removeFluid()
storeFluid(fluid)
plugin.logger.info("FluidPipe at ${location.blockX},${location.blockY},${location.blockZ} pulled ${fluid.name} from FluidContainer")
plugin.logger.atlasInfo("FluidPipe at ${location.blockX},${location.blockY},${location.blockZ} pulled ${fluid.name} from FluidContainer")
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/com/coderjoe/atlas/fluid/block/FluidPump.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.coderjoe.atlas.fluid.block

import com.coderjoe.atlas.atlasInfo
import com.coderjoe.atlas.core.BlockDescriptor
import com.coderjoe.atlas.core.PlacementType
import com.coderjoe.atlas.fluid.FluidBlock
Expand Down Expand Up @@ -138,6 +139,6 @@ class FluidPump(location: Location) : FluidBlock(location) {
storeFluid(fluidType)
cauldronFace = foundFace
pumpStatus = PumpStatus.EXTRACTING
plugin.logger.info("FluidPump at ${location.blockX},${location.blockY},${location.blockZ} extracted ${fluidType.name} from $foundFace")
plugin.logger.atlasInfo("FluidPump at ${location.blockX},${location.blockY},${location.blockZ} extracted ${fluidType.name} from $foundFace")
}
}
3 changes: 2 additions & 1 deletion src/main/kotlin/com/coderjoe/atlas/power/block/PowerCable.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.coderjoe.atlas.power.block

import com.coderjoe.atlas.atlasInfo
import com.coderjoe.atlas.core.BlockDescriptor
import com.coderjoe.atlas.core.PlacementType
import com.coderjoe.atlas.power.PowerBlock
Expand Down Expand Up @@ -64,7 +65,7 @@ class PowerCable(location: Location, override val facing: BlockFace) : PowerBloc
val pulled = source.removePower(1)
if (pulled > 0) {
addPower(pulled)
plugin.logger.info("PowerCable at ${location.blockX},${location.blockY},${location.blockZ} pulled $pulled power from ${source::class.simpleName} (now $currentPower/$maxStorage)")
plugin.logger.atlasInfo("PowerCable at ${location.blockX},${location.blockY},${location.blockZ} pulled $pulled power from ${source::class.simpleName} (now $currentPower/$maxStorage)")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.coderjoe.atlas.power.block

import com.coderjoe.atlas.atlasInfo
import com.coderjoe.atlas.core.BlockDescriptor
import com.coderjoe.atlas.core.PlacementType
import com.coderjoe.atlas.power.PowerBlock
Expand Down Expand Up @@ -60,7 +61,7 @@ class SmallBattery(location: Location, facing: BlockFace) : PowerBlock(location,
val pulled = source.removePower(1)
if (pulled > 0) {
addPower(pulled)
plugin.logger.info("SmallBattery at ${location.blockX},${location.blockY},${location.blockZ} pulled $pulled power from ${source::class.simpleName} (now $currentPower/$maxStorage)")
plugin.logger.atlasInfo("SmallBattery at ${location.blockX},${location.blockY},${location.blockZ} pulled $pulled power from ${source::class.simpleName} (now $currentPower/$maxStorage)")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.coderjoe.atlas.power.block

import com.coderjoe.atlas.atlasInfo
import com.coderjoe.atlas.core.BlockDescriptor
import com.coderjoe.atlas.core.PlacementType
import com.coderjoe.atlas.power.PowerBlock
Expand Down Expand Up @@ -39,10 +40,10 @@ class SmallSolarPanel(location: Location): PowerBlock(location, maxStorage = 1)
if (isDaytime) {
val generated = addPower(1)
if (generated > 0) {
plugin.logger.info("SmallSolarPanel at ${location.blockX},${location.blockY},${location.blockZ} generated $generated power (now $currentPower/$maxStorage)")
plugin.logger.atlasInfo("SmallSolarPanel at ${location.blockX},${location.blockY},${location.blockZ} generated $generated power (now $currentPower/$maxStorage)")
}
} else {
plugin.logger.info("SmallSolarPanel at ${location.blockX},${location.blockY},${location.blockZ} is not generating power because it is not daytime.")
plugin.logger.atlasInfo("SmallSolarPanel at ${location.blockX},${location.blockY},${location.blockZ} is not generating power because it is not daytime.")
}

// TODO: Implement power transfer to connected blocks
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Atlas Plugin Configuration

# Enable or disable plugin logging (warnings and errors are always shown)
logging: false

resource-pack:
# Enable or disable resource pack distribution
enabled: false
Expand Down