Skip to content
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
21c0375
start guide
LordIdra Jun 3, 2025
fb1c5bf
continue guide
LordIdra Jun 4, 2025
0900f55
continue guide
LordIdra Jun 4, 2025
d62934d
Merge branch 'master' into add-pylon-guide
LordIdra Jun 4, 2025
a11c354
continue guide
LordIdra Jun 7, 2025
493d910
continue guide
LordIdra Jun 10, 2025
dbfc757
continue guide
LordIdra Jun 12, 2025
1cca467
Merge branch 'master' into add-pylon-guide
LordIdra Jun 12, 2025
9f04451
Merge branch 'random-stuff' into add-pylon-guide
LordIdra Jun 12, 2025
5ab59b3
continue guide
LordIdra Jun 12, 2025
f2f90a7
continue guide
LordIdra Jun 12, 2025
1bce44d
continue guide
LordIdra Jun 12, 2025
127855d
continue guide
LordIdra Jun 12, 2025
aa66357
continue guide, lord help
LordIdra Jun 13, 2025
01b68ba
*screaming*
LordIdra Jun 13, 2025
a71d022
continue guide
LordIdra Jun 15, 2025
cb301fc
Merge search pages and add guide commands as default
LordIdra Jun 15, 2025
a735dc0
Merge branch 'random-stuff' into add-pylon-guide
LordIdra Jun 15, 2025
4c1b74f
Update pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/recipe…
LordIdra Jun 18, 2025
add8519
yeet redundant comment
LordIdra Jun 18, 2025
31c771b
field -> static
LordIdra Jun 18, 2025
bf9bef1
use java string comparison library
LordIdra Jun 18, 2025
e0205c9
allow supressing addon name warnnigs
LordIdra Jun 18, 2025
a646866
Update pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/guide/…
LordIdra Jun 18, 2025
a942db1
Update pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/guide/…
LordIdra Jun 18, 2025
91a880c
Update pylon-core/src/main/resources/lang/enws.yml
LordIdra Jun 18, 2025
b5bc627
Update pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/i18n/P…
LordIdra Jun 18, 2025
81f80d5
Update pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/guide/…
LordIdra Jun 18, 2025
b0bd1f5
make public stuff private
LordIdra Jun 18, 2025
4f33685
remove .Companion
LordIdra Jun 18, 2025
142fa6d
use editData
LordIdra Jun 18, 2025
50fda63
Split researches into subcategories and allow hiding researches
LordIdra Jun 18, 2025
78caec1
fix item button for non translatable names
LordIdra Jun 19, 2025
914344f
Merge branch 'add-pylon-guide' of github.com:pylonmc/pylon-core into …
LordIdra Jun 19, 2025
e0f541a
Merge branch 'random-stuff' into add-pylon-guide
LordIdra Jun 19, 2025
a9b4583
seggan please fix this
LordIdra Jun 19, 2025
25d0385
fix merge error??
LordIdra Jun 19, 2025
7af2e7a
pr comments
LordIdra Jun 19, 2025
76e35df
make guide instruction arrows different color
LordIdra Jun 20, 2025
d49d698
Merge permissions for /py and /py guide
LordIdra Jun 20, 2025
3ac4c5c
Merge branch 'random-stuff' into add-pylon-guide
LordIdra Jun 22, 2025
013901b
Merge branch 'random-stuff' into add-pylon-guide
LordIdra Jun 28, 2025
78c943f
Merge branch 'master' into add-pylon-guide
LordIdra Jun 30, 2025
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
3 changes: 3 additions & 0 deletions pylon-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ plugins {
}

