#help-development
1 messages · Page 1219 of 1
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
hm. that would be nice to have as an option, how would i do that?
load it into memory?
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
Creating the file object should technically do that, but you could see if memory mapping the file would work
That's uh? You save the result of your select statement and store it in a variable, it's now in memory?
You either load the entire file or you do that
wouldn't i need to update the db and re-query if i would want to make any changes?
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
no, what im saying is that if i update it after i grabbed the resultset the resultset would be inaccurate
Yes
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
Loading all of it in to memory would kind of go against the whole point of your project
Why split pdc tags out of the chunk just to keep it in memory all the time
When they're not required
im curious how to actually do it, and the idea isn't to keep memory down but to keep the data separate from the minecraft files so that it's not stuck in them once the plugin is removed
(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)
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
tbh I'm not sure what you're having trouble with anymore 🤷♂️
lol
Like most of your questions don't make much sense to me
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
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
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)
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
To keep it in memory you just have a variable in your program. And to persist it you save to db when it changes or once in a bit depending on the usecase
ah fair point
To load it in to memory you run your database call
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
Asynchronously load/unload, but yes, that would be fine. Depends on how often you're accessing that and if it's strictly necessary
rarely, but if its accessed, the faster the better
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
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
CompletableFutures are your friend
can the same connection deal with multiple queries at once?
werent those sync?
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
well i meant parallel tbh lol
coz if the async task blocks the db for something that takes a while and then the main thread tries to get something the server lags out
Well, yeah, ideally nothing you do with the database is synchronous
but if it gets queued wouldnt it just run them down in order?
would it be an idea to have an async thread that has a priority queue for the database queries?
Nah, I wouldn't overcomplicate it
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'
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
doesnt a composite key do that index automatically?
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)
Maybe easier, but not how you should be using SQL :p
black box code
SQL won't find it easier
'pls dont look'
The Swedish dictionary app has the worst SQL I've ever seen
And you'd have to try to beat it
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
ah i see
More storage space for a string as well
Then it becomes a problem with readability and useability. At that point it might as well be three separate columns
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)
Yeah that's fine
Some databases have an actual UUID type. I don't think SQLite is one of them
It doesn't
ByteBuffer bb = ByteBuffer.allocate(16);
bb.putLong(uuid.getMostSignificantBits());
bb.putLong(uuid.getLeastSignificantBits());
return bb.array();
the conversion's simple lol
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
well. would it be faster?
At that point it becomes a microoptimization
You're probably not going to run into any bottlenecks with your schema currently
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
Finding every block in a chunk on load is something that can be optimized with the current schema
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 😄
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
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
^^
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
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)
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
Because the database keeps the indexes and their hashes in memory
Indexes have a higher memory footprint, but make lookups much faster
wait are you saying this applies to each part making up the primary key
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
well to be fair i dont want a block mined and not mined at the same time
im not doing physics here lol
Schrödinger's block
i guess ill keep it as PK(x,y,z,b[16])
that way the database is easier to inspect

That b16 should be a foreign key to worlds table
the sad thing is i know exactly what hes saying
but if its indexed, would that help anything except comprehension?
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?
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
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?
The database takes care of that not you
ah
A foreign key is just a reference to a value in another table to prevent duplicate data
Realistically, a foreign key doesn't do much. It's just a constraint that prevents you from deleting the table it references
theres a reason im doing ON CONFLICT DO UPDATE lol
i dont want to have duplicates either
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
ok thats useful
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
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
alright, how do I get the corners of an item display being a player head?
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?
The math is the same, you just have to change the points you're accessing. Instead of +/-1, you would have to adjust based on the corner positions of an actual skull block. It's probably like 0.25 to 0.75 or something
You can still use the foreign key as a primary key. Both can be true
my primary key looks PRIMARY KEY(x, y, z)
can you just go PRIMARY KEY(x, y) PRIMARY KEY (z) then?
no. You can still include your world column in there
do these change anything?
For a skull, maybe? I don't remember what the model geometry looks like
Depends on the model the item has
player head
You can check the model json and see
I think it's like 0.5xyz
From the server side you have to make some assumptions because you don't have access to the model files
I guess the center being on the top and xz center is the cause of my suffering
yeah no worries about that, I'll post my results later here, you'll understand what I had to do then ;]
(if I complete it today)
can you give me an example for how to do a foreign key part of the prime? coz im just scratching my head here rn lol
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
);

