#dev-general

1 messages Β· Page 172 of 1

earnest narwhal
#

xD

jovial warren
#

I forgot that was even there lol

earnest narwhal
#

Lol

#

woah that’s a long name Kotlin

prisma wave
#

Indeed it is

jovial warren
#

his name is Brister Mitten (well, it was for about 99% of last year until he thought he was really cool and decided to start changing his nickname to something really obnoxious lol)

earnest narwhal
#

Oh I see

jovial warren
#

his real name is Alex, but that's irrelevant lol

#

(not doxxing it's on his GitHub)

earnest narwhal
#

Oki

prisma wave
#

πŸ‘€

#

you should write my biography

onyx loom
#

can i contribute

surreal quarry
#

doxxed him for his github fingerguns

onyx loom
#

by deleting the clojure part of ur life πŸ™ƒ

prisma wave
#

no

#

that's a very important bit

jovial warren
#

okay, sign me up lol

prisma wave
#

chapter 1. Java good
chapter 2. Kotlin good
chapter 3. Clojure good

onyx loom
#

what an interesting story!

prisma wave
#

it's great

jovial warren
#

"chapter 4: finally realised that Scala is the true king and that I was full of shit this whole time" pending...

#

lol

prisma wave
#

the story arc is very interesting

#

that'll be the day

#

Scala is weird

jovial warren
#

I've never used it before

#

ya know what? just for that, I'm doing it right now lol

prisma wave
#

I've only used it for the jvm-plugins repo

#

the build tool kinda sucks

#

takes like 20 seconds to build 2 classes πŸ™ƒ

empty flint
#

how do I define a setter for a var in the constructor of a kotlin class?

prisma wave
#

the short answer is you can't

#

properties declared in a primary constructor are assumed to be "pure" (no custom getter or setter)

empty flint
#

ah

ocean quartz
#

I think you'd need to do

class Test(value: String) {
  var youThing = value
}
empty flint
#

Is there a better way to do this:

abstract class LogWriter(var loggingPrefix: String,
                         var detailed: Boolean = false,
                         var padding: Int = 60,
                         logLevel: Level = Level.ALL) : Logging, Debugging {
    var logLevel: Level = logLevel
        set(value) {
            field = value
            logger.level = logLevel
        }
    protected val logger = Bukkit.getLogger().also { it.level = logLevel }
...
}
#

I don't really need the logLevel value in the class itself

prisma wave
#

kinda

#

you might as well have logLevel without a backing field

#

nvm

empty flint
#

but I would like to have a field where if you set the field, you set the logger's field

jovial warren
#

when you go on repl.it and go to make a new repl, and you find Scala at the bottom of the list of practical languages lol

prisma wave
#

😦

empty flint
#

and if you get the field, you actually get the logger's field

prisma wave
#

scala is practical

jovial warren
#

ooh objects are a thing in Scala

prisma wave
#

quite a lot of kotlin things are in scala

jovial warren
#

wait hold on a second

#

please don't tell me that you define generics with []

prisma wave
#

@empty flint any reason you can't do ```kotlin
val logLevel
get() = Bukkit.getLogger().level
set(value) { logger.level = value }

#

@jovial warren that is correct

jovial warren
#

ffs

#

lol

prisma wave
#

it's not that bad

#

I think it's pretty clean actually

#
val player = sender.asInstanceOf[Player]
empty flint
#

A 'val'-property cannot have a setter

#

@prisma wave

prisma wave
#

var*

jovial warren
#

@empty flint it's a val, the Kotlin equivalent of final

#

@prisma wave it doesn't have smart casting either?

prisma wave
#

not sure

#

one of them does

#

I think Groovy does

#

but scala doesn't

empty flint
#

No yeah that's what I was going for but I didn't know how to write it better than the way I did. Didn't know the warning about setting the field went away if you specify a custom getter

jovial warren
#

also why tf do methods look like this: ```scala
def main() = {

}

prisma wave
#

why not?

#

looks like elara :)

jovial warren
#

because it's not an assignment it's a declaration

prisma wave
#

if functions are first class

#

then isn't it both?

jovial warren
#

wdym first class?

prisma wave
#

scala is a functional language

#

it has first class functions

#

i.e higher order functions

jovial warren
#

ah okay

#

Scala has strict OOP though which is annoying

prisma wave
#

how so?

jovial warren
#
main.scala:1: error: expected class or object definition
def main(args: Array[String]) {
^
one error found
compiler exit status 1
#

what I mean by strict OOP is that everything has to be wrapped in a class, like Java

#

probably not the right definition but eh

prisma wave
#

oh I see

#

meh

#

that's not so bad

jovial warren
#

also why does it take like 2-3 seconds to literally compile 5 lines lol

prisma wave
#

sbt bad

jovial warren
#

SBT?

prisma wave
#

the build tool

jovial warren
#

also I figured out what's up with that = {} thingy btw

#

you only need the = sign if you specify the return type explicitly

old wyvern
#

=>

jovial warren
#

wait does Scala have type inference to the level where you don't have to explicitly specify the return type of a function?

old wyvern
#

E

prisma wave
#

L

old wyvern
#

A

prisma wave
#

R

old wyvern
#

A

prisma wave
jovial warren
#

wait does Scala have type inference to the level where you don't have to explicitly specify the return type of a function?

prisma wave
#

Β―_(ツ)_/Β―

#

maybe

jovial warren
#

because that's something I've wanted in Kotlin for pretty much ever

prisma wave
#

messy

ocean quartz
#

You should edit your L, it looks like EIARA

old wyvern
#

Uf you sprcify the =

#

With = it woukd infer the return type

#

Fyck cabt tupe

#

Oof

#

Brb

prisma wave
#

o_o

#

Fyck cabt tupe
who's gonna try decipher this then

jovial warren
#

the only way I can think to make Kotlin use proper type inference on functions (like it should have) is something like this: ```kotlin
fun myFunction() = run {}

old wyvern
#

Its 3;20

prisma wave
#

gross

old wyvern
#

Spare me

prisma wave
#

ok :)

jovial warren
#

which is even more annoying than specifying the return type

prisma wave
#

functions should specify return type

#

unless it's totally obvious from context

#

especially in FP

jovial warren
#

yeah but the main reason why I switched to Kotlin is so that I can write less code lol

prisma wave
#

just make every function return Any

#

ez

old wyvern
#

Back to sleep

#

Gn bois

prisma wave
#

gn

jovial warren
#

@prisma wave wat?

#

gn @old wyvern

prisma wave
#

it's like liskov

#

but extreme

#

EXTREME liskov substitution

#

every function returns Any

#

yeah but the main reason why I switched to Kotlin is so that I can write less code lol
you sound like a person in need of clojure

#

no specifying return types there

jovial warren
prisma wave
#

or parameter types

#

yes

jovial warren
#

or parameter types
wait what?

#

parameter types have always been one of those things that feels like it just kinda sucks the life out of type inference

prisma wave
#

clojijre

#

I mean you can't really infer a parameter type

jovial warren
#

true

#

