#help-development

1 messages · Page 1097 of 1

sly topaz
#

nevermind, I was looking at the wrong javadocs

#

getTo is nullable

crisp sleet
sly topaz
#

that screenshot was removed

#

ah you forgot a space

crisp sleet
sly topaz
crisp sleet
crisp sleet
sly topaz
#

just click this arrow and open one

olive lance
sly topaz
crisp sleet
sly topaz
#
var newLoc = event.getTo();

if (newLoc == null)
  return;

// do stuff
#

do that instead

sly topaz
olive lance
#

right i will do that but I just am wondering when getTo would ever return null and why

sly topaz
#

this command

sly topaz
#

probably an annotation forgotten in an upgrade

olive lance
#

interesting note

wet breach
#

IE, standing in a nether portal and you move at the time you teleport, getTo would be null

#

there is other scenarios where getTo can be null

sly topaz
#

that would be for the teleport event maybe but not for move event

wet breach
#

because packets don't just stop once sent

#

so if the client says, hey they moved lets let the server know, and then rightt after the client goes oh times up time to teleport lol

sly topaz
olive lance
#

doesnt the server tell the client when it time to teleport or no

olive lance
#

speaikng from laggy experiences

sly topaz
#

I doubt it'd be all too different from Paper

#

at most, a desync in information can happen and the getTo would just outright be wrong, but for it to be null? I don't know about that

river oracle
#

its nullable for a reason

#

make sure you check for it

river oracle
#

I think they gotta go back

sly topaz
#

ugh I don't wanna clone Spigot just to check this lol

#

welp

river oracle
#

I saw machine maker say something the other day about making it nullable again

sly topaz
#

the javadocs say nothing about why it is nullable

#

or are you talking about paper's

river oracle
#

ah its because of teleports

#

I'm speaking of why paper is returing to nullable

#

idk what every edge case for spigot is tbh

sly topaz
#

but by the sound of it, it looks like more of an API conflict more than an actual behavior issue

wet breach
#

so if they teleport, and a move packet comes in, the getTo couldn't be set because they are in a different world

#

and getTo would refer to an invalid location

#

therefore its best its null

#

like technically you could say its accurate but it wouldn't be if getFrom is one world and getTo was another lol

#

I think having it null is valid, but some people believe nothing ever should be null lol

#

personally I rather have data absent then be given incorrect data

#

simply because someone hated nulls

sly topaz
#

data shouldn't be incorrect to begin with, the data having to be null is a symptom not the solution

wet breach
#

it is a solution

#

you thinking otherwise is your opinion sure

#

but the problem arising with wrong data is that now you have to check the data that it is correct

sly topaz
#

no, if the server can't properly process the packets sent by the player, then it is a server issue

wet breach
#

no

#

in a multi-threaded environment you simply can not avoid clashes when two things can happen

sly topaz
#

that is just not true, and what part of the packet processing in the server is multithreaded anyway?

#

when two things happen at once and you don't handle it, that's called a race condition

wet breach
#

well you are advocating that data should be stuffed into it, when it potentionally could be incorrect data that no longer applies. Which sure it works but it doesn't remove the need for checks which is what null would require anyways, just it is easier to detect no data vs incorrect data or data that no longer applies

wet breach
halcyon hemlock
#

is spigot single threaded

wet breach
#

not entirely

halcyon hemlock
#

mostly?

sly topaz
#

almost everything related to the world is handled in a single thread

halcyon hemlock
#

isnt spigot made relatively recently? like 10 years ago?

sly topaz
#

only chat and login proccess isn't

wet breach
#

paper is newer then spigot is

halcyon hemlock
wet breach
#

yes

halcyon hemlock
#

im just curious as to why they went with single threaded instead of multi threaded

wet breach
#

but spigot doesn't drastatically change the way the game works or the code of it

sly topaz
#

because the vanilla server works that way

halcyon hemlock
#

spigot is an abstraction over bukkit right?

river oracle
#

spigot is bukkit now pretty much

sly topaz
#

spigot is the continuation of bukkit

halcyon hemlock
#

and paper is continuation of spigot?

wet breach
#

at this point in time you can consider bukkit and spigot one in the same

halcyon hemlock
#

or parallel?

river oracle
#

Paper is a fork of spigot

sly topaz
#

paper is a fork of spigot, they work in parallel to each other yes

wet breach
#

paper is like bleeding edge software built on top of spigot

river oracle
#

Spigot = Bukkit at this point

halcyon hemlock
#

so is paper multithreaded?

sly topaz
#

it isn't, folia is though

halcyon hemlock
#

minestom too right?

#

minestom is recent afaik

sly topaz
#

I don't know about Minestorm, never used it

halcyon hemlock
#

ye same

river oracle
#

Minestom will never be as viable as bukkit derivatives

halcyon hemlock
#

ive seen people use it

river oracle
#

sure but you won't get a good solid survival server out of it

halcyon hemlock
#

way more control

river oracle
#

unless you're literally insane

halcyon hemlock
#

if you want survival just use minecrafts own server innit

wet breach
#

one of these days I will release my own implementation

halcyon hemlock
#

the so called "nms" is bukkit or actual minecraft server?

sly topaz
#

vanilla server

river oracle
halcyon hemlock
#

is bukkit an abstraction over the actual vanilla server?

sly topaz
#

yes

halcyon hemlock
#

and spigot even over that

river oracle
#

not anymore

halcyon hemlock
#

i see, java in real life

river oracle
#

number of spigot patches decreases every year pretty much

halcyon hemlock
#

so spigot is dying basically?

wet breach
#

no lol

river oracle
#

patches are just being moved to CraftBukkit

#

because we maintain craftbukkit

halcyon hemlock
#

ah I see

sly topaz
#

craftbukkit is the server modifications to make the bukkit abstractions work

halcyon hemlock
#

I was just curious since im making my own server framework, and dont want to make the same mistakes as bukkit or others

sly topaz
#

if you want to make a server platform from scratch, I'd recommend talking to the Sponge guys

halcyon hemlock
#

i dont think itll ever compete with spigot in terms of plugins shit

#

since entirely different langs

wet breach
halcyon hemlock
#

maybe provide a scripting language like lua or some shit

halcyon hemlock
wet breach
#

