aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMy-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com>2021-08-15 00:12:53 -0400
committerMy-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com>2021-08-15 00:12:53 -0400
commitd684c34dd14c333de7f0cdf5f3d45bde2e4b7e28 (patch)
treef0af190d1b1e33bb25dd3bd552c554ea6671203e
parente12b9fd9acdd3fa237b696bc7dae969743a2b205 (diff)
downloadSkytilsMod-d684c34dd14c333de7f0cdf5f3d45bde2e4b7e28.tar.gz
SkytilsMod-d684c34dd14c333de7f0cdf5f3d45bde2e4b7e28.tar.bz2
SkytilsMod-d684c34dd14c333de7f0cdf5f3d45bde2e4b7e28.zip
add the formatted text thing
-rw-r--r--OPEN_SOURCE_SOFTWARE.md1
-rw-r--r--src/main/java/skytils/skytilsmod/mixins/transformers/gui/MixinGuiNewChat.java34
-rw-r--r--src/main/kotlin/skytils/skytilsmod/commands/CalcXPCommand.kt28
-rw-r--r--src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsLoadingPluginKt.kt34
-rw-r--r--src/main/resources/mixins.skytils.json1
5 files changed, 64 insertions, 34 deletions
diff --git a/OPEN_SOURCE_SOFTWARE.md b/OPEN_SOURCE_SOFTWARE.md
index 2883cf55..d24c13fd 100644
--- a/OPEN_SOURCE_SOFTWARE.md
+++ b/OPEN_SOURCE_SOFTWARE.md
@@ -6,7 +6,6 @@ Software | License
------------ | -------------
[Apache Commons Lang](https://github.com/apache/commons-lang) | [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt)
[awt-color-factory](https://github.com/beryx/awt-color-factory) | [GPL 2.0 with Classpath exception](https://github.com/beryx/awt-color-factory/blob/master/LICENSE#L347-L357)
-[ChatShortcuts](https://github.com/P0keDev/ChatShortcuts) | [MIT License](https://choosealicense.com/licenses/mit/)
[Danker's Skyblock Mod](https://github.com/bowser0000/SkyblockMod/) | [GPL 3.0](https://www.gnu.org/licenses/gpl-3.0-standalone.html)
[GSON](https://github.com/google/gson) | [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt)
[Minecraft Forge](https://github.com/MinecraftForge/MinecraftForge/tree/1.8.9) | [Minecraft Forge License](https://github.com/MinecraftForge/MinecraftForge/blob/1.8.9/MinecraftForge-License.txt)
diff --git a/src/main/java/skytils/skytilsmod/mixins/transformers/gui/MixinGuiNewChat.java b/src/main/java/skytils/skytilsmod/mixins/transformers/gui/MixinGuiNewChat.java
new file mode 100644
index 00000000..2306c687
--- /dev/null
+++ b/src/main/java/skytils/skytilsmod/mixins/transformers/gui/MixinGuiNewChat.java
@@ -0,0 +1,34 @@
+/*
+ * Skytils - Hypixel Skyblock Quality of Life Mod
+ * Copyright (C) 2021 Skytils
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package skytils.skytilsmod.mixins.transformers.gui;
+
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.GuiNewChat;
+import net.minecraft.util.IChatComponent;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+@Mixin(value = GuiNewChat.class, priority = 999)
+public class MixinGuiNewChat extends Gui {
+ @Redirect(method = "printChatMessageWithOptionalDeletion", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/IChatComponent;getUnformattedText()Ljava/lang/String;"))
+ private String printFormattedText(IChatComponent iChatComponent) {
+ return iChatComponent.getFormattedText();
+ }
+}
diff --git a/src/main/kotlin/skytils/skytilsmod/commands/CalcXPCommand.kt b/src/main/kotlin/skytils/skytilsmod/commands/CalcXPCommand.kt
index f194fe2f..44fc7b64 100644
--- a/src/main/kotlin/skytils/skytilsmod/commands/CalcXPCommand.kt
+++ b/src/main/kotlin/skytils/skytilsmod/commands/CalcXPCommand.kt
@@ -21,6 +21,7 @@ package skytils.skytilsmod.commands
import gg.essential.universal.UChat
import net.minecraft.command.ICommandSender
import net.minecraft.command.SyntaxErrorException
+import skytils.skytilsmod.utils.NumberUtil
import skytils.skytilsmod.utils.SkillUtils
object CalcXPCommand : BaseCommand("skytilscalcxp") {
@@ -28,25 +29,20 @@ object CalcXPCommand : BaseCommand("skytilscalcxp") {
override fun processCommand(sender: ICommandSender, args: Array<String>) {
if (args.size != 3) throw SyntaxErrorException("invalid arguments")
val type = args[0].lowercase()
- val starting = (args[1].toIntOrNull() ?: 0).inc()
- val ending = args[2].toIntOrNull() ?: 0
- val xp: Long
- when {
- type.endsWith("_slayer") -> {
- val slayer = SkillUtils.slayerXp[type.substringBefore("_slayer")] ?: return
- xp = (starting..ending).sumOf { slayer[it] ?: 0 }
- }
- type == "dungeons" -> {
- xp = (starting..ending).sumOf { SkillUtils.dungeoneeringXp[it] ?: 0 }
- }
- type == "skill" -> {
- xp = (starting..ending).sumOf { SkillUtils.skillXp[it] ?: 0 }
- }
+ var starting = (args[1].toIntOrNull() ?: 0).inc()
+ var ending = args[2].toIntOrNull() ?: 0
+ val xpMap = when {
+ type.endsWith("_slayer") -> SkillUtils.slayerXp[type.substringBefore("_slayer")]
+ type == "dungeons" -> SkillUtils.dungeoneeringXp
+ type == "skill" -> SkillUtils.skillXp
else -> {
- UChat.chat("§cThat skill is unknown to me!")
+ UChat.chat("§9§lSkytils ➜ §cThat skill is unknown to me!")
return
}
}
- UChat.chat("§bYou need §6$xp§b to get from §6$type§b level §6${starting.dec()}§b to level §6$ending§b!")
+ ending = ending.coerceIn(starting, xpMap?.keys?.last())
+ starting = starting.coerceIn(0, ending)
+ val xp = (starting.inc()..ending).sumOf { xpMap?.get(it) ?: 0 }
+ UChat.chat("§9§lSkytils ➜ §bYou need §6${NumberUtil.nf.format(xp)}§b to get from §6$type§b level §6${starting.dec()}§b to level §6$ending§b!")
}
} \ No newline at end of file
diff --git a/src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsLoadingPluginKt.kt b/src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsLoadingPluginKt.kt
index 67f370db..2139c1ec 100644
--- a/src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsLoadingPluginKt.kt
+++ b/src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsLoadingPluginKt.kt
@@ -64,23 +64,6 @@ class SkytilsLoadingPluginKt : IFMLLoadingPlugin {
}
}
- if (this::class.java.classLoader.getResource("patcher.mixins.json") == null && runCatching {
- Class.forName("club.sk1er.patcher.tweaker.other.ModClassTransformer")
- }.isSuccess) {
- val sk1erClubButton = createButton("Go to Sk1er.Club") {
- Desktop.getDesktop().browse(URL("https://sk1er.club/mods/patcher").toURI())
- }
- showMessage(
- """
- #Skytils has detected that you are using an old version of Patcher.
- #You must update Patcher in order for your game to launch.
- #You can do so at https://sk1er.club/mods/patcher
- #If you have already done this and are still getting this error,
- #ask for support in the Discord.
- """.trimMargin("#"), sk1erClubButton
- )
- SkytilsLoadingPlugin.exit()
- }
// Must use reflection otherwise the "constant" value will be inlined by compiler
val forgeVersion = runCatching {
ForgeVersion::class.java.getDeclaredField("buildVersion").get(null) as Int
@@ -127,6 +110,23 @@ class SkytilsLoadingPluginKt : IFMLLoadingPlugin {
forgeButton
)
}
+ if (this::class.java.classLoader.getResource("patcher.mixins.json") == null && Package.getPackages()
+ .any { it.name.startsWith("club.sk1er.patcher") }
+ ) {
+ val sk1erClubButton = createButton("Go to Sk1er.Club") {
+ Desktop.getDesktop().browse(URL("https://sk1er.club/mods/patcher").toURI())
+ }
+ showMessage(
+ """
+ #Skytils has detected that you are using an old version of Patcher.
+ #You must update Patcher in order for your game to launch.
+ #You can do so at https://sk1er.club/mods/patcher
+ #If you have already done this and are still getting this error,
+ #ask for support in the Discord.
+ """.trimMargin("#"), sk1erClubButton
+ )
+ SkytilsLoadingPlugin.exit()
+ }
}
}
diff --git a/src/main/resources/mixins.skytils.json b/src/main/resources/mixins.skytils.json
index 693da5e5..edf40766 100644
--- a/src/main/resources/mixins.skytils.json
+++ b/src/main/resources/mixins.skytils.json
@@ -25,6 +25,7 @@
"gui.MixinGuiContainer",
"gui.MixinGuiIngame",
"gui.MixinGuiIngameForge",
+ "gui.MixinGuiNewChat",
"gui.MixinGuiScreen",
"inventory.MixinSlot",
"item.MixinItemArmor",