I was just about to say "and also constructor parameters" but I got half way through typing the word "parameter" and went "hold on a second, that's still a type of parameter" lol

prisma wave
#

no constructors in clojure

jovial warren
ocean quartz
#

Language trends

jovial warren
#

Kotlin = poised to revolutionise programming

ocean quartz
jovial warren
ocean quartz
jovial warren
#

wait why is Go more popular than Kotlin?

ocean quartz
#

speed

jovial warren
#

speed?

prisma wave
#

go

#

pff

#

more like

#

go away

jovial warren
ocean quartz
#

Yeah GO is hella fast, idk why it's popular though, but people love it

prisma wave
#

Go feels lightweight

#

not as fast as rust

#

but also not as ugly

jovial warren
#

funny how people like the shittest of languages lol

prisma wave
#

like which

onyx loom
#

iirc sx likes go

prisma wave
#

choose your words carefully

jovial warren
#

JavaScript, Python, Java, the list goes on lol

prisma wave
#

Python is nice

#

JS and Java aren't that bad

ocean quartz
jovial warren
#

C++, PHP, C

ocean quartz
#

Rust is quire low as well

prisma wave
#

C languages good

#

rust is surprisingly low

onyx loom
#

top 20 for kotlin tho pog

jovial warren
#

C is dogshit, and C++ is even worse

prisma wave
#

Rust and Haskell are like the main circlejerky languages

#

HA

jovial warren
#

though C has its uses

#

C++ has no place in this world, same as JS

prisma wave
#

Better than Pascal or whatever was popular at the time

onyx loom
#

c++ has its uses too

prisma wave
#

????

#

C++ is insanely widely used

#

so is JS

#

lol

jovial warren
#

Rust better than Kotlin?

prisma wave
#

/uj can't compare the 2

ocean quartz
jovial warren
#

yeah they're widely used, but that doesn't stop them being shit and not deserving any credit for anything

prisma wave
#

/rj rust bad clojure good kotlin bad

#

what's wrong with c++?

ocean quartz
#

JS is gonna fall from 1st pretty soon

prisma wave
#

wait Go is in #4?

#

wow

jovial warren
#

have you even seen the syntax? lol

onyx loom
#

kekw java going down

prisma wave
#

Yeah

#

There isn't a single low level language that isn't at least a bit ugly

#

it's still powerful

ocean quartz
#

C++'s power isn't the syntax

prisma wave
#

and somewhat nice

jovial warren
#