also, I am going to turn it into a proper server setup

sly topaz
#

I mean, it doesn't matter even if it is the same language, look at fabric, minestorm, sponge. They barely get any adoption

river oracle
#

clean room implementations won't ever really be viable unfortunately

wet breach
#

IE separate some components into their own processes

river oracle
#

it takes too long to update

#

its definitely a cool project though

wet breach
halcyon hemlock
#

🤔

wet breach
#

and you simply can't anyways due to login stuff

halcyon hemlock
#

login stuff? encryption?

sly topaz
#

what do you mean by that

halcyon hemlock
#

everythings available on wiki.vg AFAIK

river oracle
sly topaz
#

the whole protocol is very well documented, so clean room is possible

wet breach
sly topaz
wet breach
#

yeah that

halcyon hemlock
#

yea thats just using an external API provided by mojang to authenticate users

sly topaz
#

could go nuts like the fosscord guys and implement the whole mojang backend like they did for discord lol

wet breach
#

anyways, the reason I am not going with a complete clean room implementation is because there is some things I am too lazy to do myself

#

such as pathfinding etc

#

or entity logic

#

I ain't going through and making all that myself lmao

sly topaz
#

that's the easier parts, what hurts is world and chunk gen

halcyon hemlock
#

pathfinding is easy innit

wet breach
halcyon hemlock
#

chunk gen, if done in proper steps shouldnt be that hard

#

would still take time though

sly topaz
#

a proper, efficient implementation is no walk in the park

umbral ridge
#

Yes

wet breach
#

well the thing about making your own implementation in regards to those things is that you don't have to follow how mojang does it

#

you can choose whatever method you want

halcyon hemlock
#

yeah thats true

wet breach
#

the downside of doing that is that seeds online won't work the same lmao

halcyon hemlock
#

for world gen you can start with perlin noise and come up with something

wet breach
#

otherwise you can use whatever randomization method you want

#

some are more optimal then others depending on what you are making

halcyon hemlock
#

have you worked on your impl? @wet breach or do you have to start?

wet breach
halcyon hemlock
#

cuz if u gonna start why not work together

wet breach
#

my implementation will require 3-4 processes

#

processes as in server processes running

sly topaz
#

I did an impl of the server myself, not clean room tho and for 1.8

wet breach
#

I am going to have a login server, chat server, world server and some others

halcyon hemlock
#

huh

#

why

sly topaz
#

splitting the logic in processes sounds like a bad idea

wet breach
# halcyon hemlock why

because splitting it like this means I can dedicate the resources to the things that really need it

#

a chat server doesn't require much and same with a login server

#

you can easily have a slim VM for that

#

then you have your world server which you can spread out over many VM's and delegate resources as needed

halcyon hemlock
#

you could have green threads innit

#

for every task

#

right now every conection for me is handled on a different thread

#

every system (keep alive, connection receiver etc)

sly topaz
#

they are looking for an arch which will allow for horizontal scaling

wet breach
#

and the upside of all this is I can reboot the world servers without players getting kicked

halcyon hemlock
#

fair

sly topaz
#

I mean, you can do all of that without splitting into processes

#

the only upside of process splitting a server impl is horizontal scaling, but at the cost of IPC latency

wet breach
#

not sure what you are going on about

#

there won't be latency issues

#

chat is not dependent on the world

#

also, the way I intend to scale the world server is by doing something along the lines of sharding

sly topaz
#

that's what horizontal scaling is

wet breach
#

ok, I don't really care not sure what issue you have

#

sharding would allow both vertical and horizontal scaling

#

vertical scaling just has to do with adding more resources or power vs using more nodes

#

but given technology today such as VM's becoming a whole lot better your horizontal scaling can also be vertical at the same time

#

nothing says VM's have to be on different hosts

#

anyways, the reason for sharding is because it would be more efficient to have a separate node for an area of a map. Since I like survival that is what my implementation is geared to

#

each node is assigned a piece of the world, and if a node goes down another node can easily take over if need be, or you can add more nodes if a shard starts becoming overwhelmed.

#

one of the main reasons I want the chat server to be its own thing

#

is because I am fan of allowing people to connect with just a chat client

#

other then we don't need the main server processes handling that stuff, as well as if something happens in the world chat won't freeze either

#

I also intend at some point in creating a custom client as well

#

I do not like the vanilla client

river oracle
#

now

#

will he actually start it

#

I'll give it a 0.01% chance

glad prawn
#

is there any way to completely disable the cobblestone generator?
cancel the event just makes liquid not flow together, i don't want that.

wet breach
alpine narwhal
river oracle
wet breach
#

y2k is most likely correct XD

#

however never know

rough ibex
#

I've had one of those 'holy shit this bug was so easy to fix' moments

#

my computeIfAbsent lambda was modifying the map, not returning the value NotLikeThis

buoyant viper
#

whats default getWalkSpeed of Player again

#

0.2f?

drowsy helm
dawn flower
#

actually it's 0.20000000298023224 🤓

#

stop spreading misinformation!!11

buoyant viper
#

i like Action.PHYSICAL's documentation

blazing ocean
#

love that

rough ibex
#

who wrote that

blazing ocean
#

this ones better tho

#

squeeehkkk

shadow night
#

The people had some fun

rough ibex
#

easter eggs

buoyant viper
#

does LivingEntity#damage(double damage, Entity source) modify damage based on source GENERIC_ATTACK_DAMAGE attribute or does it deal the direct value, and does it take into consideration the entity being hit's armor protection attribute?

#

im just having this really weird issue where its dealing correct? damage to all other mobs except Zombies

#

ie.

Player player = getPlayerSomehow();
Mob mob = (Mob) getVictimSomehow();
mob.damage(mob.getHealth(), player);

and with nothing in my hand, this will not insta kill the Zombie, however if mob is anything other than Zombie, it will

halcyon hemlock
#

I added reflections to rust

#

what are we rating this

#

frfr

#

its compile time too

#

instead of run time

#

unlike java

hazy parrot
#

How would compile time reflection work lol

halcyon hemlock
#

derive macros

#

its in rust

#

so when compiling code, its basically a macro to loop through each file and look for specific type of structs

#

the system is pretty clean tbh, the serialization

blazing ocean
#

doesn't serde do that

