#dev-general

1 messages ยท Page 347 of 1

jovial warren
#

JitPack is horrible

#

the only things I can recommend are Maven Central or own repo I guess

#

but Maven Central won't suit your purpose

runic flume
#

wdym by own repo?

jovial warren
#

I mean you self-host Nexus or Artifactory or whatever on your own VPS

runic flume
#

Ahh yeah I was about to say

#

Alright, cheers

jovial warren
#

yw

ocean quartz
#

Jcenter is closing right

jovial warren
#

yeah

#

that's why I didn't recommend it

#

and because I've never used JCenter

#

@prisma wave can you please help me with the event system? I want to know if you have any other ideas before I completely scrap the reactive setup and go for a regular event bus

prisma wave
#

I will be honest I have next to no idea where you should go from here

jovial warren
#

guess it's time to wave goodbye to flows and reactive events then

#

and switch to something like LuckPerms' event bus

prisma wave
#

๐Ÿฅฒ

hot hull
#

LP's event bus should be fine no?

stuck harbor
#

vroom

jovial warren
#

yeah it should be fine, just kinda sad how reactivity is going out the window ๐Ÿ˜”

hot hull
#

I mean try harder smh

stuck harbor
#

I just realised

jovial warren
#

R.I.P reactive event manager
12/03/2021-14/03/2021

stuck harbor
#

all I've been doing for the past month

#

is refactoring

#

ffs iwan

#

code better

#

I be sadge now

jovial warren
#

kinda swaying a bit towards Bukkit-style events ngl

#

though with a bit more immutability

#

for example: ```kotlin
class MyListener {

@Listener(ListenerPriority.NORMAL)
fun onLogin(event: LoginEvent) {
    event.isCancelled = true
}

}

#

though I also want to add a way with functions, e.g. ```kotlin
on<LoginEvent>(ListenerPriority.NORMAL) {
it.isCancelled = true
}

ocean quartz
#

Please don't do the priorities like Bukkit

jovial warren
#

wdym?

#

what do you suggest?

ocean quartz
#

Something that isn't reverse
Highest priority being called last makes no sense

winter iron
#

do something like Execute.FIRST

#

or smth

#

maybe up to 5

jovial warren
#

they will be sorted ascendingly

ocean quartz
#

How?

winter iron
#

no

#

its confusing af

jovial warren
#

e.g. HIGHEST first, then HIGH, then NORMAL, then LOW, then LOWEST, then MONITOR

#

if I add all of those

half harness
#

because if you have a low priority that cancelles the event, then a high priority that uncancelles, it's uncancelled

#

so if you want your plugin to choose what's going to happen, you'd want it to be high priority

jovial warren
#
enum class ListenerPriority {

    MAXIMUM,
    HIGH,
    MEDIUM,
    LOW,
    NONE
}
```looks good to me
ocean quartz
#

That's not priority that's importance
High priority means you want it to execute first
High importance means you want it to be the last one to handle the checks

old wyvern
#

ListenerPriority.NONE

#

๐Ÿ™‚

jovial warren
jovial warren
#

like the listener couldn't care less about getting to it first

ocean quartz
old wyvern
#

wdym get in first?

jovial warren
ocean quartz
#

For example you are getting on a plane, if you're priority you'll get in the plane first

jovial warren
#

the problem isn't PQ anyway

#

look at the ordering of the enum values

half harness
#

Yugi what r u saying

old wyvern
#

I was implying that priority is the correct term for this

jovial warren
#

anyway, trying to think of how exactly to do what I want

#

not sure about whether HandlerList is a good idea or not yet

ocean quartz
#

The thing is that Bukkit treats it like importance as you can see in the link bardy sent, but names it priority

jovial warren
#

lol

old wyvern
#

True

#

I thought you meant the usage here was about "importance"

jovial warren
#

I agree

ocean quartz
#

Oh okay, nah i was saying Bukkit is stupid

old wyvern
#

oh ok nvm then

jovial warren
obtuse gale
heady birch
ocean quartz
#

Same

jovial warren
heady birch
#

i can do it with python

prisma wave
#

Annotations ๐Ÿ˜ฉ

half harness
#

@EventHandler ๐Ÿ™‚

jovial warren
#

ew

half harness
#

lol

jovial warren
ocean quartz
#

Very ew

prisma wave
#

functional

jovial warren
#

also, I kinda like the annotation stuff

#

I gotta say

half harness
jovial warren
#

it is one of the few things that I like from Bukkit

prisma wave
#

let registerListener (func: (Event) -> Unit)

jovial warren
#

registerEvents

#

what kinda mad man you think I am

half harness
jovial warren
#

that naming is disgusting lol

half harness
#

๐Ÿ™„

old wyvern
#
eventHandler.on<PlayerJoinEvent>().priority(ListenerPriority.NORMAL).subscribe(myListener)
jovial warren
obtuse gale
#

@Subscription :+1:

half harness
#

what is wrong with my discord :C

obtuse gale
#

Or maybe even

jovial warren
obtuse gale
#

@SubsKryption

jovial warren
old wyvern
#

why

jovial warren
#

yeah no

prisma wave
#

let val register_listener! function = events += function

jovial warren
#

I kinda wanna make this at least semi Java friendly as well if I can

half harness
#
@Priority(priority = HIGHEST)
@ListenerInfo(type = PLayerJoinEvent)
@EventHandler
@Krypton
fun onJoin(PlayerJoinEvent) { ...
jovial warren
#

and supporting the OOP method of listener classes will do that

old wyvern
#

Imma PR a herobrine npc to randomly spawn ๐Ÿ™‚

prisma wave
#

listeners multi map.put(priority, function)

heady birch
#

ListenerInfo

hot heron
#

You can set the TabCompleter of a command the same way you set the executor, you'd just create the logic of what to suggest in that TabCompleter class

half harness
jovial warren
#
class MyListener {

    @Listen(NORMAL)
    fun onLogin(event: LoginEvent) {
        event.isCancelled = true // or event.cancel() may be better?
    }
}
half harness
onyx loom
#

isCancelled looks weird

jovial warren
#

and then also support for functions: ```kotlin
on<LoginEvent>(NORMAL) {
it.isCancelled = true
}

