#dev-general
1 messages ยท Page 535 of 1
cooldowns[key]?.let { System.currentTimeMillis() - it <= cooldown } == true
^
thats rank
fun isOnCooldown(key: K) {
val value = cooldowns[key] ?: return false
return TIME - value <= cooldown
๐คฎ
let ๐
i forgot that get can return null
the whole reason why the !! is there is because it can lol
keep it coming more suggestions ๐
You canโt hide your embarrassment
editing ur messages kek
happened to me too
i can easily expose u rn ๐
return System.currentTimeMillis() - (cooldowns[key] ?: return false) <= cooldown
๐
๐ฉ
decent
im guessing u removed the containsKey too
let is so cute tho
ez 1 liner
fun blah(): Boolean = System.currentTimeMillis() - (cooldowns[key] ?: return false) <= cooldown
``` ๐
rice?
Very healthy
O
fun blah() = cooldowns[key]?.let { System.currentTimeMillis() - it <= cooldown } == true
explicit Type ๐
ew no
if u using expression functions then remove the return type
ok
i sometimes keep it to make sure its correct
or to know the return value without looking too much into it
tried that but it didn't like the double returns
๐ฆ
it was confusion
use matt's 
y
hover over the function in IJ
when i first saw let i was instantly put off
takes like 5 seconds for the popup to appear
idk why
too long ๐ฉ
i didnt like it
are you a math hater too
thatโs what she sai
jhbkn
Shift+space
EDIT: alt+shift+enter is the default
maybe i will grow fond of let one day
jitpack
Dkim, you forgot also, with ๐
with is so great
what is with?
it takes a receiver then u can use it so it like shortens the code with the implicit this kinda
idk how else to explain it
with is nice
with (something) {
doThis()
doThat()
doHello()
}
// instead of
something.doThis()
something.doThat()
something.doHello()
fun getLocation(path: String): Location? {
return with (config.getString(path)) {
if (this == null) {
null
} else {
locationFromString(this)
}
}
}
smth like that
isn't that same as ```kt
something.run {}
err I'm thinking of when in kotlin
run uses it instead of this i think
I'm all over the place
that's let
i could also say its apply, also etc etc
They are similar but used for different things
^
the question I have for with is should it be
with(someshit) {}
with (someshit) {}
first one right?
Bottom
Oh wait i guess first lmao
ye
Auto format
ok
Smh
fun getLocation(path: String): Location? {
return config.getString(path)?.let { locationFromString(it) }
}
it's good
hell yea
Smh
fun getLocation(path: String) = config.getString(path)?.let { locationFromString(it) }
Ok
so let just lets you (heh) do stuff based on if something is null or not?
i like it now
it just lets you do stuff, and ?. means to do only if it's not null
oh dang someone's gotta do like a streams in java -> kotlin tutorial
where's the BM youtube series
in the void
check the kotlin yt channel
is that a terraria npc Zodd lmao
matt linked an obscure, yet cool yt vid from them like last week or smth
Hovering around with PAPI3 and Dchat hex support
yeah but that second one is coming to fruition like right now
a hack
i mean true
Yo did BM ever get back to that guy that was pinging him for like 3 hours? I need to know
#dev-general message not really streams, but still extremely cool nonetheless
This blog post accompanies this episode: https://dev.to/kotlin/advanced-kotlin-collection-functionality-5e90
In todayโs episode of Kotlin Standard Library Safari, weโre learning all about advanced collection functionality!
Weโll see how the โanyโ, โnoneโ, and โallโ functions can be used to check conditions for elements in our collections, and ...
๐
nice
Actually while i'm at it https://www.youtube.com/watch?v=SV8CgSXQe44
Kotlin 1.5.20 comes with various improvements for Kotlin/JVM, Kotlin/Native, Kotlin/JS, and the standard library. In this video, Anton Arhipov highlights features of this release.
0:00 Introduction
0:41 String concatenation via invokedynamic
2:00 Support for JSpecify nullness annotations
2:26 Support for Lombok-generated methods
4:04 Opt-In exp...
fun isOnCooldown(key: K) = cooldowns[key]?.let { System.currentTimeMillis() - it <= cooldown } ?: false
ok
let is now in my vocab
let will return a nullable boolean so == true
๐ฆ
but even so
?: will be fine here
if it returns null then i wanna default to false
if not will it not just return whatever is returned by let?
Yeah, i just think == true is more readable, though that's preference
thats true
alrdy gets weird with let
lets not make it aids
cooldowns[key] ?: 0
cooldowns.getOrDefault(key, 0)
๐ค
i think default makes sense here
since i dont wanna deal with a null
Get or default does exactly that
Not really, it's one less call
Similar to Enum#equals it just returns enum == other
So instead is better to just do enum == other instead of calling equals
idek why im rly bothering with stupid shit like this
XD
i gotta sleep
but sleep is for the weak
nope ๐
Alpha
pov: me at 5 am trying to get my CI to build properly ๐ฅฒ
Why use CI when you could use discord pinned messages
people barely want to talk to me here, I doubt they'd join a specific discord just for me ๐ฅฒ
oof
I would
Me too โบ๏ธ
awee
That is false
Blatant lies
@cinder flare โค๏ธ
๐
Star you're the only one not in my server sadge
Since like 2019 or 18 don't remember lmao
well send me an inv bro
it's too nsfw now D:
Not like there's any activity anyway ๐คฃ
We can make it active ๐
๐
ah yes, you love when you press the stop button on a server that I'm developing for and the server console doesn't work either (not using vps), so it decides to kill itself ๐ฅฒ
no idea why the stop command kills the server instead
might be hooked up to some other command causing the unknown command error
lol
give
@all plugin devs: Are there any epic methods to promote Spigot plugins? I recently published my first. So far I've only shared it on spigotmc and polymart. How do I get the ball rolling?
wait.
Small updates pushes your plugin up the recent list
yeah updating is pretty important because of that
i made a plugin, published it on spigotmc, kept it up to date for some time very frequently and it got like uh idk how many few thousand downloads lmao
i don't regret it
but
๐ฅฒ
lol
I suppose keeping an eye on r/admincraft and spigot forums won't hurt either, maybe I can suggest the plugin every now and then
I already published two updates (~3 days apart), guess I keep doing that for a while until I got a smol userbase.
Is it worth putting some SEO effort in the spigot description in order to get some organic traffic in from Google?
Um, is it me or does IntelliJ's embedded scene builder not render css updates?
wow the one single time I'm using kotlin
it lets me down
this is extremely disappointing
wdym
if you ever worked with regex patterns and match results etc, you'll know that you can make "groups", kinda like "sections" you can get out of the match result
so for instance \\d(\\w) will match any single digit + any single alphanumeric character, the () is grouping the match inside of it so I can "extract" it, result.group(1) (0 is the entire match, 1 first group, 2 second group, etc)
so kotlin and java don't have a way to get the groups?
yeah yeah they do
but
I was expecting something like match[1] to get the first group
kinda like how you access a map or a list
but nooooo
i need to add that myself
Doesnt that already work?
Are you using kotlin's regex or java's?
kt
val res = "\\d(\\w)".toRegex().find("1w")?.groupValues ?: return
println(res[1])
This seems to work
eeee not exactly what I want
oh rip
because that's a list if i'm not mistaken
yea
i mean what else would it be
!!!
operator fun Matcher.get(index: Int): String = group(index)
I love you
wait were you not doing that already emilyy?
?
i thought you wrote your own impl thingy
lol
i want kt to be my main
i'm heavily considering migrating portions of plugins to it
I think you mean hs ๐
do you need to shade the kotlin runtime or something? i swear Glare does that with Guilds
how big that be
1mb-ish
Yup
oh snap so I can use bungee library functionality!!!!
man this kotlin thing is getting better and better
its on spigot as well
paper too?
๐ญ
yes, paper has everything spigot does
until the hard fork >:)
Probably wont change things instantly
They would end up with too many broken plugins
What would be the best way to setup a layout like this?
they should definitely like get a bunch of people to sign on and like prepare their plugin for paper only compatability
uh definitely a grid setup with like bootstrap
css also has its own but it's a lot less good
Its javafx star
I tried with stackpanes and ended up with this shit
javafx has a grid system
Yes, but I probably shouldnt have have multiple inner ones
That is already in a grid pane btw
well surely that could all be in one grid, just have the top row be like 7 - 5, second row be 4 - 4 - 4, bottom be like 4 - 8
This is what you're looking at in this image
Im not sure if they would line up properly when text wraps
they really don't go next to eachother? that is so weird
well you just extend the height of the row
wdym?
like they should always be that width, but if there's like a whole paragraph in there just wrap it and make it taller
You meant a fixed width right?
well like, it changes based on percent right
Thats how its set rn
so you have the overall grid that takes like 80% of the screen
then the boxes inside all have a number or percent, bootstrap does 12
so then if you make it smaller it makes the middle bits smaller and eventually stacks them
well it's weird that it doesn't work how I'd think it should
The problem is the table-cell like area
A fun thing, wouldn't apply to this case but pretty useful
val regex = "(?<example>\\d+).(?<second>\\d+)".toRegex()
val (example, second) = regex.matchEntire("5.5")?.destructured ?: return
example.toInt() // now 5 as int
second.toInt() // now 5 as int as well
g assembly? 
๐ ฑ๏ธerhaps
hmmm
someone shoot me in the face
https://i.imgur.com/C9N0jCF.png
https://i.imgur.com/e0QfseV.png
https://i.imgur.com/dH2GrIY.png
https://i.imgur.com/KVNMIvP.png
wow that's a lot of links
Ahh the wonders of supporting
oh xD
i wonder if they finally fixed kotlin in CoC ๐ฅฒ
what's wrong with it?
It wasnt working for like 2 weeks atleast last time I played
oh dang what
It works in the editor, but all testcases fail fast on submission
There were a few reports on the discord, but not sure if its fixed yet
aww no more super-strangely-long-display?
Emily's phone
mhm
do you have some program that lets you screenshot like that
how in the world do you do it
sharex?
no i mean the phone
take a screenshot with the power and volume button, then crop it?
by zooming out on discord mobile?
wat
Tbh I never really pay too close attention to those boxes things lmao
Only used it for argument checking
i have them disabled lmao
I find them quite useful
i find them cluttering tbh
not necessarily useless but i'm like "yeah okay but i know what i'm writing and what is what, can you stop filling up precious space for my code?"
hey @frail glade do you perchance have the source code for InventoryFull
I listed what I had yesterday ๐
sheeee
i didn't know if you didn't mention it because literally nobody has ever heard of it
No I read from GitHub what I had ๐
dang dang
well it's MIT apparently
so I might be reverse engineering this bad boy lmao
what is inventoryfull
cube has it
idk
it's MIT ๐
@pallid gale can u look in clip's eclipse archives for inventoryfull source
oh god is that what the .project file is
Damn even I don't have access that that.
He does keep a usb with all his projects on it on his keychain
๐
ez
๐
Procyon to the rescue
ew what you can generate C
๐ฅฒ
java -jar cfr.jar if.jar --outputdir if
Good work
wow look at this guy
2 mins command generation time, slow pig
I can unfortunately do the same for ASM code
i like to use procyon where cfr miserably fails
but last time I checked, you really can't use procyon on an entire project
FishSlapper says otherwise
I ussually just throw the jar into here http://www.javadecompilers.com/
I tried to use procyon for a commission once and the code it generated from the bytecode was just plain wrong
semantics were different
it's fine for quickly looking at shit
but I wouldn't use it to decompile a project to work on
I got GangsPlus working with that
If all of your plugin's code isn't from Google, you're doing it wrong.
๐
i used to then I decided to just use the tools manually instead of thru that
for some reason
ah
FernFlower apparently derps when you have ternary inside constructors lol
they all have flaws
does this thing which is correct by spec but i mean lmao
from my experience I've found cfr & procyon to be the best mix
how do you mean mix?
you use cfr for the base project
then anything cfr fails on, or doesn't look quite right
you use procyon on
hmm
Alrighty. I'll see y'all on the flip side. ๐ด
gn
cya
keep up the great work Glare my boy
Ohhh Mee6 bot is a rick and morty reference
Whew
this is amazing, the vanilla game actually does load chunks in another thread other than main
and .join()s the future immediately after
surely it would be trivial, then, for spigot to utilize that and not lock it to the main thread?
i have it
pls supply star with src
hahaha
? what's that lol
gradle init
ah?
i have only used it for migrating from maven lmao
go for basic
okay sick ty
Jesus
finna make this a config file real soon
Sometimes a static import is okay
MVP!
Material.LEAVES, Material.LEAVES_2, ah the good old days, when there was only 2 leaves
What was leaves_2?
Material.RED_ROSE, Material.YELLOW_FLOWER,
acasia?
ROSES
and two flowers!
Leaves but slightly bigger
!!!!
and all for the low, low price of $2.99!
Act now and get a second block of leaves_2 FREE
yeah long ago
weird
I think it changes if your project is a git project
cause I'm working in a non-initialized project rn and it's still VCS
oh probably
but in my other project it says Git
yo wtf, my boy clip swapped to allman for a single file in this project
how peculiar
well it's been erased so
All is well
i hate type erasure
what's the ETA on project valhalla huh
soontm
well soonโข๏ธ your sadness will be alleviated
Just make assumptions about what the type is at runtime
fun function(response: List<*>): List<String> {
@Suppress("UNCHECKED_CAST")
response as List<String>
return response
}```
mm the ol' void pointer strat
for (entry in gson.fromJson<Any>(content.toString(), object : TypeToken<Set<Map<String, Any>>>() {}.type) as Set<Map<String, Any>>) {```
okay um
there must be a better way to do this in Kotlin
I also only kind of understand what's happening
is that basically converting the json into a Set of Maps of String and Any?
u using guice in that project?
not yet
well
when you do
Types.setOf(Types.mapOf(String.class, Any.class))
alternative to typetoken
That's a guice function?
well yeah but like earlier I just bound it to a cute little data class
is there no way to like, do the same thing with Sets and Maps?
No, converts json to a map and iterates over its entries
val profile = gson.fromJson(content.toString(), MojangUUIDProfile::class.java) look at that!
well yea yea I got that
it converts it to a set of maps
I think you were right
and iterates over that set
Yes
but is there no cute :: way of writing that?
i can barely read that on pc
no star because class instances don't hold runtime type parameters
yes
๐ฎ
The type token is a nice hack to overcome type erasure
it's really ugly though
maybe I'll just get guice and do that piggy thing
wtf do you mean
this looked 10x worse in java
doubt
what
do you even mean
are you saying you're a fan of this
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}```
instead of java } finally { reader?.close() }
what
var reader: BufferedReader? = null
return try {
val mojangURL = URL("https://api.mojang.com/user/profiles/${Core.getUUID(pName)}/names")
val conn = mojangURL.openConnection()
reader = BufferedReader(InputStreamReader(conn.getInputStream()))```
you can put multiple autocloseables in a try with resources
I'll auto close you
the cast is necessary
Cant the type in the parameter be that?
no, because he calls .type which returns a java Type
you have to realize I did not write this code
is there a kotlin json library or somethin that will pretty this up for me
Wait, let me get on pc, 10 mins
Gson and kotlin dont go particularly well anyway
apparently we're meant to use moshi
not gson
Lists.newArrayList()
aren't you meant to use mutableListOf()
yes
we are working on it sir
That's not how you do try-with-resources in kt ๐ฉ
You converted horrible java to horrible kt
yes and I am repairing it
Homie just tryna make progress and everyone jumping down they throat about "it bad"
smh
Well yeah