halcyon hemlock
#

serde is slow

#

the overhead

#

i compared with 3 other libs and mine is still faster, for no reason

#

i didnt even do stupid simd shit

blazing ocean
#

i do love me some rust macros

halcyon hemlock
#

derive macros are just awesome

#

dont know what id do without them fr

blazing ocean
#

real

#

also extension traits my beloved

buoyant viper
#

like now nothing takes damage lol

#

kinda funny

halcyon hemlock
#

pub TraitA: TraitB?

sly topaz
#

traits that extend structs/other traits

#

would be the equivalent of extension functions in kotlin

blazing ocean
#
trait StringExt {
    fn push_newline(&mut self);
}

impl StringExt for String {
    ...
}

let mut string = "Hello, world".to_string();
string.push_newline();
sly topaz
#

it's just syntax sugar for a wrapper. Maybe a static method that takes the object is a better description

rough drift
#

like it has that builtin

halcyon hemlock
#

it has a builtin nbt serializer?

#

damn who built the language

sly topaz
#

lmao

rough drift
#

no like

#

the reflections

#

smh

sly topaz
#

they are talking about comptime

blazing ocean
#

comptime is weird

halcyon hemlock
#

a camera as well

#

aww man you cant name nbt compounds as crabs

#

isnt it utf8

sly topaz
#

what is

blazing ocean
#

now do that for dfu concern

halcyon hemlock
#

dfu?

blazing ocean
#

datafixerupper

#

mojangs serialisation lib

halcyon hemlock
#

its not rust

blazing ocean
#

yea

halcyon hemlock
#

how would I bench it

ivory sleet
#

You could rewrite it in rust

halcyon hemlock
#

theres that

blazing ocean
#

jni
create a jar that uses it and run it in rust kekw

halcyon hemlock
#

too much effort

#

let me try bench my new approach, maybe its way slower now

sly topaz
#

minecraft's is most likely more efficient given the scale

halcyon hemlock
#

fr?

blazing ocean
#

not sure since it's mojang code

halcyon hemlock
#

its so big

#

mine is barely 2-3 files

sly topaz
#

code size barely matters in terms of performance

blazing ocean
#

well it has pretty much all the serialisation from minecraft

halcyon hemlock
#

they have fucking papers on it bro

#

i aint competing with them

blazing ocean
#

damn mojang got docs?

#

crazy

halcyon hemlock
#

im surprised they didnt obfuscate their open source library

#

thats a first

blazing ocean
#

how

#

brig ain't obfuscated

halcyon hemlock
sly topaz
#

you guys do know that a big GIF appears on these right

#

lol

blazing ocean
#

doesn't for me

#

compact mode

ivory sleet
# sly topaz

Discord on phone doesn’t show that unfortunately

halcyon hemlock
#

wtf

#

if I do Vec::new() it takes about 350ns as average

blazing ocean
halcyon hemlock
#

if I do Vec::with_capacity(2048) it takes 150ns

#

lmao???

blazing ocean
#

because without args it has unlimited capacity?

halcyon hemlock
#

prolly cuz it keeps increasing size

#

and allocating

blazing ocean
#

yes

halcyon hemlock
#

hmm how could we guess the size 🤔

#

time to use unsafe allocation 😋

blazing ocean
#

why do you even need a 200ns optimization

#

average rust user

halcyon hemlock
#

a chunk maybe a thousand times bigger

blazing ocean
#

me when kotlin

#

(goat)

#

me when

#

i love null chaining

#

ye

#

s

halcyon hemlock
blazing ocean
#

!! means "it's not null trust me bro"

#

basically assert != null

halcyon hemlock
#

ye ik

#

like typescript

#

and dart

blazing ocean
#

kotlin does uwu

#

rust format!() uwu

#

println("$myInt + 1: ${myInt + 1}")

halcyon hemlock
#

a single u8 takes 34 nanoseconds, no way

#

my benchmark is definitely broken lmao

blazing ocean
#

stop trying to get nanosecond optimisations and build shit

halcyon hemlock
#

so real

sly topaz
#

sadly they withdrew the string templates JEP, see https://youtu.be/c6L4Ef9owuQ?si=CuyKyG83f694ikp2

String templates proposed a way to readably and safely mix strings with run-time values and were a preview feature in JDKs 21 and 22. Then, to everybody's surprise, they were dropped in JDK 23! What where the reasons, what could a new proposal look like, when may we see it, and what does all this mean for the OpenJDK development process? Let's d...

▶ Play video
fossil fiber
#

i got an idea on what plugin I need but idk how to code.. anti lava and water from forming cobble/obby flags, need worldguard for dependencies,

tardy delta
halcyon hemlock
sly topaz
#

I mean, that kind of benchmark isn't even measuring real performance of anything, it is just playing around with the benchmarking crate

halcyon hemlock
#

thats a lot of 0s

#

anyways imma go do actual shit now

blazing ocean
#

what have you done

halcyon hemlock
#

make my code slow on purpose cuz its too fast, duhhh

#

sleep(Duration::from_millis(10));

sly topaz
#

premature optimization is the root of all evil people, remember

halcyon hemlock
#

the thing is. I haven't done any optimizations

#

ok well cya

sly topaz
#

I'd just sleep on it if I were you

#

otherwise you'll get burned out and never finish the project

#

when I am doing dumb shit inside a project, I know it is time to get away from the keyboard

umbral ridge
#

yes

halcyon hemlock
#

¯_(ツ)_/¯

sly topaz
#

go for a walk

#

play with a pet

umbral ridge
#

or its time to check on your cat

halcyon hemlock
#

i dont have pets

sly topaz
#

I can't recommend having one with a good concience, I love animals too much but I am too broke to have them

umbral ridge
#

I love my cat

sly topaz
#

and they are basically babies that never grow up

umbral ridge
#

XD

halcyon hemlock
#

i already have too much shit to do

sly topaz
ivory sleet
halcyon hemlock
#

how many lookups are you doing per tick?

eternal oxide
#

Do NOT do db access on the main thread

ivory sleet
#

Yes

sly topaz
#

26 seconds, jeez

ivory sleet
#

Likely will

sly topaz
#

you also may wanna check your queries, that's too long for any connection

#

is your db hosted locally?

