#help-development

1 messages · Page 1219 of 1

wet breach
#

the connection for sqlite is just a file object. I am not sure what else needs to access this sqlite file beyond your plugin but typically you justt have your plugin thus maintaining the file object for your plugin is not an issue. However its when you want something else to access sqlite that you would need to close it out

#

the bottleneck for sqlite DB's is read/write speeds of the HDD

#

most of the time you can load the entire thing into memory. Never seen an sqlite db that was any larger then 1gb

smoky oak
#

hm. that would be nice to have as an option, how would i do that?

wet breach
#

load it into memory?

smoky oak
#

ye

#

also, how can i load it into memory as SELECT * WHERE?

#

i kind of only need the area corresponding to loaded chunks in there

wet breach
#

Creating the file object should technically do that, but you could see if memory mapping the file would work

chrome beacon
#

You either load the entire file or you do that

smoky oak
#

wouldn't i need to update the db and re-query if i would want to make any changes?

chrome beacon
#

If you want to save stuff you can query the db

#

but you don't need to query the db if you already have the information you're looking for

smoky oak
#

no, what im saying is that if i update it after i grabbed the resultset the resultset would be inaccurate

chrome beacon
#

Yes

smoky oak
#

i guess loading it into memory if its small enough would work, but how exactly do i do that? is frost right saying that all i need to do is point at it with a file object

chrome beacon
#

Loading all of it in to memory would kind of go against the whole point of your project

smoky oak
#

hold

#

can i tell it to load a specific table?

chrome beacon
#

Why split pdc tags out of the chunk just to keep it in memory all the time

#

When they're not required

smoky oak
#

(which is part of why im so irritated that you need to shove an uuid into itemstacks to actually identify them uniquely; another of my projects requires attaching data to itemstacks)

worldly ingot
#

Unfortunately that's not really something you have control over. You're only able to govern what data is applied while your plugin exists. It's the responsibility of the server owner to determine whether or not that data storage is worth it. You have to do what you have to do

#

It's different than Minecraft having to store then remove data later because Minecraft is always loaded. They can datafix things away later

chrome beacon
#

tbh I'm not sure what you're having trouble with anymore 🤷‍♂️

wet breach
#

lol

chrome beacon
#

Like most of your questions don't make much sense to me

smoky oak
#

understanding how to do sqlite in java tbh :V
i don't want a 'heres a solution', i want to know how to actually do things, hence me querying about, to the current problem, unrelated things

#

like, how to load a database into memory, because that sounds useful

chrome beacon
#

Don't

#

No need to here

worldly ingot
#

It's only useful if you need it. If it's extremely urgent data that you cannot wait for. Like chunk claiming should probably be in memory to some degree so chunk lookups can be done immediately

smoky oak
#

yeeeeah one of the things I'm going to do requires a bitmap thats 1:1 to the blocks in a chunk

#

i kinda need that one in memory (hence the question about loading a table from a database)

wet breach
#

yeah typically you don't need the entire thing in memory, but the OS should have it loaded or referenced somewhere for loading if you have a file object of it.

#

but its OS dependent on that though since implementation uses the OS api for file related stuff

chrome beacon
smoky oak
#

ah fair point

chrome beacon
#

To load it in to memory you run your database call

worldly ingot
#

Yeah. At least for the sake of understanding it, if you're holding your data in like a Collection, or literally just a field, it's in memory

smoky oak
#

so map<Point2D, Bitmap> and load/unload with chunk load/unload

#

good catch

worldly ingot
#

Asynchronously load/unload, but yes, that would be fine. Depends on how often you're accessing that and if it's strictly necessary

smoky oak
#

rarely, but if its accessed, the faster the better

worldly ingot
#

Yeah but if this is unimportant data for like a command or something, it's probably not urgent. Database calls are typically relatively fast. Often no more than 500ms absolute tops, worst case scenario

smoky oak
#

i guess i can just shove it into async and rejoin main with schedulers

#

but that gives me the concern of something else trying to use the connection at the same time

worldly ingot
#

CompletableFutures are your friend

smoky oak
#

can the same connection deal with multiple queries at once?

smoky oak
worldly ingot
#

Yeah it'll queue them up I believe

#

And no, CompletableFutures are just a way to operate with something that might happen in the future

smoky oak
worldly ingot
#

Well, yeah, ideally nothing you do with the database is synchronous

smoky oak
#

but if it gets queued wouldnt it just run them down in order?

worldly ingot
#

Yes

#

Asynchronously it would, but yes

smoky oak
#

would it be an idea to have an async thread that has a priority queue for the database queries?

worldly ingot
#

Nah, I wouldn't overcomplicate it

smoky oak
#

fair

#

by the way, if i use a composite key (x, y, z) is it faster than to use a string key (x_y_z)?

#

coz my intuition says 'yes but not by much'

worldly ingot
#

Generally speaking your table data should be as normalized as possible. So you should have three separate columns for x, y, and z

#

You could then create a unique index on those three columns for faster lookup times and uniqueness

smoky oak
#

doesnt a composite key do that index automatically?

worldly ingot
#

What do you mean with composite key?

#

e.g. x + "," + y + "," + z as a string?

smoky oak
#

? no the sql composite key

#

PRIMARY KEY ( X, Y, Z)

worldly ingot
#

Oh, primary key lol

#

Yeah, it does

#

It makes an index as well

smoky oak
#

yea coz the way i designed it querying requires all keys set to a value, and will result in an empty, or 1 row, result set

#

hence my question if a composite primary key is faster access than making it into a string key

#

(bc handling a string key is... a tad easier lol)

worldly ingot
#

Maybe easier, but not how you should be using SQL :p

smoky oak
#

black box code

worldly ingot
#

SQL won't find it easier

smoky oak
#

'pls dont look'

chrome beacon
#

The Swedish dictionary app has the worst SQL I've ever seen

#

And you'd have to try to beat it

worldly ingot
#

If you were to use a joined string as a column, SQL has to hash a string. It's way more efficient to hash 3 integers

#

because the hash of an integer is just itself

smoky oak
#

ah i see

worldly ingot
#

More storage space for a string as well

smoky oak
#

what about byte[] ?

#

specifically BINARY(16)

worldly ingot
#

Then it becomes a problem with readability and useability. At that point it might as well be three separate columns

smoky oak
#

ah no i meant

#

i am storing data based on coordinates

#

so world has an uuid which translates to BINARY(16)

#

and my composite key is coord (x,y,z,world)

worldly ingot
#

Yeah that's fine

#

Some databases have an actual UUID type. I don't think SQLite is one of them

smoky oak
#

i checked the list on w3 and its not listed there so i dont think so

#

but well

chrome beacon
#

It doesn't

smoky oak
#
ByteBuffer bb = ByteBuffer.allocate(16);
bb.putLong(uuid.getMostSignificantBits());
bb.putLong(uuid.getLeastSignificantBits());
return bb.array();
#

the conversion's simple lol

worldly ingot
#

There's a more efficient way to do it in the database schema itself, but it's honestly not at all worth the hassle lol. What you have is fine

#

If you really wanted to, you could also store the LSB/MSB as separate columns too

smoky oak
#

well. would it be faster?

worldly ingot
#