repositories {
mavenCentral()
maven("https://repo.xenondevs.xyz/releases") {
name = "InvUI"
}
Expand All @@ -28,6 +29,8 @@ dependencies {

runtimeOnly(project(":nms"))

implementation("info.debatty:java-string-similarity:2.0.0")

paperLibraryApi("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1")

compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ import io.github.pylonmc.pylon.core.debug.DebugWaxedWeatheredCutCopperStairs
import io.github.pylonmc.pylon.core.entity.EntityListener
import io.github.pylonmc.pylon.core.entity.EntityStorage
import io.github.pylonmc.pylon.core.entity.PylonEntity
import io.github.pylonmc.pylon.core.guide.PylonGuide
import io.github.pylonmc.pylon.core.i18n.AddonTranslator
import io.github.pylonmc.pylon.core.item.PylonItem
import io.github.pylonmc.pylon.core.item.PylonItemListener
import io.github.pylonmc.pylon.core.item.research.Research
import io.github.pylonmc.pylon.core.mobdrop.MobDropListener
import io.github.pylonmc.pylon.core.recipe.PylonRecipeListener
import io.github.pylonmc.pylon.core.recipe.RecipeType
import io.github.pylonmc.pylon.core.registry.PylonRegistry
import org.bukkit.Bukkit
import org.bukkit.Material
import org.bukkit.NamespacedKey
import org.bukkit.entity.BlockDisplay
import org.bukkit.plugin.java.JavaPlugin
Expand Down Expand Up @@ -50,6 +54,7 @@ object PylonCore : JavaPlugin(), PylonAddon {
Bukkit.getPluginManager().registerEvents(PylonGuiBlock, this)
Bukkit.getPluginManager().registerEvents(PylonEntityHolderBlock, this)
Bukkit.getPluginManager().registerEvents(PylonSimpleMultiblock, this)
Bukkit.getPluginManager().registerEvents(PylonRecipeListener, this)

Bukkit.getScheduler().runTaskTimer(
this,
Expand All @@ -72,12 +77,21 @@ object PylonCore : JavaPlugin(), PylonAddon {
registerWithPylon()

PylonItem.register(DebugWaxedWeatheredCutCopperStairs::class.java, DebugWaxedWeatheredCutCopperStairs.STACK)
PylonGuide.hideItem(DebugWaxedWeatheredCutCopperStairs.KEY)

PylonItem.register(PhantomBlock.ErrorItem::class.java, PhantomBlock.ErrorItem.STACK)
PylonGuide.hideItem(PhantomBlock.ErrorItem.KEY)

PylonItem.register(PylonGuide::class.java, PylonGuide.STACK)
PylonGuide.hideItem(PylonGuide.KEY)

PylonEntity.register(
PylonSimpleMultiblock.MultiblockGhostBlock.KEY,
BlockDisplay::class.java,
PylonSimpleMultiblock.MultiblockGhostBlock::class.java
)

RecipeType.addVanillaRecipes()
}

override fun onDisable() {
Expand All @@ -93,7 +107,7 @@ object PylonCore : JavaPlugin(), PylonAddon {

override val javaPlugin = this

override val displayName = "Core"
override val material = Material.BEDROCK

override val languages: Set<Locale> = setOf(
Locale.ENGLISH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ import io.github.pylonmc.pylon.core.PylonCore
import io.github.pylonmc.pylon.core.config.Config
import io.github.pylonmc.pylon.core.config.ConfigSection
import io.github.pylonmc.pylon.core.i18n.AddonTranslator
import io.github.pylonmc.pylon.core.item.builder.ItemStackBuilder
import io.github.pylonmc.pylon.core.registry.PylonRegistry
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.TranslatableComponent
import net.kyori.adventure.text.format.NamedTextColor
import net.kyori.adventure.text.format.TextDecoration
import org.bukkit.Keyed
import org.bukkit.Material
import org.bukkit.NamespacedKey
import org.bukkit.configuration.file.YamlConfiguration
import org.bukkit.inventory.ItemStack
import org.bukkit.plugin.java.JavaPlugin
import java.util.Locale

Expand All @@ -17,10 +24,12 @@ interface PylonAddon : Keyed {

val languages: Set<Locale>

/**
* The display name used, for example, at the bottom of items to show which addon an item is from
*/
val displayName: String
val material: Material

val displayName: TranslatableComponent
get() = Component.translatable("pylon.${key.namespace}.addon")
.decoration(TextDecoration.ITALIC, true)
.color(NamedTextColor.BLUE)

override fun getKey(): NamespacedKey
= NamespacedKey(javaPlugin, javaPlugin.name.lowercase())
Expand All @@ -31,6 +40,15 @@ interface PylonAddon : Keyed {
fun registerWithPylon() {
PylonRegistry.ADDONS.register(this)
AddonTranslator.register(this)

if (key !in addonNameWarningsSupressed) {
val translator = AddonTranslator.translators[this]!!
for (locale in languages) {
if (!translator.canTranslate("pylon.${key.namespace}.addon", locale)) {
PylonCore.logger.warning("${key.namespace} is missing the 'addon' translation key for ${locale.displayName}")
}
}
}
}

/**
Expand Down Expand Up @@ -65,4 +83,14 @@ interface PylonAddon : Keyed {
}
return config
}

companion object {

private val addonNameWarningsSupressed: MutableSet<NamespacedKey> = mutableSetOf()

@JvmStatic
fun supressAddonNameWarnings(key: NamespacedKey) {
addonNameWarningsSupressed.add(key)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import org.bukkit.event.inventory.BrewingStandFuelEvent
import org.bukkit.event.inventory.FurnaceBurnEvent
import org.bukkit.event.inventory.FurnaceExtractEvent
import org.bukkit.event.player.PlayerInteractEvent
import org.bukkit.event.player.PlayerTakeLecternBookEvent
import org.bukkit.event.player.PlayerToggleSneakEvent
import org.bukkit.event.player.PlayerTakeLecternBookEvent


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class PhantomBlock(
companion object {
val KEY = pylonKey("error_item")
val BLOCK_KEY = pylonKey("block")
val STACK = ItemStackBuilder.pylonItem(Material.BARRIER, key)
val STACK = ItemStackBuilder.pylonItem(Material.BARRIER, KEY)
.build()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import io.github.pylonmc.pylon.core.PylonCore
import io.github.pylonmc.pylon.core.block.BlockStorage
import io.github.pylonmc.pylon.core.block.waila.Waila.Companion.wailaEnabled
import io.github.pylonmc.pylon.core.debug.DebugWaxedWeatheredCutCopperStairs
import io.github.pylonmc.pylon.core.guide.PylonGuide
import io.github.pylonmc.pylon.core.i18n.PylonArgument
import io.github.pylonmc.pylon.core.item.research.Research
import io.github.pylonmc.pylon.core.item.research.Research.Companion.researchPoints
Expand Down Expand Up @@ -36,6 +37,38 @@ import org.jetbrains.annotations.ApiStatus
@ApiStatus.Internal
internal class PylonCommand : BaseCommand() {

@Default
@Description("Open the Pylon guide")
@CommandPermission("pylon.command.open_guide")
fun default(player: Player) {
PylonGuide.open(player)
}

init {
Bukkit.getPluginManager().addPermission(
Permission(
"pylon.command.open_guide",
PermissionDefault.TRUE
)
)
}

@Subcommand("guide")
@Description("Obtain the Pylon guide")
@CommandPermission("pylon.command.guide")
fun guide(player: Player) {
player.inventory.addItem(PylonGuide.STACK)
}

init {
Bukkit.getPluginManager().addPermission(
Permission(
"pylon.command.guide",
PermissionDefault.TRUE
)
)
}

@Subcommand("give")
@CommandCompletion("@players @items")
@Description("Give a Pylon item to a player")
Expand Down Expand Up @@ -223,9 +256,24 @@ internal class PylonCommand : BaseCommand() {
player.sendRichMessage("<red>Research not found: $research")
return
}
player.removeResearch(res)
val name = MiniMessage.miniMessage().serialize(res.name)
player.sendRichMessage("<green>Removed research $name from ${player.name}")
if (player.hasResearch(res)) {
player.removeResearch(res)
val name = MiniMessage.miniMessage().serialize(res.name)
player.sendRichMessage("<green>Removed research $name from ${player.name}")
} else {
player.sendRichMessage("<red>${player.name} does not have $name")
}
}

@Subcommand("removeall")
@CommandCompletion("@players")
@Description("Remove all researches from a player")
@CommandPermission("pylon.command.research.modify")
fun removeAll(p: OnlinePlayer) {
val player = p.player
for (research in player.researches) {
player.removeResearch(research)
}
}

@Subcommand("points")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.github.pylonmc.pylon.core.event

import io.github.pylonmc.pylon.core.registry.PylonRegistry
import org.bukkit.Keyed
import org.bukkit.event.Event
import org.bukkit.event.HandlerList

class PylonRegisterEvent(
val registry: PylonRegistry<*>,
val value: Keyed,
) : Event() {
override fun getHandlers(): HandlerList
= handlerList

companion object {
@JvmStatic
val handlerList: HandlerList = HandlerList()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.github.pylonmc.pylon.core.event

import io.github.pylonmc.pylon.core.registry.PylonRegistry
import org.bukkit.Keyed
import org.bukkit.event.Event
import org.bukkit.event.HandlerList

class PylonUnregisterEvent(
val registry: PylonRegistry<*>,
val value: Keyed,
) : Event() {
override fun getHandlers(): HandlerList
= handlerList

companion object {
@JvmStatic
val handlerList: HandlerList = HandlerList()
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package io.github.pylonmc.pylon.core.fluid

import io.github.pylonmc.pylon.core.PylonCore
import io.github.pylonmc.pylon.core.i18n.AddonTranslator
import io.github.pylonmc.pylon.core.item.builder.ItemStackBuilder
import io.github.pylonmc.pylon.core.registry.PylonRegistry
import io.github.pylonmc.pylon.core.util.key.getAddon
import net.kyori.adventure.text.Component
import org.bukkit.Keyed
import org.bukkit.Material
Expand All @@ -22,6 +26,18 @@ open class PylonFluid(

override fun getKey(): NamespacedKey = key

init {
val addon = PylonRegistry.ADDONS[NamespacedKey(key.namespace, key.namespace)]!!
val translator = AddonTranslator.translators[addon]!!

for (locale in addon.languages) {
val translationKey = "pylon.${key.namespace}.fluid.${key.key}"
check(translator.canTranslate(translationKey, locale)) {
PylonCore.logger.warning("${key.namespace} is missing a translation key for fluid ${key.key} (locale: ${locale.displayName} | expected translation key: $translationKey")
}
}
}

fun addTag(tag: PylonFluidTag) = apply {
check(!hasTag(tag.javaClass)) { "Fluid already has a tag of the same type" }
tags.add(tag)
Expand All @@ -46,6 +62,19 @@ open class PylonFluid(
PylonRegistry.FLUIDS.register(this)
}

fun getItem(): ItemStackBuilder {
val item = ItemStackBuilder.of(material)
.name(Component.translatable("pylon.${key.namespace}.fluid.${key.key}"))

for (tag in tags) {
item.lore(tag.displayText)
}

item.lore(getAddon(key).displayName)

return item
}

override fun equals(other: Any?): Boolean = other is PylonFluid && key == other.key
override fun hashCode(): Int = key.hashCode()
override fun toString(): String = key.toString()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.github.pylonmc.pylon.core.fluid

import net.kyori.adventure.text.Component

interface PylonFluidTag {
// TODO add text display methods once the guide is added
val displayText: Component
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package io.github.pylonmc.pylon.core.fluid.tags

import io.github.pylonmc.pylon.core.fluid.PylonFluidTag
import io.github.pylonmc.pylon.core.i18n.PylonArgument
import net.kyori.adventure.text.Component

enum class FluidTemperature : PylonFluidTag {
COLD,
NORMAL,
HOT;

val displayName: Component = Component.translatable("pylon.pyloncore.fluid.temperature.${this.name.lowercase()}")
val valueText: Component = Component.translatable("pylon.pyloncore.fluid.temperature.${this.name.lowercase()}")

override val displayText: Component = Component.translatable("pylon.pyloncore.fluid.temperature.display-text",
PylonArgument.of("temperature", valueText)
)
}
Loading
Loading