eternal oxide
#

hosting is always shit

#

may not even be on the same box

sly topaz
#

well, then you won't ever notice latency issues that way

ivory sleet
#

Well @blissful crow dont be scared, string interpolation is likely to come back in the distant future

#

or “string templates”

#

if you now will

ivory sleet
#

very so

rough drift
sly topaz
#

Java 8 has long not been industry standard

ivory sleet
#

You’re on thin ice saying that

rough drift
#

I will pasta la vista you

sly topaz
rough drift
#

or on the first occurrence of something

#

then everything else is done async

sly topaz
#

did you do it to avoid the context switch penalty or just found it easier to not care about it

rough drift
#

so it has to run on the same thread

#

plus it loads in <5ms

tardy delta
sly topaz
#

that just means your design isn't designed around the idea of being non-blocking, normally you deal with that by using completion handlers everywhere

rough drift
sly topaz
#

not necessarily, just a lot more tedious than what it's worth

rough drift
#

var tag = tags().get("tag");
tag.has(UUID)
...

vs

tags().get("tag").then(tag -> {
  tag.has(UUID);
  ...
});
#

I like the first one better

tardy delta
rough drift
#

you may have more variables to pass in

#

that causes new instances to be made

ivory sleet
sly topaz
#

hopefully these fancy concurrency features such as scoped values and structured concurrency APIs get out of preview soon™️ so it becomes a whole lot easier

tardy delta
#

tbf i saw them being used in minestom

rough drift
ivory sleet
tardy delta
#

for things like minimessage, mightve been a personal lib

sly topaz
#

I mean, it exists in JDK 21 as a preview, so I wouldn't be surprised

ivory sleet
#

I mean both the struc conc apis are in their third preview, hopefully for the sake of love and god we get those fully delivered in j24

sly topaz
rough drift
#

java is getting some W updates

ivory sleet
#

ah, that’s interesting

rough drift
#

but honestly the one I'm most excited about is List<int>

blazing ocean
#

so much

ivory sleet
blazing ocean
#

why couldn't they just be normal

#

and be like kotlin

rough drift
#

it's apparently safer

blazing ocean
#

🤨

sly topaz
#

it was something about performance, but they later discovered it wasn't necessary and thus the JEP fell apart

ivory sleet
#

well good enough

rough drift
ivory sleet
#

Yup

rough drift
#

imagine spigot with valhalla and 401

#

major W

sly topaz
#

we are 1 month away of Java 23 too

rough drift
#

yo??

#

what they addin

sly topaz
#

this is a good one

rough drift
#

holy shit

blazing ocean
rough drift
#

can you shut the fuck up about kotlin

blazing ocean
#

no as in

#

that's literally what kotlin has

#

they are just copying kotlin shit

rough drift
#

yeah I am aware, a fuck ton of languages have this

#

maybe java is just updating and adding modern features?

blazing ocean
#

shocker

ivory sleet
#

Its also interesting gen zgc by default is just shipped fully w little preview or anything, in j23

#

I mean I suppose its been tested enough to outperform normal zgc

rough drift
#

I can't wait for java 100 🔥

tardy delta
#

are we using zgc by default already

rough drift
#

gen zgc

ivory sleet
#

^^

sly topaz
rough drift
#

Yeah

#

A lot of my optimizing code will need to be updated for all of these JEPs

#

but they just end up giving me more data to optimize better so W

sly topaz
#

with this I can stop doing dumb shit like calling map twice and abuse the hell out of method references kek

ivory sleet
sly topaz
#

it is going to be ready for 25 most likely, it isn't a big one

#

thing's going through so many phases

ivory sleet
#

Yea as long as things can be fully delivered on the lts version its pretty accepted

rough drift
#

def can be

#

they are pretty minor

tardy delta
#

more simd intrinsics?

ivory sleet
rough drift
#

yeah

sly topaz
#

it's just waiting on valhalla now

sly topaz
rough drift
#

valhalla is so W

#

but I also like most other projects

#

like panama

ivory sleet
#

Doubt valhalla will be fully delivered by 25 tho

sly topaz
#

Java has a lot of auto-vectorization code but it didn't have many utilities for manual vectorization until that API arrived

rough drift
tardy delta
#

dunno why i would need simd in java tbf

#

if i would, i wouldve written it in c

rough drift
#

and it's super easy

sly topaz
#

the same reason you need simd anywhere else, to make things faster

rough drift
#

it's like huge speed boosts for very little

tardy delta
#

working with __m128 is also super easy 👉👈

rough drift
sly topaz
#

the good thing about it being in the JDK is that it's going to eventually be fully cross-platform, so you would be able to write very performant SIMD code that works on various architectures, not like now where you have to be very mindful of it with lower level languages

#

and the JDK devs are very competent so they'll make something that works well out of the box, anything else will come from library makers

rough drift
#

tbh why write in other langs than Java when you aren't in embedded envs

#

if done right esp with the releases that are coming it is just a productivity boost

tardy delta
#

love it when ike reacts to his own message

rough drift
buoyant viper
#

hmm

dry hazel
#

they are incorporating some changes

rough drift
#

W

sly topaz
#

might be of interest to you

#

it isn't talked about a lot, but people are using Java a bunch in the enterprise side of things

halcyon hemlock
#

rate my IDE

tardy delta
#

rust 🗿

sly topaz
#

RustRover huh

tardy delta
#

is there like a reason to use rr over vscode or smth

sly topaz
#

not really

#

rust-analyzer (the lsp), is really good

#

to the point you could use notepad for what is worth as long as it supported LSPs

tardy delta
#

just learn vim

halcyon hemlock
tardy delta
#

better than what

halcyon hemlock
halcyon hemlock
tardy delta
#

the vscode extension is also literally meant for rust

halcyon hemlock
#

i just dont like vscode

#

simple

#

i have all jetbrain ides for everything i do

#

they do best what they're meant to do

#

vscode seems too basic

tardy delta
#

average jetbrains suite enjoyer

#

😂

sly topaz
#

vscode is too basic

#

but you don't need anything fancy for rust

#

I don't think jetbrains can offer anything of actual value to me as a dev in RR that I wouldn't be able to achieve in my neovim setup

tardy delta
#

same

halcyon hemlock
#