Pats for you star
sounds boring
it was kinda fun actually
gives me purpose, writing code that I know someone actually wants
idk its just imo, for me working with or off other peoples stuff is annoying
id rather just make it
git gud
How to say I don't know what I'm doing without saying it
?
hmmm I'd rather work on something that already exists and mold it than make something fresh
probably because I don't have enough experience yet with plugins
val names = gson
.fromJson<Set<Map<String, Any>>>(
content.toString(),
object : TypeToken<Set<Map<String, Any>>>() {}.type
)
.map { it["name"].toString() }
man that's... not much better
i just have a somewhat odd style and dont like a lot of stuff
I mean yeah I love the functional ๐
What else did you want?
use kryo codecs gg
You had an unnecessary cast in there like I said
use guice type util
this is what I meant btw pig fromJson<Set<Map<String, Any>>>
instead of using Any and casting
You could probably extract the typetoken part to a separate function
I mean is there really no way to get around that horribleness
bruh
inline fun <reified T> typeOf() = object : TypeToken<T>() {}.type```
oh yea I forgot about Guice
lemme get that
content = reader.lines().reduce { acc, line -> "$acc\n$line" }.orElse(null) this line will slap em all together separated by newlines or if there's nothing there it'll be null right
there's a library called Kotlin Guice that adds these sorts of things to Guice
and I made my own extensions library for Gson that has these sorts of reified thingies
Kotlin Guice!
Wow, im impressed. They didnt name it Kuice!
lol
xD
damn that would've been a good name
You should try Haskell ๐
Oo
val conn = URL("https://api.mojang.com/user/profiles/${Core.getUUID(pName)}/names").openConnection()
val reader = BufferedReader(InputStreamReader(conn.getInputStream()))
val content: Optional<String>
reader.use {
content = reader.lines().reduce { acc, line -> "$acc\n$line" }
}
return gson.fromJson<Set<Map<String, Any>>>(
content.get(),
object : TypeToken<Set<Map<String, Any>>>() {}.type
).map { it["name"].toString() }```
how's that
a lot cleaner, eh?
why arent you just memory caching this?
baby stpes
also how would that change anything
this function would still need to exist to get the stuff to cache in the first place
oh wait
not true its just a uuid and a string lol
I have a lib for this you may find useful
what
A type-safe HTTP client for Android and Java
I'd have to query mojang's servers for a namehistory still?
sure if thats what you want
how else could it be done
i thought this was only to get a uuid from a name
yea i guess tahts the move then
wait URLConnection doesn't have a use function?
does it not implement AutoCloseable?
I really need me a Kotlin http library
?
Optionals in Kotlin what am I seeing
For the love of god
You can use java libs in kotlin, lib works fine in kotlin
I thought that was a thing
well yeah I know Zodd
but then I end up doing some stupid syntax shit like this
btw kotlin has nullable types
Okhttp
well yea
val content: String?
but isn't Optionals the functional way
hmmm okay
Elvis everywhere
fun getPlayerNameHistory(pName: String): List<String> {
if (!ProxyServer.getInstance().config.isOnlineMode) {
throw RuntimeException("Can't get player name history from an offline server!")
}
// Fetch player's name history from Mojang servers
val url = URL("https://api.mojang.com/user/profiles/${Core.getUUID(pName)}/names")
with (url.openConnection() as HttpURLConnection) {
val content: String
inputStream.bufferedReader().use {
content = it.lines().reduce { acc, line -> "$acc\n$line" }.get()
}
return gson.fromJson<Set<Map<String, Any>>>(
content,
object : TypeToken<Set<Map<String, Any>>>() {}.type
).map { it["name"].toString() }
}
}```
okay how's that
well that'll throw an exception if lines() returns an empty stream
well how do I not do that
also there's .collect(Collectors.joining("\n"))
uh, doesn't seem so
that's java api
please keep in mind I am doing all this functional stuff for the first time in Kotlin ๐
Doesnt lines() return a collection?
returns a Stream
Ah
fun getPlayerNameHistory(pName: String): List<String> {
if (!ProxyServer.getInstance().config.isOnlineMode) {
throw RuntimeException("Can't get player name history from an offline server!")
}
// Fetch player's name history from Mojang servers
val url = URL("https://api.mojang.com/user/profiles/${Core.getUUID(pName)}/names")
with (url.openConnection() as HttpURLConnection) {
inputStream.bufferedReader().use { response ->
return gson.fromJson<Set<Map<String, Any>>>(
response.lines().reduce { acc, line -> "$acc\n$line" }.get(),
object : TypeToken<Set<Map<String, Any>>>() {}.type
).map { it["name"].toString() }
}
}
}```
okay how bout that
still not using types util
also will that return an empty list if it doesn't succeed in any of those
yeah gettin there
The one with $$?
ye
bs
hey will that return an empty list or whatever it succeeds with?
cause I don't have another return...
Most likely no
so why is it okay with me not having another return lol
Kotlin doesnt force you to use try / catch
this will work too btw....
for your type
wait why the fuck does this function throw a runtime exception
shouldn't it just like... return an empty list or something
Star, use reduce with the 2 args
Use an empty string as first arg
No need to use the optional version here
isn't that already reduce with the 2 args?
What are you confused about?
how to change my function to the one you said
I have literally the slimmest idea of how these work
i just copied from the kotlin examples page
Just add that emoty string argument like I showed above
k and then
And then remove the get()
ahhh I see
Because this one returns T instead of Optional<T>
Oh that's nice!
ah cause it'll just return an empty string if it doesn't have anything in it
now that's smart
Not an equivalent for a default btw
Its just what the initial value of acc will be
The identity value for your operation
well yea but if there's no elements in it, it'll just return whatever I pass in first right?
Mhm
But a change in that string will affect your output string
This might still add an extra line to your output tbh
You could move the \n to the end of the string and trim at last
well hmm
to try it I have to do a lot more lol
can I just execute this script by itself
how do those kotlin scripts work lo
I just test on kotlin playground normally
kotlin playground don't have the type shit
Oh right gson
well I guess let's trial by fire it
How come you're not using Collectors.joining
because it's a Stream
Collectors.joining is used in a stream
Wait did you just want to join by newline?
that's why I mentioned it before
๐ตโ๐ซ ๐ตโ๐ซ
Reader#lineSequence().join("\n")
joinToString*
^
what r u tryna do
I'm not entirely sure tbh
pls no make me scroll up
Is response a BufferedReader?
yes
doesn't kotlin also have reader.readAllText or something
Then ok
man see this is why I got the Genius Bar here
imagine what I'd be doing without you guys
writing bad code
why did you switch it to kotlin?
cause I think its pretty and nicer than Java
jw idc if youre doing it to learn, i do not recommend pasting java code in then converting tho cuz it makes it aids
well this entire plugin is in Java
and is moderately poorly written
so I figure converting it to Kotlin then fixing it up real nice file-by-file is a pretty good solution for all the small parts
then when it becomes more manageable, I plan on implementing Guice and other niceties project-wide
plus look at how much I'm learning about streams and stuff!
okay well guys it worked perfectly
thank you all for your support โค๏ธ
gg, kotlin you dont have to use streams so often prolly unless you prefer them over kt sequeneces
are sequences the collection operations
cause I would like to use those a lot more, it's just that this is a Java stream boi
Nah sequences are a distinct thing
They're lazy rather than eager
Similar to streams
how would I go about using those
.asSequence()
streams are pretty lazy as well tho yea
or sequenceOf()
Not particularly
Depends
If you have a big collection and / or lots of operations it might be worth converting to a sequence
okay I see
love you bristy
Ily too
hey is RedisBungee like not a thing anymore
ah just bridge it yourself
well this plugin had support for it like 5 years ago
so I'm just not touching it for a while lol
lol jesus as long as it works
I am not sure if it works
I just am not touching it lol and the one person who wanted it does not use it so
we gucci
still waiting for that coding coffee date
woah what
were just intimate like that
dang yeah apparently
so this is a weird request but... is there an easy way to take that gson that's been mapped to a Map<String, Any> and use its values in a pretty string?
okay that's a weird one nevermind
but what about
val city = if (!(attributes["city"] as String?)!!.isEmpty()) attributes["city"] as String? else "unknown"```
terser?
(attributes["city"] as? String) ?: "Unknown"
hey wait
oh empty
this JSON will only be strings won't it
one moment
why do I have a map of String and Any
idk lol
thats probably what the conversion did
it's trying its hardest
yea sometimes its handy
val city = if (attributes["city"].isEmpty()) attributes["city"] else "unknown"
that but condensed
how do
make val attribute = attributes["city"]
what
I mean is there not a terser way of saying "if this condition, return this, otherwise return myself"
not really thats kotlins way
hmmm
val city = attributes["city"].ifEmpty { "unknown" }
lol
There's a lot more querying of REST apis in this plugin than I thought there would be
this is the third time I've used that little Http script
retrofit?
what
for http requests
oh no the little thing we made earlier
val url = URL("http://ip-api.com/json/$ip?fields=country,countryCode,city")
with (url.openConnection() as HttpURLConnection) {
inputStream.bufferedReader().use { response ->
val attributes: Map<String, String> = gson.fromJson(
response.lineSequence().joinToString("\n"),
object : TypeToken<Map<String, String>>() {}.type
)
return """&7City: &f${attributes["city"]?.ifEmpty { "Unknown" }}&7
| Country: &f${attributes["country"]?.ifEmpty { "Unknown" }}&e
| (&f${attributes["countryCode"]?.ifEmpty { "Unknown" }}&e)""".trimMargin()
}
}```
I mean is it really worth it for the 3 times I used it?
๐คท
use java 11 http api
which would look like?
oof
pfft
lmao even you're not exempt from the pron
guess not
pron?
hub
Did he actually mean porn?
yes but I did not want to be censored
lol
lame
rules are rules
until you go add an exception to Barry, that is
well hang on now
mr BodyHandlers, that doesn't map it to a cute data class for me
I'll body handle you
okay so there actually is a cute little BodyHandler maker
but my brain is much too small to understand the type declaration or how I could map it myself
so that's a function that takes a ResponseInfo! and returns a BodySubscriber of some type?
fun getUUID(pName: String): String {
val request = HttpRequest.newBuilder()
.uri(URI("https://api.mojang.com/users/profiles/minecraft/$pName")).build()
val response = httpClient.send(request, BodyHandlers.ofString()).body()
return gson.fromJson(response, MojangUUIDProfile::class.java).id
}```
this is the final formm
good shout tho
looks like shit but iโm on phone
Didn't you have to use {$pName}?
Ah, now I see
val isEnabled = when (module) {
is BanConfig -> module.config.get(BanConfig.ENABLED)
is MuteConfig -> module.config.get(MuteConfig.ENABLED)
is CommentConfig -> module.config.get(CommentConfig.ENABLED)
is KickConfig -> module.config.get(KickConfig.ENABLED)
else -> false
}```
damn is that beautiful or what
this could be Java some day
like, around september actually
Any reason module itself doesnt just expose a isEnabled method?
uhhh
cause I'm silly and just stapled on MF-CFG
the old cfg framework used inheritance, so it was just a single method to get any of the enabled states
but that is an excellent suggestion sir
horrible
Irrespective of language
you... don't like pattern matching switches?
That definitely breaks some principle / guideline
No you should be doing what yugi said
Kotlin bad?
gn
yea?
Do you know of a nice way of handling errors in haskell
MonadFail isn't really what I want
Either
I think thats what libraries commonly use atleast
what if there could be multiple errors?
I think I started to understand what a monad is
nice
basically i am writing a math parser but obviously there will be certain things that don't work (dividing by 0, referencing variables that aren't bound, etc)
Hmm
class Evaluate t where
evaluate :: Context -> t -> Either Double String
``` have done something like this so far
not sure if that's the best option though
and then we can implement it with something like this: ```hs
instance Evaluate Expression where
evaluate context (VariableExpression name) = variables context M.!? name
Is Stream#flatMap a monad or no?
Stream is
try something like this maybe
data ParseException = DivisionByZero | UnboundVariableAccess | ...
class Evaluate t where
evaluate :: Context -> t -> Either Double ParseException
Oh pog
ooh that is a good idea
flatMap is equivalent to a bind

mhm
hmm
mmh
now how to get nice error messages that show where the error occurred
i guess just have ParseException take a String too
and worry about that later
ooh i wonder if i can just store the Expression that caused the error
lol

