#dev-general

1 messages · Page 169 of 1

prisma wave
#

that'll give a close approximation

old wyvern
#

a ext property

#

mhm

empty flint
#

jesus christ enough with the material. it doesn't work. All potions have the same material yet different names.

prisma wave
#

afaik there's no way to get Iron Sword from Material.IRON_SWORD if that's what you mean

#

it's client side

empty flint
#
[23:10:18] [Server thread/INFO]: [Blocky Debug] | DEBUG | item: {"type":"GRASS_BLOCK","v":2567}                            | ORIGIN: NmsTestCommand in method parseCommand at line 97
[23:10:18] [Server thread/INFO]: [Blocky Debug] | DEBUG | localized name:                                                  | ORIGIN: NmsTestCommand in method parseCommand at line 98
[23:10:18] [Server thread/INFO]: [Blocky Debug] | DEBUG | display name:                                                    | ORIGIN: NmsTestCommand in method parseCommand at line 99
#

it's client side
@prisma wave But the server has to get that info as well somehow, for sure

prisma wave
#

why would it?

pastel imp
#

hmm question of the day

#

should I make my own Essentials?

#

lol

#

I mean private server

empty flint
#

why would it?
@prisma wave To get the localized name?

#

Also I have never seen the localized name be anything other than an empty string

old wyvern
#

Should I reinvent the wheel for my car?

#

😂

empty flint
#

Should I reinvent the wheel for my car?
@old wyvern Yes. Make it square and the road bumpy

old wyvern
#

Good idea

empty flint
#

@prisma wave [23:17:14] [Server thread/INFO]: [Blocky Debug] | DEBUG | nms name string: Grass Block

#

it does have the actual name

#

on nms side only though

#

for some godforsaken reason

empty flint
#

Why does nms even exist man, can't they just put all those methods in the spigot api as well?

#

like fuck why do I have to keep track of the damn game version...

steel heart
#

well they will

ocean quartz
#

NMS is the base Minecraft server that bukkit is made on

steel heart
#

as mojang is gonna release unobsfucated mappings now

old wyvern
#

nms isnt done by spigot

steel heart
#

iirc its pretty soon

ocean quartz
#

We already have maps

old wyvern
#

The packages will still exist

#

mhm

ocean quartz
#

Since 1.14

#

Anyways you should just use the Spigot serializer that i sent you

empty flint
#

@ocean quartz This is about the item name, not the serialization anymore

#

can't get the name of a potion without nms

#

like the actual name of the itemstack

steel heart
#

Heads up Minecraft modders: On Friday we'll change the legal text on our obfuscation mappings. We're hoping that this change will make the legal terms clearer for projects like MCP/Forge/Spigot/etc to operate going forwards, ideally using our maps, and make modding easier for...

Retweets

261

Likes

2203

ocean quartz
#

It's just that the current maps aren't great plus some legal stuff that's why they're changing

empty flint
#

Where are those maps published?

#

How are they used?

#

Does Spigot handle all that or do we have to?

#

And does that mean no more NMS?

#

Also: when`??

ocean quartz
#

They are in the Minecraft folder in the versions there is a version json file with the Link to the mappings

#

Nms won't change

#

You can just look up what the names mean

#

That's all

empty flint
#

Well how does that help at all lol

#

Most of it has already been figured out and de-obfuscated

ocean quartz
#

It helps a whole lot

steel heart
#

instead of fieldnames like a it would be something more descriptive

empty flint
#

They are in the Minecraft folder in the versions there is a version json file with the Link to the mappings
@ocean quartz Server or Client Minecraft folder?

#

I don't see a versions folder

#

oh in the .minecraft folder

steel heart
#

.minecraft/version/<version>.json/

#

I think its 1.14 and above only might be wrong

ocean quartz
#

^

steel heart
#

well mcp exist for older versions

static zealot
ocean quartz
#

I think mine was simpler, just too manual xD

static zealot
#

yeah

jovial warren
#

what dis

static zealot
#

its a spiral algorithm to find the closest safe block.

#

now I have to redo my code to integrate it xD

#

but something is not right

#

because that algorithm only takes the values 0, 0 right?

#

oh I'm good.. I think its suppose to be relative coordinates

pastel imp
#

is it a good thing to make my own essentials plugin? or is it a bad idea?

static zealot
#

I mean why tho? If you want some things changed and add some features they don't have yes if not don't think so

#

I mean what I'm doing is making a Core plugin where I added features like: /giveall, changing of tablist, a new /back command which is better xD

#

also custom join/leave messages

pastel imp
#

I mean kinda depends

#

but the thing I am worried is bugs

#

cause essentials plugins

static zealot
#

isn't essentials OS tho?

pastel imp
#

are the CORE of the CORE

static zealot
#

so you could just edit Essentials to work how you like it but then when they update it it would take you a bit to update unless you follow the dev builds.

#

But as I always say probably wait for responses from more experienced developers as I am not even close to be qualified as a developer.

#

That is just my opinion.

pastel imp
#

ok ty

#

cause I mean.. a plugin like that.. if it fails.. rip server

#

if it lags... rip server

#

it's a "nasty" thing to work with

#

also editing essentials isn't the best idea

#

cause the code won't still be mine

#

soo

#

that kinda sucks

static zealot
#

oh I see you want a public plugin

#

I thought you want a private plugin for yourself. I mean I dk

#

Just make small plugins that are the best at what they do. I think that's the best idea

steel heart
#

anyone knows how to execute a gradle command like gradle -q in the console with a task. There's literally nothing on the internet about this or I am a shitty googler.

#

@prisma wave do you know

#

?

prisma wave
#

uh what

steel heart
#

nvm

prisma wave
#

Ok

ocean quartz
#

I just spent 15 minutes trying to figure why my gradients weren't working just to find i had the same hex in both places..

static zealot
#

oh man

ocean quartz
#

Basically

final MessageComponent component = message.parse("**markdown** message");
component.send(player); // sends to player with actions and stuff
component.asString(); // returns it as string for items and etc
static zealot
#

easy to use. I like that

tacit cave
#

Hwllo

#

How do I register shaped recipe in main class from a class?

#

Kotlin obviously

ocean quartz
#

I mean it's the same way in Kotlin as in Java

static zealot
#

yo matt how do I see recent changes again? xD

#

in IIJ

tacit cave
#
server.addRecipe(RecipeClass(). customItem())```
#

how

ocean quartz
static zealot
#

VCS... why is it hidden under a tab that I have no idea what it means

ocean quartz
#

version control systems

#

@tacit cave I mean yeah just like that

steel heart
#

gradle sucks sometimes

ocean quartz
#

you're trying to start a war

steel heart
#

no but this build_5n8420bxp70eddllc0ko7eue8$_run_closure1@777a8227

#

havent been able to solve it like for 2 h

#

just figured out

#
String something = {
  return "test"
}
println(something) //returns garbage value
#

and its rly pissing me off

#

oh wow im dumb as usual

static zealot
#

oh man Matt I owe you. You just spared me from another 2 days of scratching my head then hitting it in the wall xD

ocean quartz
#

That thing helps so much, you can even recover deleted files with it

static zealot
#

I was talking about the .clone() thing. The deleted thing saved me from like 2 hours of rethinking some shit. so you saved me from 50 hours of wasting time xD

ocean quartz
#

oh

static zealot
#

now I just have to understand why .isSolid is not working as I was hoping it should xD

ocean quartz
#