like wtf is ```c++
using namespace std;

int main() {
cout << "Hello World";
return 0;
}

onyx loom
#

mEmOrY MaNaGeMeNt

jovial warren
#

^ that too

ocean quartz
#

You can hate it, but memory management is one of it's greatest features

prisma wave
#

apparently using namespaces like that is an anti-pattern

#

hating manual memory management is dumb

jovial warren
#

what kind of a useless ass keyword is reinterpret_cast, or const_cast, or dynamic_cast, or static_cast, or even friend, wtf is a friend

prisma wave
#

companion

onyx loom
#

friend

jovial warren
#

companion makes more sense, because it's the companion of the class it's in

prisma wave
#

and i'm pretty sure most of those aren't keywords

jovial warren
#

yes they are

prisma wave
#

are they not macros?

#

or similar

#

idk

jovial warren
#

not sure

#

but what about wchar_t then

#

like wtf is that

onyx loom
#

C++'s power isn't the syntax

jovial warren
#

yeah ik

prisma wave
#

c++ has a ton of datatypes to give more room for optimisation

#

same with c

jovial warren
#

true

#

but they shouldn't all be keywords

#

like wchar_t should not be a fucking keyword

prisma wave
#

why not?

#

in theory it's no different to int

jovial warren
#

keywords aren't supposed to look like that, they're supposed to be easy, short, and understandable from just about no context

prisma wave
#

tailrec

#

companion object

#

volatile

#

strictfp

#

synchronized

#

crossinline

#

:)

jovial warren
#

companion object makes sense, volatile is a little bit more complex but still makes sense, synchronized makes perfect sense, and crossinline I'll admit needs some context

prisma wave
#

all of them make sense

#

but require you to know the language and its capabilities

#

the same goes for wchar_t and whatever else

jovial warren
#

true

ocean quartz
#

C++ is not meant to be a language that you look at it and you can see what it does without knowing it, it's complex but that's not a problem

jovial warren
#

yeah I guess

prisma wave
#

if you want ugly

#

look at rust

onyx loom
#

@ niall

prisma wave
#

and yet it's one of the most circlejerky languages out there

#

because it's good

jovial warren
#

but if you're working with low-level stuff anyway, why not just use C? it's probably faster, is structured a bit better, and is actually alright lol

prisma wave
#

or something

#

idk

#

C++ adds a lot of features that C is lacking

ocean quartz
#

You'll hate me for saying this but Clojure is pretty ugly as well xD

prisma wave
#

i mean

#

jokes aside I agree

onyx loom
#

the truth has been spoken.

jovial warren
#

def something nil xD

prisma wave
#

it's not the most pretty of languages

#

but most of the ugly languages are the most elegant and powerful

#

rust, c++, clojure, haskell

jovial warren
#

"elegant" my ass

prisma wave
#

bruh

#

you clearly didn't see my clash solution

#

it was great

jovial warren
#

I don't want to see your clash solution

#

also teach me the Clojure ways

#

I wanna see this

prisma wave
#

wdym

jovial warren
#

tell me where I find learning resources

onyx loom
#

u dont wanna know πŸ’€

prisma wave
#

no idea

#

i just learnt as I went along

jovial warren
#

(require '[clojure.repl :refer :all]) okay, nope lol

prisma wave
#
  • johnny
#

πŸ™„

onyx loom
#

oh yeah

#

can we see some decompiled clojure

ocean quartz
#

It's always fun to learn a new language just to do it

prisma wave
#

it would be my pleasure

jovial warren
#

@ocean quartz yeah

prisma wave
#

jokes aside, clojure is kinda ugly but once you actually realise why it's ugly, it starts to become really elegant

#

imo anyway

jovial warren
#

last time I tried learning a new language properly, it was C, and I got as far as the part where static was declaring local variables and I was like https://tenor.com/UWiC.gif

prisma wave
#

ok the decompiled clojure experience

ocean quartz
#

If you don't learn C as your first language and you learn an OOP one first once you try you get a shock

jovial warren
#

yeah I learnt Java first, big mistake lol

prisma wave
#

procedural only 😎

ocean quartz
#

C was my first one

prisma wave
empty flint
#

Is it possible to interpret a string as a string that should be interpolated?

jovial warren
#

@prisma wave wtf lol

#

I swear half of that is Java code lol

prisma wave
#

it is

#

it compiles to java bytecode

onyx loom
#

decompiled clojure

jovial warren
#

ah okay

onyx loom
#

yea

prisma wave
empty flint
#

If I had a class with a field "name" and I knew that field existed, could I pass a string to that class that it will try to interpolate with its own field names?

jovial warren
#

show me the source code

prisma wave
#

our lovely CommandExecutor

jovial warren
#

wait I gotta see some decompiled Kotlin code lol

onyx loom
#

😎

prisma wave
#

decompiled kotlin is boring

ocean quartz
#

main__var 😒

prisma wave
#

just null checks everywhere

#

hot

jovial warren
#

don't you just show Kotlin bytecode and then decompile to show decompiled Java code?

prisma wave
#

yeah

#

well

#

kotlin bytecode doesn't exist

#

it's just jvm bytecode

lunar cypress
#

Decompilers can be misleading because they assume the source was java

prisma wave
#

indeed

jovial warren
#

tbh, it's not that bad

prisma wave
#

also question for mr clojure expert

#

is this supposed to compile to use the Reflector class?

lunar cypress
#

Wdym?

jovial warren
#

when decompiled Kotlin becomes the exact same as the Java code that you're basing your code off of lol

lunar cypress
#

Is it type hinted?

prisma wave
#

in the decompiled code it has this

#

which I assume uses reflection

lunar cypress
#

Yeah it does

prisma wave
#

how would one perform type hinting?

lunar cypress
#

^Player

prisma wave
#

ah

#

i'm not sure that's possible?

#

since it's reusing a variable of type CommandSender

lunar cypress
#

It is possible

#

Just don't hint it in the parameter declaration

#

I recommend you put :global-vars {*warn-on-reflection* true} in your project.clj

prisma wave
#

it's in the main class, is that not enough?

lunar cypress
#

I already kinda did that in the lein template but the plugin namespace gets evaluated too late

prisma wave
#

i copied your clojure-plugin template

lunar cypress
#

Yeah

jovial warren
#

thonk lol (the left is decompiled Kotlin code, the right is the original Java code that I'm modelling my Kotlin code from on GitHub)

lunar cypress
#

It loads the command namespace before setting that var

prisma wave
#

I see

#

wait, if I remove the parameter type hinting then it will just use reflection for when it's not a Player, no?

jovial warren
#

I never knew when decompiled to if/else if/else

prisma wave
#

what else would it compile to lol

jovial warren
#

switch?

prisma wave
#

not versatile enough

jovial warren
#

I mean, that's basically what it is

prisma wave
#

switch has to be compile time constants

lunar cypress
#

Switch is a rather odd construct

prisma wave
#

indeed

jovial warren
#

what? @prisma wave

#

I never knew that

prisma wave
#

yea

lunar cypress
#

It actually has an own instruction that uses a constant lookup table

prisma wave
#

you can only do literals, enums, etc in switch

jovial warren
#

oh yeah you're right

#

I actually forgot about that since it's been that long since I used Java lol

prisma wave
jovial warren
#

actually ya know what, time to switch it up and make a Java project for the first time in months because why not

prisma wave
#

boring

#

clojure project

jovial warren
#

or a C project lol

#

but I know Java so that'll be easier

prisma wave
#

you'd be surprised

#

c isn't OOP

lunar cypress
#

wait, if I remove the parameter type hinting then it will just use reflection for when it's not a Player, no?
@prisma wave since clojure isn't statically typed, type hinting is really just hints. If you type hint a function parameter it's going to use the type as the parameter, but other than that it's decided for each indidividual call. But it does "remember" hints and its inference isn't so bad

prisma wave
#

Okay

#

IJ doesn't give any warnings

#

I assume it's done its job properly

empty flint
#

@prisma wave can I pass a string format in the shape of an interpolated String as a parameter to a function?

prisma wave
#

uh

#

what

old wyvern
#

Java does have switch statements with expressions allowrd i thnk

#

In java 12 or 13

#

Tho

jovial warren
lunar cypress
#

I'm not sure about this case, I'd assume since there is only a single onCommand method it may be able to resolve and infer hints on its own

prisma wave
#

14 I think

old wyvern
#

" enchan ed swotch)

#

Enhancrd

#

Enhanced

jovial warren
#

jesus christ lol

#

we got there in the end

lunar cypress
#

No it doesn't allow for synamic stuff I'm p sure

old wyvern
#

πŸ™ƒ

lunar cypress
#

That would be a big deal

jovial warren
#

also, is it just me or is it funny how you can use a Kotlin DSL build script with a Java project, just sounds like "Kotlin DSL" is something that's Kotlin-exclusive to me, idk

old wyvern
#

It does John

empty flint
#

Nvm I don't think that's possible either way

old wyvern
#

Its kinda diff from normal swtch tho

lunar cypress
#

Mind showing an example?

old wyvern
#

You use arrows

prisma wave
#

@lunar cypress welp...

old wyvern
#

And it doesnt fall through

prisma wave
#

now we're on double reflection lol

lunar cypress
#

I know switch expressions

#

But I am pretty sure they still aren't dynamic

#

Which is what this was all about

jovial warren
#

I've just thought that I'm working on a REST API for BardyBot, and I got implementations to write anyway (albeit literally no one's gonna use them, but eh, it's fun anyway, and you must get some credit for trying, right?)

lunar cypress
#

@prisma wave you removed the parameter type hint?

prisma wave
#

yeah

#

was I supposed to add one somewhere else?

jovial warren
#

also wtf does "No tests found for given includes" mean btw?

#

(trying to run unit tests)

prisma wave
#

no tests found that match the criteria

jovial warren
#

what criteria?

prisma wave
#

Β―_(ツ)_/Β―

lunar cypress
#

No I mean you should leave it I was just wondering if interop inference was strong enough

prisma wave
#

usually package, class name

#

oh

jovial warren
#

yeah I got that, but it doesn't make any sense

prisma wave
#

add gradle test { useJUnitPlatform() } if you're on junit 5

lunar cypress
#

(.kickPlayer ^Player sender text)

prisma wave
#

ah right

jovial warren
#

@prisma wave I have that, but I'm using DSL

#
tasks.withType<Test> {
    useJUnitPlatform()
}
```is what I have
prisma wave
#

yep that works

#

ty

old wyvern
#

Ah nvm john, I read the article wrong

#

Just rechecked it

#

You were rigjt

jovial warren
#

@prisma wave were you talking to me?

old wyvern
#

Its still a constant

prisma wave
#

to johnny

jovial warren
#

okay

#

any ideas about my case?

prisma wave
#

run gradle test and see if it works

lunar cypress
#

What i also like to do (you can see that in connect-four) is make some interop more idiomatic. memfn is useful for that
(def kick-player (memfn ^kickPlayer ^String message))

prisma wave
#

what does that do?

#

I mean I kinda get the gist

#

but specifically

lunar cypress
#

You can look at the source of memfn, it's just a macro that gives you a clojure function that uses interop

jovial warren
prisma wave
#

Ah I expected something like that

lunar cypress
#

Enables you to use it as first class and stop worrying about types

prisma wave
#

@jovial warren you don't have Junit?

jovial warren
#

I have kotlin("test-junit5")

#

do I need the JUnit engine thingy as well?

#

testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.2") this one

prisma wave
#

I believe so

jovial warren
prisma wave
#

@lunar cypress so you'd call it with (kick-player player "blah")?

jovial warren
#

