Skip to content

Commit

Permalink
Slimefun structure blocks!
Browse files Browse the repository at this point in the history
  • Loading branch information
Seggan committed Sep 20, 2024
1 parent 1b77fc4 commit 2c62add
Show file tree
Hide file tree
Showing 21 changed files with 676 additions and 92 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Galactifun2

This is a rewrite of [Galactifun](https://github.com/Slimefun-Addon-Community/Galactifun) in Kotlin. Also planning to redo the rocket system.
This is a rewrite of [Galactifun](https://github.com/Slimefun-Addon-Community/Galactifun) in Kotlin. Also planning to redo the rocket system.

## Credits

Big thanks to [minecraft-heads](https://minecraft-heads.com/) for providing the heads used in this plugin.

[![](https://images.minecraft-heads.com/banners/minecraft-heads_fullbanner_468x60.png)](https://minecraft-heads.com/)
13 changes: 8 additions & 5 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
plugins {
kotlin("jvm")
kotlin("plugin.serialization")
id("com.google.devtools.ksp") version "2.0.0-1.0.21"

id("com.github.johnrengelman.shadow") version "8.1.1"
id("com.gradleup.shadow") version "8.3.2"
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
id("xyz.jpenilla.run-paper") version "2.3.0"

Expand Down Expand Up @@ -44,12 +43,12 @@ dependencies {
implementation("org.bstats:bstats-bukkit:3.0.2")
implementation("co.aikar:acf-paper:0.5.1-SNAPSHOT")

implementation("io.github.seggan:sf4k:0.4.1")
implementation("io.github.seggan:sf4k:0.5.0")

testImplementation(kotlin("test"))
testImplementation("io.strikt:strikt-core:0.34.0")
testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.80.0")
testImplementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-test:2.14.0")
implementation("com.github.seeseemelk:MockBukkit-v1.20:3.93.2")
testImplementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-test:2.19.0")
}

group = "io.github.addoncommunity.galactifun"
Expand All @@ -74,6 +73,10 @@ tasks.test {
tasks.shadowJar {
dependsOn(tasks.test)

manifest {
attributes["paperweight-mappings-namespace"] = "mojang"
}

fun doRelocate(from: String) {
val last = from.split(".").last()
relocate(from, "io.github.addoncommunity.galactifun.shadowlibs.$last")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.withContext
import kotlinx.datetime.Instant
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.format.NamedTextColor
import net.kyori.adventure.text.format.Style
import net.kyori.adventure.text.format.TextDecoration
import org.bstats.bukkit.Metrics
import org.bukkit.Bukkit
import org.bukkit.Material
Expand Down Expand Up @@ -168,14 +165,6 @@ open class Galactifun2 : AbstractAddon() {
doTestingStuff()
}

override suspend fun onDisableAsync() {
Bukkit.getConsoleSender().sendMessage(
Component.text()
.content("YOU MAY SAFELY IGNORE THE COROUTINE CANCELLATION EXCEPTION BELOW, I HAVE NO IDEA HOW TO FIX IT")
.style(Style.style(NamedTextColor.GREEN, TextDecoration.BOLD))
)
}

override fun getJavaPlugin(): JavaPlugin = this

override fun getBugTrackerURL(): String = "https://github.com/Slimefun-Addon-Community/Galactifun2/issues"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.addoncommunity.galactifun.api.betteritem

import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType
Expand Down Expand Up @@ -120,6 +121,12 @@ open class BetterSlimefunItem : SlimefunItem {
}
}
}

protected fun <T : Any> itemSetting(key: String, default: T): ItemSetting<T> {
val setting = ItemSetting(this, key, default)
addItemSetting(setting)
return setting
}
}

private fun Class<*>.getAllMethods(): List<Method> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,10 @@ object GalactifunCategories {
MAIN,
CustomItemStack(Material.BONE_MEAL, "&fGases")
)

val HIDDEN = SubItemGroup(
"hidden".key(),
MAIN,
CustomItemStack(Material.BARRIER, "&fHidden")
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.github.addoncommunity.galactifun.impl

import io.github.addoncommunity.galactifun.util.items.MaterialType
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils

enum class GalactifunHeads(private val texture: String) {

// https://minecraft-heads.com/custom-heads/head/81364-floppy-disc-icon
FLOPPY_DISK("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTYyOWM4MTNlNTAxZjI0YmIyZjRjYTAyMWVlNTg2MmU0ZTIxNTgxODdmMzA3MjcyZWI2NWExZTY0ZDMwOTE0OCJ9fX0="),

// https://minecraft-heads.com/custom-heads/head/57245-file-explorer
FILE_EXPLORER("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzczZThiZDNjNDNjNDUxNGM3NjQ4MWNhMWRhZjU1MTQ5ZGZjOTNiZDFiY2ZhOGFiOTQzN2I5ZjdlYjMzOTJkOSJ9fX0="),

// https://minecraft-heads.com/custom-heads/head/94698-forest-green-l
LETTER_L("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmZhMDI5NjgyMjhkOWM0MDExZjAxMWRiNzAxZjJjNzUwZTRlYTZhZTJkM2E2MDM1NWJkZTdlNjgyMGVjZThmNyJ9fX0="),

// https://minecraft-heads.com/custom-heads/head/94709-forest-green-w
LETTER_W("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTZiZDJkZGMzZTFmYTdiY2I4YjZiYjViYTRmMGFlZWI4MjgzNDFlYWUwYTRkNzVmYzk4NWUzNzE5MWJkMGY1NCJ9fX0="),

// https://minecraft-heads.com/custom-heads/head/94694-forest-green-h
LETTER_H("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWRiMDJiMDQwYzM3MDE1ODkyYTNhNDNkM2IxYmZkYjJlMDFhMDJlZGNjMmY1YjgyMjUwZGNlYmYzZmY0ZjAxZSJ9fX0="),

// https://minecraft-heads.com/custom-heads/head/94710-forest-green-x
LETTER_X("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDZhZTIxMWI0NDAzYjg5NjNjNjc0NWYzYzk4ZWJlNzNhMmI0ZTk3YzQwYTc4YjJmZDQwM2EwOWMwZmNhZDZkIn19fQ=="),

// https://minecraft-heads.com/custom-heads/head/94711-forest-green-y
LETTER_Y("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTE5N2MwNjFjM2E1M2RmYTQ1ODMzZDgwYzM3Y2U4ZDEyYTVjMzZhMTViYmRlMjQ4OWZjYjFjYjMzYTJhZGZmOCJ9fX0="),

// https://minecraft-heads.com/custom-heads/head/94712-forest-green-z
LETTER_Z("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmEwOTg5NzVhNzI3ZTkyYmQ5YmM5OGIxY2JmMTQwZTdhNDFhOTkyZmU2NGNmYmI3MTk2ZTdkYmRhNDM0OTczIn19fQ=="),
;

val item = SlimefunUtils.getCustomHead(texture)
val materialType: MaterialType = MaterialType.Head(texture)
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package io.github.addoncommunity.galactifun.impl

import io.github.addoncommunity.galactifun.api.objects.properties.atmosphere.Gas
import io.github.addoncommunity.galactifun.impl.items.CaptainsChair
import io.github.addoncommunity.galactifun.impl.items.CommandComputer
import io.github.addoncommunity.galactifun.impl.items.FuelTank
import io.github.addoncommunity.galactifun.impl.items.RocketEngine
import io.github.addoncommunity.galactifun.impl.items.*
import io.github.addoncommunity.galactifun.pluginInstance
import io.github.addoncommunity.galactifun.units.Force.Companion.kilonewtons
import io.github.addoncommunity.galactifun.units.Volume.Companion.liters
Expand All @@ -17,6 +14,15 @@ import kotlin.time.Duration.Companion.seconds
@Suppress("unused")
object GalactifunItems {

val SLIMEFUN_STRUCTURE_BLOCK = buildSlimefunItem<SlimefunStructureBlock> {
category = GalactifunCategories.HIDDEN
id = "SLIMEFUN_STRUCTURE_BLOCK"
name = "<white>Slimefun Structure Block"
material = MaterialType.Material(Material.STRUCTURE_BLOCK)
recipeType = RecipeType.NULL
recipe = emptyArray()
}

val COMMAND_COMPUTER = buildSlimefunItem<CommandComputer> {
category = GalactifunCategories.ROCKET_COMPONENTS
id = "COMMAND_COMPUTER"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import io.github.addoncommunity.galactifun.impl.managers.RocketManager
import io.github.addoncommunity.galactifun.util.SerializedBlock
import io.github.addoncommunity.galactifun.util.bukkit.galactifunTeleport
import io.github.addoncommunity.galactifun.util.menu.PlanetMenu
import io.github.seggan.sf4k.location.plusAssign
import io.github.seggan.sf4k.extensions.plusAssign
import kotlinx.datetime.Clock
import org.bukkit.Location
import org.bukkit.entity.BlockDisplay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import io.github.addoncommunity.galactifun.units.times
import io.github.addoncommunity.galactifun.units.unitSumOf
import io.github.addoncommunity.galactifun.util.*
import io.github.addoncommunity.galactifun.util.bukkit.*
import io.github.seggan.sf4k.location.plus
import io.github.seggan.sf4k.location.position
import io.github.seggan.sf4k.extensions.plus
import io.github.seggan.sf4k.extensions.position
import io.github.seggan.sf4k.serial.blockstorage.getBlockStorage
import io.github.seggan.sf4k.serial.blockstorage.setBlockStorage
import io.github.seggan.sf4k.serial.pdc.get
Expand Down
Loading

0 comments on commit 2c62add

Please sign in to comment.