¯_(ツ)_/¯

#

i would rather use (neo)vim than vscode

blazing ocean
#

zed >>>

tardy delta
#

zed looks fairly limited

blazing ocean
#

it's pretty good

#

or just use neovim

buoyant viper
halcyon hemlock
#

its not mature enough tbh

halcyon hemlock
#

it aint that small 😢

buoyant viper
#

just looks crammed idk

halcyon hemlock
#

i have big font

blazing ocean
#

it has all you need

#

what more do you need than terminal, lsp, editor and files

quaint mantle
#

Zed is written in rust 🗣️

tardy delta
#

meanwhile all other fast langs:

#

its just llvm

halcyon hemlock
blazing ocean
#

huh?

halcyon hemlock
halcyon hemlock
blazing ocean
#

binaries exist

halcyon hemlock
#

not for windows innit

blazing ocean
#

windows 🤡

halcyon hemlock
#

ok

#

I like playing games

#

All linux shit is already in wsl

#

¯_(ツ)_/¯

wintry dagger
#

anyone good w java generics please dm

blazing ocean
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

wintry dagger
#

i cant send images

tardy delta
#

?img

undone axleBOT
#

Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.

Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org

wintry dagger
#

!verify

undone axleBOT
#

Usage: !verify <forums username>

wintry dagger
#

I see the problem

#

I’m too stupid to see the solution

drowsy helm
#

you will have to do TicketField<T> then cast it as that again

#

unless getInput takes a class to implicit cast

rough drift
#

rust is just an automatic downside

tardy delta
#

its readable

rough drift
#

joke of the year award goes to:

blazing ocean
#

you're a downside

rough drift
#

FourteenBush! With their joke "Rust is readable"!

tardy delta
#

lol

wary harness
#

anyone can recomend good discord api for bot integration

tardy delta
#

jda

wary harness
#

I got shop plugin which I want to hook in to discord

rough drift
blazing ocean
#

d4j trollface

rough drift
tardy delta
#

never heard of

wary harness
#

jda or d4j ?

blazing ocean
#

jda

wary harness
#

which one is better and easier?

blazing ocean
#

just use jda, more popular one

wary harness
#

thanks

wintry dagger
#

unless i just put in a try catch

drowsy helm
#

probs the best option

wintry dagger
#

try catch ye

#

figured it might be

lost matrix
#

You wont be able to catch an unsafe cast

drowsy helm
#

or you can do two TicketField variables

#

one type ?, other type T

#

check type then if applicable, cast

lost matrix
#

There is probably a way to make this kinda type safe. But i have no idea what this is.

drowsy helm
#
public <T> boolean addInputData(String type, T data){
  TicketField<?> field = this.category.getInput(type);

  if(!data.getClass().isInstance(field.getType())){
    return false
  }

  TicketField<T> castField = (TicketField<T>)field;
  //do stuff
}
lost matrix
#

If you keep the type checking encapsulated with an implicit relation, you can use unsafe casts but be technically type safe.

drowsy helm
#

not semantically type safe, but techincally type safe

lost matrix
#

Pretty much

wintry dagger
lost matrix
#

Eg if you have a Map<Class<?>, SomeObj> and stricly limit access to this map, you can safely cast later.

drowsy helm
#

yeah, just a java limitation atp

#

dont think theres any other way of enforcing it?

lost matrix
#

nvm, ignore me, i just got up

drowsy helm
#

that would work i think

lost matrix
#

I feel like there is a better solution. The TicketField<T> could have a Class<T> getFieldType() method.

#

What even is String type ???

#

That doesnt look right

wintry dagger
drowsy helm
#

inputData is a map im assuming

#

with key being data type?

wintry dagger
#

Ye key is the name of the field, a string, value is well, object

#

like am just messing with input fields similar to what discord has with like NumberInputField, StringInputField etcetc that provides a universal interface for all field types

#

but generics / that might be the wrong approach even idk

rough hinge
#

If in inventoryclick the player clicks on the topInventory inv, will topinventory.getcontents return the updated items?

