diff options
Diffstat (limited to 'src/main/kotlin/moe/nea')
86 files changed, 0 insertions, 4174 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/ConfigCommand.kt b/src/main/kotlin/moe/nea/ledger/ConfigCommand.kt deleted file mode 100644 index 5b964c8..0000000 --- a/src/main/kotlin/moe/nea/ledger/ConfigCommand.kt +++ /dev/null @@ -1,31 +0,0 @@ -package moe.nea.ledger - -import io.github.notenoughupdates.moulconfig.common.IMinecraft -import net.minecraft.command.CommandBase -import net.minecraft.command.ICommandSender - -class ConfigCommand : CommandBase() { - override fun canCommandSenderUseCommand(sender: ICommandSender?): Boolean { - return true - } - - override fun getCommandName(): String { - return "ledgerconfig" - } - - override fun getCommandUsage(sender: ICommandSender?): String { - return "" - } - - override fun processCommand(sender: ICommandSender?, args: Array<out String>) { - val editor = Ledger.managedConfig.getEditor() - editor.search(args.joinToString(" ")) - Ledger.runLater { - IMinecraft.instance.openWrappedScreen(editor) - } - } - - override fun getCommandAliases(): List<String> { - return listOf("moneyledger") - } -}
\ No newline at end of file diff --git a/src/main/kotlin/moe/nea/ledger/DebouncedValue.kt b/src/main/kotlin/moe/nea/ledger/DebouncedValue.kt deleted file mode 100644 index 66fba8d..0000000 --- a/src/main/kotlin/moe/nea/ledger/DebouncedValue.kt +++ /dev/null @@ -1,38 +0,0 @@ -package moe.nea.ledger - -import kotlin.time.Duration -import kotlin.time.Duration.Companion.nanoseconds -import kotlin.time.Duration.Companion.seconds - -class DebouncedValue<T>(private val value: T) { - companion object { - fun <T> farFuture(): DebouncedValue<T> { - val value = DebouncedValue(Unit) - value.take() - @Suppress("UNCHECKED_CAST") - return value as DebouncedValue<T> - } - } - - val lastSeenAt = System.nanoTime() - val age get() = (System.nanoTime() - lastSeenAt).nanoseconds - var taken = false - private set - - fun get(debounce: Duration): T? { - return if (!taken && age >= debounce) value - else null - } - - fun replace(): T? { - return consume(0.seconds) - } - - fun consume(debounce: Duration): T? { - return get(debounce)?.also { take() } - } - - fun take() { - taken = true - } -}
\ No newline at end of file diff --git a/src/main/kotlin/moe/nea/ledger/DebugDataCommand.kt b/src/main/kotlin/moe/nea/ledger/DebugDataCommand.kt deleted file mode 100644 index bab0a78..0000000 --- a/src/main/kotlin/moe/nea/ledger/DebugDataCommand.kt +++ /dev/null @@ -1,34 +0,0 @@ -package moe.nea.ledger - -import moe.nea.ledger.events.SupplyDebugInfo -import moe.nea.ledger.utils.di.Inject -import net.minecraft.command.CommandBase -import net.minecraft.command.ICommandSender -import net.minecraftforge.common.MinecraftForge - -class DebugDataCommand : CommandBase() { - - override fun canCommandSenderUseCommand(sender: ICommandSender?): Boolean { - return true - } - - override fun getCommandName(): String { - return "ledgerdebug" - } - - override fun getCommandUsage(sender: ICommandSender?): String { - return "" - } - - @Inject - lateinit var logger: LedgerLogger - - override fun processCommand(sender: ICommandSender?, args: Array<out String>?) { - val debugInfo = SupplyDebugInfo() - MinecraftForge.EVENT_BUS.post(debugInfo) - logger.printOut("Collected debug info:") - debugInfo.data.forEach { - logger.printOut("${it.first}: ${it.second}") - } - } -}
\ No newline at end of file diff --git a/src/main/kotlin/moe/nea/ledger/DevUtil.kt b/src/main/kotlin/moe/nea/ledger/DevUtil.kt deleted file mode 100644 index d0dd653..0000000 --- a/src/main/kotlin/moe/nea/ledger/DevUtil.kt +++ /dev/null @@ -1,7 +0,0 @@ -package moe.nea.ledger - -import net.minecraft.launchwrapper.Launch - -object DevUtil { - val isDevEnv = Launch.blackboard["fml.deobfuscatedEnvironment"] as Boolean -}
\ No newline at end of file diff --git a/src/main/kotlin/moe/nea/ledger/ExpiringValue.kt b/src/main/kotlin/moe/nea/ledger/ExpiringValue.kt deleted file mode 100644 index b50b14e..0000000 --- a/src/main/kotlin/moe/nea/ledger/ExpiringValue.kt +++ /dev/null @@ -1,30 +0,0 @@ -package moe.nea.ledger - -import kotlin.time.Duration -import kotlin.time.Duration.Companion.nanoseconds - -class ExpiringValue<T>(private val value: T) { - val lastSeenAt: Long = System.nanoTime() - val age get() = (System.nanoTime() - lastSeenAt).nanoseconds - var taken = false - private set - - fun get(expiry: Duration): T? { - return if (!taken && age < expiry) value - else null - } - - companion object { - fun <T> empty(): ExpiringValue<T> { - val value = ExpiringValue(Unit) - value.take() - @Suppress("UNCHECKED_CAST") - return value as ExpiringValue<T> - } - } - - fun consume(expiry: Duration): T? = get(expiry)?.also { take() } - fun take() { - taken = true - } -}
\ No newline at end of file diff --git a/src/main/kotlin/moe/nea/ledger/ItemChange.kt b/src/main/kotlin/moe/nea/ledger/ItemChange.kt deleted file mode 100644 index fda709c..0000000 --- a/src/main/kotlin/moe/nea/ledger/ItemChange.kt +++ /dev/null @@ -1,84 +0,0 @@ -package moe.nea.ledger - -import moe.nea.ledger.database.DBItemEntry -import moe.nea.ledger.database.ResultRow -import net.minecraft.event.HoverEvent -import net.minecraft.util.ChatComponentText -import net.minecraft.util.ChatStyle -import net.minecraft.util.EnumChatFormatting -import net.minecraft.util.IChatComponent - -data class ItemChange( - val itemId: ItemId, - val count: Double, - val direction: ChangeDirection, -) { - fun formatChat(): IChatComponent { - return ChatComponentText(" ") - .appendSibling(direction.chatFormat) - .appendText(" ") - .appendSibling(ChatComponentText("$count").setChatStyle(ChatStyle().setColor(EnumChatFormatting.WHITE))) - .appendSibling(ChatComponentText("x").setChatStyle(ChatStyle().setColor(EnumChatFormatting.DARK_GRAY))) - .appendText(" ") - .appendSibling(ChatComponentText(itemId.string).setChatStyle(ChatStyle().setParentStyle(ChatStyle().setColor( - EnumChatFormatting.WHITE)))) - } - - enum class ChangeDirection { - GAINED, - TRANSFORM, - SYNC, - CATALYST, - LOST; - - val chatFormat by lazy { formatChat0() } - private fun formatChat0(): IChatComponent { - val (text, color) = when (this) { - GAINED -> "+" to EnumChatFormatting.GREEN - TRANSFORM -> "~" to EnumChatFormatting.YELLOW - SYNC -> "=" to EnumChatFormatting.BLUE - CATALYST -> "*" to EnumChatFormatting.DARK_PURPLE - LOST -> "-" to EnumChatFormatting.RED - } - return ChatComponentText(text) - .setChatStyle( - ChatStyle() - .setColor(color) - .setChatHoverEvent(HoverEvent(HoverEvent.Action.SHOW_TEXT, - ChatComponentText(name).setChatStyle(ChatStyle().setColor(color))))) - } - } - - companion object { - fun gainCoins(number: Double): ItemChange { - return gain(ItemId.COINS, number) - } - - fun unpair(direction: ChangeDirection, pair: Pair<ItemId, Double>): ItemChange { - return ItemChange(pair.first, pair.second, direction) - } - - fun unpairGain(pair: Pair<ItemId, Double>) = unpair(ChangeDirection.GAINED, pair) - fun unpairLose(pair: Pair<ItemId, Double>) = unpair(ChangeDirection.LOST, pair) - - fun gain(itemId: ItemId, amount: Number): ItemChange { - return ItemChange(itemId, amount.toDouble(), ChangeDirection.GAINED) - } - - fun lose(itemId: ItemId, amount: Number): ItemChange { - return ItemChange(itemId, amount.toDouble(), ChangeDirection.LOST) - } - - fun loseCoins(number: Double): ItemChange { - return lose(ItemId.COINS, number) - } - - fun from(result: ResultRow): ItemChange { - return ItemChange( - result[DBItemEntry.itemId], - result[DBItemEntry.size], - result[DBItemEntry.mode], - ) - } - } -}
\ No newline at end of file diff --git a/src/main/kotlin/moe/nea/ledger/ItemId.kt b/src/main/kotlin/moe/nea/ledger/ItemId.kt deleted file mode 100644 index 8211cd3..0000000 --- a/src/main/kotlin/moe/nea/ledger/ItemId.kt +++ /dev/null @@ -1,35 +0,0 @@ -package moe.nea.ledger - -import moe.nea.ledger.utils.NoSideEffects - -data class ItemId( - val string: String -) { - @NoSideEffects - fun singleItem(): Pair<ItemId, Double> { - return withStackSize(1) - } - - @NoSideEffects - fun withStackSize(size: Number): Pair<ItemId, Double> { - return Pair(this, size.toDouble()) - } - - - companion object { - - @JvmStatic - @NoSideEffects - fun forName(string: String) = ItemId(string) - fun skill(skill: String) = ItemId("SKYBLOCK_SKILL_$skill") - - val GARDEN = skill("GARDEN") - val FARMING = skill("FARMING") - - - val COINS = ItemId("SKYBLOCK_COIN") - val GEMSTONE_POWDER = ItemId("SKYBLOCK_POWDER_GEMSTONE") - val MITHRIL_POWDER = ItemId("SKYBLOCK_POWDER_MITHRIL") - val NIL = ItemId("SKYBLOCK_NIL") - } -}
\ No newline at end of file diff --git a/src/main/kotlin/moe/nea/ledger/ItemIdProvider.kt b/src/main/kotlin/moe/nea/ledger/ItemIdProvider.kt deleted file mode 100644 index 0bacf32..0000000 --- a/src/main/kotlin/moe/nea/ledger/ItemIdProvider.kt +++ /dev/null @@ -1,188 +0,0 @@ -package moe.nea.ledger - -import moe.nea.ledger.events.BeforeGuiAction -import moe.nea.ledger.events.ExtraSupplyIdEvent -import moe.nea.ledger.events.RegistrationFinishedEvent -import moe.nea.ledger.events.SupplyDebugInfo -import moe.nea.ledger.gen.ItemIds -import moe.nea.ledger.modules.ExternalDataProvider -import net.minecraft.client.Minecraft -import net.minecraft.item.ItemStack -import net.minecraft.nbt.NBTTagCompound -import net.minecraftforge.client.event.GuiScreenEvent -import net.minecraftforge.common.MinecraftForge -import net.minecraftforge.fml.common.eventhandler.EventPriority -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import org.lw |
