Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2770eda
Add Dependabot config for Maven and GitHub Actions
CoderJoeW Mar 15, 2026
759d980
Update CI workflow action versions and JDK distribution
CoderJoeW Mar 15, 2026
3391f0b
Add code coverage workflow and JaCoCo plugin
CoderJoeW Mar 15, 2026
6108478
Add code quality workflow with Spotless formatting check
CoderJoeW Mar 15, 2026
5d71375
Explicitly set mock imports instead of using wildcard
CoderJoeW Mar 15, 2026
3aa3507
Explicitly set jupiter api imports instead of using wildcard
CoderJoeW Mar 15, 2026
64d3e72
Explicitly set jupiter api imports instead of using wildcard
CoderJoeW Mar 15, 2026
4b35549
formatting
CoderJoeW Mar 15, 2026
fe6acca
Refactor mock imports in GuideBookListenerTest for clarity and specif…
CoderJoeW Mar 15, 2026
f0f8ca4
Remove unused imports in GuideBookListenerTest for improved clarity
CoderJoeW Mar 15, 2026
afcf4d2
Refactor imports in test files for clarity and specificity
CoderJoeW Mar 15, 2026
0e4335b
Refactor imports in PowerNetworkIntegrationTest and SmallDrillMiningT…
CoderJoeW Mar 15, 2026
3834161
Refactor imports in MultiPowerCableTest for clarity and specificity
CoderJoeW Mar 15, 2026
abf5e56
Refactor imports in MultiPowerCableTest and PowerBlockLogicTest for c…
CoderJoeW Mar 15, 2026
1f5db99
Rename class PowerBlockRegistrationTest to PowerBlockInitializerTest …
CoderJoeW Mar 15, 2026
f82584a
Refactor imports in PowerBlockDialogTest and PowerBlockInitializerTes…
CoderJoeW Mar 15, 2026
a61f869
Refactor imports in CobblestoneFactoryTest for clarity and consistency
CoderJoeW Mar 15, 2026
41b4936
Refactor imports in test files for clarity and consistency
CoderJoeW Mar 15, 2026
60490b7
Refactor imports in AutoSmelterTest and PowerMergerTest for clarity a…
CoderJoeW Mar 15, 2026
3811932
Refactor offsets in PowerBlockRegistryTest for clarity and consistency
CoderJoeW Mar 15, 2026
d0bef73
Refactor imports and offsets in PowerBlockRegistryTest for clarity an…
CoderJoeW Mar 15, 2026
976d8be
Refactor code for consistency and clarity across multiple files
CoderJoeW Mar 15, 2026
5468009
Add code style guidelines for explicit imports in CLAUDE.md
CoderJoeW Mar 15, 2026
0a9e6f0
Add line length guideline to code style in CLAUDE.md
CoderJoeW Mar 15, 2026
f8056a1
Refactor code for improved readability and consistency across multipl…
CoderJoeW Mar 15, 2026
60886d1
Refactor logging statements for improved readability and consistency …
CoderJoeW Mar 15, 2026
9993b10
Refactor code for improved readability and consistency across multipl…
CoderJoeW Mar 15, 2026
1b59339
Refactor code for improved readability and consistency across multipl…
CoderJoeW Mar 15, 2026
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
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up JDK 21
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
distribution: 'corretto'
cache: maven

- name: Build and verify
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Code Coverage

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
coverage:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6

- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'corretto'
cache: maven

- name: Run tests with coverage
run: mvn test jacoco:report -B

- name: Upload coverage report
uses: actions/upload-artifact@v6
with:
name: coverage-report
path: target/site/jacoco/
24 changes: 24 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Code Quality

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
formatting:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6

- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'corretto'
cache: maven

- name: Check formatting
run: mvn spotless:check -B
5 changes: 5 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Atlas Project Instructions

## Code Style
- Always use explicit imports — never use wildcard imports (e.g., `import com.example.Foo`, not `import com.example.*`)
- No line should exceed 140 characters in length
63 changes: 63 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<kotlin.code.style>official</kotlin.code.style>
<kotlin.version>2.1.10</kotlin.version>
<java.version>21</java.version>
<jacoco.version>0.8.14</jacoco.version>
</properties>