jovial warren
hot heron
old wyvern
#
listen PRIORITY_NORMAL PlayerJoinEvent (\x -> liftIO $ putStrLn $ show x)
old wyvern
#

๐Ÿ˜Œ

jovial warren
#

Haskell syntax is so fucked lol

old wyvern
#

It isnt tho

jovial warren
#

it's a nice language, but the syntax gets confusing sometimes

old wyvern
#

Theres pretty much like 3 things at max thats a "syntax"

jovial warren
#

anyway, no going off on tangents about Haskell

onyx loom
half harness
#
while(true) {
    if (PlayerJoinEvent.activated) {
        joinLogicHere();
        while(PlayerJoinEvent.activated) {}
    }
}
```ez
old wyvern
jovial warren
jovial warren
old wyvern
#

You mena just the $?

jovial warren
#

and the \

old wyvern
#

lambda

jovial warren
#

anyway, no tangents

old wyvern
#

\x means lambda x

jovial warren
#

nice

old wyvern
#

which would be the parameter in the anon function

jovial warren
#

yeah

old wyvern
#

$ is just for right associativity

#

s oyou dont have to spam brackets everywhere

jovial warren
old wyvern
#
liftIO $ putStrLn $ show x

Is equal to

liftIO (putStrLn (show x))
heady birch
heady birch
#

If you want multi thread

#

Have each while loop on its own thread ๐Ÿ™ƒ

half harness
#

lol

jovial warren
#

Niall you make no sense sometimes lol

#

anyway, what do you guys think of the functions and the listener classes?

old wyvern
#

You using annotations?

jovial warren
#

also, notice that listener class doesn't implement Listener because it's completely redundant and unnecessary

heady birch
#

maybe just a bog standard class you can override onPlayerJoin e.g

jovial warren
old wyvern
#

Bad ๐Ÿคท

jovial warren
#

not sure though

jovial warren
old wyvern
#

let them register a functional interface as the event instead, so they can register it like they want to and keep listeners separate

jovial warren
#

example?

old wyvern
#

That way, they can either use lambdas or a separate class depending on the usage size

jovial warren
#

also, the one flaw to having a functional interface with a SAM for handling events is that means you need a listener class per event if you want to use classes

old wyvern
# jovial warren example?
server.eventDispatcher.listenTo(PlayerJoinEvent::class).withPriority(Priority.HIGH).subscribe(MyListener())
jovial warren
#

what would MyListener be?

old wyvern
#

An implementation of the "Listener" interface

jovial warren
#

which is?

old wyvern
#

Or ofc, yo ucould use a lambda

heady birch
#

listenFor maybe?

#

onHear

jovial warren
#

lol

#

I mean, I guess the functional interface method does enforce SRP

prisma wave
#

Would (liftIO . putStrLn . show) work?

#

oh

stuck harbor
#

;)

prisma wave
#

Meant to reply to yugis message

old wyvern
old wyvern
jovial warren
obtuse gale
#

Type erasure ๐Ÿ˜ฌ

prisma wave
#

Poggers

jovial warren
#

then ```
fun <T : Event> listen(class: KClass<T>, listener: Listener<T>)

#

(with a reified extension function ofc)

#

yeah type erasure seems to be biting me in the ass here

#

override fun <T : Event> call(event: T) = listeners.filter { it is Listener<T> } this obviously doesn't work

#

okay looks like filterIsInstance just saved my ass there lol

#

override fun <T : Event> call(event: T) = listeners.filterIsInstance<Listener<T>>().forEach { it.onEvent(event) } looks like it'll work

#

right, now time to deal with priorities ๐Ÿ˜ฌ

#

should I use some sort of priority queue?

distant sun
#

obv

hot hull
#

fellas so I'm in doubts

forest pecan
#

always

hot hull
#

so this is what I currently have, and I'm kind of unhappy how it's panning out since it's not really all that expandable, and some stuff is just ew to begin with (some static registries), anyone got any suggestions as to how I should approach it, I'm gonna be rewritting it from scratch but I'm unsure of what kind of structure to make
https://github.com/op65n/Bedwars

jovial warren
#

@old wyvern any idea how I should handle priorities in my case? was thinking some sort of map to store a listener to its priority and then sort that, but sorted maps only sort by key, not value

forest pecan
#

why not the opposite?

#

priority -> set of listeners

jovial warren
#

ah yeah, that's a good idea

forest pecan
#

lmao

#

multimap

jovial warren
#

wait so how would I actually do that?

#
listeners.toSortedMap { first, second -> if (first.ordinal == second.ordinal) 0 else if (first.ordinal > second.ordinal) -1 else 1 }
```then what?
#
override fun <T : Event> call(event: T) = listeners
    .toSortedMap { first, second -> if (first.ordinal == second.ordinal) 0 else if (first.ordinal > second.ordinal) -1 else 1 }
    .values
    .filterIsInstance<Listener<T>>()
    .forEach { it.onEvent(event) }
```?
#

I'm confused myself just looking at that mess lol

forest pecan
#

Well, define a Multimap right

#

then Multimap.get(PRIORITY).add(LISTENER)

#

are multimaps sorted?

#

by any chance they have a sorted version

#

hm

jovial warren
#

maybe BungeeCord's triple map isn't actually a bad idea

forest pecan
#

triple map?

hot hull
#

no input, sadge

jovial warren
#

private val listeners = mutableMapOf<KClass<Event>, MutableMap<ListenerPriority, Listener<*>>>() @forest pecan

#

but yet again, type erasure makes sure that doesn't work

forest pecan
#

that looks quite horrific

#

lol

jovial warren
#

this is actually just pissing me off now

forest pecan
#

make your own data structure?

#

maybe

jovial warren
#

all I want is a FUCKING EVENT MANAGER THAT WORKS

#

jesus fucking christ

ocean quartz
jovial warren
forest pecan
#

ditch java and kotlin and switch to C++ KEKW

jovial warren
#

maybe the only way to do this is to just not use generics for call

#

okay wtf am I doing

#