@EventHandler(priority = EventPriority.HIGH)
    public void onInventoryClick(InventoryClickEvent event) {

        Player player = (Player) event.getWhoClicked();
        Inventory inventory = player.getOpenInventory().getTopInventory();

        System.out.println("antes");

        if (!inventory.getName().equals("Backpack")) {
            System.out.println("TOMAA" + inventory.getName());
            return;
        }

        System.out.println("depois");

        Backpack backpack = plugin.getBackpackService().get(player.getName());
        updateBackpack(backpack, inventory);

    }```
lost matrix
lost matrix
lost matrix
# rough hinge then what can i do?

First of all, you should never use the name of your inventories as identifiers.
People can just rename a chest, place them and then basically spoof all of your guis.

lost matrix
rough hinge
#

basically if a person put a item on backpack inventory, the backpack#getContents() will update and update on database too

lost matrix
# rough hinge backpack

Backpacks should be straight forward.

  1. When the player opens a backpack -> Load the content and put them in an inventory
  2. When the player closes the backpack -> Go over the inventory and save everything

There is no need to sync/save the backpack on every click. Just open a plain old inventory and let the players
throw their stuff in there.
Then save it on close and load it on open.

wintry dagger
rough hinge
rough hinge
lost matrix
lost matrix
wintry dagger
#

Bad idea having a string name as key yeah?

lost matrix
#

User input always results in Strings

#

Honestly i have no idea how your system works and who can register new types.

rough hinge
lost matrix
rough hinge
lost matrix
#

Then its gone

rough hinge
#

But how do I close all inventories when the server closes? Doesn't this happen anymore? Do I have to go through all the players and close the inv in the ondisable?

wintry dagger
rough hinge
#

Bukkit.getScheduler().cancelTasks(this); i need make this on disable?

rough hinge
lost matrix
#

Sadly, for some reason, spigot doesnt kick all players before stopping.

tardy delta
rough hinge
#

Should I kick all players or close the inventory?

lost matrix
#

Really depends on what plugins are loaded at this point. If its a single plugin server, then kick them.
This will result in the PlayerQuitEvent being fired for all of them. Alternatively you can manually save all of your Managers live data in onDisable.

rough hinge
#

In this case, the only thing I have to save is just that, the rest is all synchronized.

#

and it is a unique plugin

#

I'll choose to kick anyway

lost matrix
# rough hinge I'll choose to kick anyway

Btw, this has a tricky implication.
You should never run IO operations on the main thread. (Accessing Files, Databases, Web endpoints, etc)
unless you are in your onEnable/onDisable. This means you need a flag that you can set, to switch between sync/async access.
The inventory should be saved in the InventoryCloseEvent, but this should happen async, unless it is fired as a result of your onDisable kicks.

#

Just keep that in mind. Running IO in events or other parts of the main thread will result in lags.

lost matrix
#

Which part

eternal oxide
rough hinge
# lost matrix Which part

First of all, why would I use an asynchronous database if I have to use the CompletableFuture's .join method? It will even use more resources and stop the main thread for the same amount of time!

eternal oxide
#

You don;t understand Futures

#

you do not call .get on a future

#

it defeats the whole purpose

onyx fjord
#

whats the event for sapling changing its stage?

lost matrix
rough hinge
#

Imagine, if I use .thenAccept or something like that, let's consider that it takes 5 minutes for the response to be returned. A get is used that returns the player's coins and it takes 5 minutes to return the response that will return 1 million coins. However, the player has 0 coins and sells an item in the store for 100 million. The player will receive the 100 million in the cache and will set it in the database, then after 5 minutes the database will overwrite the cache and the player will only have 1 million.

#

So in most cases I'm forced to use .join, which makes it completely useless and just wastes more resources.

#

It uses more resources because several tasks that will be executed in another thread are rewritten, and it will end up overloading the system as well.

wet breach
#

your imaginary scenario is flawed

lost matrix
#
  public ItemStack[] loadItemsFromDatabase(UUID playerId) {
    // Load items from database
  }

  public CompletableFuture<ItemStack[]> loadItemsFromDatabaseAsync(UUID playerId) {
    return CompletableFuture.supplyAsync(() -> loadItemsFromDatabase(playerId));
  }

  public void openBackpack(Player player) {
    BukkitScheduler scheduler = Bukkit.getScheduler();
    JavaPlugin plugin = ...;
    UUID playerId = player.getUniqueId();
    Inventory backpack = Bukkit.createInventory(null, 27, "Backpack");
    // Load items async
    CompletableFuture<ItemStack[]> futureItems = loadItemsFromDatabaseAsync(playerId);
    // With thenAccept you can define some code that should run after the future is completed
    futureItems.thenAccept(items -> {
      // This code is used to get back to the main thread
      scheduler.runTask(plugin, () -> {
        backpack.setContents(items);
        player.openInventory(backpack);
      });
    });
  }
lost matrix
wet breach
#

when you have a cache system in place, you should storing data in the DB right away before it goes to cache since cache can be lost at any moment. If you follow this, there shouldn't be a scenario where your coins get overwritten

rough hinge
rough hinge
rough hinge
lost matrix
#

Look at the example ive sent. Lets not deviate from backpacks, because currency is an entirely different topic.

wet breach
#

no it won't unless you are just completely ignoring the DB

rough hinge
rough hinge
wet breach
#

the reason they should be async is because you can encounter a long query for whatever reason and it will hault the main thread

lost matrix
rough hinge
#

will stop the main thread anyway and still use more resources

lost matrix
#

Yeap. Do not use .join() on the main thread.

#

And lets keep caching out of this discussion for now.

rough hinge
#

and even because nothing is important for the player to keep his data in the database because the guy decided to make the DB asynchronous in 100% of the systems 🤡

pseudo hazel
#

you dont wanna crash the server due to freezing atleast

rough hinge
#

and even because a get in mysql is very expensive 🤡

pseudo hazel
#

the player is impacted by the server not responding for several minutes afaik

lost matrix
wet breach
#

alright I see we have an inexperienced person and I am just not going to bother. DB tables can be locked while performing operations where you don't want overwriting to occur like in your scenario. If the table is structured properly you will know that the data you are about to insert is now stale and you can implement code around this in how you want to handle the exception that occurs.

wet breach
lost matrix
#

ola, you are making the argument that simply crashing the server is a proper strategy to handle connection problems...

wet breach
#

mysql can handle millions of queries a second easily with not a whole lot of resources being needed for it

rough hinge
eternal oxide
#

ANY delay on teh main thread is detrimental

rough hinge
#

and if the player can do what I said in 5 minutes, in milliseconds. any player is subject to having rollback at any time Do you think this is good?

pseudo hazel
#

you should always program for the exception, not the rule

wet breach
pseudo hazel
#

no but it cant be prevented

tardy delta
#

someone shaking with the harddrives hehe

wet breach
#

if the connection from server to DB dies for whatever reason, your query will hang for 30 seconds since that is the TCP timeout

lost matrix
#

Thats why i dont even query redis (which is right in memory) sync.

rough hinge
pseudo hazel
#

roll back what

rough hinge
#

Really weird

wet breach
#

with how many queries a second?

rough hinge
# pseudo hazel roll back what

Imagine, if I use .thenAccept or something like that, let's consider that it takes 5 minutes for the response to be returned. A get is used that returns the player's coins and it takes 5 minutes to return the response that will return 1 million coins. However, the player has 0 coins and sells an item in the store for 100 million. The player will receive the 100 million in the cache and will set it in the database, then after 5 minutes the database will overwrite the cache and the player will only have 1 million.
So in most cases I'm forced to use .join, which makes it completely useless and just wastes more resources.

rough hinge
wet breach
#

a moment?

lost matrix
wet breach
#

that is not a number

eternal oxide
#

ola you are arguing pointlessly. Not a single person here will agree with you doing sync db access on the main game thread.

rough hinge
wet breach
rough hinge
pseudo hazel
#

i think thats the wrong image

rough hinge
blazing ocean
rough hinge
#

Basically it's a rust server (more similar to factions if you don't know) with a synchronized DB and all the data synchronized, anything the player does (setting up a base, evolving it, will be synchronized)

blazing ocean
#

showing a list of packages helps with nothing lmfao

eternal oxide
#

also TPS is a bad measurement

lost matrix
rough hinge
#

but yes, the solution will be to have data inconsistency with the DB, and all players will lose their things at any time.

pseudo hazel
#

when did we say that

eternal oxide
#

done correctly (async) you will never have data inconsistencies or data loss

wet breach
pseudo hazel
#

the solution is certainly not to crash your server on a blue monday because the database wasnt feeling it

rough hinge
wet breach
#

this is why I was curious with their statement, how many queries were they performing

lost matrix
blazing ocean
#

db host slow: server just dies

void sigil
#

Id not take that

#

@rough hinge Come back

wet breach
wet breach
#

again proving my point you don't know anything about DB's

eternal oxide
#

that there is a design flaw

rough hinge
wet breach
#

I already told you that you can lock tables

eternal oxide
#

get the data in the Async pre join so it is available in the Join

blazing ocean
eternal oxide
#

you also delay the pre join until the data has been fetched so you 100% guarantee it is ready

lost matrix
#

No need to lock. For currencies you simply run queries like INC and DEC, with field constraints. You can define a DB number collumn to always stay above 0.
Then you run your DEC query, and it will either be successful or not.

wet breach
#

You can do it that way too

lost matrix
#

100% consistency in your values as the DB ensures consecutive calls

wet breach
#

^

#

this is one of many ways to do it

blazing ocean
lost matrix
wet breach
#

anyways, @rough hinge I recommend doing more research or learning in regards to DB's. They are very powerful tools on their own and can facilate many things for you if you just knew what it had and in some cases remove code you didn't even need.

#

concurrency with DB's dates probably before you were born(guessing you are young from your example arguments)

onyx fjord
wet breach
#

oh its stage

onyx fjord
#

just it never finishes growing

wet breach
#

lol

wet breach
#

because you could just reset the stage back

onyx fjord
#

so there isnt a specific event that handles that>?

#

like BlockGrowEvent for plants

wet breach
#

only one I know of is structuregrowevent

onyx fjord
#

yea im cancelling it and stage changes

wet breach
#

so reset the stage back of the sapling

#

all you really need the event for is just so you know the stage changed

onyx fjord
#

but doesnt structuregrowevent only trigger when last stage turns into a structure?

#

not each stage

wintry dagger
#

im gonna run every single database call on main thread

#

or else inconsistencies

pseudo hazel
#

lol

#

dont

wintry dagger
#

Ofc not im trolling

#

I had a good laugh reading the above thread

pseudo hazel
#

xS

wintry dagger
#

ur funny @west shoal

#

wait wrong tag

#

@lost matrix

echo basalt
#

I'd suggest informed is the right word there

hidden spade
#

Does anyone here know how exactly the custom crop plugins work, from what ive gathered they use blockentities but from what i can see i wouldnt be able to display the crop properly

wintry dagger
#

Can transient be used like this private transient final JavaPlugin plugin in classes with multiple instances to free up ram/memory usage?

#

if i need to reference the main class a lot

#

when dependency injecting

eternal oxide
#

no, ther is only ever one instance of JavaPlugin

echo basalt
#

transient is about serialization not about GC

pseudo hazel
#

yeah it would store references to the plugin class object, not the actual object

wintry dagger
#

ah so like if I have multiple Profiles stored in a List and every Profile has a JavaPlugin field, transient isn’t anything to add

echo basalt
#

It is if you're yeeting profile POJO's in the database

#

(because you can't really encode JavaPlugins)

#

But otherwise no

wintry dagger
echo basalt
#

I've done it in the past yeah

#

And that's the whole purpose of transient

wintry dagger
#

Got it

#

it’s not a too common keyword eh?

#

dont think i’ve ever used it in plugin or even seen it for that matter

echo basalt
#

In the minecraft context, no

wintry dagger
#

im still stuck on my generics problem

echo basalt
#

You need to convert your tickettype<?> to TicketType<T>

#

casting is fine

rough hinge
wintry dagger
#

In the addInputData method

#

Acc no that wouldn’t work

wintry dagger
#

I could cast it to TicketType<T> after first if check?

echo basalt
#

Yes

rough hinge
echo basalt
#

You can just sendMessage in the thenAccept

rough hinge
echo basalt
#

The way we do it at work (we're a pretty big bedrock studio) is that everything that needs to be done in order is blocking

#

Our economy service is blocking and every request goes through the database

echo basalt
echo basalt
#

sigh this will take a while to get across

rough hinge
echo basalt
#

There are a few keywords that are tossed around and they can often get confused

#

Mostly we need to know the difference between sync vs async vs multi-threaded vs thread-safe vs blocking

#

because labelling everything "sync" is just a huge meme

rough hinge
echo basalt
#

Nope

#

A blocking method is a method that takes a while to execute regardless of what thread you're on

#

For example, an IO operation

echo basalt
#

Not exactly

rough hinge
#

then

echo basalt
#

and stop jumping to conclusions so fast ffs

#

you're here to learn not to 1-up me

#

Thread-safe means that a method is "alright" to be ran on another thread, or multiple threads at once

#

So for example, sending a packet is thread-safe. You can queue up multiple packets on multiple threads at once, and the server doesn't care

#

Then you have the term "sync", which doesn't necessarily mean "main thread" but it means that a method runs in a synchronized operation to the thread that calls it

#

It might run on another thread but eventually join back the main thread

#

In minecraft terms we just refer to it as "running on the main thread"

#

And "async" doesn't necessarily mean "running off the main thread", it just means that "it runs.. eventually.. somewhere"

#

It's parallel to what your operation is doing

mellow edge
#

is it a common practice if I make my plugin use reflection and compile it with the java version that is run by lowest supported minecraft version my plugin uses. Then I can make a single jar that is supporting versions 1.8-1.21

quiet ice
#

I mean, you can also use MRJ \s

quiet ice
#

Which is a shame, because it undermines the beauty of lockless concurrent datastructures and algorithms

echo basalt
#

(it basically just means don't expect immediate results)

#

Now, what we do at work is that we have a "blocking" bunch of services for our database operations

#

So for example economy is blocking, where any get / set might run through a cache but usually takes a while to execute

mellow edge
echo basalt
#

So you're encouraged to execute transactions off the main thread (because blocking it is stupid)

quiet ice
echo basalt
#

And if you care about constant updates (let's say a scoreboard or something) you can store a snapshot of the last let's say 5 seconds

mellow edge
#

tbh I never heard for that

echo basalt
#

And update the snapshot if any payment data is received on the same server within those 5 seconds

#

That's one example, there are a lot more complex structures

quiet ice
mellow edge
#

I didn't know that even exists so I tought I could write my own tool that does that. But then I remembered that I can make a single jar for every version. But the problem comes that basically I need to refactor every existing nms code to reflection and then add new reflection for newer versions and etc....

rough hinge
quiet ice
rough hinge
echo basalt
#

Sending a message is just sending a packet

#

Same for spawning particles

rough hinge
#

I wanted to know how in my case I would use ./money <...> and use the findone method being async (async on this case, outside the minecraft thread) in the db

rough hinge
echo basalt
#

You can yeah

rough hinge
# echo basalt You can yeah

I would like to know everything about Minecraft that is thread safe. Sending messages, particles in the world is threadsafe. updating an armorstand for example is not thread safe, right?

mellow edge
# quiet ice I mean, you're probably better off using MethodHandles instead of Reflection unl...

I understand and good points. But the plugin's base is already in 1.8 and it was meant to be like that. But I want the plugin to work in modern versions, like the latest ones. And my plugin is forced into using NMS on multiple parts, because on some things I didn't use APIs because there is no guarantee that they will work later and upgrading that would be harder than upgrading NMS.

quiet ice
#

upgrading that would be harder than upgrading NMS.
Uh what

mellow edge
#

like third party APIs***, for example book api or smth

#

because as u know in 1.8.8 book support isn't as good as in 1.21

rough hinge
# rough hinge I would like to know everything about Minecraft that is thread safe. Sending mes...

I have a vehicle plugin that whenever a player presses W in the packetreceiveevent (I used packetevents as the lib) updates the location of an armorstand. But, I update the location of the armorstand outside the game thread, which I believe is not thread-safe, what can I do about this? I tried to execute a task but the server thread stopped because there must be like 1000 threads in a single second. The thread stopped with only one player, which in this case was me using the vehicle.

mellow edge
#

so I tought I could maybe get bukkit package name and extract NMS version from it automatically and with that make it support all versions

eternal oxide
#

jump back sync to apply world changes

thin frost
#

Is it possible to block coal from being consumed in a furnace using spigot java

eternal oxide
#

oh you mean stop it being used, not consumed

torn shuttle
#

how do I get an enity's body's yaw?

#

not eye

eternal oxide
#

nms

torn shuttle
#

I thought just getting the entity location and getting the yaw would do it but seemingly no

torn shuttle
eternal oxide
#

API is lacking in that it applies the yaw to the body and adds Eye height for eye location

mellow edge
#

I think I need just 1 single NMS rewrite from 1.8. 1.13 was released together with mojang mappings, so this is the only version that I need to refactor NMS and then 1.13+ versions will all work? correct me if I am wrong. All NMS I am currently using is for packets.

eternal oxide
#

it would be a breaking change to fix it

torn shuttle
#

can't get get an entity.getBodyLoc

eternal oxide
#

from nms you can

torn shuttle
#

or at least an entity.getBodyYaw

#

damnation

torn shuttle
eternal oxide
#

I'll have to open my ide

torn shuttle
#

is it just getBukkitYaw?

mellow edge
eternal oxide
#
this.setYRot(yaw);
this.setYHeadRot(yaw);```
#

