Skip to content

Commit

Permalink
Add stack size limit Challenge + entity item mode
Browse files Browse the repository at this point in the history
  • Loading branch information
MiraculixxT committed Jun 15, 2024
1 parent cd048f8 commit ee332f1
Show file tree
Hide file tree
Showing 15 changed files with 265 additions and 35 deletions.
16 changes: 15 additions & 1 deletion .github/assets/README-Modrinth.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ All challenges can be combined and played in multiplayer or singleplayer (some r
You have an idea for a new Challenge?
We would be happy to hear it in our [discord](https://dc.mutils.net)!

**▪ Current Challenge count**``67``
**▪ Current Challenge count**``68``

<!-- modrinth_exclude.start -->
> **Important**<br>
Expand Down Expand Up @@ -276,6 +276,20 @@ The world gone crazy and every few seconds the gravity switches between 4 new gr

🏷️ **Tags**
- `Medium` - Slightly more difficult than normal Minecraft but still very doable
</details><details><summary><b>MLG Challenge</b> ▪ <img src='https://mutils.net/images/mc/grab/items/water_bucket.png' width='18'></summary>
Once a while you are forced to perform a random MLG! Can you survive the fall?

---

⚙️ **Settings**
- `Delay` - Minimum and maximum duration between MLGs
- `Height` - Minimum and maximum height in blocks to perform the MLG
- `Hard MLGs` - Activate to perform the hardest MLGs. Only for skilled players!

🏷️ **Tags**
- `Hard` - Good for everyone searching a Challenge!

![Challenge Preview](https://cdn.modrinth.com/data/5fu9B7as/images/a8459259ae87fe5386a7206fa665784030a2ec98.gif)<br>*Currently requires full access*
</details><details><summary><b>Death Hunt</b> ▪ <img src='https://mutils.net/images/mc/grab/items/totem_of_undying.png' width='18'></summary>
Die to all given deaths in a specific order to finish! Use /deathhunt to modify

Expand Down
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ All challenges can be combined and played in multiplayer or singleplayer (some r
You have an idea for a new Challenge?
We would be happy to hear it in our [discord](https://dc.mutils.net)!

**▪ Current Challenge count**``67``
**▪ Current Challenge count**``68``

<!-- modrinth_exclude.start -->
> **Important**<br>
Expand Down Expand Up @@ -269,6 +269,20 @@ The world gone crazy and every few seconds the gravity switches between 4 new gr

🏷️ **Tags**
- `Medium` - Slightly more difficult than normal Minecraft but still very doable
</details><details><summary><b>MLG Challenge</b> ▪ <img src='https://mutils.net/images/mc/grab/items/water_bucket.png' width='18'></summary>
Once a while you are forced to perform a random MLG! Can you survive the fall?

---

⚙️ **Settings**
- `Delay` - Minimum and maximum duration between MLGs
- `Height` - Minimum and maximum height in blocks to perform the MLG
- `Hard MLGs` - Activate to perform the hardest MLGs. Only for skilled players!

🏷️ **Tags**
- `Hard` - Good for everyone searching a Challenge!

![Challenge Preview](https://cdn.modrinth.com/data/5fu9B7as/images/a8459259ae87fe5386a7206fa665784030a2ec98.gif)<br>*Currently requires full access*
</details><details><summary><b>Death Hunt</b> ▪ <img src='https://mutils.net/images/mc/grab/items/totem_of_undying.png' width='18'></summary>
Die to all given deaths in a specific order to finish! Use /deathhunt to modify

Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ dependencies {
// MC Libraries
implementation("de.miraculixx:mc-commons:1.0.1")
implementation("de.miraculixx:kpaper-light:1.2.1")
implementation("dev.jorel:commandapi-bukkit-shade-mojang-mapped:9.5.0-SNAPSHOT")
implementation("dev.jorel:commandapi-bukkit-kotlin:9.5.0-SNAPSHOT")
implementation("dev.jorel:commandapi-bukkit-shade-mojang-mapped:9.4.2")
implementation("dev.jorel:commandapi-bukkit-kotlin:9.4.2")
implementation("io.github.matyrobbrt:javanbt:0.0.3")

// Internal APIs
Expand Down
25 changes: 23 additions & 2 deletions data/challenges.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
[
{
"key": "STACK_LIMIT",
"version": 119,
"item": "bundle",
"tags": [
"HARD",
"FREE"
],
"settings": [
"limit"
],
"new": true,
"preview": "https://cdn.modrinth.com/data/5fu9B7as/images/f69cb41ee20d2e8f194676793a00d0379db5c4ff.gif"
},
{
"key": "MLG",
"version": 118,
"item": "water_bucket",
"tags": [
"HARD"
],
"new": true
"settings": [
"delay",
"height",
"hardMLGs"
],
"new": true,
"preview": "https://cdn.modrinth.com/data/5fu9B7as/images/a8459259ae87fe5386a7206fa665784030a2ec98.gif"
},
{
"key": "DEATH_HUNT",
Expand Down Expand Up @@ -567,7 +587,8 @@
"RANDOMIZER"
],
"settings": [
"random"
"random",
"itemMode"
]
},
{
Expand Down
11 changes: 11 additions & 0 deletions data/language/mchallenge/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@ items:
MLG:
n: "MLG Challenge"
l: "Once a while you are forced to perform<br>a random MLG! Can you survive the fall?"
STACK_LIMIT:
n: "Onestack (Stack limit)"
l: "You can only hold one item on each slot<br>in your inventory!<br>Can be modified up to 99 items"
chS:
FLY:
power:
Expand Down Expand Up @@ -526,6 +529,9 @@ items:
random:
n: "Full Random"
l: "Enabled: Each action is random,<br>Disabled: Same mob = same drop"
itemMode:
n: "Item Mode"
l: "Activate to randomize all items<br>except only mob drops"
RANDOMIZER_BIOMES:
random:
n: "Full Random"
Expand Down Expand Up @@ -819,6 +825,11 @@ items:
hardMLGs:
n: "Hard MLGs"
l: "Activate to perform the hardest<br>MLGs. Only for skilled players!"
STACK_LIMIT:
limit:
n: "Stack Limit"
l: "Amount of items that can be<br>hold in one slot"


tags:
FUN:
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kotlin.code.style=official

# Project Settings - set name in settings.gradle.kts
version=118
version=119
group=de.miraculixx
name=MChallenge
description=MUtils Challenges - Play various Challenges that can modify the game slightly to completely against or in coop with your friends!
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/de/miraculixx/mchallenge/MChallenge.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import de.miraculixx.mcommons.minorVersion
import de.miraculixx.mcommons.text.*
import dev.jorel.commandapi.CommandAPI
import dev.jorel.commandapi.CommandAPIBukkitConfig
import io.papermc.paper.command.brigadier.PluginVanillaCommandWrapper
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ import de.miraculixx.mchallenge.gui.buildInventory
import de.miraculixx.mchallenge.gui.items.ItemsChallenge
import de.miraculixx.mchallenge.gui.items.ItemsMenu
import de.miraculixx.mchallenge.modules.ChallengeManager
import de.miraculixx.mchallenge.modules.challenges.Challenges
import de.miraculixx.mchallenge.modules.challenges.challenges
import de.miraculixx.mchallenge.modules.challenges.resetSetting
import de.miraculixx.mchallenge.utils.UniversalChallenge
import de.miraculixx.mchallenge.utils.config.ConfigManager
import de.miraculixx.mchallenge.utils.config.ConfigManager.settings
import de.miraculixx.mchallenge.utils.getAccountStatus
import de.miraculixx.mcommons.extensions.enumOf
import de.miraculixx.mcommons.extensions.soundEnable
import de.miraculixx.mcommons.extensions.soundError
import de.miraculixx.mcommons.text.*
import dev.jorel.commandapi.arguments.ArgumentSuggestions
import dev.jorel.commandapi.arguments.LiteralArgument
import dev.jorel.commandapi.kotlindsl.*
import org.bukkit.Sound
Expand Down Expand Up @@ -140,7 +146,8 @@ class ChallengeCommand {
}
}

argument(LiteralArgument("settings").withPermission("mutils.command.settings")) {
literalArgument("settings") {
withPermission("mutils.command.settings")
literalArgument("debug") {
booleanArgument("active") {
anyExecutor { sender, args ->
Expand All @@ -151,6 +158,7 @@ class ChallengeCommand {
}
}
}

literalArgument("language") {
stringArgument("lang") {
anyExecutor { sender, args ->
Expand All @@ -163,6 +171,22 @@ class ChallengeCommand {
}
}
}

literalArgument("resetConfig") {
stringArgument("module") {
replaceSuggestions(ArgumentSuggestions.stringCollection { Challenges.entries.map { it.name } })
anyExecutor { sender, args ->
val module = args[0] as String
val challenge = enumOf<Challenges>(module)
if (challenge == null) {
sender.sendMessage(prefix + cmp("Invalid module: $module", cError))
return@anyExecutor
}
challenges.resetSetting(challenge)
sender.sendMessage(prefix + cmp("Successfully reset settings for $module", cSuccess))
}
}
}
}
}
}
39 changes: 36 additions & 3 deletions src/main/kotlin/de/miraculixx/mchallenge/commands/TestCommand.kt
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
package de.miraculixx.mchallenge.commands

import de.miraculixx.kpaper.extensions.server
import de.miraculixx.kpaper.scoreboard.createCustomScoreboard
import de.miraculixx.mcommons.text.cmp
import dev.jorel.commandapi.kotlindsl.*
import io.papermc.paper.scoreboard.numbers.NumberFormat
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.format.NamedTextColor
import net.minecraft.world.flag.FeatureFlagSet
import net.minecraft.world.flag.FeatureFlags
import org.bukkit.Bukkit
import org.bukkit.Material
import org.bukkit.World
import org.bukkit.WorldCreator
import org.bukkit.WorldType
import org.bukkit.block.data.BlockData
import org.bukkit.craftbukkit.CraftServer
import org.bukkit.inventory.ItemStack
import org.bukkit.scoreboard.Criteria
import org.bukkit.scoreboard.DisplaySlot
import org.bukkit.scoreboard.Objective
import org.bukkit.scoreboard.ScoreboardManager
import java.util.UUID

class TestCommand {
val command = commandTree("test") {
val command = commandTree("mtest") {
withPermission("mchallenge.command.mtest")

literalArgument("flat") {
blockStateArgument("block") {
playerExecutor { player, args ->
Expand All @@ -29,13 +41,34 @@ class TestCommand {
}
}

literalArgument("experimantal") {
literalArgument("experimental") {
playerExecutor { player, _ ->
val worldData = (server as CraftServer).handle.server.worldData
worldData.dataConfiguration = worldData.dataConfiguration.expandFeatures(FeatureFlagSet.of(FeatureFlags.UPDATE_1_21))
player.sendMessage("Experimental features enabled")
player.inventory.addItem(ItemStack(Material.WIND_CHARGE), ItemStack(Material.MACE))
}
}

literalArgument("scoreboard") {
fun Objective.setScore(score: Int, display: Component) {
val entry = getScore(score.toString()) // Get unique entry
entry.customName(display) // Apply name
entry.score = score // Apply score for ranking
entry.numberFormat(NumberFormat.blank()) // Hide score number
}

playerExecutor { player, _ ->
val myScoreboard = Bukkit.getScoreboardManager().newScoreboard
player.scoreboard = myScoreboard
val obj = myScoreboard.registerNewObjective("test", Criteria.DUMMY, cmp("Test Scoreboard"))
obj.displaySlot = DisplaySlot.SIDEBAR

// Display
repeat(17) { id ->
obj.setScore(id, cmp("Score $id"))
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ fun MutableMap<Challenges, ChallengeData>.getSetting(challenge: Challenges): Cha
ChallengeData(challenge.getDefaultSettings(), emptyMap(), false)
}
}

/**
* Reset the settings of a challenge
*/
fun MutableMap<Challenges, ChallengeData>.resetSetting(challenge: Challenges) {
challenges[challenge] = ChallengeData(challenge.getDefaultSettings(), emptyMap(), false)
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ enum class Challenges(val filter: Set<ChallengeTags>, val icon: Icon, val status
FLY(setOf(ChallengeTags.FUN, ChallengeTags.FREE), Icon("ELYTRA"), true),
GRAVITY(setOf(ChallengeTags.MEDIUM, ChallengeTags.FREE), Icon("SAND"), true),
HP_DRAIN(setOf(ChallengeTags.MEDIUM, ChallengeTags.FREE), Icon("SWEET_BERRIES"), true),
STACK_LIMIT(setOf(ChallengeTags.HARD, ChallengeTags.FREE), Icon("BUNDLE"), true),

COLLECT_BATTLE(setOf(ChallengeTags.FUN, ChallengeTags.FORCE), Icon("HEART_OF_THE_SEA")),
IN_TIME(setOf(ChallengeTags.MEDIUM), Icon("CLOCK")),
Expand Down Expand Up @@ -138,7 +139,12 @@ enum class Challenges(val filter: Set<ChallengeTags>, val icon: Icon, val status
)

RANDOMIZER_BLOCK -> mapOf("random" to ChallengeBoolSetting("DROPPER", false))
RANDOMIZER_ENTITY -> mapOf("random" to ChallengeBoolSetting("DROPPER", false))

RANDOMIZER_ENTITY -> mapOf(
"random" to ChallengeBoolSetting("DROPPER", false),
"itemMode" to ChallengeBoolSetting("CHEST", false),
)

RANDOMIZER_BIOMES -> mapOf("random" to ChallengeBoolSetting("DROPPER", false))
RANDOMIZER_MOBS -> mapOf("random" to ChallengeBoolSetting("DROPPER", false))
FORCE_COLLECT -> mapOf(
Expand Down Expand Up @@ -342,6 +348,10 @@ enum class Challenges(val filter: Set<ChallengeTags>, val icon: Icon, val status
),
"hardMLGs" to ChallengeBoolSetting("OAK_BOAT", true)
)

STACK_LIMIT -> mapOf(
"limit" to ChallengeIntSetting("BUNDLE", 1, max = 99, min = 1)
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import de.miraculixx.mchallenge.modules.mods.simple.fly.FLY
import de.miraculixx.mchallenge.modules.mods.simple.hpDrain.HPDrain
import de.miraculixx.mchallenge.modules.mods.simple.noDoubleKill.NoDoubleKills
import de.miraculixx.mchallenge.modules.mods.simple.rightTools.RightTools
import de.miraculixx.mchallenge.modules.mods.simple.stackLimit.StackLimit
import de.miraculixx.mchallenge.modules.mods.simple.stayAway.StayAway
import de.miraculixx.mchallenge.modules.mods.simple.tickRate.TickRateChanger
import de.miraculixx.mchallenge.modules.mods.worldChanging.blockWorld.BlockWorld
Expand Down Expand Up @@ -123,6 +124,7 @@ class StatusChanger {
Challenges.HP_DRAIN -> HPDrain()
Challenges.DEATH_HUNT -> DeathHunt()
Challenges.MLG -> MLGChallenge()
Challenges.STACK_LIMIT -> StackLimit()
}
}

Expand Down
Loading

0 comments on commit ee332f1

Please sign in to comment.