Yeah, i remember doing a crate animation before and the armorstand was doubling in location all the time before of it

steel heart
#

like how dumb can one possibly be?

static zealot
#

I was hoping that this check !location.block.type.isSolid || (location.block.boundingBox.widthX < 16 || location.block.boundingBox.widthZ < 16) would be true when the location is either air or a solid block that is not a full block.

steel heart
#

fkn forgot to close an input stream so it potatofied my pc rly hard

static zealot
#

xD

ocean quartz
#

like how dumb can one possibly be?
Well..
I just spent 15 minutes trying to figure why my gradients weren't working just to find i had the same hex in both places..
Me ^

steel heart
#

lol

static zealot
#

I guess I have to do something like location.block.type.isAir|| (location.block.boundingBox.widthX < 16 || location.block.boundingBox.widthZ < 16) hmm I wonder if this would work for all blocks.

steel heart
#

well I'm dumb and thought a Closure would return its type

viscid charm
viscid charm
#

u'd need a custom jar/spigot.jar

split talon
#

@ocean quartz How're you getting gradients on itemnames? o.o

ocean quartz
#

Just as string

surreal quarry
#

is that using the MD parser you have

ocean quartz
#

Basically §x§0§0§0§0§0§0
And nah

split talon
#

dang lol

distant sun
#

Can you even use regex to match hex on a string?

hot hull
#

Yes?

distant sun
#

Test it :(

split talon
#

regex bad if it's called a bajillion times

empty flint
#

regex bad if it's called a bajillion times
@split talon Nothing is good if it's called a bajillion times except the suicide hotline, that means its working

obtuse gale
lunar cypress
#

I know

#

I'm having the same issue and already opened a gh issue over at pdm

obtuse gale
#

ah

#

alrig ht can you update me if you fix it please :))

empty flint
#

How do I reverse this map:

val nmsToBukkit = mapOf<String, Set<String>>(
            "1_12_R1" to setOf("1.12-R0.1-SNAPSHOT", "1.12.1-R0.1-SNAPSHOT", "1.12.2-R0.1-SNAPSHOT"),
            "1_13_R1" to setOf("1.13-R0.1-SNAPSHOT"),
            "1_13_R2" to setOf("1.13.1-R0.1-SNAPSHOT", "1.13.2-R0.1-SNAPSHOT"),
            "1_14_R1" to setOf("1.14-R0.1-SNAPSHOT", "1.14.1-R0.1-SNAPSHOT", "1.14.2-R0.1-SNAPSHOT", "1.14.3-R0.1-SNAPSHOT", "1.14.4-R0.1-SNAPSHOT")
            "1_15_R1" to setOf("1.15-R0.1-SNAPSHOT", "1.15.1-R0.1-SNAPSHOT", "1.15.2-R0.1-SNAPSHOT"),
            "1_16_R1" to setOf("1.16.1-R0.1-SNAPSHOT"),
            "1_16_R2" to setOf("1.16.2-R0.1-SNAPSHOT")
)

to get

val bukkitToNms = mapOf<String, String> (
  "1.12-R0.1-SNAPSHOT" to "1_12_R1",
  "1.12.1-R0.1-SNAPSHOT" to "1_12_R1",
  "1.13-R0.1-SNAPSHOT" to "1_13_R1"
  ...
)

?

prisma wave
#

i guess

empty flint
#

so basically I want to assign the keys to the sets and then flatten the sets to get multiple keys to the same values

old wyvern
#

should key be a set of those or the individual values?

empty flint
#

individual

lunar cypress
#

(reduce-kv (fn [m k vs] (apply assoc m (interleave vs (repeat k))) {} nms-to-bukkit)

old wyvern
#

cluster

empty flint
#

(reduce-kv (fn [m k vs] (apply assoc m k (interpose k vs)) {} nms-to-bukkit)
@lunar cypress I have no idea what that means, can you explain that code like I'm 5 pls?

old wyvern
#

Clojure

prisma wave
#

Huge

lunar cypress
#

A similar approach should be possible in kotlin with fold

empty flint
#

I can't read clojure code, have no idea what that does

prisma wave
#

does what you want

obtuse gale
#

clojure looks gross

empty flint
#

...

prisma wave
#

I'm basically a Clojure expert now

#

I've used it twice

lunar cypress
#

It performs a reduction by adding each entry to a new map

empty flint
#

does what you want
@prisma wave fun isHelpful(): Boolean { return false }

obtuse gale
#
fun isHelpful() = false```
prisma wave
#

(def helpful false)

empty flint
#

It performs a reduction by adding each entry to a new map
@lunar cypress how do I perform that reduction in kotlin though?

lunar cypress
#
nmsToBukkit.entries.fold(mutableMapOf<String, String>()) { map, (key, values) -> 
  for (value in values) {
    map[value] = key
  }
  map
}```
#

Just noticed I made a mistake earlier

prisma wave
#

Would the type arguments be necessary?

lunar cypress
#

Possibly not if you declare them earlier

empty flint
#

ty

lunar cypress
#

Kotlin does not have freeform syntax

empty flint
#

I have no idea how folding works

old wyvern
#

Folding is like accumulating
here you initially passed in a map and return the map everytime

the problem with that you have is for isnt an expression. Just change that into a block and return map at the end

lunar cypress
#

No block needed

old wyvern
#

oh does return work with the last identifier beign the returning value

#

I see

lunar cypress
#

I already corrected my snippet

empty flint
#

so folding means I create a new object and do stuff with my initial object to manipulate the created object and then return the created object if I want to?=

lunar cypress
#

Not necessarily

empty flint
#

this works

#

ty

lunar cypress
#

It is more abstract than that

old wyvern
#

I already corrected my snippet
Ah didnt notice

lunar cypress
#

fold/reduce are the same thing and come from functional programming, where this would be called a left fold (lfold). The way it works is you have some sequence and a function, and you take the first two elements of the sequence and apply the function to it, then you take the result of that and the third element and apply the function, than result of that + the fourth element etc.

#

There is a variant of this where you provide an initial value

#

Which we do here

#

So instead of the first two values it's going to use the initial value and the first element

old wyvern
#

so folding means I create a new object and do stuff with my initial object to manipulate the created object and then return the created object if I want to?=
Could be anything.
Imagine you have a collection {5, 6, 7, 8, 9, 8, 15}
You can sum it by folding
You specify a identity value as the initial value, for addition -> 0

so fold with initial value 0, on every iteration a you can return (initial + current value) and the next iteration would receive that as "initial" and after the last iteration whatever is the returned value from the last iteration will be your result

lunar cypress
#

And all that the function does is manipulate the left value (which is a map) as a side effect

old wyvern
#

mhm

lunar cypress
#

Because clojure is much better you can do it side effect free easily there

old wyvern
#

at the simple cost of ()()()()([][][]}}}}}

lunar cypress
#

Literally the same amount of parens as kotlin here lmao

old wyvern
#

😂

lunar cypress
#

Ok tbf kotlin has more {}, <> and other syntax junk

#

Clear W for clojure

empty flint
#

can I define a variable in a gradle parent build script and use it in the child one?

steel heart
#

Yeah

#

Putting a variable in ext Closure maybe does that

prisma wave
#

yet another Clojure good moment

distant sun
#

Closure*

prisma wave
#

Clojure*

distant sun
#

Pretty sure it says Closure, check your eyes

prisma wave
#

Scroll up a bit and it says Clojure

distant sun
#