At that point it becomes a microoptimization

#

You're probably not going to run into any bottlenecks with your schema currently

smoky oak
#

oh btw

#

does a PK(x,y,z) mean it stops searching for results sooner if theres, for example, no entries for that given 'x' value?

#

bc that would be a HUGE reason to use taht over a strin key

chrome beacon
#

Finding every block in a chunk on load is something that can be optimized with the current schema

worldly ingot
#

An index (which a primary key will make) hashes the three columns together for a faster lookup

#

Indexes are super powerful. Looking into how SQL databases treat those is actually really interesting if you wanted to do a bit of research on it 😄

smoky oak
#

wait. are you implying that it could potentially be faster to have the primary key be the world only and have the coordinates as indexed colums

worldly ingot
#

No because your lookup times are going to be faster with the world, x, y, and z as an indexed key

#

Or, well, I guess... it depends what you're querying

#

If you're querying only the world, then it may be worth making an index on the world

chrome beacon
#

^^

smoky oak
#

well, im asking bc im pretty sure hashing the pk into one value would make lookup O(log_2 n)
but what I'm querying is going to be (coordinate -> null OR value) with there only being a value if something has been saved there first, so its somewhere around 95-99% null

worldly ingot
#

What matters is the queries you're making to the database. Your WHERE clauses

#

If you're doing WHERE world = ? AND x = ? AND y = ? AND z = ?, then an index across those four columns is going to result in faster lookup times than if you didn't have an index. If all you're doing is WHERE world = ? and that's it, then an index on world will be faster as well

#

(Your JOIN cases also matter, but I don't imagine you're doing joins)

smoky oak
#

first, but i still dont get how, if the primary key hashes those together into one value, that could be faster than using only world as PK and the coordinates as separately indexed keys

worldly ingot
#

Because the database keeps the indexes and their hashes in memory

#

Indexes have a higher memory footprint, but make lookups much faster

smoky oak
worldly ingot
#

No it takes the values of world, x, y, and z, and hashes them all together into one numeric value that can be looked up

#

At least that's my understanding of indices. That might be wrong. It's unique one way or another lol

#

Unique indexes (as is a primary key) have the additional benefit of adding a uniqueness constraint on your tables :p

smoky oak
#

well to be fair i dont want a block mined and not mined at the same time

#

im not doing physics here lol

chrome beacon
#

Schrödinger's block

smoky oak
#

i guess ill keep it as PK(x,y,z,b[16])
that way the database is easier to inspect

worldly ingot
chrome beacon
#

That b16 should be a foreign key to worlds table

worldly ingot
#

Let's not get too complicated here

#

You're right, but baby steps

smoky oak
#

the sad thing is i know exactly what hes saying

smoky oak
#

but if its indexed, would that help anything except comprehension?

chrome beacon
#

?

#

"it"

smoky oak
#

the uuid representing the world
like, indexing means you always find it in O(log n) / O(1) depending on how you look at it right?
so having it as foreign key doesnt sound like it would help with anything except for being able to easier see which world that entry belongs to, since you could write down the world name in the worlds table

#

i mean i guess it makes the database slightly smaller?

worldly ingot
#

Yes. Instead of inserting the same binary data over and over and over and over again, you could insert it once in another table and represent it as a single byte or something

smoky oak
#

there's no guarantee someone (cough ftb server cough) won't have more than 256 worlds though

#

can you say that the size of a column should be dynamically allocated?

chrome beacon
#

The database takes care of that not you

smoky oak
#

ah

chrome beacon
#

A foreign key is just a reference to a value in another table to prevent duplicate data

worldly ingot
#

Realistically, a foreign key doesn't do much. It's just a constraint that prevents you from deleting the table it references

smoky oak
#

theres a reason im doing ON CONFLICT DO UPDATE lol
i dont want to have duplicates either

chrome beacon
#

You can tell SQL to cascade delete stuff as well

#

So if you remove a world you can cascade delete all blocks in said world

smoky oak
#

ok thats useful

worldly ingot
#

If you have a unique key (which you do, you have a primary key), ON CONFLICT will, instead of add a new entry, update the entry that it collided with

smoky oak
#

ye

#

for the cascade deletion, do i just clear the entry from the worlds table?

worldly ingot
#

Oh, sorry, you were making a statement, not asking a question lol

#

There's a CASCADE keyword :p

#

You can use it when creating your foreign key

#
FOREIGN KEY (your_key_column)
    REFERENCES other_table(other_column)
    ON DELETE CASCADE
grim hound
#

alright, how do I get the corners of an item display being a player head?

smoky oak
#

would've thought you needed to put that in the worlds table

#

though how do i make a foreign key part of the prime key?

worldly ingot
#

You can still use the foreign key as a primary key. Both can be true

smoky oak
#

my primary key looks PRIMARY KEY(x, y, z)

#

can you just go PRIMARY KEY(x, y) PRIMARY KEY (z) then?

worldly ingot
#

thonk no. You can still include your world column in there

worldly ingot
#

For a skull, maybe? I don't remember what the model geometry looks like

chrome beacon
#

Depends on the model the item has

grim hound
#

player head

chrome beacon
#

You can check the model json and see

grim hound
#

I think it's like 0.5xyz

worldly ingot
#

From the server side you have to make some assumptions because you don't have access to the model files

grim hound
#

I guess the center being on the top and xz center is the cause of my suffering

grim hound
#

(if I complete it today)

smoky oak
worldly ingot
#
CREATE TABLE your_table (
    world    INT NOT NULL,
    x        INT NOT NULL,
    y        INT NOT NULL,
    z        INT NOT NULL,
    -- Whatever other data you want to include
    PRIMARY KEY (world, x, y, z),
    FOREIGN KEY (world)
        REFERENCES worlds(world_id)
        ON DELETE CASCADE
);
smoky oak
#

ty

#

ill just adapt this so i can generate it based on the desired keys

worldly ingot
smoky oak
#

(ie, changing the int type depending on the input. world -> y = smallint, chunk -> x,z mediumint)

worldly ingot
#

Yeah, whatever it is you need to do

smoky oak
#

like i figured why waste storage space when i know it cant exceed those values lol

worldly ingot
#

For sure

remote swallow
#

But what if I need to store the far lands

smoky oak
#

im assuming you're not running a version of minecraft that allows coordinates in the 2^32 range lol

#

the existence of the worldborder is both a blessing and a curse i tell ya

worldly ingot
#

Bold assumption PES3_HmmCoffee

remote swallow
#

What if I go outside the world border

worldly ingot
#

I modded my server to store 2^64 cooridnates

remote swallow
#

Who's gonna stop me

smoky oak
#

the game tbh

#

it stops generating past 30m doesnt it?

worldly ingot
#

It still generates but you can't break or place blocks

remote swallow
smoky oak
#

yea but the world border is offset from 30m

worldly ingot
#

Yes. The whole network is actually just run on one massive 2^64 by 2^64 world

#

Hypixel leaks spigot

remote swallow
#

When do you move to 2^128 worlds

worldly ingot
#

I suppose BigIntegers exist. Nothing stopping us

remote swallow
#

BiggerInteger when

shadow night
worldly ingot
#

Can you believe Discord doesn't have a leek emoji?

#

🥬