okay works now

#

cheers again mate

prisma wave
#

np

lunar cypress
#

Yeah

prisma wave
#

Looks cool

lunar cypress
#

Yeah well. It's nothing special and you don't technically need it but I just don't like having too many . forms around

#

Interop isn't bad for the most part, but staying as much in clojure as possible is definitely the most convenient

prisma wave
#

yeah idiomatic is always better

lunar cypress
#

Idk if you saw the discussion we had about type hinting arrays @ discljord

#

Now that actually sucks

prisma wave
#

I skimmed it

#

Will have a look

empty flint
#
private var paddingFormat = "%1$-${padding}s"
    var padding = padding
        set(value) {
            field = value;
            paddingFormat = "%1$-${value}s"
        }

I don't like this implementation, is there a cleaner way to simulate setter variable type overloading? (padding is an integer!)

var paddingFormat = "%1$-${padding}s"
        get() = field.removeSurrounding("%1$-", "s").toInt() }
        set(value: Int) { "%1$-${value}s" }

doesn't compile of course

prisma wave
#

What exactly are you trying to do here?

empty flint
#

rofl

#

I am trying to create a string format based on a number

#

"%1$-${padding}s" would result in the format "%1$-60s" for the padding number 60

#

but I want to both access the number 60 and set the value using a number, not a string

#

normally you would write a method that returns that returns that private field in java

#

but I want to access it using a field accessor instead of a method

#

no, actually that's dumb

#

nvm

empty flint
#

I'm having trouble with scratch file encodings for utf-8 characters.

var output = String.format("%s  β†’  %d", "joe", 35)
println(output)

results in
joe ? 35

#

Any ideas how to set that up properly?

#

the IDE is set to UTF-8 and the file does appear to be UTF-8

ocean quartz
#

Holy shit i just spent way too long trying to get Javafx to work with Kotlin and intellij's plugin

quiet depot
#

tornadofx

#

@ocean quartz beepy boopy

ocean quartz
#

Yeah it's what i'm using

quiet depot
#

ah

old wyvern
#

Pig

quiet depot
#

hi

old wyvern
#

Did you have any issues with using gradle with tornadofx

#

didnt seem to work for me last time I used it

quiet depot
#

i’ve never used tornadofx

old wyvern
#

ah

#

There was this weird issue where maven worked but gradle didnt

quiet depot
#

i don’t even use kotlin

old wyvern
#

ohhh rip

#

nvm

empty flint
distant sun
#

i don’t even use kotlin
@quiet depot im so proud of you

onyx loom
#

thanks for the meme matt 🌝

ocean quartz
oak raft
#

why did c# beat java in the race?

#

hint: you're supposed to say "why?"

old wyvern
#

why?

#

@oak raft

oak raft
#

because java couldn't c# 😏

#

I'm somewhat of a comedian if you couldn't tell already

old wyvern
obtuse gale
lunar cypress
#

If I had a penny for every time I heard that joke

lavish notch
#

If I had a pound for every time I heard that ^ joke

obtuse gale
#

because java couldn't c# 😏
Triggered

lunar cypress
#

What joke?

#

"If I had a penny for every time..." is not a joke

heady birch
#

If I had a penny for every time I heard that joke

#

Id probaly have 10 pence

obtuse gale
#

since when do you need to see someone to beat them in a race tho

heady birch
#

@prisma wave

#

How to make kotlin lambda for Supplier

empty flint
#

How do I prevent this from leaking in an abstract class constructor? Is there some init {...} block equivalent for after initialisation where it's certain this has been fully initialised?

prisma wave
#

() -> Type

heady birch
#

Oh nvm

#

Nice

#

Magic

prisma wave
#

@empty flint pretty sure your only option is to ignore the warning (or move to a separate function perhaps)

empty flint
#

vacuum noises

prisma wave
#

😳

heady birch
#

🌝

prisma wave
#

no more

#

i cant take it anymore

#

please stop

empty flint
#

Hm when is a Kotlin companion object initialised?

prisma wave
#

classloading

empty flint
#

Can I specify it as the Main class for a plugin?

prisma wave
#

no

empty flint
#

I guess not, right?

#

yeah

prisma wave
#

because bukkit has to initialize it with the PluginClassLoader

empty flint
#

yeah

#

what would be the best way to implement it as a singleton Plugin object without using the companion?

prisma wave
#

how do you mean?

empty flint
#

I guess just by using an instance variable, right?

#

I feel stupid for asking

prisma wave
#

lol i'm not sure what you're asking

empty flint
#

I just want my class that extends the JavaPlugin to be a singleton

obtuse gale
#

?kotlin-dependency

compact perchBOT
#
FAQ Answer:

Dependency Injection
Dependency injection is when we pass a class through other class constructors to access that specific class in those other classes.

class Main : JavaPlugin() {
    
    override fun onEnable() {
      val other = Other(this)
      
      other.method()
    }
    
    fun myMethod() {
       /* Some code goes in here */
    }
}
class Other(private val main: Main) {

    fun method() {
      main.myMethod()
    }
}
prisma wave
#

practically speaking it is

empty flint
#

that actually works I guess

prisma wave
#

DI > Static

#

or pseudo-static

empty flint
#

DI?

#

oh

prisma wave
#

dependency injection

empty flint
#

yeah

#

I have no idea what that is actually

empty flint
#

How is that example injecting dependencies?

#

explain it to me like im 5

obtuse gale
#

its passing it through the classes constructors

#

?java-dependency

compact perchBOT
#
FAQ Answer:

Dependency Injection
Dependency Injection is a method of passing our dependencies, into the classes that need them. In java, this is commonly done by passing an instance of the dependency via the constructor.

public final class CoolPlugin extends JavaPlugin {
    @Override
    public void onEnable() {
        final Other other = new Other(this);
        other.method();
    }

    public void myMethod() {
        /* Some code goes in here */
    }
}

public final class Other {
    private final CoolPlugin main;

    public Other(@NotNull final CoolPlugin main) {
        this.main = main;
    }

    public void method() {
        main.myMethod();
    }
}```
obtuse gale
#

thats it in java

empty flint
#

And why is that better than static stuff?

prisma wave
#

Because Java (and Kotlin to a degree) are object oriented languages

#

The very idea of static is not object oriented

#

But also it creates a more explicit dependency graph making code more or less tightly coupled which makes it easier to extend in the future

#

lol that sentence kind of means nothing

#

read into SOLID principles if you wanna find how to write "clean" object oriented code

#

?solid

compact perchBOT
empty flint
#

So much stuff to know man

#

it's too much all at once

heady birch
#

Its all fake

#

"Principles" made my Big Coda

empty flint
#
class BlockyDebugPlugin : DistributedBlockyPlugin() {
    init {
        instance = this
    }
    companion object {
        lateinit var instance: BlockyDebugPlugin;
    }

    override fun onEnable() {
        
    }
}

Can I somehow direct every invocation of the companion object to an invocation of the instance? Do I have to specify the same methods in both for that to work or is there a generic method?

obtuse gale
#

static <

empty flint
#

static >
@obtuse gale That's a little too little info for me, what do you mean?

obtuse gale
#

I mean static < lol

#

you should be using DI

empty flint
#
class BlockyDebugPlugin : DistributedBlockyPlugin() {
    init {
        instance = this
    }
    companion object {
        lateinit var instance: BlockyDebugPlugin;
        fun callableFunction() = instance.callableFunction()
    }

    override fun onEnable() {

    }

    fun callableFunction() {

    }
}

Like this?

#

callableFunction

obtuse gale
#

you shouldnt use instance = this anyway

#

so say you need ur main class in like a listener

#
class Listener(private val main:CoolPlugin
0{
  @EventHandler
  fun onPlaceBlock(event:BlockBreakEvent){
    println(main.getConfig().getString("test"))
  }
}
class CoolPlugin: JavaPlugin(){
  override fun onEnable(){
    server.pluginManager.registerEvents(Listener(this), this)
  }
}```
empty flint
#