so read those for yaw

torn shuttle
#

well getBukkitYaw returns yRot

#

so I think I got it?

mellow edge
eternal oxide
#

yRot0 is also yaw

#

its what setYRot sets

rough hinge
#

can i use player#sendMessage if player is offline but player != null?

young knoll
#

Probably?

drowsy helm
young knoll
#

It just won’t do anything

pseudo hazel
#

I guess

mellow edge
#

nothing happens but it works

drowsy helm
#

Just chexk

eternal oxide
#

You can but its a stale object so will do nothing

drowsy helm
#

Yeah just put an if statement

eternal oxide
#

you May get a connection error in console but it should not crash the server

rough hinge
pseudo hazel
#

sending the message probably

rough hinge
pseudo hazel
#

right

rough hinge
#

player.isonline check if player is a map or list idk

pseudo hazel
#

but the player object should already know if its online

pseudo hazel
#

its in the Player

#

boolean

rough hinge
mellow edge
young knoll
#

Why is performance a concern here

#

The difference is tiny

rough hinge
rough hinge
pseudo hazel
#

yes

#

but then at that point it will either be online or not

#

like the player object will know if its online

#

or atleast should

young knoll
#

Plus this is in an async task, so it matters even less

rough hinge
pseudo hazel
#

even then

#