#

That's the closest they have to a leek

quaint mantle
slender elbow
grim hound
#

when rendering block displays from each corner till the next it results in this:

#

If I render one more layer the whole texture becomes 1 layer too thick on each side

#

does anyone know how I can, without manually hardcoding the values, know where the "inside" is, if I know all of the block's faces and corners?

#

I just need to know what the offset to the inside is (how I need to move them xyz)

quaint mantle
#

Hi guys, its possible to create custom events with koltin?

chrome beacon
#

Yes

worldly ingot
#

NOW YOU'RE MAKING ME QUESTION IT

slender elbow
#

yeah they do

#

according to oracle

#

not that you should trust them, they are researching to integrate LLM into medical tech 🗿

tawny furnace
#

Guys, can you tell me the flag to prohibit the flow of lava in the region?

blazing ocean
misty ingot
#

whats the best way to remove all of a specific block from around a player
and fast, because its not just one block actually its multiple diff blocks

quaint mantle
chrome beacon
#

🤷‍♂️ I don't use Kotlin

#

?eventapi

undone axleBOT
chrome beacon
#

You can look at this for the Java version

blazing ocean
#

You need to know both Java and Kotlin if you want to do Kotlin plugin dev

#

90% of guides are in Java

quaint mantle
#

I'm watching that yeah, but I'm having problems with the @JvmStatic

blazing ocean
#

What problems are you having

quaint mantle
#

ohh nvm I saw my error

#

thanks anyway

marsh sluice
#

yo can someone help me

#

im trying to line up characters but the width of the emojis im using before the text is different

#

so all the text is missalligned

#

and idk what unicodes to use or if i should be using them

#

its for a scoreboard btw

#

and i have a photo if anyone wants it

blazing ocean
#

This is the width of every character in Minecraft's default font

marsh sluice
#

but how do i make the gap equal

#

lik should i use unicodes

#

and how big are the dif unicodes

remote swallow
#

nerd font in mc when

blazing ocean
#

Unifont however is a different story

marsh sluice
#

so how would i close that gap with an invisible character

#

is that possible?

blazing ocean
#

You can have characters with negative width

marsh sluice
blazing ocean
#

You will have to add spaces after the one that's shorter, to pad it out

#

6+7 != 8 (I know, shocking)

marsh sluice
#

cause i added 2 and 1 spaces

#

but it just went way to big

#

like the space was like a full emoji width

#

instead of being a 1 space or however you say it

#

unless i need to put it in the code a different way

blazing ocean
#

Okay fuck discord

#

That's not meant to be aligned like that

#

Right, kind of works now

#

You just cannot display 13px and 8px in one column without one of them being padded out

#

So you'd need some invisible space characters, preferably pixel-perfect

#

If your text doesn't get too long, I'd just go for repeating a single pixel space, if it gets longer, do binary

marsh sluice
#

i cant really do a resource pack

#

cause its for a server

#

should i just find like new emojis or sum

blazing ocean
#

You could rely on the space character but it's gonna be inaccurate

blazing ocean
marsh sluice
blazing ocean
#

You didn't send any

marsh sluice
blazing ocean
#

Those aren't emojis, just characters

#

The crossed swords one uses the same unicode as the actual emoji but yeah

marsh sluice
#

oh well they were emojis but mc and discord swapped them

misty ingot
#

how could i go about detecting when the server is reloaded?
people have been complaining to be about how a part of the plugin breaks when they reload the server (which is unstable and isnt recommended -_-)
so i want to add aa warning message every time they reload the server

blazing ocean
#

ServerLoadEvent has a reason or something

remote swallow
misty ingot
#

oh

#

didnt know that existed

blazing ocean
#

Yea, load type

marsh sluice
#

so what can i do @blazing ocean what do you recommend

blazing ocean
#

Plus, it's not guaranteed that the characters even have that width

#

Resource packs can just override the texture

marsh sluice
#

and its without a resource pack

#

also wym spaces

#

like when i copy paste

#

its too big

#

so hjow can i implement it into the code

blazing ocean
#

?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

marsh sluice
blazing ocean
#

Looks like they just chose characters with a similar width and added 2/3 space characters

marsh sluice
#

pretty sure there $ is just bigger

#

but like i couldnt find that

#

and also i have the "⬤" so i wanted to be able to use those

#

ok well I just changed the emoji but idk what to do for the $

#

like how did they get a bold version of the $ without a texture pack

blazing ocean
#

Bold text?

marsh sluice
#

@blazing ocean do you know by any chancwe

marsh sluice
marsh sluice
#

anyone know hoe to get a dolar sign like this on a mc scoreboard

#

and no its not just $ in bold

#

i see so many servers using it but i cant find it

glad prawn
#

it can only be it, have you tried

marsh sluice
marsh sluice
#

and only 6 wide

#

but i need it to be 8

#

does anyone know

#

andddddd im dumb

#

i realize my mistake 😭

glad prawn
marsh sluice
#

but now its too wide

#

like bruh

#

im so confused

glad prawn
#

bruh

marsh sluice
#

im a perfectionist and this annoying me like crazy

#

my ocd bouta crash out

#

😭 🙏

#

i could use a hair unicode but idk if those work in mc

kindred valley
#

im sorry

blazing ocean
marsh sluice
#

that took me way too long to figure out lowkey

silver robin
#

thank you i went with this, i just needed to remove uid.dat otherwise i would get [21:19:54 INFO]: [STDOUT] [org.bukkit.craftbukkit.CraftServer] World tempworlddir is a duplicate of another world and has been prevented from loading. Please delete the uid.dat file from tempworlddir's world directory if you want to be able to load the duplicate world.

grim hound
#

I'm attempting to remake a block with text displays

#

it was simple with block displays since they are 3d

#

but these need to always face the inside

#

does anyone know how I could do that?

silver robin
grim hound
#

just makin a block texture out of text displays

#

since they can have any background color

grim hound
#

and then their translation is adjusted per

#

while keeping the left & right rotation

#

and this worked well for blocks, but I'd need the text displays to always face inward

silver robin
# grim hound so uh

ah so the redstone block, bedrock and emerald is correct but these blue things which I assume are text displays are not?

grim hound
#

the default method:

grim hound
grim hound
#

emerald is the rotated center of a face

#

redstone is the non-rotated emerald

silver robin
#

let's move to a thread

#

the default method:

soft hound
#

Why did my gradle all of a sudden stop building my .jar files ?

chrome beacon
quaint mantle
#

How can I use the gradle project version in the plugin.yml version?

blazing ocean
#

You can use the processResources task

quaint mantle
#

thanks!

soft hound
chrome beacon
#

Did you change anything in your gradle file?

#

Also any errors?

soft hound
#

Nope, somehow it doesn't work.

chrome beacon
#

Try stopping the server before running it

smoky oak
#

-# (not sure how relevant this is, but i am using a maven copy pluign in <build> and its overwriting the target jar in an active server. I also noticed that using a FTP client/server does the same)

smoky oak
#

was replying to the conversation above, hence the -#

sullen marlin
#

Sorry idk what the small text meant

smoky oak
#

nah its fine

#

i just marked it like that bc, well, not sure how relevant kek

#

i dont mind the random pings if thats what youre worried about it