Putting a variable in ext Closure maybe does that

prisma wave
#

Clear W for clojure

distant sun
#

¯\_(ツ)_/¯

prisma wave
#

Clojure moon is a benevolent god

distant sun
#

Whats that for smh bm

#

Barry🇲

prisma wave
#

clojure moon

#

clojure 🌚

distant sun
#

Ok but why

steel heart
#

Why not

prisma wave
#

clojure in the moon who will he illuminate

#

all the good people of helpchat that's who

lunar cypress
#

Can you send me an invite to wherever this emote is from

#

Not that I could use it on this server but anyway

prisma wave
#

Absolutely

#

Elara discord

empty flint
hot hull
#

It's always been like that

distant sun
#

Minecraft dev plugin

empty flint
#

Ah right

#

ty

deft patrol
distant sun
#

Reason to add doomful?

deft patrol
#

do you need a reason? don't accept then, I don't need people like you that think they need a reason

hot hull
#

Lmao

prisma wave
#

😳

#

anyway

obtuse gale
#

lol

empty flint
#

Do you guys write any UnitTests for your Plugin implementations?

prisma wave
#

@deft patrol don't use assert,
Liskov
you shouldn't use string concatenation in a prepared statement, that defeats the point
you might want to use an empty list instead of returning null

#

@empty flint yes

empty flint
#

@empty flint yes
@prisma wave How do you write those tests for stuff that requires a working, running server?

prisma wave
#

MockBukkit if it's necessary

deft patrol
#

@prisma wave thank you! but am I using the completable future right?

prisma wave
#

I usually try and decouple the code though

#

@deft patrol pretty much

deft patrol
#

ok

lunar cypress
#

well you can use string concatenation here

#

it's nothing you can template with prepared statements

#

you could collapse the two try with resources blocks

#

assert is useless

empty flint
#

Task 'wrapper' not found in project ':<subproject>:<sub-subproject>'.

What's a 'wrapper' task and why does this subproject need it and no other project does?

prisma wave
#

context?

#

the wrapper task is usually to download a gradle wrapper

empty flint
#

I think I got it, it seems as though this one sub-submodule was somehow registered as a project

steel heart
#

alex, whats a good way of adding a second gradle build script? would that have to be with moduling or can I put something nice in just my original build.gradle to add tasks and variables from other.gradle

prisma wave
#

you can make other .gradle files

empty flint
#

and it only had the gradle stuff necessary for a module, not a standalone project

prisma wave
#

and then you can do apply from: 'file.path' iirc

steel heart
#

so a fully qualified name?

prisma wave
#

?

#

a file path

empty flint
#

Does each module have to have a version associated with it?

prisma wave
#

I believe it has to have one

#

but it can be from a parent module

empty flint
#

for instance if I have a root project without any source code, I won't ever need the version of it

#

but it can be from a parent module
@prisma wave how?

steel heart
#

ok nice got it working

prisma wave
#