why am I trying to use is instead of just ==

#

no wonder that doesn't work

onyx loom
#

๐Ÿ™‚

jovial warren
#
override fun <T : Event> listen(`class`: Class<T>, priority: ListenerPriority, listener: Listener<T>) {
    if (`class` !in listeners) listeners[`class`] = mutableMapOf()
    listeners[`class`]?.plusAssign(priority to listener)
}
```wonder if this will work
stuck harbor
winter iron
#

if i wanted a rest api with some authentication, could i just generate a token per user on my system and when they make a request to say domain.com/resources/<resource-id>/<auth-token>

#

would that be a good way

#

or how else should i handle it

#

most likely using ktor aswell

jovial warren
#

fucking piece of shit useless event manager crap

#

fuck this

#

I can't fucking take any more

ocean quartz
lunar cypress
#

yeah you should definitely use a standard jwt flow

jovial warren
#

I swear, I'm just gonna copy BungeeCord's in a minute and just leave it alone

#

this is fucked

winter iron
#

i see, it just passes the token in the header

jovial warren
#

type erasure is literally the worst idea that Sun ever came up with I swear

ocean quartz
#

True words

lunar cypress
#

it's really not

winter iron
#

is there any difference in passing the token through header or query parameter?

jovial warren
#
class KryptonEventManager : EventManager {

    private val listeners = mutableMapOf<Class<*>, MutableMap<ListenerPriority, Listener<Any>>>()

    override fun call(event: Any) = listeners[event::class.java]?.toSortedMap { first, second ->
        if (first.ordinal == second.ordinal) 0 else if (first.ordinal > second.ordinal) -1 else 1
    }?.values?.forEach { it.onEvent(event) } ?: Unit

    override fun listen(`class`: Class<Any>, priority: ListenerPriority, listener: Listener<Any>) {
        if (`class` !in listeners) listeners[`class`] = mutableMapOf()
        listeners[`class`]?.plusAssign(priority to listener)
    }
}
```like this is complete BS
#

and it probably won't even work

lunar cypress
#

no matter how you twist and turn it, you won't get internally type safe code like this

#

but it is sufficient to make the api typesafe

winter iron
#

how so

#

both are viewable no?

#

i mean it will be over secure lines anyways

ocean quartz
#

Probably not i am not sure, but header seems to be the place to do it
Plus it'll make it easier for you to do with header when using Ktor
https://ktor.io/docs/jwt.html

lunar cypress
#

header is simply made for this sort of stuff

jovial warren
lunar cypress
#

your token has nothing to do with how you query an endpoint

winter iron
#

true

#

header it is

#

!

hot hull
#

I will accept this lack of response as a sign of superiority

jovial warren
#

lol

#

or that no one gives a fuck

#

ยฏ_(ใƒ„)_/ยฏ

hot hull
#

More likely yea sadly

winter iron
#

ill give a fuck?

#

what it is

hot hull
#

scroll up to my msg

heady birch
#

NO Jvm required

#

QUICK startup

prisma wave
#

That's also just ew in general

prisma wave
#

Also why not keep the maps sorted internally

#

Rather than sorting every time

old wyvern
prisma wave
#

``class: Class<*>

#

It breaks the highlighing

old wyvern
#

Use a TreeSet or something

#

Actually I guess that would still require it to be fetched

#

hmm

ocean quartz
old wyvern
#

just saw that

#

clazz is the way to go ๐Ÿ˜Œ

oblique heath
#

is it possible to tell your DNS provider to point every conceivable subdomain to a specific ip (your main domain ip, in my case)

#

like a wildcard for subdomains

#

wait nvm that's literally a thing lol

heady birch
#

The runtime is meant to be packaged within any application anyway!

old wyvern
#

Lol

oblique heath
#

o.o

tranquil crane
#

IntelliJ has decided to stop syntax highlighting and I'm about to strangle it

old wyvern
#

did it start throwing random errors yet?

tranquil crane
#

nope

ocean quartz
#

You start to strangle it and IJ will be like "Harder!"

tranquil crane
#

I tried restarting and invalidating caches and it still didn't do anything

old wyvern
ocean quartz
#

Hell yeah

old wyvern
#

rule34 ij

tranquil crane
#

as a last resort I am installing the 2021.1 beta

#

this sounds terrifying

stuck harbor
#

man

prisma wave
#

Actual gimmick

#

Change my mind

stuck harbor
#

codetogether was a plugin, no?

#

they pulling microsoft stunts here bois

tranquil crane
#

nono this is code with me

#

entirely different

old wyvern
#

Does anyone actually use code with me?

prisma wave
#

There's no way it's practical

old wyvern
#

I've only seen people even mentioning it at the time when it got released

stuck harbor
old wyvern
#

Time to test

tranquil crane
#

amazingly the beta fixed my syntax highlighting

lunar cypress
#

I've tried it before. still in early stages

#

like there's a lot of features you can't use as a guest

#

dunno if they've improved on that now

old wyvern
#

Oh the version that came with ij was a beta?

prisma wave
#

Evil

#

the day that Microsoft/elara gets forked is when humanity is doomed

stuck harbor
#

haha

old wyvern
#

๐Ÿ˜ฎ

stuck harbor
#

elara#

prisma wave
#

god

old wyvern
#

Elara++

stuck harbor
#

checked elara

old wyvern
#

ElaraScript

prisma wave
#

elara studio

stuck harbor
#

at least ms are open sourcing... some... things

old wyvern
#

Elarasaur

stuck harbor
#

github needs a competitor or 3 tho

old wyvern
#

Elara/git to the rescue

stuck harbor
#

github, gitlab, gitea

#

stanks

prisma wave
stuck harbor
#

mhm

old wyvern
#
import elara/git

fingerguns

prisma wave
#

Gitlara will take over from github

old wyvern
#

Glara

stuck harbor
#

it shall

old wyvern
#

Elarit

stuck harbor
#

but how shall elara incorporate?

#

a foundation?

old wyvern
#

Elit

stuck harbor
#

non-profit?

prisma wave
#

Yes

stuck harbor
#

llc?

#

gmbh?

#

