Skip to content

Commit 01d6069

Browse files
authored
Merge pull request #597 from pylonmc/idra/collimators-and-cargo-recipes
Cargo recipe stuff
2 parents f633c94 + a540ec7 commit 01d6069

File tree

4 files changed

+33
-31
lines changed

4 files changed

+33
-31
lines changed

rebar/src/main/kotlin/io/github/pylonmc/rebar/Rebar.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ object Rebar : JavaPlugin(), RebarAddon {
393393
val nsKey = NamespacedKey(namespace, key)
394394
val section = mainResearchConfig.getSection(key) ?: continue
395395

396-
Research.loadFromConfig(section, nsKey).register()
396+
Research.loadFromConfig(section, nsKey)?.register()
397397
}
398398
}
399399
}

rebar/src/main/kotlin/io/github/pylonmc/rebar/command/RebarCommand.kt

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ import io.papermc.paper.math.BlockPosition as PaperBlockPosition
5757
private val guide = buildCommand("guide") {
5858
permission("rebar.command.guide")
5959
executesWithPlayer { player ->
60-
RebarMetrics.onCommandRun("/re guide")
60+
RebarMetrics.onCommandRun("/rb guide")
6161
player.inventory.addItem(RebarGuide.STACK)
6262
}
6363
argument("players", ArgumentTypes.players()) {
6464
permission("rebar.command.guide.others")
6565
executes {
66-
RebarMetrics.onCommandRun("/re guide")
66+
RebarMetrics.onCommandRun("/rb guide")
6767
val players = getArgument<List<Player>>("players")
6868
for (player in players) {
6969
player.inventory.addItem(RebarGuide.STACK)
@@ -102,14 +102,14 @@ private val give = buildCommand("give") {
102102

103103
permission("rebar.command.give")
104104
executes {
105-
RebarMetrics.onCommandRun("/re give")
105+
RebarMetrics.onCommandRun("/rb give")
106106
givePlayers(this, 1)
107107
}
108108

109109
argument("amount", IntegerArgumentType.integer(1)) {
110110
permission("rebar.command.give")
111111
executes {
112-
RebarMetrics.onCommandRun("/re give")
112+
RebarMetrics.onCommandRun("/rb give")
113113
givePlayers(this, IntegerArgumentType.getInteger(this, "amount"))
114114
}
115115
}
@@ -120,7 +120,7 @@ private val give = buildCommand("give") {
120120
private val debug = buildCommand("debug") {
121121
permission("rebar.command.debug")
122122
executesWithPlayer { player ->
123-
RebarMetrics.onCommandRun("/re debug")
123+
RebarMetrics.onCommandRun("/rb debug")
124124
player.inventory.addItem(DebugWaxedWeatheredCutCopperStairs.STACK)
125125
player.sendVanillaFeedback("give.success.single", Component.text(1), DebugWaxedWeatheredCutCopperStairs.STACK.vanillaDisplayName(), player.name())
126126
}
@@ -129,7 +129,7 @@ private val debug = buildCommand("debug") {
129129
private val key = buildCommand("key") {
130130
permission("rebar.command.key")
131131
executesWithPlayer { player ->
132-
RebarMetrics.onCommandRun("/re key")
132+
RebarMetrics.onCommandRun("/rb key")
133133
val item = RebarItem.fromStack(player.inventory.getItem(EquipmentSlot.HAND))
134134
if (item == null) {
135135
player.sendFeedback("key.no_item")
@@ -146,7 +146,7 @@ private val setblock = buildCommand("setblock") {
146146
argument("block", RegistryCommandArgument(RebarRegistry.BLOCKS)) {
147147
permission("rebar.command.setblock")
148148
executes {
149-
RebarMetrics.onCommandRun("/re setblock")
149+
RebarMetrics.onCommandRun("/rb setblock")
150150
val location = getArgument<PaperBlockPosition>("pos").toLocation(source.location.world)
151151
if (!location.world.isPositionLoaded(location)) {
152152
source.sender.sendMessage(Component.translatable("argument.pos.unloaded"))
@@ -172,7 +172,7 @@ private val gametest = buildCommand("gametest") {
172172
argument("test", RegistryCommandArgument(RebarRegistry.GAMETESTS)) {
173173
permission("rebar.command.gametest")
174174
executesWithPlayer { player ->
175-
RebarMetrics.onCommandRun("/re gametest")
175+
RebarMetrics.onCommandRun("/rb gametest")
176176
val position = BlockPosition(getArgument<PaperBlockPosition>("pos").toLocation(player.world))
177177
val test = getArgument<GameTestConfig>("test")
178178
player.sendFeedback(
@@ -219,15 +219,15 @@ private val researchAdd = buildCommand("add") {
219219
permission("rebar.command.research.add")
220220
executes {
221221
// no confetti for all research otherwise server go big boom
222-
RebarMetrics.onCommandRun("/re research add")
222+
RebarMetrics.onCommandRun("/rb research add")
223223
addResearches(this, RebarRegistry.RESEARCHES.toList(), false)
224224
}
225225
}
226226

227227
argument("research", RegistryCommandArgument(RebarRegistry.RESEARCHES)) {
228228
permission("rebar.command.research.add")
229229
executes {
230-
RebarMetrics.onCommandRun("/re research add")
230+
RebarMetrics.onCommandRun("/rb research add")
231231
val res = getArgument<Research>("research")
232232
addResearches(this, listOf(res))
233233
}
@@ -254,7 +254,7 @@ private val researchList = buildCommand("list") {
254254
argument("player", ArgumentTypes.player()) {
255255
permission("rebar.command.research.list")
256256
executes { sender ->
257-
RebarMetrics.onCommandRun("/re research list")
257+
RebarMetrics.onCommandRun("/rb research list")
258258
val player = getArgument<Player>("player")
259259
listResearches(sender, player, "_other")
260260
}
@@ -281,15 +281,15 @@ private val researchRemove = buildCommand("remove") {
281281
literal("*") {
282282
permission("rebar.command.research.remove")
283283
executes {
284-
RebarMetrics.onCommandRun("/re research remove")
284+
RebarMetrics.onCommandRun("/rb research remove")
285285
removeResearches(this, RebarRegistry.RESEARCHES.toList())
286286
}
287287
}
288288

289289
argument("research", RegistryCommandArgument(RebarRegistry.RESEARCHES)) {
290290
permission("rebar.command.research.remove")
291291
executes {
292-
RebarMetrics.onCommandRun("/re research remove")
292+
RebarMetrics.onCommandRun("/rb research remove")
293293
val res = getArgument<Research>("research")
294294
removeResearches(this, listOf(res))
295295
}
@@ -302,7 +302,7 @@ private val researchPointsSet = buildCommand("set") {
302302
argument("points", LongArgumentType.longArg(0)) {
303303
permission("rebar.command.research.points.set")
304304
executes { sender ->
305-
RebarMetrics.onCommandRun("/re research points set")
305+
RebarMetrics.onCommandRun("/rb research points set")
306306
val points = getArgument<Long>("points")
307307
for (player in getArgument<List<Player>>("players")) {
308308
player.researchPoints = points
@@ -322,7 +322,7 @@ private val researchPointsAdd = buildCommand("add") {
322322
argument("points", LongArgumentType.longArg()) {
323323
permission("rebar.command.research.points.add")
324324
executes { sender ->
325-
RebarMetrics.onCommandRun("/re research points add")
325+
RebarMetrics.onCommandRun("/rb research points add")
326326
val points = getArgument<Long>("points")
327327
for (player in getArgument<List<Player>>("players")) {
328328
player.researchPoints += points
@@ -342,7 +342,7 @@ private val researchPointsSubtract = buildCommand("subtract") {
342342
argument("points", LongArgumentType.longArg()) {
343343
permission("rebar.command.research.points.subtract")
344344
executes { sender ->
345-
RebarMetrics.onCommandRun("/re research points subtract")
345+
RebarMetrics.onCommandRun("/rb research points subtract")
346346
val points = getArgument<Long>("points")
347347
for (player in getArgument<List<Player>>("players")) {
348348
player.researchPoints -= points
@@ -361,7 +361,7 @@ private val researchPointQuery = buildCommand("get") {
361361
argument("player", ArgumentTypes.player()) {
362362
permission("rebar.command.research.points.get")
363363
executes { sender ->
364-
RebarMetrics.onCommandRun("/re research points get")
364+
RebarMetrics.onCommandRun("/rb research points get")
365365
val player = getArgument<Player>("player")
366366
val points = player.researchPoints
367367
sender.sendFeedback(
@@ -392,7 +392,7 @@ private val exposeRecipeConfig = buildCommand("exposerecipeconfig") {
392392
argument("recipe", RegistryCommandArgument(RebarRegistry.RECIPE_TYPES)) {
393393
permission("rebar.command.exposerecipeconfig")
394394
executes { sender ->
395-
RebarMetrics.onCommandRun("/re exposerecipeconfig")
395+
RebarMetrics.onCommandRun("/rb exposerecipeconfig")
396396
val addon = getArgument<RebarAddon>("addon")
397397
val recipeType = getArgument<RecipeType<*>>("recipe")
398398
if (recipeType !is ConfigurableRecipeType) {
@@ -401,7 +401,7 @@ private val exposeRecipeConfig = buildCommand("exposerecipeconfig") {
401401
}
402402
sender.sendFeedback(
403403
"exposerecipe.warning",
404-
RebarArgument.of("file", "plugins/Rebar/${recipeType.filePath}")
404+
RebarArgument.of("file", "plugins/rbbar/${recipeType.filePath}")
405405
)
406406
mergeGlobalConfig(addon, recipeType.filePath, recipeType.filePath)
407407
}
@@ -413,19 +413,19 @@ private val confetti = buildCommand("confetti") {
413413
argument("amount", IntegerArgumentType.integer(1)) {
414414
permission("rebar.command.confetti")
415415
executesWithPlayer { player ->
416-
RebarMetrics.onCommandRun("/re confetti")
416+
RebarMetrics.onCommandRun("/rb confetti")
417417
ConfettiParticle.spawnMany(player.location, IntegerArgumentType.getInteger(this, "amount")).run()
418418
}
419419
argument("speed", DoubleArgumentType.doubleArg(0.0)) {
420420
permission("rebar.command.confetti")
421421
executesWithPlayer { player ->
422-
RebarMetrics.onCommandRun("/re confetti")
422+
RebarMetrics.onCommandRun("/rb confetti")
423423
ConfettiParticle.spawnMany(player.location, IntegerArgumentType.getInteger(this, "amount"), DoubleArgumentType.getDouble(this, "speed")).run()
424424
}
425425
argument("lifetime", IntegerArgumentType.integer(1)) {
426426
permission("rebar.command.confetti")
427427
executesWithPlayer { player ->
428-
RebarMetrics.onCommandRun("/re confetti")
428+
RebarMetrics.onCommandRun("/rb confetti")
429429
ConfettiParticle.spawnMany(
430430
player.location,
431431
IntegerArgumentType.getInteger(this, "amount"),
@@ -442,7 +442,7 @@ private val setphantom = buildCommand("setphantom") {
442442
argument("pos", ArgumentTypes.blockPosition()) {
443443
permission("rebar.command.setphantom")
444444
executes { sender ->
445-
RebarMetrics.onCommandRun("/re setphantom")
445+
RebarMetrics.onCommandRun("/rb setphantom")
446446
val position = getArgument<PaperBlockPosition>("pos").toLocation(source.location.world)
447447
if (!position.world.isPositionLoaded(position)) {
448448
source.sender.sendMessage(Component.translatable("argument.pos.unloaded"))
@@ -468,7 +468,7 @@ private val setphantom = buildCommand("setphantom") {
468468
internal val ROOT_COMMAND = buildCommand("rebar") {
469469
permission("rebar.command.guide")
470470
executesWithPlayer { player ->
471-
RebarMetrics.onCommandRun("/re")
471+
RebarMetrics.onCommandRun("/rb")
472472
RebarGuide.open(player)
473473
}
474474

@@ -485,7 +485,7 @@ internal val ROOT_COMMAND = buildCommand("rebar") {
485485
}
486486

487487
@JvmSynthetic
488-
internal val ROOT_COMMAND_RE_ALIAS = buildCommand("re") {
488+
internal val ROOT_COMMAND_RE_ALIAS = buildCommand("rb") {
489489
redirect(ROOT_COMMAND)
490490
}
491491

rebar/src/main/kotlin/io/github/pylonmc/rebar/item/builder/RebarMiniMessage.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import net.kyori.adventure.text.Component
88
import net.kyori.adventure.text.ComponentLike
99
import net.kyori.adventure.text.TextReplacementConfig
1010
import net.kyori.adventure.text.format.NamedTextColor
11+
import net.kyori.adventure.text.format.Style
1112
import net.kyori.adventure.text.format.TextColor
13+
import net.kyori.adventure.text.format.TextDecoration
1214
import net.kyori.adventure.text.minimessage.Context
1315
import net.kyori.adventure.text.minimessage.MiniMessage
1416
import net.kyori.adventure.text.minimessage.tag.Modifying
@@ -40,6 +42,7 @@ val customMiniMessage = MiniMessage.builder()
4042
it.tag("star", ::star)
4143
it.tag(setOf("instruction", "insn")) { _, _ -> Tag.styling(TextColor.color(0xf9d104)) }
4244
it.tag(setOf("guideinstruction", "guideinsn")) { _, _ -> Tag.styling(TextColor.color(0xc907f4)) }
45+
it.tag("story") { _, _ -> Tag.styling { builder -> builder.color(TextColor.color(0xcc9bf2)).decorate(TextDecoration.ITALIC) } }
4346
it.tag(setOf("attribute", "attr")) { _, _ -> Tag.styling(TextColor.color(0xa9d9e8)) }
4447
it.tag(setOf("unit", "u"), ::unit)
4548
// No break space

rebar/src/main/kotlin/io/github/pylonmc/rebar/item/research/Research.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ class Research(
301301

302302

303303
@JvmStatic
304-
fun loadFromConfig(section: ConfigSection, key : NamespacedKey) : Research {
304+
fun loadFromConfig(section: ConfigSection, key : NamespacedKey) : Research? {
305305

306306
try {
307307
val item = section.getOrThrow("item", ConfigAdapter.ITEM_STACK)
@@ -311,10 +311,9 @@ class Research(
311311

312312
return Research(key, item, Component.translatable(name), cost, unlocks)
313313
} catch (e: Exception) {
314-
throw IllegalArgumentException(
315-
"Failed to load research '$key' from config",
316-
e
317-
)
314+
Rebar.logger.severe("Failed to load research '$key' from config")
315+
e.printStackTrace()
316+
return null
318317
}
319318
}
320319
}

0 commit comments

Comments
 (0)