worthy yarrow
#

@floral drum help it no worky

sout("It no worky purple");
floral drum
#

:(

dawn flower
#

is there a way to make the server not crash because of a breakpoint during debugging

it almost feels like a speedrun trying to find the bug before the server crashes

bronze laurel
#

I am trying to make ranks with prefixes and tab sorting automatically from my luckperms ranks

#

with the luckperms api

#

I can't figure out how to do it.

#

Teams ends up getting overriden by my scoreboard.

mortal vortex
worthy yarrow
#

solid plan

nova notch
#

y'all still using antivirus in 2025?

dawn flower
grim hound
#

Just trying to have the text displays face outward

#

While each is riding an entity

#

And normal rotation causes them to rotate around their rider's axis

unborn hollow
#

How do you cancel a player middle clicking to open the spectator menu in spectator mode?

dawn flower
#

i dont think you can

#

and if you can it's probably gonna need some packet listening

sullen marlin
#

I don't think you can cancel opening the menu

unborn hollow
#

I know it's possible but maybe it is through packets

chrome beacon
#

It's not

unborn hollow
#

Last time I checked Wynncraft did it unless I'm misinterpreting their methods

chrome beacon
#

During cutscene you mean?

unborn hollow
#

No during their recent update to their class selection screen

chrome beacon
#

Haven't seen that one so 🤷‍♂️

dawn flower
#

wynncraft has a custom resource pack iirc so they probably did some resource pack magic

#

could be bs though don't take my word for it

unborn hollow
#

no it's a good consideration

#

i don't know if the spectator menu is tied to a texture (minus its icons) so they could just make the entire thing invisible altogether

#

and then cancel the teleport functions of it

unborn hollow
#
    public void onSpectateTeleport(PlayerTeleportEvent event ) {

        if(event.getCause() == (PlayerTeleportEvent.TeleportCause.SPECTATE)) {
            event.setCancelled(true);
        }

    }```
#

for some reason this isn't stopping a player from left clicking to spectate an entity

dawn flower
#

you could probably also cancel onPlayerInteract if the player is targetting an entity and is spectator

pseudo hazel
#

thats what I had to do too, cancel interacts from spectator

#

because apparently they keep their inventory so if you put an item with some custom action in the slot that the player used before going into spectator, they can activate those actions

sullen marlin
unborn hollow
sullen marlin
#

probably worth opening a bug report in that case please

#

?jira

undone axleBOT
unborn hollow
#

submitted :,>

sullen marlin
#

Thanks

misty ingot
#

hm

hushed spindle
#

i made a unicode character and i want to display it ingame, but when i do there's this black background added to it that makes the character look wrong. is there a way i can remove this?

pseudo hazel
#

iirc in 1.21.4 you can disable the shadows or change the color of it atleast

#

atleast in paper, im not 100% sure about spigot, but it should probably be possible

sinful iron
#

hello, is it possible to add armour enchantments to another materials ? im doing work around to handle custom model data for armor, currently using iron_ingot to replace iron armour. however, the iron_ingot cannot be enchanted like armour set.

hushed spindle
blazing ocean
#

But yeah with components you can remove it

hushed spindle
#

cool cool ill look into it

#

shadow is the term i was looking for lol

smoky oak
#

hey md you here?

blazing ocean
#

why

remote swallow
#

It's like a solid midnight for him

smoky oak
#

that doesnt mean shit for people like us tbh

blazing ocean
#

again, why

smoky oak
#

wanted to ask about spigot internals

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!

remote swallow
#

I'm pretty sure there's a few people that vam answer it

eternal oxide
#

Choco vam often answer

blazing ocean
#

vam

#

ebic learn to type on your phone smh

remote swallow
#

I love choco van

remote swallow
sinful iron
#

hello,
is it possible to add armour enchantments to another materials ? im doing work around to handle custom model data for armor, currently using iron_ingot to replace iron armour. however, the iron_ingot cannot be enchanted like armour set.
thank youuu ;-;

smoky oak
#

bc imma be honest i kinda expect a player to exist when closing an inventory

#

given yknow

#

this

sinful iron
#

hmm,, will have a look thanksss

hushed spindle
#

you can add any enchantment to any item but i dont think thats what they were asking

#

going this route would mean you need to hook into anvil mechanics to basically mimic anvil combining

#

assuming you want players to be able to use this item as if it were a normal helmet

sinful iron
#

yessss !!! let me have a try on anviling iron_ingot + enchant book, but so far the enchant table is not going to show any available enchatments for the iron ingot
update: anvil works as expected, so my only problem is just the enchant table

young knoll
#

Enchantments are tag based now

#

So you would have to mess with those

soft hound
#

Okay so I have 3 different jars in my server files, one being the Library that conntains all the code that will be used over and over again, then I have Essnetials, which means that it'll handle the essentials stuff and the last one Chat, meaning it'll handle chat stuff, now the way I connect all of them is I do compileOnly 'Library.....' in Essentials and Chat, should I do implementation in Essentials then just compileOnly essentials into Chat or is it fine as it is now ?

chrome beacon
#

If Essentials doesn't need anything from Chat then it doesn't need to be declared

soft hound
#

Well it doesnt, they share the same data declared in Library.

#

But compileOnly gets only the code that is used, right?

chrome beacon
#

hm? What do you mean?

soft hound
#

Like, does it compile all the classes inside of the final jar, or only the ones used ?

#

For example you have Class1 and Class2 inside of the thing you just added, but you only used Class1, will it also compile Class2 inside of the final jar ?

chrome beacon
#

compileOnly will only reference the class it will not add it to your jar

#

That's what implementation did which is why we told you to change it

blazing ocean
#

shadow will only shade the runtime classpath

#

implementation adds onto the compile and runtime classpath

#

compileOnly does not

soft hound
#

Ohhhhhhhhhhhhh okay okay, so that's why my jars were so fat 😂

#

Thank ya both!

heavy fulcrum
#

Hi. I'm trying to build a command which stores the player's current location as coordinates by name. It's something like /save locationname. I save the data into a custom YAML file. I also have a /saves which shows all the locations which are saved. But the problem is that once the server is restarted, the data is virtually gone. It's right there in the YAML file, but when running /saves, no data shows up. If I save a new location during the current runtime, it does show up. But any older data is not saved.

chrome beacon
#

You need to load the locations

heavy fulcrum
#

I did something like copyDefaults(true) for the custom YAML file at plugin startup. That should load the locations, right? But it doesn't.

chrome beacon
#

No it does not load anything

#

?configs

undone axleBOT
chrome beacon
#

?jd-s

undone axleBOT
heavy fulcrum
chrome beacon
#

?paste your code

undone axleBOT
heavy fulcrum
#

This is the save command.

chrome beacon
#

huh you're abusing defaults to store values

heavy fulcrum
heavy fulcrum
chrome beacon
#

also you're getting ints and setting strings

heavy fulcrum
#

Oh.

#

But the string data should still show up?

#

Before this, i used the simple get() method instead of getString() or getInt()

chrome beacon
#

need your custom yaml class

heavy fulcrum
#

alright one sec

smoky oak
#

whats the default modifier for fields?

#

(public protected private)

heavy fulcrum
#

private

remote swallow
#

package private

#

iirc anyway

chrome beacon
chrome beacon
smoky oak
#

aint that just protected

chrome beacon
#

No

#

Protected works if I extend the class as well

chrome beacon
#

Just discarding the loaded config

heavy fulcrum
#

I was dumb enough to simply follow the tutorial without using my brain

smoky oak
#

r/meirl

soft hound
#

Is there a way to remove the [13:57:28 INFO]: from the console?

heavy fulcrum
#

Well, I'll try loading it in the config variable and see if it works

chrome beacon
#

it's useful info

soft hound
#

I know, but I want to make it look a bit different.

#

Is there a way tho?

chrome beacon
#

Yes it's possible but you really shouldn't

soft hound
#

Oh okay..

smoky oak
#

throw a runtime exception and suppress the message kek

blazing ocean
#

log4j config

soft hound
#

When using the JavaPlugin#getLogger(), you get the message printed out like [PluginName]: <Message> is there a way to print out just <message>?

pseudo hazel
#

probably not since that is the goal of the plugin logger

#

to log a message from a plugin

remote swallow
#

most people want the time + level on the message

pseudo hazel
#

if you just wanna change it because you want your plugin to be fancy, there are other areas to be fancy in which arent disrupting things like existing structures meant to help debugging and issue solving

#

if this is like your own environment or some custom server you making then I guess it doesnt really matter

smoky oak
#

how do i write a value in non-decimal, non-int again?

#

I'm trying to define a byte as the string of 0 and 1 making it up

valid burrow
#

what

chrome beacon
#

byte b = 0b010101

#

Is that what you're talking about?

#

If not I'm lost

remote swallow
#

or are you talking about casting to a byte

valid burrow
smoky oak
#

yea

#

i want to write a byte in code such that i can quickly see it's bits

#

its for mask purposes

smoky oak
#

the mask is part of a constructor

#

and new thing((byte) 0b01000001) just looks weird

blazing ocean
#

why would you need the cast there

smoky oak
#

bc for some fuckin reason its an int

chrome beacon
#

Magic value 💀

#

Please at least make it a constant so it has a name

smoky oak
#

yea it gets put into the mask field?

#

or would if 0b<something> would be a byte and not a int

valid burrow
#

im like 200% sure what ever you are trying to achive, there about a million better ways to do that

smoky oak
#

i have an enum and need to ensure that in a set there are no collisions as defined by the mask

#

so my idea was a la

byte mask = 0;
for(value : set) {
  if(mask AND value.mask != 0) return false;
  mask = mask OR value.mask;
}
#

but i guess having a separate enum with collusion types might work better if you focus on expandability, but im pretty sure that bitwise stuff on masks is way faster

wet breach
smoky oak
#

32 or 64?

wet breach
#

int in Java is 32bits and long is 64

smoky oak
#

hm so just a 0b with 32 locations

#

sounds abt right lol

#

dont see how that wouln't be enough values

wet breach
#

but yeah, everything smaller then an int is still backed by an int and in some cases so is boolean but that could have changed. But in the JVM it will constrain based on type though. Just backing wise its an integer

smoky oak
#

i see

#

btw is there a 'this character is 0'?

#

so that you can easier see where the 1s are?

#

i know that _ gets ignored completely to make numbers more readable

wet breach
#

not sure I understand what you are asking lol

smoky oak
#

like, this is how it looks rn

(0b00000000000000000001)
(0b00000000000000000011)
(0b00000000000000000010)
(0b00000000000000000100)
#

so i was wondering if theres some way to make those ones pop out more a la

(0b                   1)
(0b                  11)
(0b                  1 )
(0b                 1  )
#

so functionally the same but you can actually comprehend the mask at a glance

slender elbow
#

give them names via constants? other than that, no, you cannot do things the language does not have in the spec

wet breach
smoky oak
#

well the reason im doing it like this is so i can quickly input the masks

wet breach
#

well how large is your mask?

#

if its 8 bits, then you only need to use the 8 bits

#

and can just exclude all the positions to the left of that

smoky oak
#

eh true

#

i think its 6 so good point

wet breach
#

so you only need a byte

#

8bits

#

leaves you only with 2 0's on the left

#

and its not hard to setup checks to ensure that the two left most bits are not set

#

or just simply ignored

#

or you could reverse it, and just have the two least significant bits never set and just bit shift right to knock out any sets there

quaint mantle
#

?paste

undone axleBOT
wet breach
#

ironically that last option still works and only requires a byte 😛

quaint mantle
pseudo hazel
#

idk, how many debug prints do you get?

quaint mantle
#

Just the first 3

#

Can I somehow intercept this with packets?

pseudo hazel
#

well if by first 3 you mean debug #1 to #3, then the event should be cancelled right?

quaint mantle
pseudo hazel
#

but thats the player interact event

#

that doesnt make any sense

quaint mantle
#

I can equip the armor just fine

pseudo hazel
#

which is the issue right?

quaint mantle
#

Yeah

pseudo hazel
#

like you want to prevent them from equipping it

quaint mantle
#

Also, yes

pseudo hazel
#

weird

slender elbow
#

i seriously doubt #3 is logging at all

#

itemStack.equals(Material.CHAINMAIL_BOOTS) & co. will always be false

pseudo hazel
#

oh haha

#

yeah for sure

slender elbow
#

you want to check the item's type

#

also, players have two hands now; use the ItemStack provided directly in the PlayerInteractEvent via the getItem() method

heavy fulcrum
quaint mantle
#

lol

heavy fulcrum
#

It's like, the plugin turns a blind eye to the saved data.

smoky oak
#

can you directly assign values to enums, or do you need to use constants for that?

slender elbow
#

what

smoky oak
#

well given how the masks are numeric, i thought i could just put the masks into a separate enum class so that they're more readable than just a indecypherable number, and look like strings

#

have them be powers of two and add them

slender elbow
#

just use int/byte constants?

#

private static final byte FOO_MASK = 0b00001000;

smoky oak
#

hm

#

i guess value AND mask != 0 serves to check for its presence just as well

slender elbow
#

parenths between (value & mask)

smoky oak
#

yea im aware

#

just llazy

slender elbow
#

😄

hushed spindle
#

how can i use custom unicode characters to have text be higher or lower than its origin point? i know you can change the "ascent" property of a character but this only seems to move the character itself up or down visually, any text that follows it stays at the same height

#

or do you need to map every letter to a different height to get the desired effect

smoky oak
#

that sounds like something i would do so theres probably a better solution 🙃

hushed spindle
#

lmao yea

#

horizontal axis is covered with negative space but i cant find anything on how to increase or decrease the height of text placement

blazing ocean
#

Or just use a TTF and have a shift applied

#

Or, if you really want to, use a shader

hushed spindle
#

damn

rough ibex
#

Shader is much easier probably

#

if color, move pixel up

glossy laurel
#

is there an easy way to make player open the shulker they have in their inventory? Or will I have to code all the interactions myself?

worthy yarrow
#

I don't see a #getInventory method for shulker tho

glossy laurel
#

sweet, i'll try it out

tight compass
#

?paste

undone axleBOT
tight compass
#

For some reason I can't get the mojang mappings to work. Here's my pom.xml, https://paste.md-5.net/jazecigiho.xml, when I reload it I get

Unresolved dependency: 'org.spigotmc:spigot:jar:1.21.4-R0.1-SNAPSHOT'

blazing ocean
#

did you follow this guide

#

?nms

upper hazel
#

at org.mongodb.morphia.mapping.lazy.LazyFeatureDependencies.testDependencyFullFilled(LazyFeatureDependencies.java:42) ~[mclans.jar:?]
at org.mongodb.morphia.mapping.lazy.LazyFeatureDependencies.createDefaultProxyFactory(LazyFeatureDependencies.java:57) ~[mclans.jar:?]

#

java.lang.ExceptionInInitializerError:

#

mongo db

#

wthat this mean?

blazing ocean
#

send the whole stacktrace

#

that part is completely useless

upper hazel
blazing ocean
#

what the fuck are you doing

tight compass
remote swallow
upper hazel
#

wth

tight compass
#

Uh

#

probably not

#

If that was the default then yea

upper hazel
#

what going on

tight compass
#

show the code

upper hazel
#

this not plugin if you want know

remote swallow
#

whats Mongo.java:25

upper hazel
#

mongo db i gess

#

oyu want check maven?

remote swallow
#

what is Mongo.java line 25

upper hazel
blazing ocean
#

ru.jampire.mclans.utils.Mongo.connect

upper hazel
#

oh

worthy yarrow
#

@blazing ocean I'm making my own economy :p

blazing ocean
#

normaleconomy

worthy yarrow
#

Indeed

blazing ocean
#

(it is not gonna be normal)

#

also join vc

remote swallow
#

randomnormaleconomy

worthy yarrow
#

No it will not

upper hazel
blazing ocean
#

are you referring to yourself in the third person

upper hazel
#

this not my plugin idk what heppened

#

i know he use mongo but uh

tight compass
remote swallow
#

paste ur Clan.class

remote swallow
tight compass
#

is --rev 1.21.4 the same flag?

#

That's the command it's giving me

remote swallow
#

use --remapped as well

blazing ocean
#

Run it with --remapped --rev 1.21.4

tight compass
#

okay

upper hazel
#

someone?

remote swallow
#

paste ur Clan.class

upper hazel
remote swallow
#

im not seeing anything obvious, talk to mongodb is the best i can say

blazing ocean
#

talk to morphia

tight compass
#

Thanks guys

#

Wait

#

where did it output?

remote swallow
#

it will add it to your maven local

upper hazel
#

what you talking obaut

kindred valley
#

?learnjava

undone axleBOT
#

For Beginners:

Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/

For Intermediate to Advanced Learners:

Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/

Practice and Hands-on Learning:

Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/

Free Resources and Documentation:

Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/

Community and Support:

Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/

Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉

upper hazel
#

bro wha

tight compass
remote swallow
#

the only file you need to use (the runnable server) is copied to the same directory the bt jar is in, any other stuff used for development is copied to maven local

remote swallow
upper hazel
#

😦

wet breach
#

which you are not doing

#

hence the linkage error

#

paper or spigot does not provide that DB driver so you need to shade it in or make use of the libraries thing in plugin.yml

tight compass
#

Now when I compile the project, I get

no suitable method found for register(net.minecraft.core.Registry<net.minecraft.core.component.DataComponentType<?>>,java.lang.String,net.minecraft.core.component.DataComponentType)

But my IDE recognizes the method

#

stupid nms

#

any thoughts?

chrome beacon
#

Could you send your new pom

#

?paste

undone axleBOT
tight compass
#

I didn't change it

#

I just ran buildtools with remapped

tight compass
chrome beacon
#

As far as I'm aware that maven shade plugin does not support Java 21

#

so I assumed you had changed it (I haven't actually checked the entire convo)

tight compass
#

Ah, I'm still on java 21

#

Doesnt 1.21.4 require java 21?

chrome beacon
#

It does

tight compass
#

soooo

chrome beacon
#

That shade plugin version is ancient

tight compass
#

Oh, is there a new one?

chrome beacon
#

3.6.0 should be the latest one

tight compass
#

not found

chrome beacon
#

I don't think that's the cause of your issue but it's worth updating

tight compass
#

yea

chrome beacon
tight compass
#

I did

chrome beacon
#

Special source?

#

I was talking about the shade plugin

tight compass
#

oh brhu

#

Well

#

Yeah I guarentee that's not gonna fix it

#

Any other ideas?

glossy laurel
#

how do I cast stack to ShulkerBox (to get it's inventory)? Cuz this isnt working if(stack instanceof ShulkerBox shulker){

chrome beacon
wet breach
tight compass
chrome beacon
#

You need to get the BlockStateMeta

#

ItemMeta and then cast, get block state and then cast that to shulker box

smoky oak
#
if(! Tag.SHULKER_BOXES.isTagged(stack.getType())) return 0;
        BlockStateMeta bMeta = (BlockStateMeta) stack.getItemMeta();
        if(bMeta == null) return 0;
        ShulkerBox box = (ShulkerBox) bMeta.getBlockState();
        // if changing things, box.update() might be enough. writeback not guaranteed to be excluded.
        int count = 0;
        for(ItemStack held : box.getInventory())```
#

this counts specific materials in the shulker but you can probs just change what u need

wet breach
#

return 0 ?

smoky oak
#

counts the number of occupied slots by specific materials

#

old project to, well, understand block meta

wet breach
#

ah

smoky oak
#

(and prevent shulkers from despawning if they contain them. made for a friend. lol)

#

oh by the way, if you set an item entity's age to a negative number thats not -32768, does it's despawn timer increase by that many ticks?

glossy laurel
wet breach
glossy laurel
#

but

#

wait

#

no

#

what

glossy laurel
#

no??

chrome beacon
#

yes

remote swallow
#

i love when my ItemStack is instance of ShulkerBox

glossy laurel
#

same

#

blockstate from blockstate meta

remote swallow
glossy laurel
#

mmm

wet breach
remote swallow
#

check the typeof the shulker to know if its a shulker, then use block state meta

#

and by type i mean material

wet breach
#

so apparently this works since JDK 14, however there is some scenarios where this will not work and cause circular recursion

glossy laurel
#

lmao

wet breach
#

so, yes it does work for the most part and you are correct

#

I am just not up to speed on all the new features 😛

#

I probably would still use the old way

#

since it compiles to the same thing

glossy laurel
#

I picked up java later than 14 was released 💀

wet breach
#

I been using Java ever since it was released 🙂

#

so as you can imagine, I can't always remember everything that gets released XD

glossy laurel
wet breach
#

little less then that, but close

#

Java was released in 1998

smoky oak
#

three decades then

glossy laurel
#

i knew it was somewhere in 90s

smoky oak
#

saying it with words means its less accurate

wet breach
#

I am quite happy with all the new stuff in Java and how better it has become since then

glossy laurel
#

anyways, player.openInventory(shulker.getInventory()); is not updating the shulker 💀 (who would've thought am I right)

#

how fix

glossy laurel
wet breach
#

I wouldn't say everyone

glossy laurel
#

ur the 2nd person

#

so thats obviously everyone

#

smh

wet breach
#

if it makes you feel better md_5 is younger then me

glossy laurel
#

what is that

#

guy with slime pfp?

#

gotcha

glossy laurel
#

register inventory in a hashmap that maps it to a shulker and listen on click?

wet breach
#

what version are you using?

#

don't see the openInventory method in Player interface

wet breach
#

oh comes from HumanEntity

blazing ocean
#

i'd guess like 30

wet breach
#

he isn't 30 yet

blazing ocean
#

how old is he then

glossy laurel
chrome beacon
#

You update the meta after the inventory has been closed

#

Do watch out for dupe bugs

glossy laurel
#

idrc care about dupe bugs here

chrome beacon
wet breach
blazing ocean
#

damnn

wet breach
#

yeah so I think he is 28 or 29, depends when his bday is which I don't remember when it is

glossy laurel
smoky oak
#

the inventory self updates coz its a reference

#

ShulkerBox box = (ShulkerBox)
//edits
stack.setItemMeta = box;

glossy laurel
#

Gotcha

smoky oak
#

hm i responded from memory

#

lemme check that again

#

ah
missing the intermediate step to get the blockmeta into itemmeta

#

blockstate.setBlockMeta or something like that

glossy laurel
smoky oak
#

pretty sure no

glossy laurel
#

so

#

wtf am I supposed to do

pseudo hazel
#

set the meta back to the item

smoky oak
glossy laurel
#

I think I did it

glossy laurel
#

blockMeta.setBlockState(shulkerBox);
stack.setItemMeta(blockMeta);

thats the same thing right

#

I mean

#

thats how

#

right

smoky oak
#

luckily for everyone that knows me im not a prophet and as such

#

?tas

undone axleBOT
glossy laurel
#

real

#
        Inventory inventory = event.getView().getTopInventory();
        ItemStack stack = inventoryToItem.get(inventory);
        if(stack == null){
            return;
        }
        ShulkerBox shulkerBox = inventoryToShulker.get(inventory);
        ItemMeta meta = stack.getItemMeta();
        if(meta == null){
            return;
        }
        if(meta instanceof BlockStateMeta blockMeta) {
            blockMeta.setBlockState(shulkerBox);
            stack.setItemMeta(blockMeta);
        }
    }```

this is my code. The shulker box is delayed by one click 🤔
#

Im guessing the inventory updates after my even but how do I fix that

tight compass
#

I'm having trouble writing nbt in 1.21.4. I'm basically trying to implement custom enchants, and I'm not really sure how to write say a custom tag under components which stores all the custom enchants that I'll have. Any suggestions?

worthy yarrow
#

?pdc

chrome beacon
#

^^ or just add them to the registry

tight compass
#

😔

misty ingot
#

if i have WorldEdit as my dependency, and the server has FAWE
will it work alright

#

-# (and vice versa?)

remote swallow
#

if you use wapi and have fawe it should work

#

if you use fawe-api and use worldedit it mightnot

misty ingot
#

hmm so maybe i should make FAWE be the dependency

#

and make players use FAWE

#

its better anyway

#

not like they have to change anything major either

young knoll
#

The FAWE api encourages you to run actions async

#

Doing that with just worldedit on the server will break

misty ingot
#

yeah ill do FAWE and make people use FAWE

#

cus my plugin will also be doing quite a bit of world edit stuff so its good to have FAWE anyway

tight compass
# worthy yarrow ?pdc

I was kind of trying to do something like:

custom_enchants: {
  auto_smelt: 1,
  whatever_else: 2
}

Can you do this in PDC?

chrome beacon
#

yes

tight compass
#

How?

worthy yarrow
#

It’s in the link

soft orchid
#

I'm working on a plugin that sends Minecraft messages to Discord. I'm trying to figure out how to send console messages to Discord as well. Essentially, I want to duplicate the console output and send it to a Discord channel.

Here's what I have so far:

package org.implorestudios.consoletodiscord;

import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public class ConsoleInjector {
    private final ConsoleToDiscordPLugin plugin;

    public ConsoleInjector(ConsoleToDiscordPLugin plugin) {
        this.plugin = plugin;
    }

    public void inject() {
        //TODO
    }
}

I don't have an idea what is the correct approach for this or the better way to achieve this. Any help or suggestions would be greatly appreciated!

Thanks in advance!

tight compass
misty ingot
#

is there a way to make it so player's cant see a specific chunk? like it just doesnt load in for them? (till i tell it to)

chrome beacon
#

Capture the packet and send an empty chunk

#

Then when you want the player to see it send an update one

misty ingot
#

how would i go about doing that?

chrome beacon
#

Doing that is not easy

misty ingot
#

yeah i figured

chrome beacon
#

Chunk packets are horrible to work with

misty ingot
wet breach
#

but that wouldn't be per player

quaint mantle
#

Can someone help with pom.xml?

misty ingot
#

i just want each chunk to be shown to the player when i tell it to
whether that is through packets or loading idc

quaint mantle
eternal oxide
#

?paste no one is going to be able to help with your pom if you don;t show us your pom

undone axleBOT
eternal oxide
#

?maven you specify no repositories

undone axleBOT
wet breach
misty ingot
#

and how could i go about doing that

grim hound
#

how do I revert a commit if it ain't in github desktop/

misty ingot
#

so i could just

#

event.setcancelled?

wet breach
#

and then use these to load/unload as you please

misty ingot
#

and then manually load each chunk when i feel like it

#

great

wet breach
#

there is even an unloadchunk event too, but not sure if you would need that

#

so, for your purpose it seems there is no need to mess with packets

#

just use the api 🙂

young knoll
#

Except the load event isn’t cancellable

smoky oak
#

can someone explain what intelliJ is cooking here

#

valueIndex is final

misty ingot
#

i could just unload the chunk as soon as it loads

#

i dont think it should reload itself

#

nvm it for whatever reason loads the chunks anyway even if i .unload them on loadevent

wet breach
#

you used to be able to cancel chunk loading 🤔

#

maybe someone can pr a change for it at some point lol

smoky oak
#

does CREATE TABLE table (x, z, data, PRIMARY KEY (x, z)) result in the same table as CREATE TABLE table (z, x...)

aka

does for sql the column order matter?

wet breach
#

Yes, the order you specify is the order it will be created/displayed

#

so if you are expecting z to be column 1 for example, and you created the table with z in column 2

#

then it will be in column 2 forever

soft hound
#

What was the thing called that auto created Getters and Setters for you in intelliJ

soft hound
wet breach
#

and it isn'tt just for intellij just fyi

soft hound
smoky oak
wet breach
#

the last one especially is where it matters most

smoky oak
#

no if i dont have the key values ordered at creation someone shuffling around their code could swap around the key order

#

so that would point at a distinct table

wet breach
#

interesting

#

anyways, if you need to ensure order I guess you could do an enum class and specify your enums

#

the order you list them in the Enum is the order they will remain

#

unless some assembly magic is used

smoky oak
#

wait so the enum order is set<Enum> iteration order?

#

wtf

#

i - sure

wet breach
#

depends which way you are getting the list of Enums

smoky oak
#

well for ease of use i do want to have multiple possible inputs, those being Set<Enum> and Enum[] (and Enum, but that one... doesnt have order issues LOL)

wet breach
#

your way of doing in the above you could change the order but this is because you are creating your own list. Enum has built in api to get a list if I am not mistaken

#

and with the built in api, the order is the order it was listed in the enum class

smoky oak
#

yea that'd do it

#

just... do NOT change the order in the enum after release kek

wet breach
#

yeah lol

smoky oak
#

oh this is so annyoing. i have the code i need but i cant decide where to put it bc it feels wrong no matter where i shove it

#

btw canstringbuilder pull off something similar to preparedStatement, where it replaces '?' but not inserted '?' on the next call?

chrome beacon
#

preparedStatement ? does a bit more than just replace

wet breach
smoky oak
#

im aware, but im doing purely string manipulation atm

wet breach
#

and then just shove that query string into the prepared statement

#

it was the old way before prepared statements were a thing and having to sanitize queries

smoky oak
#

ah no i meant
since i can have different formats of keys, i basically have this
INSERT INTO ? (?, data) VALUES (?) ON CONFLICT (?) DO...
but i cant just replace the first ? bc well this is supposed to turn into something a la
INSERT INTO UUID_STRING (uuid, data) VALUES (?, ?) ON CONFLICT (uuid) DO...
and the question marks fuck that up

basically, i want to do the sanitized input thingy from PreparedStatement on the String

wet breach
#

you could replace just some of them

#

and then leave the others in

#

and then have prepared statment take care of those

smoky oak
#

but since there can be a variable number of keys i dont know the locations of those

wet breach
#

how would you not know the location?

#

what are you even creating?

smoky oak
#

im generating the statement strings, and since the number of keys can vary, after the keys have been inserted, the position of the remaining ? shifts

#

coz of the VALUES (?, ?) thing

smoky oak
#

table keys?

wet breach
#

why would they vary?

smoky oak
#

because a chunk is x,z,world and a location is x,y,z,world and a player is uuid etc, and i do not want to write separate statements for every combination of allowed keys

#

that sounds suspiciously 2^n amount of work to me

#

so i generate the statements from the list of keys

wet breach
#

so use an enum to help decide which is which

smoky oak
#

keep track of the offset, i could do that, but i thought that if i could just do something similar to preparedStatement it'd be simpler to execute

wet breach
#

idk you seem to making this complex

#

and not sure why

#

like you should be able to know which table is which before hand

#

however though, you don't need a chunk table

#

you can get a chunk from a block coord

#

just bitshift by 4

misty ingot
#
        plugin.protocolManager.addPacketListener(new PacketAdapter(plugin, PacketType.Play.Server.MAP_CHUNK) {
            @Override
            public void onPacketSending(PacketEvent event) {
                int chunkX = event.getPacket().getIntegers().read(0);
                int chunkZ = event.getPacket().getIntegers().read(1);

                if (chunkX == 0 && chunkZ == 0) return;
                plugin.getLogger().info(chunkX + " " + chunkZ);
                event.setCancelled(true);
            }
        });

i made it so every chunk except the 0,0 chunk wont be loaded on my client but it doesnt load the 0,0 chunk either

wet breach
#

don't have to use long

#

just some example I had at the moment

smoky oak
#

not really the usecase here tbh lol

eternal oxide
misty ingot
wet breach
smoky oak
#

ah

#

no i meant that since it can be either, that would change the number of key elemenets

#

the idea here is to have a system that allows for table creation and management without knowing the table structure beforehand, so that the sql code can be put into a blackbox and forgotten about

wet breach
#

I guess you could always count

#

but you should know the table structure o.O

smoky oak
#

this is still the same thing i was workign on last week lol

#

a class that takes the keys and value types, then handles sql for you

wet breach
#

because if you are its a futile thing

smoky oak
#

yesnt

#

this is for an edge case

primal island
#

Okay, so i have tried to make my own placeholders in a plugin.. But how do i use them in skript? I have tried for the last like 2 hours

BandePlaceholders.java:

package dk.un1log1n.un1bande.placeholders;

import dk.un1log1n.un1bande.Un1Bande;
import dk.un1log1n.un1bande.database.DatabaseManager;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;

public class BandePlaceholders extends PlaceholderExpansion {

    private final Un1Bande plugin;
    private final DatabaseManager databaseManager;

    public BandePlaceholders(Un1Bande plugin, DatabaseManager databaseManager) {
        this.plugin = plugin;
        this.databaseManager = databaseManager;
    }

    @Override
    public @NotNull String getIdentifier() {
        return "un1bande";
    }

    @Override
    public @NotNull String getAuthor() {
        return "Un1Log1n";
    }

    @Override
    public @NotNull String getVersion() {
        return plugin.getDescription().getVersion();
    }

    @Override
    public boolean persist() {
        return true;
    }

    @Override
    public boolean canRegister() {
        return true;
    }

    @Override
    public String onRequest(OfflinePlayer player, @NotNull String identifier) {
        if (player == null || player.getUniqueId() == null) {
            return "N/A";
        }

        String playerUUID = player.getUniqueId().toString();
        int bandeId = databaseManager.getBandeId(playerUUID);  // Find bandeID

        // Hvis spiller ikke har en bande
        if (bandeId <= 0) {
            return "N/A";
        }

        // Placeholder: %un1bande_name%
        if (identifier.equalsIgnoreCase("name")) {
            String bandeName = databaseManager.getBandeName(playerUUID);
            return bandeName != null ? bandeName : "Udefineret";
        }```

pom.xml:

<repositories>
<repository>
```

#

<id>spigotmc-repo</id>
          <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
      </repository>
      <repository>
          <id>sonatype</id>
          <url>https://oss.sonatype.org/content/groups/public/</url>
      </repository>
      <repository>
          <id>jitpack.io</id>
          <url>https://jitpack.io</url>
      </repository>
      <repository>
          <id>codemc-snapshots</id>
          <url>https://repo.codemc.io/repository/maven-snapshots/</url>
      </repository>
  </repositories>

  <dependencies>
      <dependency>
          <groupId>org.spigotmc</groupId>
          <artifactId>spigot-api</artifactId>
          <version>1.8.8-R0.1-SNAPSHOT</version>
          <scope>provided</scope>
      </dependency>
      <dependency>
          <groupId>com.github.MilkBowl</groupId>
          <artifactId>VaultAPI</artifactId>
          <version>1.7</version>
          <scope>provided</scope>
      </dependency>
      <dependency>
          <groupId>io.github.rysefoxx.anvilgui</groupId>
          <artifactId>anvilgui</artifactId>
          <version>1.6.5</version>
      </dependency>
      <dependency>
          <groupId>com.github.placeholderapi</groupId>
          <artifactId>placeholderapi</artifactId>
          <version>2.10.9</version>
      </dependency>
      <dependency>
          <groupId>org.xerial</groupId>
          <artifactId>sqlite-jdbc</artifactId>
          <version>3.36.0.3</version>
      </dependency>
      <dependency>
          <groupId>com.j256.ormlite</groupId>
          <artifactId>ormlite-jdbc</artifactId>
          <version>6.1</version>
      </dependency>
  </dependencies>

Just don't know how to use it in skript i have tried a lot now...`

tight compass
#

Can I set a TAG_CONTAINER and then set the children of it? OR do I have to set the children first and then set the TAG_CONTAINER?