ymca?

old wyvern
#

El-it-E

prisma wave
#

I'd love to use gitlab but the github UX is just so much better

old wyvern
#

ELara gIT Extension

prisma wave
#

git 2 made in elara/native

old wyvern
#

๐Ÿ˜ฎ

#

Once elara is usable, I wanna try remaking Clash

prisma wave
#

ooooooo yes

onyx loom
#

๐Ÿ‘€

prisma wave
#

except only purely functional languages allowed

#

which is like

#

3

old wyvern
#

xD

#

Clash of Purity

#

let the purest win!

prisma wave
#

all challenges have no IO

#

you have to solve them as purely as possible

old wyvern
#

yes!

stuck harbor
#

rust... :(

old wyvern
#

Did you guys see cssbattle?

#

Like clash for css

#

xD

stuck harbor
#

jesus

#

that sounds like

#

death

#

i hate css

#

and web dev

old wyvern
prisma wave
#

it's kinda cool

old wyvern
#

I only hate the css part

stuck harbor
#

meh i dislike js

#

but go

#

:)))

#

if only go could be frontend and good as well

old wyvern
#

js is mostly fine for now. Btw all browsers can run wasm rn right?

stuck harbor
#

yeah

#

p much

#

and webgl

old wyvern
#

Are there any non-js properly web languages using that rn? Like without compiling to js to be the intermediary

prisma wave
#

go wasm

stuck harbor
#

rust

old wyvern
#

Oh Rust compiles to wasm?

prisma wave
#

Yeah afaik

stuck harbor
#

yeah

prisma wave
#

C++ probably does too

old wyvern
#

cool

stuck harbor
#

i think wasm was partially designed for rust

#

also yeah c++

prisma wave
#

Probably

stuck harbor
#

with emscripten

#

emscripten is insane

#

so powerful

prisma wave
#

Corrupt mozilla enforcing the monopoly!

stuck harbor
#

mad

old wyvern
#

Elara/wasm

stuck harbor
prisma wave
#

soon we will be drinking Mozilla FOSS Water

stuck harbor
#

filezilla

#

firefox

#

idfk

#

qBitTorrentZilla

prisma wave
#

Firezilla

stuck harbor
#

Disczilla

old wyvern
#

Godzilla

stuck harbor
#

netscape navigator... zilla

old wyvern
#

Godroid

prisma wave
#

๐Ÿ˜ณ

#

It do be fast tho

old wyvern
#

xD

#

Fuchsia when?

prisma wave
#

imagine ... Android plugins in rust with a rust api

old wyvern
#

Hasnt fuchsia been in dev since like 2013?

#

oof

heady birch
#

time to make Java os in swing

prisma wave
#

Android would be 10x faster than ios if google had made the smart decision and used rust

#

But no JACA is veyter

heady birch
#

stupid google

prisma wave
#

Idiots

heady birch
#

Java faster than high performance native swift?

oblique heath
#

android is generally slower than ios

prisma wave
#

ios is generally faster because apps are native

heady birch
#

Is swift native?

oblique heath
#

they make up for it with better specs though

ocean quartz
old wyvern
#

Java on Android is sometimes.... funny

#

Something things just dont work

#

Clabbered with permissions everywhere

prisma wave
#

It has a runtime

#

I think

#

Not zero cost

#

Unlike some languages ๐Ÿ˜…

old wyvern
#

Dalvik bein shit

onyx loom
old wyvern
onyx loom
#

๐Ÿคจ

prisma wave
#

elarasaurus = GIANT kotlinsaurysu = idiot small dinosaur gets stepped on

onyx loom
#

elarasaurus was the true apex predator question mark?

old wyvern
#

elarasaurus IS the true apex predator

#

look whats at your back door

ocean quartz
#

Well Elarasaur was one of the biggest one to have ever existed, but was a herbivore, it'd take around 5 Kotlisaurus to take one down

hot hull
#

@winter iron I presume you gave up? :kek:

prisma wave
#

I have a controversial announcement to make

#

We should see the changes being rolled out shortly

onyx loom
#

that is very controversial

#

although a great addition to enlighten the closed minded of great languages

winter iron
#

๐Ÿ™‚

#

@hot hull is there like 1 map per world thing going on?

#

and im gonna assume its just a plugin u can add to any server for a minigame?

hot hull
#

Yes and yes lol, have you read the name of it

old wyvern
#

@prisma wave bro

#

What was that black 2d game thing you were playing earlier??

#

I forgot its name

forest pecan
#

ScuffedCraft

prisma wave
#

Uh

#

hollow knight?

winter iron
#

@hot hull by the looks of it you have to make each world separately and add its configuration but if your looking to have an expandable amount of arenas, you could spin up a new world and use worldedit to paste in a pre-made schematic of the map at a certain position

#

that way instead of registering each arena as its own, you just make a general layout

hot hull
#

That's exactly what it does rn lol

#

You make a new arena file, specify the shit and you're rolling

winter iron
#

im hella tripping then

hot hull
#

The structure is a mess, probs why

jovial warren
#

that's how fed up I am with this

hot hull
#

It's annoying cause shit depends on other shit so it's hard to make a modular design

jovial warren
#
    private fun findHandlers(listener: Any): MutableMap<Class<*>, MutableMap<ListenerPriority, MutableSet<Method>>> {
        val handler = mutableMapOf<Class<*>, MutableMap<ListenerPriority, MutableSet<Method>>>()
        listener::class.java.declaredMethods.forEach {
            val annotation = it.getAnnotation(Listener::class.java) ?: return@forEach

            val parameters = it.parameterTypes
            if (parameters.size != 1) {
                LOGGER.info("Function $it of class ${listener::class} annotated with $annotation does not have a single argument!")
                return@forEach
            }

            handler.getOrPut(parameters[0]) { mutableMapOf() }
                .getOrPut(annotation.priority) { mutableSetOf() }
                .apply { this += it }
        }
        return handler
    }
