Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/not-your-order-or-auction' into …
Browse files Browse the repository at this point in the history
…not-your-order-or-auction
  • Loading branch information
RayDeeUx committed Feb 9, 2024
2 parents 6ca627a + 5afc944 commit 784022f
Show file tree
Hide file tree
Showing 62 changed files with 1,013 additions and 611 deletions.
20 changes: 10 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.security.MessageDigest

plugins {
kotlin("jvm") version "1.9.20"
kotlin("plugin.serialization") version "1.9.20"
kotlin("jvm") version "1.9.21"
kotlin("plugin.serialization") version "1.9.21"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("net.kyori.blossom") version "2.0.0"
id("io.github.juuxel.loom-quiltflower") version "1.10.0"
Expand All @@ -34,7 +34,7 @@ plugins {
signing
}

version = "1.8.0-pre12"
version = "1.8.1"
group = "gg.skytils"

repositories {
Expand Down Expand Up @@ -96,13 +96,6 @@ dependencies {
exclude(module = "gson")
}

shadowMeMod("com.github.Skytils:Hylin:3ad11efbc1") {
exclude(module = "kotlin-reflect")
exclude(module = "kotlin-stdlib-jdk8")
exclude(module = "kotlin-stdlib-jdk7")
exclude(module = "kotlin-stdlib")
exclude(module = "kotlinx-coroutines-core")
}
shadowMeMod("com.github.Skytils:AsmHelper:91ecc2bd9c") {
exclude(module = "kotlin-reflect")
exclude(module = "kotlin-stdlib-jdk8")
Expand All @@ -117,6 +110,13 @@ dependencies {
shadowMe(ktor("serialization-kotlinx-json"))
shadowMe(ktor("serialization-gson"))

shadowMe("org.jetbrains.kotlinx:kotlinx-serialization-json") {
version {
strictly("[1.5.1,)")
prefer("1.6.2")
}
}

shadowMe(ktorClient("core"))
shadowMe(ktorClient("cio"))
shadowMe(ktorClient("content-negotiation"))
Expand Down
2 changes: 1 addition & 1 deletion events/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.apache.tools.ant.filters.FixCrLfFilter

plugins {
kotlin("jvm") version "1.9.20"
kotlin("jvm") version "1.9.21"
id("gg.essential.loom") version "1.3.12"
id("gg.essential.defaults") version "0.3.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ public class Reference {
public static final String MOD_NAME = "Skytils";
public static final String VERSION = "{{ version }}";

public static final int apiVersion = 4;
public static final int apiVersion = 5;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
import kotlin.text.StringsKt;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;

Expand All @@ -46,11 +51,10 @@ public class SkytilsLoadingPlugin implements IFMLLoadingPlugin {
public static final String kotlinErrorMessage =
"<html><p>" +
"Skytils has detected a mod with an older version of Kotlin.<br>" +
"The most common culprit is the ChatTriggers mod.<br>" +
"If you do have ChatTriggers, you can update to 1.3.2<br>" +
"or later to fix the issue. https://www.chattriggers.com/<br>" +
"In order to resolve this conflict you must<br>" +
"delete the outdated mods.<br>" +
"You can also try to rename Skytils to be above other mods alphabetically<br>" +
"by changing Skytils.jar to !Skytils.jar<br>" +
"If you have already done this and are still getting this error,<br>" +
"or need assistance, ask for support in the Discord.";

Expand Down Expand Up @@ -122,8 +126,33 @@ public SkytilsLoadingPlugin() throws URISyntaxException {
String name = realFile.getName().contains(".jar") ? realFile.getName() : StringsKt.substringAfterLast(StringsKt.substringBeforeLast(file.getAbsolutePath(), ".jar", "unknown"), "/", "Unknown");

if (name.endsWith("!")) name = name.substring(0, name.length() - 1);

showMessage(kotlinErrorMessage + "<br>The culprit seems to be " + name + "<br>It bundles version " + KotlinVersion.CURRENT + "</p></html>");
JButton openModFolder = new JButton("Open Mod Folder");
openModFolder.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
try {
Desktop.getDesktop().open(new File("./mods"));
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
if (realFile.getParentFile().getName().equals("essential") && name.contains("Essential")) {
JButton watchVideo = new JButton("Open Tutorial Video");
watchVideo.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
try {
Desktop.getDesktop().browse(URI.create("https://l.skytils.gg/update-essential-video"));
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
showMessage(kotlinErrorMessage + "<br>The culprit seems to be " + name + "<br>It bundles version " + KotlinVersion.CURRENT + "</p></html>", openModFolder, watchVideo);
} else {
showMessage(kotlinErrorMessage + "<br>The culprit seems to be " + name + "<br>It bundles version " + KotlinVersion.CURRENT + "</p></html>", openModFolder);
}
exit();
}
if (checkForClass("com.sky.voidchat.EDFMLLoadingPlugin")) {
Expand Down
44 changes: 38 additions & 6 deletions src/main/kotlin/gg/skytils/skytilsmod/Skytils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package gg.skytils.skytilsmod
import gg.essential.api.EssentialAPI
import gg.essential.universal.UChat
import gg.essential.universal.UKeyboard
import gg.skytils.event.Events
import gg.skytils.skytilsmod.commands.impl.*
import gg.skytils.skytilsmod.commands.stats.impl.CataCommand
import gg.skytils.skytilsmod.commands.stats.impl.SlayerCommand
Expand Down Expand Up @@ -100,13 +99,16 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
import net.minecraftforge.fml.common.network.FMLNetworkEvent
import skytils.hylin.HylinAPI
import sun.misc.Unsafe
import java.io.File
import java.net.DatagramPacket
import java.net.DatagramSocket
import java.net.InetAddress
import java.util.*
import java.util.concurrent.Executors
import java.util.concurrent.ThreadPoolExecutor
import kotlin.coroutines.CoroutineContext
import kotlin.math.abs

@Mod(
modid = Skytils.MOD_ID,
Expand Down Expand Up @@ -172,10 +174,6 @@ class Skytils {

override val coroutineContext: CoroutineContext = dispatcher + SupervisorJob() + CoroutineName("Skytils")

val hylinAPI by lazy {
HylinAPI("", false, this, HylinConnectionHandler, "https://hypixel.skytils.gg")
}

val deobfEnvironment by lazy {
Launch.blackboard.getOrDefault("fml.deobfuscatedEnvironment", false) as Boolean
}
Expand Down Expand Up @@ -232,6 +230,8 @@ class Skytils {
const val prefix = "§9§lSkytils §8»"
const val successPrefix = "§a§lSkytils §8»"
const val failPrefix = "§c§lSkytils §8»"

var trustClientTime = false
}

@Mod.EventHandler
Expand Down Expand Up @@ -413,6 +413,8 @@ class Skytils {
UChat.chat("$prefix §fYou are on a development version of Skytils. Change your update channel to pre-release to get notified of new updates.")
}
}

checkSystemTime()
}

@SubscribeEvent(priority = EventPriority.HIGHEST)
Expand Down Expand Up @@ -585,4 +587,34 @@ class Skytils {
}
}
}

private fun checkSystemTime() {
IO.launch {
DatagramSocket().use { socket ->
val address = InetAddress.getByName("time.nist.gov")
val buffer = NtpMessage().toByteArray()
var packet = DatagramPacket(buffer, buffer.size, address, 123)
socket.send(packet)
packet = DatagramPacket(buffer, buffer.size)

val destinationTimestamp = NtpMessage.now()
val msg = NtpMessage(packet.data)

val localClockOffset =
((msg.receiveTimestamp - msg.originateTimestamp) +
(msg.transmitTimestamp - destinationTimestamp)) / 2

println("Got local clock offset: $localClockOffset")
if (abs(localClockOffset) > 3) {
if (ModChecker.canShowNotifications) {
EssentialAPI.getNotifications().push("Skytils", "Your system time is inaccurate.", 3f)
} else {
UChat.chat("$prefix §fYour system time appears to be inaccurate. Please sync your system time to avoid issues with Skytils.")
}
} else {
trustClientTime = true
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ import gg.skytils.skytilsmod.Skytils.Companion.mc
import gg.skytils.skytilsmod.commands.BaseCommand
import gg.skytils.skytilsmod.core.API
import gg.skytils.skytilsmod.utils.MojangUtil
import gg.skytils.skytilsmod.utils.nonDashedString
import kotlinx.coroutines.launch
import net.minecraft.client.entity.EntityPlayerSP
import net.minecraft.util.ChatComponentText
import net.minecraft.util.IChatComponent
import skytils.hylin.extension.nonDashedString
import java.lang.Exception
import java.util.*

abstract class StatCommand(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import gg.skytils.skytilsmod.utils.SkillUtils
import gg.skytils.skytilsmod.utils.append
import gg.skytils.skytilsmod.utils.formattedName
import gg.skytils.skytilsmod.utils.setHoverText
import skytils.hylin.request.HypixelAPIException
import java.util.*
import kotlin.time.Duration
import kotlin.time.DurationUnit
Expand All @@ -42,7 +41,7 @@ object CataCommand : StatCommand("skytilscata") {
override fun displayStats(username: String, uuid: UUID, profileData: Member) {
val playerResponse = try {
API.getPlayerSync(uuid)
} catch (e: HypixelAPIException) {
} catch (e: Throwable) {
printMessage(
"$failPrefix §cFailed to get dungeon stats: ${
e.message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ import gg.skytils.skytilsmod.Skytils.Companion.failPrefix
import gg.skytils.skytilsmod.Skytils.Companion.prefix
import gg.skytils.skytilsmod.commands.stats.StatCommand
import gg.skytils.skytilsmod.utils.*
import io.ktor.client.call.*
import io.ktor.client.request.*
import skytils.hylin.extension.nonDashedString
import java.util.*


Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1002,10 +1002,10 @@ object Config : Vigilant(

@Property(
type = PropertyType.SWITCH, name = "Predict Clicks for Alignment Solver",
description = "Predict the amount of clicks needed on the device in Floor 7.",
description = "Predict the amount of clicks needed on the alignment device in Floor 7.\nHighly recommended for high latency.",
category = "Dungeons", subcategory = "Terminal Solvers"
)
var predictAlignmentClicks = false
var predictAlignmentClicks = true

@Property(
type = PropertyType.SWITCH, name = "Shoot the Target Solver",
Expand Down Expand Up @@ -1367,10 +1367,10 @@ object Config : Vigilant(

@Property(
type = PropertyType.SWITCH, name = "Boss Bar Fix",
description = "Hides the Witherborn boss bars.",
description = "Attempts to stop boss bars from disappearing.",
category = "Miscellaneous", subcategory = "Fixes"
)
var bossBarFix = true
var bossBarFix = false

@Property(
type = PropertyType.SWITCH, name = "Fix Falling Sand Rendering",
Expand Down
8 changes: 2 additions & 6 deletions src/main/kotlin/gg/skytils/skytilsmod/core/GuiManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ object GuiManager : PersistentSave(File(Skytils.modDir, "guipositions.json")) {
try {
GlStateManager.pushMatrix()
GlStateManager.translate(element.scaleX, element.scaleY, 0f)
GlStateManager.scale(element.scale, element.scale, 0f)
GlStateManager.scale(element.scale, element.scale, 1f)
element.render()
GlStateManager.popMatrix()
} catch (ex: Exception) {
Expand Down Expand Up @@ -251,9 +251,5 @@ object GuiManager : PersistentSave(File(Skytils.modDir, "guipositions.json")) {
}

@Serializable
data class GuiElementMetadata(val x: Float, val y: Float, val scale: Float = 1f, val textShadow: SmartFontRenderer.TextShadow = SmartFontRenderer.TextShadow.NORMAL) {
companion object {
val DEFAULT = GuiElementMetadata(0f, 0f, 1f, SmartFontRenderer.TextShadow.NORMAL)
}
}
data class GuiElementMetadata(val x: Float, val y: Float, val scale: Float = 1f, val textShadow: SmartFontRenderer.TextShadow = SmartFontRenderer.TextShadow.NORMAL)
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ abstract class GuiElement(var name: String, var scale: Float = 1f, var x: Float,
}

init {
applyMetadata(GuiManager.elementMetadata.getOrDefault(name, GuiManager.GuiElementMetadata.DEFAULT))
GuiManager.elementMetadata[name]?.let {
applyMetadata(it)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import gg.skytils.skytilsmod.events.SkytilsEvent
import net.minecraft.client.renderer.culling.ICamera
import net.minecraft.entity.Entity
import net.minecraftforge.fml.common.eventhandler.Cancelable
import net.minecraftforge.fml.common.eventhandler.Event.HasResult

@Cancelable
@HasResult
data class CheckRenderEntityEvent<T : Entity>(
val entity: T,
val camera: ICamera,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import gg.essential.universal.UMatrixStack
import gg.skytils.skytilsmod.Skytils
import gg.skytils.skytilsmod.Skytils.Companion.mc
import gg.skytils.skytilsmod.core.structure.GuiElement
import gg.skytils.skytilsmod.features.impl.dungeons.DungeonFeatures.dungeonFloorNumber
import gg.skytils.skytilsmod.utils.RenderUtil
import gg.skytils.skytilsmod.utils.Utils
import gg.skytils.skytilsmod.utils.graphics.ScreenRenderer
import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer
import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer.TextAlignment
import gg.skytils.skytilsmod.utils.graphics.colors.CommonColors
import gg.skytils.skytilsmod.utils.stripControlCodes
Expand Down Expand Up @@ -54,7 +54,7 @@ object BossHPDisplays {

@SubscribeEvent(receiveCanceled = true, priority = EventPriority.HIGHEST)
fun onChat(event: ClientChatReceivedEvent) {
if (!Utils.inDungeons || event.type.toInt() == 2) return
if (!Utils.inDungeons || event.type == 2.toByte()) return
val unformatted = event.message.unformattedText.stripControlCodes()
if (unformatted.startsWith("[BOSS] Sadan")) {
if (unformatted.contains("My giants! Unleashed!")) {
Expand Down Expand Up @@ -86,12 +86,7 @@ object BossHPDisplays {
val hasSadanPlayer = mc.theWorld.getPlayerEntityByName("Sadan ") != null
giantNames = mc.theWorld.loadedEntityList.filterIsInstance<EntityArmorStand>().filter {
val name = it.displayName.formattedText
name.contains("") && (!hasSadanPlayer && name.contains("§e﴾ §c§lSadan§r") || (name.contains("Giant") && Utils.equalsOneOf(
DungeonFeatures.dungeonFloor,
"F7",
"M6",
"M7"
)) || GiantHPElement.GIANT_NAMES.any {
name.contains("") && (!hasSadanPlayer && name.contains("§e﴾ §c§lSadan§r") || (name.contains("Giant") && dungeonFloorNumber?.let { it >= 6 } == true) || GiantHPElement.GIANT_NAMES.any {
name.contains(
it
)
Expand All @@ -100,12 +95,7 @@ object BossHPDisplays {
Pair(it.displayName.formattedText, it.positionVector.addVector(0.0, -10.0, 0.0))
}
} else giantNames = emptyList()
if (Skytils.config.showGuardianRespawnTimer && DungeonFeatures.hasBossSpawned && Utils.equalsOneOf(
DungeonFeatures.dungeonFloor,
"M3",
"F3"
) && mc.theWorld != null
) {
if (Skytils.config.showGuardianRespawnTimer && DungeonFeatures.hasBossSpawned && dungeonFloorNumber == 3 && mc.theWorld != null) {
guardianRespawnTimers = mutableListOf<String>().apply {
for (entity in mc.theWorld.loadedEntityList) {
if (size >= 4) break
Expand Down
Loading

0 comments on commit 784022f

Please sign in to comment.