right?

obtuse gale
#

that way you dont need static/companion object

empty flint
#

but what's wrong with a static companion object? Or is this about the SOLID principles again?

#

Because why would they implement that functionality if that's such a bad thing to do?

#

I don't want to have to pass around the plugin to every class I create that needs it

heady birch
#

solid

#

basically if you want to test some part of your plugin seperatley

#

or whatever

obtuse gale
#

its not that static/companion object are always bad

empty flint
#

but having val plugin: BlockyDebugPlugin in every single class just seems very boilerplate-y and really unnecessary to do when I can access the effectively singleton via the companion

obtuse gale
#

tbh im pretty sure its better to not even pass ur main round, just pass the things you need round, but I mean I dont do that i always pass my main round

heady birch
#

☝️

empty flint
#

tbh im pretty sure its better to not even pass ur main round, just pass the things you need round, but I mean I dont do that i always pass my main round
@obtuse gale Sometimes you need the plugin object though

heady birch
#

Yeah

obtuse gale
#

true

heady birch
#

And that annoys me alot

empty flint
#

same

#

that's why I think my companion object solution is OO enough and clean enough for nobody to complain

obtuse gale
#

I mean its not OO in anyway is it?

empty flint
#

well it's an object so it's gotta be at least 50% of the OO

#

says so right in the name

heady birch
#

Kotlin

#

Wacklin

empty flint
#

That is amazing. Maybe I'm googling something completely wrong but I can't find any tutorial on how to use gradle to replace strings in the plugin.yml file with values from the gradle build file

#

is there a plugin for that?

prisma wave
#

ProcessResources

#

Any form of static state is not object oriented

#

That's not necessarily a bad thing, but you can't deny that

empty flint
#

And I don't

#

But it doesn't have to be

#

conforming to standards when it clearly makes more sense from a logical and readability standpoint to break the standard makes no sense to me

#

that sentence is a mess

#

but I hope it's understandable enough

prisma wave
#

Welcome to OOP

#

Where everything is over engineered and more verbose than it needs to be

empty flint
#

when I specify sourceSets in gradle, do I have to start from the src/ folder or the main/ folder?

prisma wave
#

for what?

empty flint
#

hm no actually I don't need sourceSets, do I?

#

I still don't understand how gradle works exactly :S

prisma wave
#

Β―_(ツ)_/Β―

#

which bit?

empty flint
#
processResources {
    with copySpec {
    ...
    }
}

what does the "with copySpec" mean?

#

What's copySpec in this case? an object? a function?

obtuse gale
#
processResources {
    from(sourceSets.main.resources.srcDirs) {
        filter ReplaceTokens, tokens: [version: version]
    }
}```
prisma wave
#

Probably a function

obtuse gale
#

thats what ive got, it replaces @version@ in the plugin.yml with theversiion

prisma wave
#

but that's more a case of not knowing groovy than Gradle

#
import org.apache.tools.ant.filters.ReplaceTokens

processResources {
    from(sourceSets.main.resources.srcDirs) {
        filter ReplaceTokens, tokens: [version: version]
    }
}
#

this is what I use

#

so yeah pretty similar to aj's

#

just with the import

empty flint
#

why @version@? Does it have to be surrounded by @?

hot hull
#

yus

empty flint
#

Hm does that work with the kotlin source file as well?

prisma wave
#

no

#

from(sourceSets.main.resources

hot hull
#
public class ScrewYouSpigot implements Listener {

    public ScrewYouSpigot(final SpawnerMechanics plugin) {
        System.out.println("Registering Event");
        plugin.getServer().getPluginManager().registerEvents(this, plugin);
        System.out.println("Registered Event");
    }

    @EventHandler
    public void onBlockExplode(final BlockExplodeEvent event) {
        System.out.println("Fired @BlockExplodeEvent!");
    }
}

Being initialized onEnable, yet it doesn't get fired, what the fuck is this shit

prisma wave
#

it'll only process in the resources directory

empty flint
#

from(sourceSets.main.resources
@prisma wave sure but can't you then do from(sourceSets.main.kotlin...) ?

prisma wave
#

spigot bad

#

@empty flint I believe so

#

although it'll probably slow down the build a fair bit since there's now a lot more to process

empty flint
#

Can I specify a single file as well?

prisma wave
#

probably

#

not sure how off the top of my head though

hot hull
#

So it was actually EntityExplodeEvent which gets triggered which begs the question, does BlockExplodeEvent trigger for anything :kek:

obtuse gale
#

Blocks exploding

hot hull
#

But it doesn't Aj

obtuse gale
#

What did you try it with?

hot hull
#

tnt, and creepers

obtuse gale
#

are end crystals considered blocks?

hot hull
#

no

#

entities

obtuse gale
#

how about a bed in the nether

empty flint
#

How do I specify source dirs in kts?

#

the internet isn't very helpful when it comes to examples

#
sourceSets {
    main {
        kotlin {
            srcDirs("src/main/kotlin")
        }
    }
}
#

doesn't work

prisma wave
#

You shouldn't need any of that?

#

that's for multi-platform builds iirc

empty flint
#

But how does sourceSets.main.resources.srcDirs this get populated then?

#

is that automatic?

prisma wave
#

wdym?

#

sourceSets.main.resources refers to a SourceSet that basically wraps src/main/resources

empty flint
#

help

prisma wave
#

you using the kotlin dsl?

empty flint
#

yeah

prisma wave
#

yeah that's groovy syntax

empty flint
#

well

#

that explains it

#

Could you translate that to kotlin for me?

#

I have no idea what these constructs are in groovy

#

this is the right task, right?

prisma wave
#

yeah

empty flint
#

oh I guess I need the task container?

#

is that a task?

prisma wave
#
tokens: [version: version]
``` I believe is equivalent to ```kotlin
tokens = mapOf("version", version)
empty flint
#

how do I print something during the build process?

prisma wave
#

you can probably just extend one of the tasks

empty flint
#

one of which tasks?

prisma wave
#

in groovy it would be like gradle jar { println "Hello" }

#

one of the tasks that gets run in the build process

empty flint
#

I have exactly 0 tasks

prisma wave
#

gradle build is shorthand for assemble, compileJava, jar, etc

empty flint
#

in any of my gradle files

prisma wave
#

there are premade tasks

empty flint
#

which ones?

#

how do I extend them?

prisma wave
#

in groovy it would be like gradle jar { println "Hello" }

gradle build is shorthand for assemble, compileJava, jar, etc

empty flint
#

oh those are tasks?

prisma wave
#

Yes

#

everything that comes after gradle [blah] is a task

empty flint
#

ah

jovial warren
#

DI is better with Koin πŸ™‚

prisma wave
#

kids these days

#

all they know is framework this, framework that

#

i just wanna grill code!

jovial warren
#

lol

#

Koin is a good DI framework

#

and also, yes, frameworks good

#

I love both making and using them lol

prisma wave
#

pff

#

over engineered poppycock

jovial warren
#

wtf?

quiet depot
#

koin

#

tf dat

#

guice masterrace

jovial warren
#

it's a Kotlin DI framework

#

and it's super lightweight

prisma wave
#

supposedly "more idiomatic"

jovial warren
#

it is

prisma wave
#

i'll tell you what's idiomatic

quiet depot
#

what does that word even mean

prisma wave
#

the good old fashioned way

jovial warren
#

because you write DI like this: ```kotlin
val myInjectableClass by inject<MyInjectableClass>