<repositories>
Expand Down Expand Up @@ -99,6 +100,68 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<kotlin>
<ktlint>
<version>1.0.1</version>
</ktlint>
</kotlin>
<java>
<googleJavaFormat>
<version>1.19.1</version>
</googleJavaFormat>
</java>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<configuration>
<excludes>
<exclude>net/sf/jsqlparser/**</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>jacoco-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>PACKAGE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.0</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
92 changes: 52 additions & 40 deletions src/main/kotlin/com/coderjoe/atlas/Atlas.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package com.coderjoe.atlas

import com.coderjoe.atlas.core.AtlasBlockListener
import com.coderjoe.atlas.core.BlockSystem
import com.coderjoe.atlas.guide.GuideBook
import com.coderjoe.atlas.guide.GuideBookListener
import com.coderjoe.atlas.fluid.FluidBlockDialog
import com.coderjoe.atlas.fluid.FluidBlockFactory
import com.coderjoe.atlas.fluid.FluidBlockPersistence
import com.coderjoe.atlas.fluid.FluidBlockRegistry
import com.coderjoe.atlas.guide.GuideBook
import com.coderjoe.atlas.guide.GuideBookListener
import com.coderjoe.atlas.power.PowerBlockDialog
import com.coderjoe.atlas.power.PowerBlockFactory
import com.coderjoe.atlas.power.PowerBlockPersistence
Expand Down Expand Up @@ -57,51 +57,63 @@ class Atlas : JavaPlugin() {
initTransportSystem()

// Register unified listener
val powerSystem = BlockSystem<com.coderjoe.atlas.power.PowerBlock>(
name = "power",
registry = powerBlockRegistry,
factory = PowerBlockFactory,
descriptors = powerDescriptors(),
showDialog = { player, block ->
PowerBlockDialog.showPowerDialog(player, block as com.coderjoe.atlas.power.PowerBlock, powerBlockRegistry)
}
)

val fluidSystem = BlockSystem<com.coderjoe.atlas.fluid.FluidBlock>(
name = "fluid",
registry = fluidBlockRegistry,
factory = FluidBlockFactory,
descriptors = fluidDescriptors(),
showDialog = { player, block ->
FluidBlockDialog.showFluidDialog(player, block as com.coderjoe.atlas.fluid.FluidBlock, fluidBlockRegistry)
}
)

val transportSystem = BlockSystem<com.coderjoe.atlas.transport.TransportBlock>(
name = "transport",
registry = transportBlockRegistry,
factory = TransportBlockFactory,
descriptors = transportDescriptors(),
showDialog = { player, block ->
TransportBlockDialog.showTransportDialog(player, block as com.coderjoe.atlas.transport.TransportBlock, transportBlockRegistry)
}
)
val powerSystem =
BlockSystem<com.coderjoe.atlas.power.PowerBlock>(
name = "power",
registry = powerBlockRegistry,
factory = PowerBlockFactory,
descriptors = powerDescriptors(),
showDialog = { player, block ->
PowerBlockDialog.showPowerDialog(player, block as com.coderjoe.atlas.power.PowerBlock, powerBlockRegistry)
},
)

val fluidSystem =
BlockSystem<com.coderjoe.atlas.fluid.FluidBlock>(
name = "fluid",
registry = fluidBlockRegistry,
factory = FluidBlockFactory,
descriptors = fluidDescriptors(),
showDialog = { player, block ->
FluidBlockDialog.showFluidDialog(player, block as com.coderjoe.atlas.fluid.FluidBlock, fluidBlockRegistry)
},
)

val transportSystem =
BlockSystem<com.coderjoe.atlas.transport.TransportBlock>(
name = "transport",
registry = transportBlockRegistry,
factory = TransportBlockFactory,
descriptors = transportDescriptors(),
showDialog = { player, block ->
TransportBlockDialog.showTransportDialog(
player,
block as com.coderjoe.atlas.transport.TransportBlock,
transportBlockRegistry,
)
},
)

server.pluginManager.registerEvents(
AtlasBlockListener(this, listOf(powerSystem, fluidSystem, transportSystem)),
this
this,
)

val guideBookListener = GuideBookListener(this)
server.pluginManager.registerEvents(guideBookListener, this)
server.addRecipe(GuideBook.createRecipe(this))

// Auto-save every 5 minutes (6000 ticks)
autoSaveTask = server.scheduler.runTaskTimer(this, Runnable {
powerBlockPersistence.save(powerBlockRegistry)
fluidBlockPersistence.save(fluidBlockRegistry)
transportBlockPersistence.save(transportBlockRegistry)
}, 6000L, 6000L)
autoSaveTask =
server.scheduler.runTaskTimer(
this,
Runnable {
powerBlockPersistence.save(powerBlockRegistry)
fluidBlockPersistence.save(fluidBlockRegistry)
transportBlockPersistence.save(transportBlockRegistry)
},
6000L, 6000L,
)

logger.atlasInfo("Atlas plugin enabled!")
}
Expand Down Expand Up @@ -169,7 +181,7 @@ class Atlas : JavaPlugin() {

private fun transportDescriptors(): Map<String, com.coderjoe.atlas.core.BlockDescriptor> {
return listOf(
com.coderjoe.atlas.transport.block.ConveyorBelt.descriptor
com.coderjoe.atlas.transport.block.ConveyorBelt.descriptor,
).associateBy { it.baseBlockId }
}

Expand All @@ -184,7 +196,7 @@ class Atlas : JavaPlugin() {
com.coderjoe.atlas.power.block.MultiPowerCable.descriptor,
com.coderjoe.atlas.power.block.CobblestoneFactory.descriptor,
com.coderjoe.atlas.power.block.ObsidianFactory.descriptor,
com.coderjoe.atlas.power.block.PowerMerger.descriptor
com.coderjoe.atlas.power.block.PowerMerger.descriptor,
).associateBy { it.baseBlockId }
}

Expand All @@ -193,7 +205,7 @@ class Atlas : JavaPlugin() {
com.coderjoe.atlas.fluid.block.FluidPump.descriptor,
com.coderjoe.atlas.fluid.block.FluidPipe.descriptor,
com.coderjoe.atlas.fluid.block.FluidContainer.descriptor,
com.coderjoe.atlas.fluid.block.FluidMerger.descriptor
com.coderjoe.atlas.fluid.block.FluidMerger.descriptor,
).associateBy { it.baseBlockId }
}
}
5 changes: 4 additions & 1 deletion src/main/kotlin/com/coderjoe/atlas/NexoIntegration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ class NexoIntegration(private val plugin: JavaPlugin) {
}
}

private fun discoverResources(prefix: String, suffix: String): List<String> {
private fun discoverResources(
prefix: String,
suffix: String,
): List<String> {
val url = javaClass.classLoader.getResource(prefix) ?: return emptyList()

return when (url.protocol) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/com/coderjoe/atlas/PlayerJoinListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import org.bukkit.event.Listener
import org.bukkit.event.player.PlayerJoinEvent

class PlayerJoinListener(
private val resourcePackManager: ResourcePackManager
private val resourcePackManager: ResourcePackManager,
) : Listener {

@EventHandler
fun onPlayerJoin(event: PlayerJoinEvent) {
val player = event.player
Expand Down
30 changes: 15 additions & 15 deletions src/main/kotlin/com/coderjoe/atlas/ResourcePackManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ package com.coderjoe.atlas
import net.kyori.adventure.resource.ResourcePackInfo
import net.kyori.adventure.resource.ResourcePackRequest
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.format.NamedTextColor
import org.bukkit.entity.Player
import org.bukkit.plugin.java.JavaPlugin
import java.net.URI
import java.util.UUID

class ResourcePackManager(private val plugin: JavaPlugin) {

private var packInfo: ResourcePackInfo? = null
private var isRequired: Boolean = false
private var promptMessage: Component? = null
Expand Down Expand Up @@ -39,11 +37,12 @@ class ResourcePackManager(private val plugin: JavaPlugin) {
val packId = UUID.nameUUIDFromBytes(url.toByteArray())

try {
packInfo = ResourcePackInfo.resourcePackInfo()
.uri(URI.create(url))
.hash(hash)
.id(packId)
.build()
packInfo =
ResourcePackInfo.resourcePackInfo()
.uri(URI.create(url))
.hash(hash)
.id(packId)
.build()

if (prompt.isNotBlank()) {
promptMessage = Component.text(prompt)
Expand All @@ -58,14 +57,15 @@ class ResourcePackManager(private val plugin: JavaPlugin) {
fun sendToPlayer(player: Player) {
val info = packInfo ?: return

val request = ResourcePackRequest.resourcePackRequest()
.packs(info)
.required(isRequired)
.replace(true)
.apply {
promptMessage?.let { prompt(it) }
}
.build()
val request =
ResourcePackRequest.resourcePackRequest()
.packs(info)
.required(isRequired)
.replace(true)
.apply {
promptMessage?.let { prompt(it) }
}
.build()

player.sendResourcePacks(request)

Expand Down
Loading
Loading