subprojects {
    group 'me.bristermitten'
    version '0.0.20'```
#

i have this in my parent module's buildscript

#

so all others share the same group and version

steel heart
#

subprojects { subproject ->
subproject.group 'lol.lol'
}

empty flint
#

what is the relevancy of the group?

steel heart
#

thats how I do

empty flint
#

like what does it actually do? Does it have to do with the classpath in any way?

steel heart
#

uh I think its for maintainability but there's probably some more logic behind it

prisma wave
#

it's for artifact resolution

#

in the same way that maven group id's are

#
compileOnly "org.spigotmc:spigot-api:blah"
#

group id is org.spigotmc

empty flint
#

Got it. So if multiple subprojects have the same group that's not gonna clash like it would with classpaths?

lunar cypress
#

group + artifact id should be unique

#

Like, world wide

empty flint
#

and the artifact id is defined by the project/module name?

lunar cypress
#

Yes

jovial warren
#
compileOnly "org.spigotmc:spigot-api:blah"

imo specifying that as compileOnly("org.spigotmc","spigot-api","blah") looks better (that only really works like that in Kotlin DSL)

prisma wave
#

Whoever invented the kotlin dsl should be shot

#

Twice

#

Maybe even 3 times

#

Although that's a bit extreme if you ask me

empty flint
#

Could not resolve: org.bukkit:craftbukkit:1.12.2-R0.1-SNAPSHOT

How do I access that repo?

old wyvern
#

Have you built the 1.12.2 jar?

prisma wave
#

maven local

steel heart
#

Why craftbukkit

#

Use spigot then?

empty flint
steel heart
#

Did you run buildtools?

old wyvern
#

^

empty flint
#

Does buildtools install the appropriate version in my local repo?

#

Use spigot then?
@steel heart Could not find org.spigotmc:spigot:1.12.2-R0.1-SNAPSHOT. Does that contain the craftbukkit stuff as well?

prisma wave
#

yes

steel heart
#

In fact I think 1.16 doesn’t even create a craftbukkit one

#

Well wouldn’t be an issue for you rn but just fyi

empty flint
#

java -jar BuildTools.jar --rev 1.12.2 --compile craftbukkit like this? or do I need anything else?

steel heart
#

Just the rev argument should be enough

empty flint
#

just ran that command

#

Could not find org.spigotmc:spigot:1.12.2-R0.1-SNAPSHOT.

#

Nothing

#

org.bukkit:craftbukkit:1.12.2-R0.1-SNAPSHOT works though

#

so basically spigot is not placed in the repo, craftbukkit is

shadow wasp
#

any ideas what causing this?

empty flint
#

is that the  character?

#

is that what you mean?

#

^ and A combined

shadow wasp
#

yes

#

it's just &8 in the config

#

&8»

kindred hatch
#

It's not saving as UTF-8

shadow wasp
#

thought so

#

but how do i change that?

lunar cypress
#

In which config

shadow wasp
#

what do you mean?

#

in config.yml

lunar cypress
#

set the file.encoding system property then

#

-Dfile.encoding="UTF-8"

lunar cypress
#

does anyone wanna test my connect four plugin with me

#

I'm too lazy to download a cracked launcher

rose dirge
#

I can @lunar cypress

lunar cypress
#

cool

ocean quartz
hot hull
#

Sexy

old wyvern
#

Does that work with colors?

ocean quartz
#

kinda

old wyvern
#

or is that just the default one from brig

ocean quartz
#

Doesn't seem like tabcomplete handles hex colors

old wyvern
#

ah

ocean quartz
old wyvern
#

Really o.o

#

Nice

empty flint
#

Can a plugin detect if it's running on a bungee network or not?

hot hull
#

How would this, [ 367, 1537083095 ] result in 1578169576722 the first being the given info, the second being a timestamp of that given info

empty flint
#

How would this, [ 367, 1537083095 ] result in 1578169576722 the first being the given info, the second being a timestamp of that given info
@hot hull In what context? What kind of information? Are both related to time?

hot hull
#

Yes, the first one is the raw data given, the second one is a timestamp of that data, if that makes sense

empty flint
#

Hm no idea tbh, where do you get that data from?

hot hull
#

Player nbt

jovial warren
#

what are you doing with that original data?

#

like how are you getting to the outcome

hot hull
#

Exactly what I need to figure out

old wyvern
#

Holy shit Rider feels so comfy compared to vs

#

auto converts my K&R to Allman as well ❤️

prisma wave
#

hot

ocean quartz
#

I wanna test Rider at some point too

old wyvern
#

its so... idk how to explain it, feels very polished

#

Jetbrains ftw

empty flint
#

How would I go about making one plugin for both bungeecord and spigot where, if it runs on bungee, the frontend/backend communication happens via messages and if the backend is on spigot instead of bungee, the backend manipulates the frontend directly?

old wyvern
#

Just add a bungee.yml file declaring the main class for the bungee implementation

#

For communication with spigot plugins

prisma wave
#
    val stages = listOf<Stage<Int, Int>>(
                Stage { context, i ->
                    context["double"] = i * 2
                    i + 1
                },
                Stage { context, i ->
                    context.get<Int>("double") + i
                },
        )

        val pipeline = SimplePipeline<Int, Int>(stages)

        assertEquals(10, pipeline.process(3))```
on a scale of 1 to 10 how clean is this?
#

aside from the bad formatting

old wyvern
#

looks fine 👌

prisma wave
#

Cool

empty flint
#

Just add a bungee.yml file declaring the main class for the bungee implementation
@old wyvern So on a spigot server the plugin.yml file will be checked and its main class instanceated and on bungee the bungee.yml will be checked for the main class?

old wyvern
#

bungee can use both but checks for bungee.yml first I think

#

it should ignore plugin.yml if it finds bungee.yml

#

yup

empty flint
#

But can I package both the bungee api and spigot api into the same jar file? Would that not fail on Spigot if it can't find the classpath to the bungee api classes?

old wyvern
empty flint
#

Or is spigot shaded into the bungee api?

old wyvern
#

Youd just not have to load any classes that use spigot libs

#

Spigot is not included in bungee and will result in a ClassNotFoundException

empty flint
#

Right...

#

So in the bungee part I use only bungee api stuff and in spigot I use spigot...

old wyvern
#

You couldhave the bungee classes not interact with any classes that load spigot libs

#

Yes

#

What did you want to do?

empty flint
#

I want to structure my plugin into a backend (data storage and validation) and a frontend (user interaction, commands, inventory guis...). When the jar is placed on the central bungee server, it handles the backend and relays the frontend-stuff via messaging to the spigot servers running the plugin. When the jar is on a spigot server though, it checks if there is a bungee backend running and handles only the frontend if so. If there is no other backend, it handles the backend as well.

#

So basically I have a frontend in spigot and a backend in both spigot and bungee

old wyvern
#

Sure, the backend shouldnt interact with spigot directly then

empty flint
#

exactly

#

So in the bungee backend I only need to handle the backend and send messages. The spigot backend can have a class for the frontend and receiving messages or a class handling the backend as well as the front end

#

So the Bungee main class is loaded from the bungee.yml file and sets up without having to check for anything.
the Spigot main class has to check if there is a bungee backend or not

#

How would that work? Is there a loading order regarding the servers? Is there a guarangee that the plugin on the bungee server is up and running before the spigot server is?

old wyvern
#

Not sure

#

You could have a handshake listeners on either side

empty flint
#

I was thinking of sending a ping message and checking if something comes back.

old wyvern
#

brb

empty flint
#

You could have a handshake listeners on either side
@old wyvern yeah, that

#

Is that handshake an actual event?

#

or manual?

old wyvern
#

Manual

empty flint
#

Thanks I think I got it figured out now 🙂

hot hull
#

What particle would be good to use for a lazer/beam effect?

#

I was thinking fire and some end ones

ocean quartz
onyx loom
#

o

meager cairn
#

I forgot how to set texture value for head. Do I need to access skull NBT? I got texture like this

ewogICJ0aW1lc3RhbXAiIDogMTU5ODIwMDg4NzEyMCwKICAicHJvZmlsZUlkIiA6ICIyNzBiMGRiZDc1MjI0NDFlODgwZTI5NzQxNjljZWVmNCIsCiAgInByb2ZpbGVOYW1lIiA6ICJIb2VuVG9tIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzQwODBhYzRhZDQ4MTA1ODllNTFhYWZjOTRjMTRlYWFjMWI0MGZmMDcxNDgzOWNjODU1M2FlMTcxMTNjOGM2MDkiLAogICAgICAibWV0YWRhdGEiIDogewogICAgICAgICJtb2RlbCIgOiAic2xpbSIKICAgICAgfQogICAgfQogIH0KfQ==
steel heart
#

base64?

meager cairn
#

idk

steel heart
#

I did it this way:

private static final BiConsumer<SkullMeta, GameProfile> SET_PROFILE = new BiConsumer<SkullMeta, GameProfile>() {

        private Field field;

        @Override
        public void accept(SkullMeta skullMeta, GameProfile gameProfile) {
            if (field == null) {
                try {
                    cache(skullMeta);
                } catch (NoSuchFieldException e) {
                    e.printStackTrace();
                }
            }
            try {
                field.set(skullMeta, gameProfile);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }

        private void cache(SkullMeta skullMeta) throws NoSuchFieldException {
            field = skullMeta.getClass().getDeclaredField("profile");
            field.setAccessible(true);
        }
};

    public static void setSkullTexture(SkullMeta meta, String base64) {
        GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "");
        gameProfile.getProperties().put("textures", new Property("textures", base64));
        SET_PROFILE.accept(meta, gameProfile);
    }
``` it was a util class btw
meager cairn
#

Oh cool. I just found topic have same solution. But since I use NBT api, maybe I can put through NBT 🤔

steel heart
#

well nah

#

use that otherwise

meager cairn
#

thanks cool utils though

steel heart
#

I dont like nbt api because last time I looked the code was kinda meh

#

maybe they evolved

meager cairn
#

I'm just too lazy to make my own stuff, since I use it for myself so NBT api is fine

lunar cypress
#

@meager cairn

meager cairn
#

awesome!

lunar cypress
#

Read the comments

steel heart
#

Any ideas how to make gradle replace a string in all .java files on compileJava and before annotationProcessing

shadow wasp
#

can i use the 1.16 api for 1.8 dev?

steel heart
#

Use 1.8?

shadow wasp
#

just wondering

ocean quartz
#

You can

hot hull
#

How tf do you cast in kotlin?

ocean quartz
#

something as Something

hot hull
#

Thanks

ocean quartz
#

Or if you want magic

if (something !is Something) return
// from here on out, something IS Something

Cuz smart casting

hot hull
#

Can't for this, but thanks

onyx loom
#

sm0rt casting

static zealot
#

Question. When I upload a plugin to github. I upload build.gradle and the other files that are in the folder, the src folder and the gradle folder only?

#

because .gradle and .idea I assume I don't have to actually I think I even can't but don't know about the build folder

#

I would assume no but its good to be sure

onyx loom
#

yeah u dont need .gradle or .idea

#

theres some others u dont need but cant think from the top of my head

steel heart
#

Some people just straight up pushing all their files

#

Like aikar

onyx loom
#

kek

static zealot
#

the only one that I don't know about is the build folder

onyx loom
#

yea no need to push the build folder

ocean quartz
static zealot
#

then I have everything I guess. thanks

#

btw github has a dark theme?

steel heart
#

Ye

onyx loom
#

dark reader fingerguns

ocean quartz
#

It's an extension

steel heart
static zealot
#

I remember using it but I think on Opera its a bit broken and I stoped using it

ocean quartz
#

I don't like dark reader, it messes up some websites

static zealot
#

nvm doesn't even have a Opera extension

#

well then what extension are you using?

ocean quartz
onyx loom
#

pick up the material atom icons extension while ur at it fingerguns

static zealot
ocean quartz
static zealot
#

oh that makes more sense xd

#

ty ty

ocean quartz
#

Was there no action bars in 1.8?

hot hull
#

There was

steel heart
#

It is

#

But nms

hot hull
#

^

ocean quartz
hot hull
#

Check FJ if you wanna copy paste fingerguns

steel heart
#

Yh iirc

ocean quartz
#

Oh it uses the chat packet what

steel heart
onyx loom
#

lmao

jovial warren
#

this is a mixed-language project smh

hot hull
#

That's the thing I was going mad about a few days ago

#

It's a kotlin lib, and for some reason I can't access it from kotlin

#

So I had to do some shenanigans

jovial warren
#

wdym you can't access it from Kotlin?

#

lemme try this lol

hot hull
#

Try initializing the ActionHandler inside the Loader class directly

#

And you'll see

jovial warren
#

you mean try using ActionHandler within Kotlin code

hot hull
#

Either or

jovial warren
#
Could not find com.github.frcsty:FrozenActions:1.0.0.
Required by:
    project :

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
```🤔
#

please don't tell me this comes from mavenLocal()

hot hull
#

Yea it does cause jitpack was being a bitch

#

Just throw FrozenActions to your maven local

jovial warren
#

how exactly do you expect me to do that?

hot hull
#

By clonining my FrozenActions project and throwing it in maven local

jovial warren
#

righty then

#

where tf is your maven-publish plugin in this?

hot hull
#

What are you on about?

#

If you don't know how to throw a jar into maven local, don't sweat it fingerguns

jovial warren
#

usually, you use the maven-publish plugin to push to a Maven repo

#

and that includes Maven Local

#

and ofc I don't know how you put a JAR in Maven Local, I rarely ever use Maven Local because I do the smart thing and use dependencies from repos

#

and when I do use Maven Local, I use the maven-publish plugin

frigid badge
#

building the project will install it to your local repo anyway

jovial warren
#

okay

#

still won't import, probably because it can't find it

#

(it won't import in the Handler class)

ocean quartz
#

God, so i need checks for 1.8-1.11, 1.12-1.15, 1.16, lovely nms changes

hot hull
#

@jovial warren Bardy, considering jitpack is being a bitch, and I don't really care about putting it in an actual maven repo, it's fine fingerguns

jovial warren
#

no it isn't

#

since having to compile a separate dependency and manually put that in maven local is a pain in the ass

#

somebody tell me how tf I'm supposed to manually put a JAR in to maven local

#

because gradle build doesn't seem to be doing it for me

old wyvern
#

gradle build isnt supposed to add to maven local

jovial warren
#

yeah I thought that, but from what I understood, that's what @frigid badge was implying

old wyvern
#

Use the maven plugin and install task or maven-publish and publishToMavenLocal

#

With the jar

jovial warren
#

okay

#

also how tf does the maven publish plugin work in regular Gradle?

#

because I'm doing what the guide says and it's just yellow underlining it

jovial warren
#

I'm literally reading that

frigid badge
#

my bad, I expected he would’ve had publishToMavenLocal in his build file.

old wyvern
#

ah

ocean quartz
#

Ayy all versions working now, no more errors

old wyvern
#

gg

ocean quartz
#

This class is a mess though

jovial warren
#

@frigid badge yeah I would've expected that too tbh

#

why is Groovy Gradle so shit with the maven publish plugin

#

like that's one of those times where Kotlin DSL triumphs without question

old wyvern
#

HOLY

#

WTF

ocean quartz
#

Gradle isn't great with maven publish in general

jovial warren
#

@old wyvern what

old wyvern
#

so this question

jovial warren
#

not visible bud

#

nvm

#

was probably a glitch

old wyvern
#

They give us vertices of a polygon and ask us to find the total vertexes

#

thing is

#

We didnt need the vertices

#

we jsut needed n apparently

#

I ws just randomly trying it xD

#
for (int i = 0; i < n; i++) sc.nextLine();```
Skipped all point data xD
jovial warren
#

lol

old wyvern
#

They playin us

jovial warren
#

also can anyone else agree that: ```kotlin
create<MavenPublication>("name") {

}
is better than groovy
name(MavenPublication) {

}

distant sun
#

No

jovial warren
#

wdym no?

#

actually idewk

ocean quartz
#

I don't agree either, it's just more to achieve the same lol

jovial warren
#

but the second one literally makes no sense

hot hull
#

@jovial warren PR or Shut Up angry_fingerguns

jovial warren
#

okay then I won't bother

onyx loom
#

😂

hot hull
#

Meaning you can't say shit if you aren't willing to PR, stop bullying me weeb

jovial warren
#

I'm not gonna even try and work on your code until you fix that maven local bullshit

#

at least configure the maven publish plugin so people can properly build and publish to maven local if you're not gonna put it on a public repo

hot hull
#

Yeye I gotta learn how to use an actual maven repo

jovial warren
#

alright I'll leave ya to it

frigid badge
#

ez bintray or gh packages or smth

distant sun
#

Gh packages ewwwww

jovial warren
#

@frigid badge exactly

#

or even your own repo, if you have one

frigid badge
#

I mean who even uses non-dockerized applications?

jovial warren
#

non-dockerized?

#

you mean applications outside of a docker container?

frigid badge
#

an application which has not been dockerized

#

so yes not running in a docker container

hot hull
#

Oh yea I was gonna ask something, is there an IJ plugin that just tracks how much overall time you spend on a project, like idc about details just how much time I spend on it

old wyvern
#

wakatime

frigid badge
#

wakatime

hot hull
#

Only 2 weeks

frigid badge
#

prob sells all the data too lol

old wyvern
#

really?

frigid badge
#

idk never used it

old wyvern
#

oof

#

I have it on

frigid badge
#

I really don't care about stats like that

old wyvern
#

welp

hot hull
#

I need something that's perma time not just 2 weeks

old wyvern
#

i mean it doesnt matter if they sell that I guess

frigid badge
#

all I track is how much I work and therefore how much money I receive monthly

#

😉

old wyvern
#

🍬

jovial warren
#

you receive money for your work?

frigid badge
#

I work at a software company

jovial warren
#

ah okay

frigid badge
#

I never do any bukkit stuff

hot hull
#

I spent 60 hours for 40€ @frigid badge be jealous ||I wanna cri||

frigid badge
#

oh god, I hope you learned something atleast?

#

like a new lib or framework or language or some stuff

hot hull
#

Nope

frigid badge
#

F

jovial warren
#

I've spent at least 100+ hours working over time for fuck all lol

#

but I program because it's a fun hobby for me, not because I want money out of it

hot hull
#

Not even gonna respond since that's a shit argument fingerguns

#

Anyhow Lemmo, I learned that spigot is even more gae than I thought

jovial warren
#

Not even gonna respond since that's a shit argument fingerguns
wdym?

#

"a shit argument"

steel heart
#

Frosty knows how to boilerplatify a code

jovial warren
#

is WakaTime premium worth it btw guys?

#

because $9/month seems like a bit of a rip off just to see more than 2 weeks of history

hot hull
#

It's not worth Bardy

#

That's why I was asking if anyone knows of any other IJ plugins that track time

jovial warren
#

I could just make my own plugin which uses prometheus metrics

old wyvern
#

its free

jovial warren
#

it's Free* @old wyvern (free with a catch)

hot hull
#

Yugi, 2 weeks data history is free

old wyvern
#

?

hot hull
#

You can view 2 weeks of wakatime history for free

old wyvern
#

Its mails it to you

hot hull
#

For anything more you need premium

#

You don't get it smh

old wyvern
#

wdym?

jovial warren
#

I swear that expiry date is 2 weeks from the date you receive that

#

and also, that's only weekly

old wyvern
#

Whats the issue exactly?

jovial warren
#

that you need premium to view more than 2 weeks' history

old wyvern
#

If you have your entire history in your email does it matter tho?

hot hull
#

Yes lol, I'm not about to go counting up the time

jovial warren
#

^

old wyvern
#

🤷‍♂️

hot hull
#

If I wanted that I can just use a stopwatch and time myself

old wyvern
#

you do you my guy

hot hull
#

What do you think this is the middle ages smh

jovial warren
#

well, guess it's time to learn how the JetBrains plugin API works and make a custom alternative that uses prometheus then

#

¯_(ツ)_/¯

#

what's that

#

idk

true grail
#

how do i fix this?

jovial warren
#

wrong channel, no context, no stack trace

#

@true grail we need more info than that, and also, not in here

true grail
#

which channel then?

hot hull
ocean quartz
#

There is no voting reaction

lunar cypress
#

it's too powerful

prisma wave
#

@lunar cypress very nice indeed

#

I thought "wow only 5 files" and then I saw the contents lmao

lunar cypress
#

I mean... it's not much either way

#

the entire game logic is just 100 lines

prisma wave
#

I would upvote if I could

#

😔

lunar cypress
#

😔

prisma wave
#

:clojurepensive:

lunar cypress
#

I tried around with core.async concurrency and it worked out quite well

prisma wave
#

with the scheduler?

lunar cypress
#

Events, mostly

#

but I also needed the scheduler for server thread actions

#

that was simple though, I just wrote this lil macro

(defmacro runsync
  "Executes the given body on the server thread and returns a channel that receives the result when it's done."
  [plugin & body]
  `(let [result-channel# (chan)]
     (run-task
       (Bukkit/getScheduler)
       ~plugin
       (fn []
         (if-let [result# (do ~@body)]
           (put! result-channel# result#)
           (close! result-channel#))))
     result-channel#))
#

For events there is just a function that pipes all events of a given type on a channel and you can take them off sequentially

#

I also made an item stack "dsl" in a couple of lines

#

Looks like this in practice

(def drop-item
  {:type       Material/STAINED_GLASS_PANE
   :durability 8
   :meta       {:display-name "Drop a disc"
                :lore         ["Click to drop a disc here"]}})
onyx loom
#

gonna throw up if i see any more of that

#

🌚

lunar cypress
#

that's envy speaking

onyx loom
#

o

lunar cypress
#

go write "classes" and create "objects"

hot hull
#

See, you call it stupid and it starts working fingerguns

distant sun
#

Probably the api is having problems

lunar cypress
#

ok new attempt

#

lol

#

it doesn't like Clojure

hot hull
#

Leave it for some time

#

Might just be slow

empty flint
#

Is there a naming convention in Kotlin for Interfaces and their Implementations?

#

I really hate the IInterface and InterfaceImpl naming convention

ocean quartz
#

Same, i'd just go with what you like

slow jewel
#

?jdk

compact perchBOT
slow jewel
#

is this best jdk can i use

#

bcs im starter

ocean quartz
#

I actually like the way bukkit does it, like Player interface, CraftPlayer implementation

slow jewel
#

when i try to test my first code using intellij i see

ocean quartz
#

There is no such thing as a best jdk

slow jewel
#

Cannot run program "C:\Users\mynamel.jdks\openjdk-14.0.2\bin\java.exe" (in directory "C:\Users\myname\AppData\Local\JetBrains\IdeaIC2020.2\compile-server"): CreateProcess error=216, This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher

#

i typed code right but whats wrong here i use win 10 32x bit

#

can someone help me

#

please

steel heart
#

I usually use IInterface for instance if the name would be Enchantment, I don't want an interface name to be the same as the bukkit class and therefore I'd name it as IEnchantment. I use Impl when the implementation is kind of standalone like the interface SingleFactory I don't want to name its implementation to something more specific else than SingleFactoryImpl where as a List has more implementations like LinkedList and ArrayList and in that case I wouldn't use -Impl suffix. @empty flint well I think its most preferences

empty flint
#

I actually like the way bukkit does it, like Player interface, CraftPlayer implementation
@ocean quartz Me too but I can't think of a name for my NMSInterface implementations

slow jewel
#

There is no such thing as a best jdk
@ocean quartz orcale jdk can used in intellij idea ce

#

?

empty flint
#

I have the NMSInterface that defines which methods each namespaced implementation needs and then I have an injector for that interface that gets me whatever implementation I need

#

I need names for both

ocean quartz
#

@slow jewel Yeah?

slow jewel
#

aw

#

i made intellij install jdk auto so do i need to re select a 32x bit jdk to order to solve this problem @ocean quartz and sorry for ping

ocean quartz
#

Hmm I am not sure what your problem is

slow jewel
#

kk

prisma wave
#

@empty flint if I specifically can't think of an implementation name I'd just do SimpleInterface

jovial warren
#

anyone know if Kotlin coroutines has its own version of ScheduledThreadPoolExecutor (SES)?

prisma wave
#

you can make CoroutineDispatchers from Executors

jovial warren
#

yeah but how would I schedule tasks with it?

prisma wave
#

You'd use something like delay()

#

Direct scheduling is not an idiomatic concept to coroutines

#

Not in the way you're thinking anyway

jovial warren
#

ah okay

#

should I just use SES then instead of coroutines?

#

since it's only a single thread executor anyway

prisma wave
#

That's up to you

jovial warren
#

and it's only used for scheduleWithFixedDelay I think

empty flint
#

Why don't Java classes get a companion object from Kotlin?

#

Can't extend them statically 😦

#

fun ItemStack(serializedItem: String): ItemStack = NMSInjector.deserializeItem(serializedItem) Ayyy don't need a workaround for that though 🤣

prisma wave
#

Why don't Java classes get a companion object from Kotlin?
@empty flint what?

#

Oh

empty flint
#

yeah

#

you can extend a KotlinClass.Companion but not a JavaClass.Companion because they do not exist

prisma wave
#

Well you've answered your own question then lol

empty flint
#

Yeah it was more of a rant than a question

#

but I got the bright idea to make the static deserialize() method I planned to create into a constructor

remote goblet
#

The entire language of clojure

#

just looks

#

fucking trashy and garbage

#

i aint even mad if i get crusaded for it

#

its fuckin dumb

wooden trout
#

ok

lunar cypress
#

Well that's one way to admit you have no idea what you're talking about

onyx loom
#

how does it look like python thonking

remote goblet
#

i dont know python

#

but thats what comes to mind when i see clojure

#

its also just

#

looks incredibly stupid

lunar cypress
#

You're in good company

#

People like bashing Lisp even though they couldn't say anything substantial about it

prisma wave
#

classic

empty flint
#

I don't get reflexion in Kotlin

#

In Kotlin class references aren't the same as in Java

prisma wave
#

People hating on clojure when they're out here writing stateful OOP spaghetti garbage

empty flint
#

how do I call a class constructor via the classpath?

prisma wave
#

With kotlin-reflect?

empty flint
#

ye

#

or any other way, idc

prisma wave
#

With a static reference to the class?

#

Or dynamic

empty flint
#

dynamic. I only have the classpath of the class

#

so java.lang.String for example. how do I get the Constructor for that class

lunar cypress
#

Wdym you only have the classpath

#

That is the name

prisma wave
#

You could do Class#kotlin or there might be KClass.forName?

#

@lunar cypress I think he means the FQCN

lunar cypress
#

Very different meaning

empty flint
#

yeah sorry, classpath + name

#

fqcn

lunar cypress
#

No not classpath

empty flint
#

I'm not that good with nomenclature

#

isn't java.lang the classpath

#

package I meant

prisma wave
#

Classpath is the classes that are available at runtime (loosely don't correct me pls)

empty flint
#

fuck my life

prisma wave
#

Yeah that's package

empty flint
#

I just brainfarted and didn't smell it before you didn't point it out

#

my bad

#

I meant the package + name

#

as a string

#

Anyway. KClass.forName?

#

I will check

delicate star
#

Is there a dev build of Deluxemenus?

prisma wave
delicate star
#

sorry

prisma wave
#

@empty flint not sure if it exists or not, if not just use Class#kotlin (or Java reflection which is faster for the record)

#

np

empty flint
#

@empty flint not sure if it exists or not, if not just use Class#kotlin (or Java reflection which is faster for the record)
@prisma wave Oh is it? How so?

prisma wave
#

uh

#

It just is

#

Lol

#

idrk what else to say

remote goblet
#

from what i can see, clojure just arrow codes

prisma wave
#

arrow code isn't a problem in clojure

#

It's more idiomatic to write longer lines than to try and hack your way around it

#

Since curly brackets aren't a thing

remote goblet
prisma wave
#

and the same thing in kotlin would be at least double the size

onyx loom
#

what does that even say

#

i dont understand a single thing

prisma wave
#

Idk enough about Clojure to say

onyx loom
#

@ johnny

prisma wave
#

Some sort of list transformation I think

remote goblet
#

So clojure is also just like

#

incredibly unreadable ?

onyx loom
#

one of its main features 😎

remote goblet
#

Yes 😎 lets make a shitty language that no one can read other than developer to tackle the need for obfuscation

onyx loom
#

😎 😎 😎

prisma wave
#

I can read it

#

I just don't know what the functions do

#

It's like asking someone who's barely used kotlin to know what fun O.t(closure: G.() -> Unit) means

remote goblet
#

well yes but the entire of clojure is like that

#

the code literally just looks like a mess

prisma wave
#

not really

remote goblet
#

it doesn't matter how 'small' the code is

#

the code just looks like a mess of words thrown together

prisma wave
#

(def name value) is pretty easy to understand

#

(println "Hello")

steel heart
#

Clojure is pure functional right?

prisma wave
#

Yes

#

Not quite as strict as Haskell afaik

remote goblet
#

idk i just hate the entire structure and wording of it all

steel heart
#

Is clojure good when doing simple I/O tasks as well?

prisma wave
#

I mean

#

In FP IO is classed as a side effect

#

I'm not an expert but afaik they have a fairly elegant workaround

steel heart
#

Yh

lunar cypress
#

Clojure is not pure

#

Functional programming is encouraged and all the default data structures are immutable but it does not put any restrictions on you

prisma wave
#

ah my bad

lunar cypress
#

No problem

#

It's just that haskell and ml are usually what's considered pure because they don't allow for side effects and the likes regurlarly

#

Clojure is very different from that

#

And no worries if you don't understand macros. Most of the confusing stuff is evaluation rules which are a major mindfuck

prisma wave
#

Oh do macros have a special syntax?

lunar cypress
#

No

prisma wave
#

I've not seen the ~ and things anywhere else

#

Oh

lunar cypress
#

Yeah it's not typical but it's nothing macro-exclusive

#

The two basic things you need to know are quote and unquote

#

quote aka ' means "treat this as data, do not evaluate it"

prisma wave
#

oh yeah

#

You use that for lists too right?

#

like to pass around

lunar cypress
#

You can, although you should mostly use vectors instead

#

Because stopping evaluation means the contents of the list are not evaluated either

prisma wave
#

I see

#

Makes sense

lunar cypress
#

And that's where unquote aka ~ comes in

#

Say you have this: '(foo bar)

#

foo and bar are two symbols you bound in that scope to some value

#

And you want the list to contain those values

#

But since they aren't evaluated you get a list of literally two symbols

#

'(~foo ~bar) that way you would resolve them

prisma wave
#

that's both messy and elegant

lunar cypress
#

And this can be nested arbitrarily

#

Now what you often see instead of ' in macros is ` which is virtually the same but it fully qualifies symbols you use

#

So clj `(map identity ~list)
becomes clj (clojure.core/map clojure.core/identity whatever-the-value-is)

#

This is useful because it ensures that the semantics stay the same across namespaces

#

When you declare a macro in one namespace the symbols used may be bound differently in another

prisma wave
#

Ohh yeah that makes sense

lunar cypress
#

And honestly there's not much more to it

#

The only thing left would be ~@ which "unfolds" sequences

#

Forgot what it's called exactly

prisma wave
#

Is it like the kotlin spread operator?

lunar cypress
#

So if I had this:

(let [body `((println "one") (println "two"))]
  `(do ~@body))```
It would result in ```clj
(do (println "one") (println "two"))```
#

Yeah kinda but not just for such a specific usage

prisma wave
#

I see

#

Clever stuff

lunar cypress
#

And well to explain the cond-doto macro: it takes an input value and a sequence of tests and actions

#

It results in a do form where each action is executed with the input value as its first argument if the test evaluates to true

#

I use this for the item stack stuff (if a durability is specified, set the durability, if an amount is specified, set the amount, etc etc)

#

It could have been more specific to the use case but I thought I might as well make it generally applicable

#

Because this macro doesn't exist in core for some reason

limber stream
#

whats the best monthly crate plugin? someone dm me please?

lunar cypress
#

There is -> which inserts the result of each action into the next, cond-> which does the same but with a test for each action, doto which only uses the initial value and is for side effects, but no cond-doto

surreal quarry
#

@limber stream #minecraft is where you wanna ask. this is a channel to talk about dev stuff

lunar cypress
#

But as I said, don't worry about macros too much. They used to give me headaches like nothing else but recently I felt like I finally got the hang of it

#

Just ask Suskey over at discljord, who wrote a meta-macro for other macros that should ensure that all values are only evaluated once

#

He said that took him like a day and it ended up being a couple lines of code

#

Also @onyx loom because you said you do not understand a single thing

pliant badger
#

it be like that sometimes

empty flint
#
inline fun <R> executeAndMeasureTime(block: () -> R, method: () -> Long = { System.currentTimeMillis() }): Pair<R, Long> {
    val start = method()
    val result = block()
    return result to (method() - start)
}

inline fun <R> executeAndPrintTime(block: () -> R, 
                                        timeMethod: () -> Long = { System.currentTimeMillis() }, 
                                        timePrintTransform: (msg: String) -> String = { it },
                                        printMethod: (msg: String) -> Unit = { println(it) }): R {
    val start = timeMethod()
    val result = block()
    val time = timeMethod() - start
    printMethod(timePrintTransform("$time"))
    return result;
}

What do you guys think of these methods to execute code and track the time it took?

#

Formatting is a bit screwed up but I think it's legible

surreal quarry
#

measureTimeMillis { }
measureNanoTime { } @empty flint

empty flint
#

measureTimeMillis { }
measureNanoTime { } @empty flint
@surreal quarry Can't get the result of a method via those though

surreal quarry
#

wdym by that

empty flint
#

if you have a method that returns something

surreal quarry
#

they both return a long

empty flint
#

say you want to measure how long it takes to retrieve something from the database

surreal quarry
#

val i = measureNanoTime { }

#

println(i)

empty flint
#

you retrieve it, but then you gotta return it and the time

#
measureTimeMillis {  }
measureNanoTime {  }

are similar but not equal to my methods

surreal quarry
#

im not quite sure what you are getting at, but i think this is what you are looking for

    val i = measureTimeMillis {
        (1..3000).forEach { print("$it ") }
    }
    println("\nTook $i ms.")```
that prints each number and then `Took 12 ms.`
empty flint
#

executeAndPrintTime(fetchDataFromTable(table), timePrintTransform = { Logger.log("Table retrieval took $it milliseconds") })

#

im not quite sure what you are getting at, but i think this is what you are looking for

    val i = measureTimeMillis {
        (1..3000).forEach { print("$it ") }
    }
    println("\nTook $i ms.")```
that prints each number and then `Took 12 ms.`

@surreal quarry I am looking for exactly what I made.

#

What would you do if you wanted the sum of 1..3000?

#

and the time it took to calculate it

prisma wave
#

@empty flint measureTimedValue

#

Already exists lol

surreal quarry
#
Sum is 4501500```
```kotlin
fun main() {
    var sum = 0
    val i = measureTimeMillis {
        (1..3000).forEach { sum += it }
    }
    println("Took $i ms. \nSum is $sum")
}```
empty flint
#

No @surreal quarry

surreal quarry
#

but i guess i see your point

prisma wave
#
val (value, duration) = measureTimedValue {
    sqlQuery()
}
empty flint
#

what the fuck

#

@empty flint measureTimedValue
@prisma wave Why do you have to ruin everything? 😄

#

Alright I guess measure timed value...

prisma wave
#

There's something very satisfying about suggesting 1 liners after someone has got a really complicated fix

empty flint
#

actually I thought it was a rather elegant fix to that particular problem

#

and my solution wasn't so far off the actual one

prisma wave
#

I suppose

#

It does the job

empty flint
#

What is a monotonic time source?

#

How do you get a long from TimedValue though?

prisma wave
#

Duration.milliseconds or something

empty flint
#

@ExperimentalTime blah

prisma wave
#

Not experimental in 1.4

#

I don't think

surreal quarry
#

pretty sure it is

empty flint
#

I am in 1.4 🤔

prisma wave
#

Oh

surreal quarry
#

im using 1.4 and i had to have it

prisma wave
#

Rip

#

Smh

#

I thought that came out of experimental

#

Stupid jetbrains

empty flint
#

how do I get this to compile

#

Or rather how do I annotate those values in the string as experimental?

#
@ExperimentalTime
val timedVal = measureTimedValue { "This is being timed." }
println("${timedVal.duration.inSeconds}")
surreal quarry
#

compiles fine for me

#

what's the error when you hover over it

prisma wave
#

Annotatr the whole function?

#

Or the expression

empty flint
#

This declaration is experimental and its usage must be marked with '@kotlin.time.ExperimentalTime' or '@OptIn(kotlin.time.ExperimentalTime::class)'

#

Annotatr the whole function?
@prisma wave I'm asking how

surreal quarry
#

annotate the println maube

prisma wave
#

Is that a scratch file?

empty flint
#

yes

prisma wave
#

Uh

#

@file:ExperimentalTime maybe

empty flint
surreal quarry
#

nvm lol

#

try just making it a who;le fun and annotating that

empty flint
#

@file:ExperimentalTime maybe
@prisma wave where do I put that annotation? after the imports?

prisma wave
#

Anywhere at the top I think

empty flint
#

try just making it a who;le fun and annotating that
@surreal quarry That works but now I can't call it 🤣

#

Anywhere at the top I think
@prisma wave no dice

#

This annotation is not applicable to target 'file' and use site target '@file'

surreal quarry
#

just try to open a new file maybe

empty flint
#

yeah I think I'll stick to my methods xD

surreal quarry
#

and make a main method

prisma wave
#

lol

#

Pretty sure you could use the @OptIn and they would work

#

Idk

#

It's late

empty flint
#

what's that now?

prisma wave
#

This declaration is experimental and its usage must be marked with '@kotlin.time.ExperimentalTime' or '@OptIn(kotlin.time.ExperimentalTime::class)'

empty flint
#

I'd need the compiler arg Opt in or something

#

scratch files are weird

#

And I have managed to get some circular dependency going now...

#

fuck

prisma wave
#

It's just a warning for the compiler afaik

#

Works fine without

empty flint
#

It's late
@prisma wave Amen, thanks for this little adventure in the world of experimental features I'm not touching anymore.

#

Works fine without
@prisma wave Oh yeah ur right

#
@OptIn(kotlin.time.ExperimentalTime::class)
experiment()

worked

#

but that's disgusting af so I'm still sticking to my methods

prisma wave
#

👀

#

At least clean it up to allow destructuring

empty flint
#

I love the timedVal.duration.inSeconds part though...

#

At least clean it up to allow destructuring
@prisma wave How do you mean?

prisma wave
#

the val (a, b) = blah

#

Actually nvm you probably can already if you're returning a Pair

frail glade
#

Pdm

prisma wave
#

pdm is being rewritten

#

It has turned into spaghetti

surreal quarry
#

sometimes spaghetti is good

#

like for dinner

prisma wave
#

ye but not in this case

frail glade
#

How long

prisma wave
#

No idea

#

Few days maybe idk

frail glade
#

Alrighty been waiting 2 months I guess I can wait another

prisma wave
#

lol true

empty flint
#

I guess I can turn my methods into TimeUnits as well instead of Pairs

#

makes more sense

#

and I don't need the second one actually

#

cuz measureTimeMillis() already does everything I do there

#

zomfg Kotlin has typealiasing

#

I love this language more and more every day

#

Thanks for showing me the light, Mitten

#

And thanks for all the help with my annoying questions

pastel imp
#

yo so idk any other person was here when I asked but is it a good idea to create my own essentials with only the things I need for my private server?

versed ridge
#

Sure, why not

surreal quarry
#

I think so @pastel imp. It gives you total control of the plugin and the things it does, which makes it easy to fix bugs for users, track the stats on your players you need, add core features, etc.

pastel imp
#

wdym by track the stats on my players

#

?

oak coyote
#

Well you control and can therefore understand and monitor any data stores

#

I found it incredibly interesting to watch how eco was balanced by viewing gains per day and what activities each person did.

#

Plus as they said you have full control so you never have that issue of going I wish it was done like this instead.

pastel imp
#

welp I have no clue how I could do something like that

#

I mean with the eco

surreal quarry
#

wdym by track the stats on my players
@pastel imp well for example, when i was doing a core plugin, i setup an extensive playtime thing so i could see statistics on what gamemodes were most popular, how many people were playing the server, etc. I also did things like supporting offline things about players like teleporting to them, getting info about what their character was doing when they logged off, etc.
having your own core allows for stuff like that

pastel imp
#

welp I am not that good of a dev

surreal quarry
#

yea but you will be eventually

#

you start with the basics of a core plugin

#

and you can add stuff like that as you go

pastel imp
#

I suppose you use mysql or sqlite to store that specific data?

surreal quarry
#

yea mysql