prisma wave
#

hideous

quiet depot
#

yeah that’s disgusting

prisma wave
#

constructor injection or nothing

jovial warren
#

no it isn't

#

nope

quiet depot
#

lel

#

i’m messing idc

jovial warren
#

delegate injection is really handy

#

and it's really idiomatic as well

prisma wave
#

buzzword

jovial warren
#

because I totally know the meaning of that word

quiet depot
#

brug

empty flint
#

So if I define my task using

tasks {
    processResources {

    }
}

how do I call that task?

quiet depot
#

bruh*

prisma wave
#

gradle processResources @empty flint

quiet depot
#

β€œbuzzword” is way more common than all the other words ur saying

prisma wave
#

although it already exists iirc

jovial warren
#

processResources is called when you call build though isn't it?

prisma wave
#

yes

empty flint
#

so if it exists

jovial warren
#

and also that task already exists

empty flint
#

I have to override it?

prisma wave
#

correct

jovial warren
#
processResources {
    // do thingys
}
empty flint
#

getting the hang of it

prisma wave
#

you probably have to do it inside the tasks closure in the DSL or something

#

idk

#

DSL bad

#

groovy good

jovial warren
#

you're not "overriding" it, you're configuring it

#

@prisma wave your mental lol

prisma wave
#

nope

jovial warren
#

I ❀️ the Kotlin DSL

prisma wave
#

groovy is much more flexible

jovial warren
#

but it's ugly and just not good imo

prisma wave
#

ugly?

quiet depot
#

it’s not ugly imo

jovial warren
#

and it doesn't have the kotlin() function xD

empty flint
#

I just didn't feel like having to learn groovy and kotlin at the same time that's why I went with the kotlin dsl

prisma wave
#
compileKotlin {
    kotlinOptions.jvmTarget = '1.8'
}
tasks {
    compileKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }
}
#

don't tell me the first is ugly

quiet depot
#

you don’t need to know kotlin or groovy to use gradle

prisma wave
#

@empty flint groovy is easy

jovial warren
#

and it means that the way I write dependencies would look like this: groovy implementation group: '' artifact: '' version: '' , whereas in DSL they look like this: ```kotlin
implementation("","","")

quiet depot
#

wat

jovial warren
#

(writing dependencies in that way I find is easier to read and looks nicer, but that's just personal preference)

quiet depot
#

they’re literally not comparable

jovial warren
#

what's not comparable?

prisma wave
#

using the group: artifact: syntax is ugly

jovial warren
#

in Groovy it is

quiet depot
#

the point of manually declaring group: and blah is to enjoy the benefits of named parameters

#

the dsl sample you provided, is not named

jovial warren
#

yeah you don't need to name them in DSL, and IJ just shows the names up in those boxes anyway

prisma wave
#

you don't need to in groovy either

quiet depot
#

it’s the equivalent of the shorthand group:artifact:ver

#

albeit, uglier

prisma wave
#

the direct equivalent would be kotlin implementation(group = "", artifact = "", version = "")

jovial warren
#

yeah, that does look a bit worse I'll give ya that

prisma wave
#

groovy good dsl bad

jovial warren
#

I just prefer the way things in Kotlin DSL are laid out, like for example: ```kotlin
tasks.withType<KotlinCompile> {

}
makes more sense to me than groovy
kotlinCompile {

}

prisma wave
jovial warren
#

idk, it's really personal preference

prisma wave
#

verbose

#

bad

#

😠

jovial warren
#

I love the DSL personally, because it's made from Kotlin (meaning it kinda just feels like writing normal code), and it's laid out like it's programming, and it's very idiomatic for Kotlin

prisma wave
#

ofc it's personal preference but I don't get how you could prefer kotlin configure<JavaPluginConvention> { sourceCompatibility = JavaVersion.VERSION_1_8 }
to gradle sourceCompatibility = JavaVersion.VERSION_1_8

quiet depot
#

erm

jovial warren
#

what are you on about BM

quiet depot
#

bardy ur example before

jovial warren
#

that bottom one works in both

prisma wave
#

well

quiet depot
#

once again those aren’t equivalent

prisma wave
#

Β―_(ツ)_/Β―

#

the only benefit of the DSL is having kotlin features

#

and groovy pretty much has most of them

jovial warren
#

@quiet depot yeah I think you're right, wouldn't the equivalent in DSL be something like: ```kotlin
val kotlinCompile by tasks.getting(KotlinCompile::class) {

}

onyx loom
#

grooooooovyyy

jovial warren
#

or am I still wrong lol

quiet depot
#

idk what the dsl ver

#

i use groovy

jovial warren
#

ah okay

#

yeah I don't know how the DSL works all that much either, I've just seen examples of it and kinda just google it when I get stuck

#

one thing that is objectively better in DSL though is the maven-publish plugin's publications layout

#

even though this is very specific, hear me out

quiet depot
#

i’ve never published shit through gradle

#

i just use mvn cli, usually via a bash script

jovial warren
#

in Groovy, you configure the maven-publish plugin a little something like this: groovy publishing { publications { publicationName(MavenPublication) { // configure your publication in here } } } whereas, in DSL, you do it like this: ```kotlin
publishing {
publications {
create<MavenPublication>("publicationName") {
// configure your publication in here
}
}
}

#

and as I said, that's a very specific example, but it still counts

heady birch
#

Lets say I have a few objects (50-100) all using the same value for one of their String fields, is it worth using a small cache (not intern())

jovial warren
#

"a few objects" lol

heady birch
#

Lol

jovial warren
#

I recommend you cache any data that you want to be able to use/be used frequently that comes from an external source

empty flint
#

I just need help with the ReplaceTokens() class for Kotlin dsl, please:

from("src/main/resources/plugin.yml") {
            filter(ReplaceTokens(), mapOf("" to ""))
        }
#

How does that syntax work that you wrote in groovy?

jovial warren
#
tasks.withType<ProcessResources> {
    filter(ReplaceTokens, mapOf("" to ""))
}
```I think?
#

lemme see

empty flint
#

Classifier 'ReplaceTokens' does not have a companion object, and thus must be initialized here

jovial warren
#
tasks.withType<ProcessResources> {
    from("src/main/resources") {
        include("plugin.yml")

        val tokens = mapOf(
                "" to "",
                "" to ""
        )

        filter<ReplaceTokens>("tokens" to tokens)
    }
}
#

that's pretty much what I have

#

I forgot that filter is a reified function in DSL lol

empty flint
#

filter<ReplaceTokens>(mapOf("" to "")) that's it

#

ty

jovial warren
#

yw

empty flint
#

what does reified mean?

jovial warren
#

it's not something I can really explain, @prisma wave this one's your turn lol

empty flint
#

Also, why does it say "tokens" to tokens? doesn't that replace the literal token "@tokens@" with the map.toString() string?

prisma wave
#

Means you can access the type parameter as if it was a class

jovial warren
#

^^ there ya go

#

@empty flint because it's replacing all tokens with the map of tokens

empty flint
#

Means you can access the type parameter as if it was a class
@prisma wave Is that like static access?

jovial warren
#

not quite

#

he means exactly what he says

#

you can access the reified type parameter as if it was a class

prisma wave
#

You can literally do T::class for example

#

It's a byproduct of the inlining process

empty flint
#

mmmmh

jovial warren
#

e.g. imagine doing this in Java: java public <T> T myFunction(Class<T>) { return something; } with reified type params you could do this: ```kotlin
inline fun <reified T> myFunction() = something

#

basically, you don't need to provide a class as a parameter, you can just provide it as a type parameter

empty flint
#

ooooh

prisma wave
#

the function has to be inline though

#

You can't use it with any function

obtuse gale
#

bruh

empty flint
#

so it's a typed inline function similar to a typed class? (idk the correct terminology here)

prisma wave
#

Uh

#

Do you mean generics?

empty flint
#

yes

#

xD

#

but what do you call a class that uses generics?

#

like List<String>

prisma wave
#

The common pattern is a function that takes a Class/KClass with a reified helper function

jovial warren
#

a... generic class...

prisma wave
#

A generic class

empty flint
#

right

#

anyway back to the filter function

#

@empty flint because it's replacing all tokens with the map of tokens
@jovial warren I don't really understand what the literal "tokens" is there for.

jovial warren
#

basically, it's using the class ReplaceTokens to replace tokens, is all you need to know in this context

empty flint
#

what does "tokens" refer to?

jovial warren
#

"tokens" refers to the fact that you want to replace tokens

lunar cypress
#

Lets say I have a few objects (50-100) all using the same value for one of their String fields, is it worth using a small cache (not intern())
@heady birch no

jovial warren
#

or I believe so

empty flint
#

"tokens" refers to the fact that you want to replace tokens
@jovial warren what else would you replace other than tokens?

jovial warren
#

filter can replace other things

empty flint
#

like..?

jovial warren
#

no idea

#

it's just basically putting the contents of the files through a filter

#

there are other things that you'd want to replace

#

I just don't really know what they are

empty flint
#

alright I guess that's not something I need to know now anyhow

#

ty for the reified thingy again

#

oh, also, @hot hull I owe you a coffee because I was stupid yesterday

#

how do I send you some?

hot hull
#

=pl frozen join

compact perchBOT
#

vv2.1.2 by Frcsty
A Fully Customizable Join/Quit Plugin Which Supports JSON Messages, Alongside Unlimited Formats!

Downloads:

571

Likes:

4

Reviews:

14

hot hull
#

You click buy me a coffee fingerguns

prisma wave
#

You should buy me one too since I'm a contributor

#

:)

empty flint
#

send me the link

prisma wave
#

πŸ‘€

#

Uh

hot hull
#

What an unprepared nerd :kek:

prisma wave
#

Lol

heady birch
#

Using a boxed primitive for an optional value e.g:

Integer fieldName;

vs

int fieldName;
boolean has(FieldName);
prisma wave
#

what

heady birch
#

Oh that looks like a method

#

Imagine (FieldName) is the field name

#

Its a variable

hot hull
#

bruh @empty flint Thanks for the 3 coffee ❀️

prisma wave
#

oh shit ty @empty flint

#

I was actually joking lol

empty flint
prisma wave
#

@heady birch so it would be boolean hasFieldName()?

heady birch
#

no

#

int someNumber;
boolean hasSomeNumber;

#

they are fields

empty flint
#

oh shit ty @empty flint
@prisma wave I have no idea if you actually got the cup of coffee or if paypal took all of it.

heady birch
#

vs using an Integer

prisma wave
#

PayPal took like 1/5 of it

#

@heady birch might as well use an Integer

#

Rather than adding a degree of complexity

hot hull
#

Blocky, that site is nice, just sad no spigot kids actually donate :c

prisma wave
#

Or an Optional

lunar cypress
#

OptionalInt

prisma wave
#

^

empty flint
#

I was actually joking lol
@prisma wave I wanted to show my gratitude for all your help :)

bruh @empty flint Thanks for the 3 coffee ❀️
@hot hull ❀️

heady birch
#

Oh yh

#

I forgot about those

lunar cypress
#

niall you can't react to optionals with a puke emoji. i thought you were doing rust

prisma wave
#

@empty flint appreciate it πŸ™‚

#

If only more people did the same thing

heady birch
#

Yeah but rust is different

empty flint
#

Blocky, that site is nice, just sad no spigot kids actually donate :c
@hot hull Gotta force them donations with premium plugins. make those kids yeet their parents' credit cards at their screens

prisma wave
#

Unfair

#

I will file lawsuit

heady birch
#

new File(lawsuit)

hot hull
#

Blocky, ain't got any premium worthy shit :p

lunar cypress
#

Yeah but rust is different
@heady birch how so?

empty flint
#

I don't think I've published enough plugins for premium xD

hot hull
#

You need 3

heady birch
#

It just is

empty flint
#

I got 2

prisma wave
#

πŸ™„

empty flint
#

xD

heady birch
#

Its an enum πŸ™‚

prisma wave
#

you're an enum

heady birch
#

Maybe if Java could do

hot hull
#

I had 5, but deleted 4 (well some still need to be deleted)

heady birch
#

Optional.SOME(10)

prisma wave
#

disgusting

heady birch
#

vs

#

Option::Some(10)

#

So much nicer

empty flint
#

I could probably just publish my debugging plugin and tell people not to download it as I won't be updating it

lunar cypress
#

meh

heady birch
#

oh yes I need some expertises here

lunar cypress
#

the only thing you get from that is pattern matching and java can't do that

#

other than that its functions are very similar

prisma wave
#

It can in 14 or something

#

Kotlin can't do that

lunar cypress
#

not rust pattern matching

#

enums are their own kinda thing