many things will be faster than sending a packet

rough hinge
mellow edge
#

look, if the player object is valid, you can do whatever you want, or you can just store UUIDs and get player by uuid

pseudo hazel
#

but idk the implementation so sendMessage might not even send if no player is online

rough hinge
rough hinge
young knoll
#

Just do the check

#

Then you don’t have to worry about something changing in the future

eternal oxide
#

Better. STOP holding Player references and fetch from UUID

pseudo hazel
#

your plugin is not gonna break because you missed a 1 ns increase optimization

rough hinge
# young knoll Just do the check

In 99% of cases the check will be redundant, so I think it has more performance in 1% of cases to send the message to a player who is not even online, but I don't know if it returns an error.

torn shuttle
#

does that mean it's not even exposed?

young knoll
#

Why do you care about performance

rough hinge
young knoll
#

This is a single Boolean check that isn’t even on the main thread

torn shuttle
#

oh wait

#

it's public

#

I'm dumb

pseudo hazel
#

if you already made up your mind then just go for it, maybe add a comment or whatever

#

the idea behind programming is that you are aware of the consequences

rough hinge
paper viper
#

If you want to use Player you can use weak references

eternal oxide
mellow edge
#

^^

pseudo hazel
#

generally yes, but this is such a non issue in this instance

mellow edge
#

always prefer uuids for any real systems

rough hinge
mellow edge
#

what?

rough hinge
#

So like I said, don't generalize

pseudo hazel
#

well that sounds like your issue xD

#

I usually develop for premium servers

rough hinge
#

well, I'll check if the player is online because it should return an error

young knoll
mellow edge
torn shuttle
#

it works when they start moving but now when they're standing still