```lol
hot hull
#

Ew

heady birch
#

Oh it looks worse because I have discord in a small window.

hot hull
#

On mobile it's disgusting

jovial warren
#

stuck on bakeHandlers

#

since it uses the byte value of the priority and loops

hot hull
heady birch
#

Same naming as bukkit lol

prisma wave
#

Way too much mutableX

jovial warren
#

yeah ik

#

you wanna help me fix it senpai?

prisma wave
#

Rule of thumb: mutabile should only appear 0 times in a file

prisma wave
jovial warren
#

oh also, take a look at bakeHandlers for me pls

prisma wave
#

why the heck is the function returning a mtualbe map anyway

jovial warren
#

look at the do while

tranquil crane
#

I'm in pain reading that

jovial warren
prisma wave
#

Don't blame bungeecord for that atrocity

jovial warren
#

the only thing I like about the source code for BungeeCord is the comments md_5 leaves

winter iron
#

@hot hull is it supposed to make a new world when a new game starts right?

jovial warren
#

was he really tired or was he correct in that statement

heady birch
#

is it me or do {} while () are quite rare

jovial warren
#

yeah they are

#

because it's not very often you want to guarantee that something happens at least once but can happen more than once

tranquil crane
#

that's a good use for it though

hot hull
winter iron
#

ok

jovial warren
#

oh btw, anything I can do about that?

winter iron
#

thats why am tripping

jovial warren
#

because my ListenerPriority is an enum

tranquil crane
#

though I feel like that's inefficient iterating over every single index even if most of them are going to be null

winter iron
#

i couldnt find anything like that so i was hella confused

prisma wave
#

Make a programming language where do while is the only control flow structure

hot hull
#

BM, you need to shut up and your programming languages

#

Finish elara you hoe

tranquil crane
#

can we get a do while do loop

jovial warren
#

lol

#

no

#

you got any ideas btw?

onyx loom
#

๐Ÿค”

jovial warren
#

I don't even understand what this method is for lol

prisma wave
tranquil crane
#

it puts the handlers in the oven and bakes them

jovial warren
#

-_-

#

what does it actually do

prisma wave
#

Bakes them

jovial warren
#

which is?

#

what is baking in this context?

heady birch
#

im pretty sure it just puts them into a list

#

goes through everything

#

PUT in sorted list

#

If i recall it needs rebaking every time a listener is registered/unregistered?

jovial warren
#

OH I see what it does

prisma wave
#

would be nicer with an immutable list

heady birch
#

a mutable list is immutable if you dont change it ๐Ÿ˜Š

jovial warren
#

with the knowledge of BungeeCord's event priorities, I know this is how it sorts them

jovial warren
#

jesus christ this is whack

#

I bet there's an extension function I can use to sort this that's better than that mess

heady birch
#

There is no need to be storing these in maps and wasting valuable RAM

#

When you can so easily scan everything WHEN the event occurs

jovial warren
#

maybe toSortedMap { first, second -> if (first.ordinal == second.ordinal) 0 else if (first.ordinal > second.ordinal) -1 else 1 }

prisma wave
#

what the hell

#

Int.compareTo exists

heady birch
#

๐Ÿ˜ต

prisma wave
#

Please don't do this to me

onyx loom
jovial warren
#

right, so I can just scrap the do while and use what I sent right? (with the compareTo)

#

wait what

#

I'm confusing myself just looking at this lol

#

someone please help me

heady birch
#

What are you trying to do?

#

Cant you just scan all classes and put them in a hashmap?

jovial warren
#

could do yeah

#

need to sort them by priority though

prisma wave
#

map[string]string

jovial warren
#

wat

prisma wave
#

Map<String, String>

jovial warren
#

what about it

heady birch
#

Lmao

prisma wave
#

might be useful

#

Maps are a very important data structure

jovial warren
#

oh come on, that is a terrible hint

prisma wave
#

modern languages like go incorporate maps natively into the language

#

With map literals and types

jovial warren
#

cool

#

gonna try and pretend I care

prisma wave
#

my_hashmap := map[string]string {}

#

Empty map

#

How much memory will this use??

heady birch
#

Is that Go?

prisma wave
#

Maybe 1 byte

#

Maybe 20

prisma wave
jovial warren
#

BM enough

heady birch
#

Rust would use 0

#

ZERO

prisma wave
#

struct {} will use 0 bytes memory

heady birch
#

Doesnt a java object have like 40 bytes overhead

prisma wave
#

yes

#

VwEey inefficient

heady birch
#

Why

jovial warren
#

why do I bother to ask for anything in this channel

prisma wave
#

headers

heady birch
#

You see if I was James Gosling I would not have added that

#

I am honestly not sure

#

Map<[event enum or something?], List<[handlers]>?

#

Where List<[handlers]> is sorted

#

What does bungeecord use as the Map<1, List<2>> 1

heady birch
#

Oh class ofcourse

#

Lol

#

For a moment I was thinking string

prisma wave
# heady birch Why

they need to store important information like if you are on the windows insider build version 3.225438 (which is not important trust me) in every single object

jovial warren
#

right, the best way to solve this actually is to stop looking at this code and think about the problem I need to solve

heady birch
#

yeah

#

Draft it in Jython

prisma wave
#

draft it in rust

#

Rust is basically pseudocode

jovial warren
#

I need to take a class of functions with annotations, group them by event and sort them by priority, then dispatch events to them

prisma wave
#

gcse computer science will be teaching our kids to write &mut T before hello world

jovial warren
#

lol

heady birch
#

println!("Hello, World!");

jovial warren
#

my GCSE computer science class can barely write hello world in Python without help lol

heady birch
#

LOL

prisma wave
heady birch
#

Hmmmm.

#

I want to know what is behind println!

prisma wave
#

pain

#

You can look at the source

#

It's not pretty

jovial warren
#

I think one of the best ways I can kill a lot of the mutability here is by disallowing registration of the same class twice

onyx loom
prisma wave
#

the putStrLn impl in haskell is also terrifying

jovial warren
#

right, so first I need to find the handler functions in the class

#

then I need to get the priorities and sort them

#

right?

#

then put them in the map

heady birch
prisma wave
#

many modern languages will have convenience functions for sorting lists

jovial warren
#

why do I bother asking for any help in this channel

prisma wave
#

not configuration help

onyx loom
#

sortedBy :)

heady birch
#

Hey I have provided help

jovial warren
prisma wave
#

it's not

#

Just reminding you

#

In case you ask for configuration help

jovial warren
#

thanks Niall

prisma wave
#

Because if you did ask for configuration help you would be asking in the wrong channel

#

Because this channel is not for configuration help

#

๐Ÿ™‚

jovial warren
#

right, cool, now would you mind helping?

#

you reckon I can replace forEach with map somehow btw in findHandlers?

prisma wave
#

probably

onyx loom
#

people in helpchat are not required to help other members, instead helping is done at will in peoples free time ๐Ÿ™‚

prisma wave
#

yes even an esteemed HELPFUL ROLE member has no obligation

#

But the answer to your question is yes

static zealot
#

WRONG. you are all our slaves and will help at any hour in the day and any day in the year.

#

If you refuse then something very bad will happen

prisma wave
#

STOP

unkempt tangle
#

How can you identify a files associated file type? When you can't tell by his file header?

#

Stop making senpai mad

prisma wave
#

lol

ocean quartz
#

So, i'm working with a stupid API that returns a list of skills separated by new line, something like:

1367483,320,595908
1566226,16,2810
1228885,33,19403
1545972,16,2810
1358646,32,17475
1048681,31,16000
832153,43,55462

What would be the best way to map this into a data class without having to go over each line one by one? thonking

rapid helm
hot hull
#

Isn't it just print("Hello World") in python?

winter iron
#

yes

#

lol

prisma wave
jovial warren
#

I'm just gonna depend on BungeeCord Event in a minute and be done with it

hot hull
#

My brain

winter iron
#

line by line is the way

jovial warren
#

I'm fucking done with this shitty fucking event bus PIECE OF SHIT

hot hull
#

My event bus doesn't work bardy

obtuse gale
#

Bardy I'm going to wash your mouth with soap

hot hull
#

It get's executed but doesn't call any of it's subscribers :((

prisma wave
#

gcse curriculum should cover the drawbacks of mutability and how purely functional languages are objectively better

jovial warren
#

I've spent ALL FUCKING DAY trying to get this mother fucker to work and I've got NOWHERE

obtuse gale
#

Lots of soap

jovial warren
#

I'm not in the mood

rapid helm
#

in my computer science class i was asked "write benefits of waterfall"
all that was coming in my head was minecraft water fountain

hot hull
#

Fefo I got soap for you as well

onyx loom
#

but swearing is bad!

#

wash ur mouth it!

hot hull
#

Bungee fork

rapid helm
#

guess they meant waterfall network? or i don't remember what was the question

winter iron
#

development life cycle

hot hull
#

If that's what they meant kek

ocean quartz
# prisma wave Why can't you go like by line?

Like, this is my data class, it's stupid long so i'll cut more than half of it

data class Skills(
    val overall: Int,
    val attack: Int,
    val defence: Int,
    ...
)

I have a list with each line that i'll have to map into that class, the thing is I don't want to have to go like:
Skills(data[0], data[1], data[2])

rapid helm
jovial warren
#

can't you use destructuring there?

#

right fuck it

#

I'm depending on BungeeCord Event

#

I actually can't be assed anymore

hot hull
#

Bardy

prisma wave
hot hull
#

Shame on you!

jovial warren
#

FFS

onyx loom
#

lol

hot hull
#

You were supposed to beat them, not join them

prisma wave
#

Do you do that in GCSE?

jovial warren
#

I can't be FUCKING ASSED ANYMORE

rapid helm
#

it's AS Levels, igcse

hot hull
#

Just depend on it for rn and you'll change it later Bardy

ocean quartz
rapid helm
#

cie basically

prisma wave
prisma wave
ocean quartz
#

Yeah that was what i didn't want to do, I'll show you why lmao

prisma wave
#

I don't think our course covers that

winter iron
#

oh god, pre the 400 vars in his class

unkempt tangle
#

Anyone knows the file extension .ls ?

ocean quartz
#

Actually that won't work, i'll just go manually ๐Ÿ˜ฉ

ocean quartz
hot hull
#

Kek

onyx loom
#

oh my god

hot hull
#

That seems prone to breaking

ocean quartz
#

Exactly but i can't think of any other way to do this

hot hull
#

jSoN

ocean quartz
#

Tell that to the stupid api

hot hull
#

Mcmmo I'm guessing?

prisma wave
#

Possibly the worst thing I've ever seen

ocean quartz
hot hull
#

Kek

ocean quartz
prisma wave
#

๐Ÿคข

#

shame that kotlin doesn't have some sort of spread operator

ocean quartz
#

Each skill/category is on a new line (split by a new line delimiter: \n), and each line has three comma-separated values:

hot hull
#

Atleast do checks so it doesn't error out if one is fucked up

ocean quartz
#

I'll do something else but god this is so bad

ocean quartz
#

Doesn't work for non varargs stuff

prisma wave
#

Yeah that's just for varargs

#

I mean kinda like what JS has

#

Skills(data...)

ocean quartz
#

I have a better idea, not as organized as data class would be but less painful

#

Nevermind I don't have a better idea, someone shoot me please

old wyvern
#

What are you trying to do?

obtuse gale
tropic mountain
#

Alright thanks

jovial warren
#

finally

ocean quartz
# old wyvern What are you trying to do?

Basically the stupid api will return a bunch oh numbers that i need to map to the right skill

Each skill/category is on a new line (split by a new line delimiter: \n), and each line has three comma-separated values:

jovial warren
#

may or may not have taken me copying BungeeCord's EventBus into Kotlin but I got cancellable events

#

oh btw, the Listener interface doesn't exist, since it's literally pointless

obtuse gale
#

Just use Guava EventBus ezpz

prisma wave
#

elara standard library has a thing for this

jovial warren
obtuse gale
#

Bardy I told you already to use KyoriPowered/event ::::::)

jovial warren
jovial warren
#

Kyori stuff all seems to use methods that aren't Java standard, so Kotlin can never convert them to properties

obtuse gale
#

Weren't you gonna use something like LPs event bus?

jovial warren
ocean quartz
obtuse gale
#

What's wrong with it?

jovial warren
#

which I actually kinda like tbh

obtuse gale
#

With LPs*

jovial warren
old wyvern
#

๐Ÿ˜ฌ

ocean quartz
#

Exactly

young kettle
#

How easy would it be to make a plugin that would shoot out tnt at different fire arcs using a defined cannon/turretbuild. Similiar to that seen in the Cannons plugin? I wonder whether Iโ€™d be better off paying someone to edit that plugin to get tnt working as a projectile. Not sure if devs like working on other open source stuff tho

old wyvern
#

Have they provided any ordering index?

old wyvern
#

Like somewhere else?

jovial warren
ocean quartz
#

They have a list in which other the skills come, but nothing on the request
So no matter what I'll have to manually map all 24 skills

old wyvern
#

Damn ๐Ÿ’€

ocean quartz
#

I think best way is to make an enum for each skill then add it all to a map

heady birch
#

Go + fortran?

prisma wave
#

Anything under E?

heady birch
#

You will love this

#

o:XML is an open source, dynamically typed, general-purpose object-oriented programming language based on XML-syntax. It has threads, exception handling, regular expressions and namespaces. Additionally o:XML has an expression language very similar to XPath that allows functions to be invoked on nodes and node sets.

obtuse gale
heady birch
#

Erlang

prisma wave
heady birch
#
<?xml version="1.0"?>

<o:program>
  <o:type name="HelloWorld">
    <o:function name="hello">
      <o:do>
        <o:return select="'Hello World'"/>
      </o:do>
    </o:function>
  </o:type>
  <o:set instance="HelloWorld()"/>
  <o:eval select="$instance.hello()"/>
</o:program>
#

Actually this is pretty cool

#

Its like PHP but for vector graphics

obtuse gale
#

lmao

prisma wave
#

What the hell

heady birch
#
<o:program>
  <o:param name="file"/>
  <o:import href="lib/io/File.oml"/>
  <svg:svg>
    <o:for-each select="io:File($file).parse()//section">
      <o:set x="count(preceding::section) * 30 + 20"/>
      <o:set words="count(.//text().match('\w+')) * 2"/>
      <svg:rect width="10" x="{$x}" y="{250 - $words}">
        <o:attribute name="height" select="$words"/>
      </svg:rect>
      <svg:g transform="rotate(45, {$x}, 260)">
        <svg:text x="{$x}" y="260">
          <o:eval select="title/text()"/>
        </svg:text>
      </svg:g>
    </o:for-each>
  </svg:svg>
</o:program>
#

This was in 2004

#

They were way ahead of their time

jovial warren
#

more like way behind their time

#

XML big ew

heady birch
#

Society if we used o:xml

prisma wave
#

I feel like big tech is hurting themselves by not adopting this

prisma wave
#

Ok liberals... So there's a rust foundation but not an o:xml foundation...? So much for inclusivity

heady birch
#

O:xml

#

SuperX++

#

wait so can a web browser just run this

#
<class name="XTree" inherit="XPlant">
   <construct>
      <scope type="public">
         <Chlorophylic>yes</Chlorophylic>
      </scope>
   </construct>
   <scope type="public">
      <func type="string" name="GetChlorophylic">
         <body>
            <return>
               <eval object="Chlorophylic" />
            </return>
         </body>
      </func>
      <func type="void" name="SetChlorophylic">
         <parm type="string" name="sVal" pass="val" />
         <body>
            <eval object="Chlorophylic">
               <eval object="sVal" />
            </eval>
         </body>
      </func>
      <func type="int" name="GetAge">
         <body>
            <return>
               <eval object="this" member="Age" />
            </return>
         </body>
      </func>
      <func type="void" name="SetAge">
         <parm type="int" name="sVal" pass="val" />
         <body>
            <eval object="this" member="Age">
               <eval object="sVal" />
            </eval>
         </body>
      </func>
   </scope>
   <scope type="protected">
      <var type="int" name="Age">0</var>
   </scope>
</class>
prisma wave
#

What the fuck

errant geyser
#

What in the shit is that

heady birch
#

๐Ÿฅบ Who going to make Intelli J plugin for it

ocean quartz
# old wyvern Damn ๐Ÿ’€

Not so ugly

val data = rawData.split("\n").chunked(24).first().map { it.split(",").getOrNull(1)?.toIntOrNull() ?: 1 }
return values().withIndex().associate { it.value to data[it.index] }

(The chunked is because it has categories at the end, i only need skills)

errant geyser
prisma wave
#

Lmao not at all

heady birch
prisma wave
#

Amazing

#

Interested in seeing where this goes

heady birch
#

Last update: 2015

old wyvern
#

Btw should you really be using a default value there in case of null?

#

Shouldnt it fail at that point instead of taking wrong data?

ocean quartz
#

I think so, since that's similar to how the API works, it'll be 1 by default

old wyvern
#

ah alright

static zealot
#

Imagine having to set an option in config.yml for absolutely every check you make in your plugin. At that point they'd be better of using Skript ๐Ÿ˜ข

narrow geyser
#

Hi

ocean quartz
#

Heyo

half harness
#

im confused

#

what doesn't know the server version

#

and how can a jar break the Bukkit#getBukkitVersion thonking

#

and what is a "check"

static zealot
#

he's using a custom jar which breaks Bukkit#getBukkitVersion and glare has a check in VoteParty that checks if its 1.13+ or lower and since it doesn't actually give the version it gives just Unknown and breaks the whole plugin because glare just parses the string as an int

half harness
#

oh jeez

#

some custom jar

obtuse gale
half harness
#

i thought he was talking about a plugin

#

where's a good place to store source jars/zips? (for intellij to use)

#

like

#

where are all the others stored?

oblique heath
half harness
#

but the thing is, the maven repo doesn't always have sources.jar

#

so i have to download via github

#

(which works btw)

#

but where should I store the zip?

#

and where are the other source jars stored

obtuse gale
#

You can click Choose Sources... and just point it to the sources jar

half harness
#

where should i put the sources jar

obtuse gale
#

anywhere

half harness
#

but

#

like

half harness
obtuse gale
#

in the same folder the jar with the compiled classes is

half harness
#

which is where?

obtuse gale
#

by default in maven local, user folder -> .m2/repositories/<groupId>/<artifactId>/<version>/<artifactId>-<version>-sources.jar

half harness
#

thx

half harness
#

since i dont have repositories

obtuse gale
#

yeah ig

half harness
#

alr

#

thx

#

uh

forest pecan
#

lol

static zealot
#

they did not

forest pecan
#

oh

#

im not in there

onyx loom
#

buy the plugin fingerguns

obtuse gale
#

Just buy the plugin

#

Duh

#

๐Ÿ’

oblique heath
forest pecan
#

im sry im poor

obtuse gale
#

Why would you be sorry thonking

ocean quartz
oak raft
#

Just stop lol

static zealot
#

โ€ซ> โ€ซ<

#

copy one of the arrows and paste them back

#

or just both

hot hull
#

Blitz, go sleep

obtuse gale
#

@jovial warren tbh I don't really get what you don't understand about cancellable events in LP, I found that bit very straightforward compared to the whole other runtime generated event classes & methods & fields and all that reflection megahack

#

Took a peek at it, I was like "why are there no implementations...?"

#

But yeah given the amount of events there are it would definitely be a huge PITA to have interface + impl for all of them for a handful of fields lol

errant geyser
jovial warren
#

I will probably switch to something different in the future, but this will do for now

#

I think my comment in KryptonEventBus just says it all though

jovial warren
#

fun fact I just found out btw: Math wonโ€™t always actually call StrictMath internally even though the source code says otherwise. according to the docs, StrictMath is actually what you should be using most of the time, as its implementation must always be the same on all platforms. The same canโ€™t be said for Math, which varies with implementation

#

in short, use strict math where you want to essentially guarantee producing the same result regardless of the platform

#

I doubt this is news to some of the more technical of you lot here

#

elara/math will have reproducible results on all platforms ๐Ÿ˜Ž

#

and will be faster than slow JVM trash math lol

#

if JNI can actually be reliable for once

half harness
#

me: didn't even know that StrictMath existed and didn't know what it does

jovial warren
#

but FP on the JVM is a sin lol

jovial warren
#

FP is great, donโ€™t get me wrong, but the JVM is just not designed to support it

half harness
#

what is FP?

stuck harbor
#

functional programming, I assume

jovial warren
#

We should scrap the JVM and just make Elara run natively imo

stuck harbor
#

mmm

#

nah

#

.net bois

jovial warren
#

Also, when most of the issues highlighted in a review for a PR that's not yours are your fault ๐Ÿฅฒ

lunar cypress
#

that's why strictfp exists

lunar cypress
#

we have several functional languages on the JVM that work great

#

The days where the JVM was only built for java are long gone

jovial warren
#

Wrapping everything in objects just feels like it defeats the point of FP imo

lunar cypress
#

that's implementation detail

#

when you use functional programming you don't really care how that is represented internally?

jovial warren
#

Yeah what I meant by my statement is what it looks like and how it functions internally

#

Not the usage of the languages

lunar cypress
#

no cpu can understand the lambda calculus

#

It's always going to be imperative at some level

jovial warren
#

True

lunar cypress
#

The JVM is very flexible nowadays, who says that the implementation of a functional language has to be functional itself

jovial warren
#

True

jovial warren
#

Might do a big refactor of Krypton's internals soon to fix the issues highlighted by Codacy's static code analysis

#

Like splitting up the packet handler, or beginPlayState, or even loadWorld, to absolutely obliterate god objects and functions

#

Also to get the server in a state where you can depend on it without having a headache trying to figure out what everything does and why it's there

prisma wave
#

Say that again

#

if we can make ruby run on the JVM we can get FP on it

#

Granted interop can sometimes be annoying

#

But it's a lot easier than native implementations

jovial warren
#

Lol

#

Will Elara have native implementation support btw?

#

Like native in Java

#

Or external in Kotlin

forest pecan
#

Interprotation when

#

i cant spell

jovial warren
#

Lol

prisma wave
#

Probably to a degree

jovial warren
#

So I can write native maths

prisma wave
#

What do you mean by native

#

Because Java native is different to external

jovial warren
#

Like maths in C

prisma wave
#

oh so JNI

jovial warren
#

Yeah

prisma wave
#

Probably not then

#

We can just delegate to java if that's ever necessary

frail glade
jovial warren
#

Yeah JNI might make it slower lol

#

Hello Glare

prisma wave
#

well for maths most of it is already done

jovial warren
#

Yeah

prisma wave
#

No need to reinvent the wheel

#

Apart from for convenience stuff

jovial warren
#

We probably want to use StrictMath though

prisma wave
#

Math...?

jovial warren
#

Since Math is unreliable

prisma wave
#

Not particularly

jovial warren
#

Did you read what I detailed earlier?

prisma wave
#

yes

#

However given 99% of code uses the Math class we might as well use that

jovial warren
#

Eh, Kotlin's helper functions use StrictMath

#

Math is not guaranteed in its implementation to be platform agnostic

prisma wave
#

Do they?

jovial warren
#

StrictMath is

jovial warren
#

Which calls StrictMath

prisma wave
#

Huh TIL

jovial warren
#

StrictMath must always return the same results in its implementation, platform agnostic

old wyvern
#

You ussually never need the exact precision

prisma wave
#

But that sacrifices platform specific optimizations

#

^

old wyvern
#

If you do ever need that, onyl then is it useful to specifically use StrictMath

jovial warren
#

Math contains some compiler stuff from what I read internally, and its implementations that call StrictMath don't always call that internally

prisma wave
#

StrictMath is like using BigDecimals everywhere

prisma wave
#

Which are usually faster

#

I can see the pros and cons to both

jovial warren
#

Yeah

half harness
#

๐Ÿ‘€

lunar cypress
#

and that's the thing, most of the time when you want consistent results you also want precision and don't use floating point numbers to begin with

#

The field where you really need this is rather narrow I believe

prisma wave