prisma wave
#

true

#

But the syntax isn't ugly as hell unlike rust

empty flint
#

Hm when you unlock a premium plugin, can you delete the free plugins and still publish premium ones?

lunar cypress
#

lmao are you just shitposting yourself to premium perks?

prisma wave
#

Just make 3 clearchat plugins and never update them

#

Ez

empty flint
#

lmao are you just shitposting yourself to premium perks?
@lunar cypress I could, yeah

hot hull
#

Legit just upload some shitty projects

#

Or smaller ones, it doesn't matter, just the count matters

heady birch
#

I am designing a system that needs to look up details via multiple methods "LookupProvider"s. There may be more than 1 lookup provider. Some lookup provider that connect to internet may want to batch stuff (e.g make 1 single HTTP request with 10 lookups instead of 10 separate HTTP requests). This is fine and all but such thing as a "LookupPipeline" exists so that multiple pipelines may be combined if required. Not really sure the best way to design this will callbacks or something? the system I used had a blocking pipeline so Provider 1 would do its lookup and take like half a second on a Map<K, V> (the batch) and Provider 2 would lookup after Provider 1 is done. I guess that actually works fine to be honest but there might be some room for improvement.

for (provider in pipeline) {
provider.lookup(batch);
}

//all processed fine.

prisma wave
#

I am designing a system that needs to look up details via multiple methods "LookupProvider"s. There may be more than 1 lookup provider. Some lookup provider that connect to internet may want to batch stuff (e.g make 1 single HTTP request with 10 lookups instead of 10 separate HTTP requests). This is fine and all but such thing as a "LookupPipeline" exists so that multiple pipelines may be combined if required. Not really sure the best way to design this will callbacks or something? the system I used had a blocking pipeline so Provider 1 would do its lookup and take like half a second on a Map<K, V> (the batch) and Provider 2 would lookup after Provider 1 is done. I guess that actually works fine to be honest but there might be some room for improvement.

for (provider in pipeline) {
provider.lookup(batch);
}

//all processed fine.
@heady birch yes

onyx loom
#

free xp

prisma wave
#

Classic

empty flint
#
class Boop : JavaPlugin() {
    override fun onEnable() {
        System.out.println("maximum boopage activated.")
    }
}

My contribution to unlocking premium perks. The system totally works.

prisma wave
#

Lol 2mb for a plugin that does nothing

hot hull
#

I am designing a system that needs to look up details via multiple methods "LookupProvider"s. There may be more than 1 lookup provider. Some lookup provider that connect to internet may want to batch stuff (e.g make 1 single HTTP request with 10 lookups instead of 10 separate HTTP requests). This is fine and all but such thing as a "LookupPipeline" exists so that multiple pipelines may be combined if required. Not really sure the best way to design this will callbacks or something? the system I used had a blocking pipeline so Provider 1 would do its lookup and take like half a second on a Map<K, V> (the batch) and Provider 2 would lookup after Provider 1 is done. I guess that actually works fine to be honest but there might be some room for improvement.

for (provider in pipeline) {
provider.lookup(batch);
}

//all processed fine.
@heady birch Cool

onyx loom
#

I am designing a system that needs to look up details via multiple methods "LookupProvider"s. There may be more than 1 lookup provider. Some lookup provider that connect to internet may want to batch stuff (e.g make 1 single HTTP request with 10 lookups instead of 10 separate HTTP requests). This is fine and all but such thing as a "LookupPipeline" exists so that multiple pipelines may be combined if required. Not really sure the best way to design this will callbacks or something? the system I used had a blocking pipeline so Provider 1 would do its lookup and take like half a second on a Map<K, V> (the batch) and Provider 2 would lookup after Provider 1 is done. I guess that actually works fine to be honest but there might be some room for improvement.

for (provider in pipeline) {
provider.lookup(batch);
}

//all processed fine.
@heady birch yes

heady birch
#

The system is currently great. One of the greatest that exist. There is room for improvement. Not much though. Maybe a bit. It is already a great system. Great. If anyone... anyone. has any improvements I am happy to take these up. In fact I will be more than happy. Really happy. Thank you for taking the time to read my issue and I hope it find you well

prisma wave
#

how does one do multiple lookups with a single request?

empty flint
#

Lol 2mb for a plugin that does nothing
@prisma wave it activates maximum boopage, wdym?

prisma wave
#

I would suggest you write in clojure to boost the size up to 5mb

empty flint
#

The system is currently great. One of the greatest that exist. There is room for improvement. Not much though. Maybe a bit. It is already a great system. Great. If anyone... anyone. has any improvements I am happy to take these up. In fact I will be more than happy. Really happy. Thank you for taking the time to read my issue and I hope it find you well
@heady birch Are you a spigot dev or wdym by "take it up"?

onyx loom
#

:clojuremoon:

prisma wave
#

πŸ₯΄

jovial warren
#

guess what I've just managed to do

prisma wave
#

Clojure

#

?

jovial warren
#

nope, get an NPE from Kotlin code

prisma wave
#

πŸ™„

#

Y'all really scared of a good old NPE

tacit cave
#

Jotlin

prisma wave
#

Clotlin

jovial warren
#

I got an NPE from Kotlin code

#

and it's a Java NPE, not a Kotlin NPE

prisma wave
#

Sounds like a you problem

jovial warren
#

probably is tbh

heady birch
#

Multiple lookups with a single request: The service I'm connecting to do a multiple lookup accepts some form data. It is a dated service but Nice. One of the nicest systems to work with. Such request parameter might look like values=000000+000001+000002. There may be a lot of this values. Not loads but a lot. A decent amount, You could say anywhere between 1-100. Although its likely to be 1-5 the majority of the time. So not many. It would only reach higher numbers as the program startups. So the api service will return json data with each of the corresponding values sent in the form data, that is the the form data I have mentioned above. The response may be large. But not really large. Not large enough for any compression but still relatively large. Again that depends on the data being requested.

prisma wave
#

this has transcended irony

heady birch
#

What is the irony? Too many people making accusations without backing up their claims these days. If there is irony prove it. Or you could answer my question... I put a lot of effort into detailing the issue and outlining several important points of which you have requested, just to respond with "this has transcended irony" I am unhappy. Not angry just disappointed. But I can assure you I will not let this effect my general view on you or my perspective of the world. Thank you

#

Trump

jovial warren
#

@prisma wave since when could a non-null value in Kotlin become null and throw an NPE?

prisma wave
#

reflection

#

java interop

#

platform types

jovial warren
#

platform types? what are those?

#

also it's literally passed through the constructor

prisma wave
#

like String!

jovial warren
#

it's passed through the constructor as Lavalink<*>

#

at node = lavalink.loadBalancer.determineBestSocket(guildId)

prisma wave
#

yikes

jovial warren
#

lavalink is null apparently, according to debugging

#

and I did some debugging before that point and there's literally 0 reason at all why lavalink should ever be null

#

I literally debugged where that's created, which is at override fun buildNewLink(guildId: String) = JDALink(this, guildId), and I evaluated this, and it told me that it was fine