(ie, changing the int type depending on the input. world -> y = smallint, chunk -> x,z mediumint)
Yeah, whatever it is you need to do
like i figured why waste storage space when i know it cant exceed those values lol
For sure
But what if I need to store the far lands
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
Bold assumption 
What if I go outside the world border
I modded my server to store 2^64 cooridnates
Who's gonna stop me
It still generates but you can't break or place blocks
Is that how hypixel maximises server performance, using all of the world
yea but the world border is offset from 30m
Yes. The whole network is actually just run on one massive 2^64 by 2^64 world
Hypixel leaks 
When do you move to 2^128 worlds
I suppose BigIntegers exist. Nothing stopping us
BiggerInteger when
Hypixel leeks when
Can you believe Discord doesn't have a leek emoji?
🥬
That's the closest they have to a leek
Storing entity coordinates 🗿
do they now?
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)
Hi guys, its possible to create custom events with koltin?
Yes
I don't know. Do they!? 
NOW YOU'RE MAKING ME QUESTION IT
yeah they do
according to oracle
not that you should trust them, they are researching to integrate LLM into medical tech 🗿
Guys, can you tell me the flag to prohibit the flow of lava in the region?

Sounds like a question for #help-server
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
there is any example?
You can look at this for the Java version
You need to know both Java and Kotlin if you want to do Kotlin plugin dev
90% of guides are in Java
I'm watching that yeah, but I'm having problems with the @JvmStatic
What problems are you having
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
This is the width of every character in Minecraft's default font
omg thank you i have been looking for something like this
but how do i make the gap equal
lik should i use unicodes
and how big are the dif unicodes
nerd font in mc when
All characters in the MC font have their width in the file I sent
Unifont however is a different story
wait so the difference between the emojis is 2
so how would i close that gap with an invisible character
is that possible?
You can have characters with negative width
idk how to do that
I have a "$(6)" and a "⬤(pretty sure 7)" and i want them to be the same width as "⚔(8)" on a mc scoreboard
You will have to add spaces after the one that's shorter, to pad it out
6+7 != 8 (I know, shocking)
im so confused 😭
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
$⬤
⚔
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
You can just use spaces from https://github.com/AmberWat/NegativeSpaceFont
i cant really do a resource pack
cause its for a server
should i just find like new emojis or sum
You could rely on the space character but it's gonna be inaccurate
What emojis are you currently using?
the ones i sent
You didn't send any
i tried to copy and paste it but it was like massive
these ones
Those aren't emojis, just characters
The crossed swords one uses the same unicode as the actual emoji but yeah
oh well they were emojis but mc and discord swapped them
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
ServerLoadEvent has a reason or something
declaration: package: org.bukkit.event.server, class: ServerLoadEvent, enum: LoadType
Yea, load type
so what can i do @blazing ocean what do you recommend
Well you're gonna have to do some character width fuckeration and pad everything. If you really don't want to use a resource pack, you can rely on space characters but they're 2 or 3 pixels, so it's not going to be as accurate ^
Plus, it's not guaranteed that the characters even have that width
Resource packs can just override the texture
ive seen other smps do it but idk how they do like even if i use the same emojis as them there $ simble is some how bigger
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
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
idk how to verify so ill just do this https://prnt.sc/CDpQl1RK4s1a
Looks like they just chose characters with a similar width and added 2/3 space characters
the one i sent was my server and my code but this one is from a random smp i found
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
Bold text?
@blazing ocean do you know by any chancwe
na i tried that
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
it can only be it, have you tried
yes
i did this but it comes out looking different
and only 6 wide
but i need it to be 8
does anyone know
andddddd im dumb
i realize my mistake 😭
💲bro try this one
i found it
but now its too wide
like bruh
im so confused
bruh
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
nah i dont
im sorry
You can't fix this without resource packs
i fixed it with unicodes
that took me way too long to figure out lowkey
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.
so uh
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?
could you please elaborate?
just makin a block texture out of text displays
since they can have any background color
these are all riding on a single block display
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
ah so the redstone block, bedrock and emerald is correct but these blue things which I assume are text displays are not?
well that's the best chatgpt could do
the default method:
so this
bedrock is the overall rotated center
emerald is the rotated center of a face
redstone is the non-rotated emerald
Why did my gradle all of a sudden stop building my .jar files ?
Are you running the build task? Any errors?
How can I use the gradle project version in the plugin.yml version?
You can use the processResources task
thanks!
It builds just fine, but copyJar doesn't copy it im the provided dir
Nope, somehow it doesn't work.
Try stopping the server before running it
-# (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)
What's the question
was replying to the conversation above, hence the -#
Sorry idk what the small text meant
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
@floral drum help it no worky
sout("It no worky purple");
:(
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
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.
Disable watchdog
Try turning off your antivirus.
solid plan
y'all still using antivirus in 2025?
nah i just let viruses fight each other, strongest one takes my pc
Could anyone help out?
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
How do you cancel a player middle clicking to open the spectator menu in spectator mode?
I don't think you can cancel opening the menu
I know it's possible but maybe it is through packets
It's not
Last time I checked Wynncraft did it unless I'm misinterpreting their methods
During cutscene you mean?
No during their recent update to their class selection screen
Haven't seen that one so 🤷♂️
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
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
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
i dont know the event for it but i know the packet for it https://minecraft.wiki/w/Minecraft_Wiki:Projects/wiki.vg_merge/Protocol#Set_Camera
you could probably also cancel onPlayerInteract if the player is targetting an entity and is spectator
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
should work - 1) version; 2) is the event firing?
- CraftBukkit version 4430-Spigot-d421948-d20d4c1 (MC: 1.21.4) (Implementing API version 1.21.4-R0.1-SNAPSHOT
- the event's firing properly (i tested event.getPlayer().sendMessage("test")), its just not canceling
submitted :,>
Thanks
hm
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?
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
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.
It's the characters shadow
code driven? i thought that would be a local setting
But yeah with components you can remove it
hey md you here?
why
It's like a solid midnight for him
that doesnt mean shit for people like us tbh
again, why
wanted to ask about spigot internals
?ask
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!
I'm pretty sure there's a few people that vam answer it
Choco vam often answer
I love choco van
No
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 ;-;
given that the issue i reported a while back https://hub.spigotmc.org/jira/browse/SPIGOT-7466 has a very similar problem in https://hub.spigotmc.org/jira/browse/SPIGOT-5799 that's been resolved by apparantly removing one of the thrown inventory close events (see net.minecraft.server.players.PlayerList.java#remove(EntityPlayer entityplayer), why has this been done by removing the InventoryCloseEvent BEFORE the player leaves the server, and not after?
bc imma be honest i kinda expect a player to exist when closing an inventory
given yknow
this
unsafe enchantment maybe
hmm,, will have a look thanksss
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
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
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 ?
If Essentials doesn't need anything from Chat then it doesn't need to be declared
Well it doesnt, they share the same data declared in Library.
But compileOnly gets only the code that is used, right?
hm? What do you mean?
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 ?
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
shadow will only shade the runtime classpath
implementation adds onto the compile and runtime classpath
compileOnly does not
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.
You need to load the locations
I did something like copyDefaults(true) for the custom YAML file at plugin startup. That should load the locations, right? But it doesn't.
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
?jd-s
I followed this exact tutorial before
?paste your code
huh you're abusing defaults to store values
And here is the command which should list all the saves
https://paste.md-5.net/ixawofojos.java
I actually used FileConfiguration.set() before. In hopes that the data works as default, i used addDefault() but to no avail
also you're getting ints and setting strings
Oh.
But the string data should still show up?
Before this, i used the simple get() method instead of getString() or getInt()
need your custom yaml class
alright one sec
none of the above 
this
aint that just protected
You're never loading the config in to anything
Just discarding the loaded config
I was dumb enough to simply follow the tutorial without using my brain
r/meirl
Is there a way to remove the [13:57:28 INFO]: from the console?
Well, I'll try loading it in the config variable and see if it works
You should keep that there
it's useful info
Yes it's possible but you really shouldn't
Oh okay..
throw a runtime exception and suppress the message kek
log4j config
When using the JavaPlugin#getLogger(), you get the message printed out like [PluginName]: <Message> is there a way to print out just <message>?
probably not since that is the goal of the plugin logger
to log a message from a plugin
most people want the time + level on the message
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
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
what
or are you talking about casting to a byte
are you talking about a number value
yea
i want to write a byte in code such that i can quickly see it's bits
its for mask purposes
why would you need the cast there
bc for some fuckin reason its an int
yea it gets put into the mask field?
or would if 0b<something> would be a byte and not a int
im like 200% sure what ever you are trying to achive, there about a million better ways to do that
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
its backed by an int anyways
32 or 64?
int in Java is 32bits and long is 64
hm so just a 0b with 32 locations
sounds abt right lol
dont see how that wouln't be enough values
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
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
not sure I understand what you are asking lol
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
give them names via constants? other than that, no, you cannot do things the language does not have in the spec
you could just use the int representation of the mask
well the reason im doing it like this is so i can quickly input the masks
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
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
?paste
ironically that last option still works and only requires a byte 😛
Players can't equip the armor by dragging it into their boot slots, but they can equip it by right-clicking. How can I fix this?
idk, how many debug prints do you get?
well if by first 3 you mean debug #1 to #3, then the event should be cancelled right?
It stops the drag and drop, that's it
I can equip the armor just fine
which is the issue right?
Yeah
like you want to prevent them from equipping it
Also, yes
weird
i seriously doubt #3 is logging at all
itemStack.equals(Material.CHAINMAIL_BOOTS) & co. will always be false
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
not on 1.8 
I'm back again. Loading the config also didn't work.
lol
It's like, the plugin turns a blind eye to the saved data.
can you directly assign values to enums, or do you need to use constants for that?
what
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
parenths between (value & mask)
😄
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
that sounds like something i would do so theres probably a better solution 🙃
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
You would need to create a seperate font with every glyph raised
Or just use a TTF and have a shift applied
Or, if you really want to, use a shader
damn
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?
If you can get the inventory of the shulker then I assume you can? Not too sure tho
I don't see a #getInventory method for shulker tho
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/Container.html#getInventory() it's under ShulkerBox actually
sweet, i'll try it out
?paste
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'
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?
what the fuck are you doing
LOL WHAT
did you run buildtools with --rempaped?
wth
show the code
this not plugin if you want know
whats Mongo.java:25
what is Mongo.java line 25
ru.jampire.mclans.utils.Mongo.connect
oh
@blazing ocean I'm making my own economy :p
normaleconomy
Indeed
randomnormaleconomy
No it will not
are you referring to yourself in the third person
Should I?
paste ur Clan.class
yeah
use --remapped as well
Run it with --remapped --rev 1.21.4
okay
someone?
paste ur Clan.class
im not seeing anything obvious, talk to mongodb is the best i can say
talk to morphia
it will add it to your maven local
what you talking obaut
?learnjava
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! 🎉
bro wha
No I mean the buildtools files
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
go and ask mongo db about it, they can help better
😦
you need to shade the mongodb driver
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
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?
So should be the same as in here
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)
It does
soooo
That shade plugin version is ancient
Oh, is there a new one?
3.6.0 should be the latest one
not found
I don't think that's the cause of your issue but it's worth updating
yea
reload your pom
I did
Could not find artifact net.md-5:specialsource-maven-plugin:pom:3.6.0 in central (https://repo.maven.apache.org/maven2)
how do I cast stack to ShulkerBox (to get it's inventory)? Cuz this isnt working if(stack instanceof ShulkerBox shulker){
what is stack
You don't cast the item stack itself
instanceof check is not casting rather checking if it is an InstanceOf that type
sec i have code for this

You need to get the BlockStateMeta
ItemMeta and then cast, get block state and then cast that to shulker box
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
return 0 ?
counts the number of occupied slots by specific materials
old project to, well, understand block meta
ah
(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?
tf? I thought it checks type and casts if its the same?
ty
in the if method if the check passes, you could have a cast happen, but instanceof does not do any casting
yeah I get that
but
wait
no
what
if(stack instanceof ShulkerBox shulker){}
ShulkerBox shulker = (ShulkerBox) stack;
}```
no??
yes
i love when my ItemStack is instance of ShulkerBox
mmm
sorry for late reply I was looking up JVM stuff
check the typeof the shulker to know if its a shulker, then use block state meta
and by type i mean material
so apparently this works since JDK 14, however there is some scenarios where this will not work and cause circular recursion
lmao
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
I picked up java later than 14 was released 💀
I been using Java ever since it was released 🙂
so as you can imagine, I can't always remember everything that gets released XD
thats like 30 years ago
three decades then
i knew it was somewhere in 90s
saying it with words means its less accurate
I am quite happy with all the new stuff in Java and how better it has become since then
anyways, player.openInventory(shulker.getInventory()); is not updating the shulker 💀 (who would've thought am I right)
how fix
bro why is everyone here so damn old
I wouldn't say everyone
if it makes you feel better md_5 is younger then me
guys :3
register inventory in a hashmap that maps it to a shulker and listen on click?
well yes
BlockState is a copy
oh comes from HumanEntity
how old is he
i'd guess like 30
he isn't 30 yet
how old is he then
how do I modify a non-placed shulker then
You update the meta after the inventory has been closed
Do watch out for dupe bugs
idrc care about dupe bugs here
Or when inventory has changed
he was like 14 or 15 if I remember right when he created spigot
damnn
he what
yeah so I think he is 28 or 29, depends when his bday is which I don't remember when it is
so uhm. How do I cast an inventory to item meta
the inventory self updates coz its a reference
ShulkerBox box = (ShulkerBox)
//edits
stack.setItemMeta = box;
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
will the itemmeta auto update when I update blockMeta?
pretty sure no
set the meta back to the item
this, but backwards
meta.setBlockstate(box)
I think I did it
meta.setBlockState?
blockMeta.setBlockState(shulkerBox);
stack.setItemMeta(blockMeta);
thats the same thing right
I mean
thats how
right
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
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?
?pdc
^^ or just add them to the registry
😔
if i have WorldEdit as my dependency, and the server has FAWE
will it work alright
-# (and vice versa?)
if you use wapi and have fawe it should work
if you use fawe-api and use worldedit it mightnot
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
The FAWE api encourages you to run actions async
Doing that with just worldedit on the server will break
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
I was kind of trying to do something like:
custom_enchants: {
auto_smelt: 1,
whatever_else: 2
}
Can you do this in PDC?
yes
How?
It’s in the link
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!
Is that the whole custom datatype thing?
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)
Capture the packet and send an empty chunk
Then when you want the player to see it send an update one
how would i go about doing that?
Doing that is not easy
yeah i figured
Chunk packets are horrible to work with
https://www.spigotmc.org/threads/custom-chunk-packets.666766/
think i found something
you could halt the chunk loading using the event
but that wouldn't be per player
Can someone help with pom.xml?
isnt meant to be per player
i just want each chunk to be shown to the player when i tell it to
whether that is through packets or loading idc
Could not find artifact org.spigotmc:spigot-api:pom:1.16.5 in central (repo.maven.apache.org/maven2)
?paste no one is going to be able to help with your pom if you don;t show us your pom
?maven you specify no repositories
then unloading/loading chunks would be your best bet
and how could i go about doing that
how do I revert a commit if it ain't in github desktop/
declaration: package: org.bukkit.event.world, class: ChunkLoadEvent
you would cancel the load event
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Chunk.html#load()
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Chunk.html#unload()
declaration: package: org.bukkit, interface: Chunk
and then use these to load/unload as you please
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 🙂
Except the load event isn’t cancellable
yep just found that out
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
guess that is another change I wasn't aware of
you used to be able to cancel chunk loading 🤔
maybe someone can pr a change for it at some point lol
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?
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
What was the thing called that auto created Getters and Setters for you in intelliJ
lombok
Thank ya!
and it isn'tt just for intellij just fyi
yeah i just saw that xD
no what im expecting is user error lol
guess I'll have to sort the key inputs. is there a simpe way to assign 'rankings' to enums and then have a set containing values of that enum iterate it in that order?
or do i have to go
List<Enum> list = List.of(Enum.A, Enum.B, Enum.C);
for(Enum i : list) {
if(! set.contains(i)) continue;
//setup
}
not sure what user error you are expecting. The only place where the order affects anything is if you are selecting all data in a query or you are inserting into the table
the last one especially is where it matters most
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
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
depends which way you are getting the list of Enums
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)
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
yeah lol
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?
preparedStatement ? does a bit more than just replace
You can still use prepared statement, however instead you would use a string variable, before your prepared statement you would use stringbuilder to format the query
im aware, but im doing purely string manipulation atm
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
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
you could replace just some of them
and then leave the others in
and then have prepared statment take care of those
but since there can be a variable number of keys i dont know the locations of those
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
what number of keys?
table keys?
why would they vary?
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
so use an enum to help decide which is which
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
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
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
int chunkX = (int) Math.floor(player.getLocation().getX()) << 4;
int chunkZ = (int) Math.floor(player.getLocation().getZ()) << 4;
return (long) chunkX & 0xffffffffL | ((long) chunkZ & 0xffffffffL) << 32;
don't have to use long
just some example I had at the moment
not really the usecase here tbh lol
Are you sure your central chunk is actually at 0,0?
well i went to chunk 0,0 (according to f3 menu) and it wasnt thefe
well not sure why you are saving both chunks and coords =/
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
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
are you making some kind of api for people who don't know sql?
because if you are its a futile thing
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...`
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?