#help-development
1 messages · Page 1279 of 1
under age people can't generally sign CLA's anyways
and if they are allowed, at least in the US anyways, they can nullify a contract at anytime and the other party can't do anything about it
well, young adults anyway
I doubt md accepts the CLA from anyone under 18
i will get a hobo off the street to sign the cla on my behalf
I am addicted to contributing, I NEED TO PLEASE LET ME
reminds me I should actually update my PR lol
how i can reload configuration? I just make like fast command to test it. I changed value in config.yaml clicked ctril + s and do /reloadcmd but the value didnt change
@Override
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
SMPSettings.getInstance().reloadConfig();
return false;
}
public void reloadConfig() {
save();
SMPCore.getInstance().reloadConfig();
}
Where do you use the value?
How did you check your value?
@Override
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
Player player = (Player) commandSender;
player.sendMessage(Colorize.toColor((String) SMPSettings.getInstance().get("test-text")));
return false;
}
to display text when using command
Doesn’t this give u a overflow error
Why are u saving and then trying to reload config anyway
Was thinking the same. But he has SMPSettings and SMPCore
like when i changing something
What’s the get function on ur SMPSettings
i just save the changes and then reload
Show your SMPSettings class pls. Im guessing your arent creating a new FileConfiguration and still using the old one in memory.
Smart
public Object get(String path) {
return config.get(path);
}
?paste
Yikws
Why are you handling most of that urself? U do know JavaPlugin handles most of that
what?
Calling SMPCore.getInstance().reloadConfig() does nothing in this code.
You are using a YamlConfiguration that doesnt change unless you write some code that actually changes it.
Do you already have a config.yml?
yes
oh ok
Honestly, i think the entire SMPSettings class could be removed. Your JavaPlugin instance should do exactly the same.
I’m guessing he’s using it for config.yaml and the core for config.yml idk why tho
so like transport methods from SMPSettings to SMPCore right?
They should already be there
noo
im using only one
i like the way to sepparate this config from main
Nope. JavaPlugin already has all of those methods.
oh
Just rename ur file to config.yml instead of config.yaml
then u can run saveDefaultConfig on enable
And otherwise just use getConfig / reloadConfig / saveConfig as u need
ok
public static boolean givePlayerItems(Player player, ItemStack... items) {
Location location = player.getLocation();
World world = player.getWorld();
for (int i = 0; i<items.length; i++) {
if (items[i] == null) {
items[i] = new ItemStack(Material.AIR);
}
}
Map<Integer, ItemStack> leftOvers = player.getInventory().addItem(items);
for (Map.Entry<Integer, ItemStack> entry : leftOvers.entrySet()) {
world.dropItemNaturally(location, entry.getValue());
}
return !leftOvers.isEmpty();
}
better way to do it ?
maybe i should just iterate once and have a different leftOver Map for every itemstack?
so i dont have to iterate 2 times
that sounds worse
iterating two times is fine
but look
i just finished
public static boolean givePlayerItems(Player player, ItemStack... items) {
Location location = player.getLocation();
World world = player.getWorld();
boolean anyLeftOvers = false;
for (ItemStack item : items) {
if (item == null) continue;
if (!player.getInventory().addItem(item).isEmpty()) {
world.dropItemNaturally(location, item);
anyLeftOvers = true;
}
}
return anyLeftOvers;
}
if anything, you could use nullability annotations so that the array never contains nulls
why isnt it better
i preffer to allow it and handle it \
i dont even have to access the map, i jsut use the item from the loop
because addItem isn't free
ok, so the first version or should i change anything ?
the first version is fine
okay
though you might want to return leftOvers.isEmpty() without negating
it's kinda pointless tbh
I mean, you aren't removing the elements from the map so it's always going to be false
you might wanna tell player their inventory was full
whaa
ah, that makes sense, yeah
but the map will be empty if all items fit
I was thinking you were trying to check if all the items were dropped successfully
; )
should i create 1 Random instance for my class instance?
like in CommandExecutor class
or use 1 per plugin
i guess its not safe to create it often
What’s the random for
No but like
lets say its a flip a coin game
or some other prize-generating method
i think its safe to do it once at the onEnable, or in the constructors
i dont really know how exacly its unsafe to do it often
someone before said that using static might not be safe, but i still dont understand in which cases, do you know ?
Example. Let’s say you have an arena and you make that static. It doesn’t make sense for it to be static because you could be making many arenas at once
Very general example
uhm
Having static on a field is different from static on a method by the way
so just using static when it doesnt make sense?
no, they say using static is a beginner habit
It’s really not
It’s just easier to slap static on something without fully understanding what you’re doing
bleh
oh ohi
public static void give(Player player, ItemStack item) {
PlayerInventory inv = player.getInventory();
for (Map.Entry<Integer, ItemStack> entry : inv.addItem(item).entrySet()) {
ItemStack copy = entry.getValue().clone();
item.setAmount(entry.getKey());
player.getWorld().dropItemNaturally(player.getLocation(), copy);
}
}
?
oh hi*
thats different method
you can just loop over it
dropping the entire stack when only part of it got consumed can cause dupes
There is nothing wrong with making a singleton like that, some people just like to whine about it
It’s honestly debated for plugin instances
why 😭
I don’t think anyone will kill you for either
Avoid it if possible but it can make large projects cleaner in general
look this up and you have 2 explanations of static
mine's better imo
what about the dupes
why does it happen
why NOT to do this
is it just cause its unnecesary ???
@echo basalt (idk if i can ping)
It's because you're abusing the concept of static
The idea is that the static keyword is used for constants that should never change
If you're using it everywhere it kinda breaks the point
i can pass it but its a lot of passing
You can use it for your plugin instance but it's a debatable topic
uhm
I personally avoid it for projects under ~15k lines of code because there just is no point
You can pass it with DI which is the more proper approach
If you have a one and only Circus, it should be set up that way, but you probably want to instance multiple Circus at once making it impossible
yeah
probably thats better
i was thinking about makin external class, but idk how i didnt think of this
lol
what if I store the plugin instance in a static field AND use a DI framework
no u
that's the solution
koin is actually good
was literally about to say koin
what even is that 😭 xd
yeah but exclusively casinos?
They got the money to spare i guess 😅
I feel like they're all using some lib / provider that forces them to sponsor koin
Like some high profile dev / company in the casino biz that has it in their TOS they gotta sponsor every FOSS project they use
is that actually a thing
if so that's kinda ridiculous
CasinoCore
could be an interesting contract clause
or a licensing term
Oops! All gambling
@blazing ocean I might need some insights again
😔
We're tackling the problem with gui text rendering funky
what did you do now
We took a look at it with a fresh set of eyes and individually counted pixels
the algorithm I stole calculated a length of 147 while the text was actually 151 pixels long
That's 4 pixels off, and we happen to also have 4 spaces in our text
This is the text
There are 26 characters, 4 spaces
How big is a space
a space is 4 pixels wide
there is a pixel after every character
And our characters themselves are 109 pixels long
Is that including the pixel after each character
no
Total length = 109 + 4*4 + 26
Which is 151
But rad's funny little algorithm only counted 147 and I dunno why
Wait why does the size matter
If I take all the spaces out of the equation it works out fine
Isn’t this item lore
Ah
Now, this doesn't happen when the color is always the same
I'm thinking that changing the colors adds a child component or something
isn't there an utility under java graphics that calculates the width of a string from a font face
fonts are from a bitmap and I know the length of every character
I’m pretty sure each colour does add a child component yeah
we did a separate test where we rendered every character and make sure it all aligned
Does that add another pixel?
And when we have color changes it breaks
I don't think it adds another pixel
I think rad's algorithm is off
Ah
Let’s shame him
If it only happens with colours though how could the algorithm be the issue
Because it's his algorithm
No but it looks through component children
This still isn't breaking
hm
lemme do the math as if I was the algo
Hm
Adding all the numbers together does give me 147
so the algorithm sums them fine
Why would doing the math separately not result in the same
It actually calculates 151 fine I just forgot about the space at the start
unless rad's algo is also forgetting
hm probably gonna have to fix that
the funny little german man made a funny little pixel calc algorithm?
i got it
i was touching some grass
but in the command i dont need to do reloadConfig() but just load()
genuinely confused
and it works perfectly fine
Could this be related to a font change?
Rad? More like radle
Could it also be that I have an empty text component that's just a color
unless I don't
watch me have to account for the pixel between my shifts
Removing the space at the beginning of every line fixes it
😭 what the actual fuck
So <gray> <color:#aabbcc>Whatever</color> breaks it
but <shift:4><color:#aabbcc>Whatever</color> works
crazy shit
@blazing ocean is this on your end or do I blame mojang
bro's boutta get in trouble
I charged my boys like 100$ to figure this out they're not too happy
genuinely took 4-5 hours
blame ebic
@remote swallow you're fired
there's no way to make text transparent right?
maybe w a font even then I'm not making 20 fonts for each shade
@blazing ocean I blame the femboy
Is there a way to change how long it takes for minecarts to accelerate to full speed?
good
Don’t be mean to femboy
Is that friendly advice or as a threat from a chat mod?
Yes
shaders
You should be able to do integrated GLSL with packets (wait nvm i dont think so)
peak AI hallucinations
bahah no
you know the numbers on the scoreboard? you could disable it using shaders, i swear using protocol lib I had disabled it once.
but lowkey ,cant rmemeber how
You can disable them without shaders now
probably by setting the number format
Mhm
i'm trying to make it possible to open chests without the animation- I've tried using Lidded#close() on an interact event but that didn't work, I also added a slight tick delay, that also didn't work.
Is it something to do with the order of events, perhaps the block doesn't update when the interact event is fired?
try cancelling the interact/open event and opening the inventory manually
yeah i thought about that but i want to keep the live updating nature of opening chests naturally
that should still work, unless you are opening an inventory snapshot or something
what would the code look like opening a snapshot vs the live inventory?
actually on spigot i'm not sure if you can even get a non-snapshot inventory
on paper you pass false for Block::getState to get a live view of the state rather than a snapshot
Yeah I made the mistake of thinking that before
Calling getInventory on the block state returns the live inventory
Even if the state is copied
There’s a getSnapshotInventory
Yeah
So if I would like the live inventory I would obtain it from the block state ?
Yes
Perfect, thanks guys I will give it a try in the morning
I want to save the inventory of a player in the database, and I want to serialize the inventory. What is the best way to take the item stacks with each attribute, i.e. Durability, Name, Lore, Enchantments, etc.?
on spigot, the BukkitObjectOuputStream and Base64
|| on paper, ItemStack has some to byte[] methods for ItemStack and ItemStack[] ||
Which of the two do you recommend?
Alright, thank you!
easiest way to make a duels system without accidently wiping a player or giving them items?
dueling a player teleports them to another world and gives them a kit
after the duel is done your kit is gone and whatever you had you get back
but there are many edge cases like server crashing, player leaving, somehow i cant retrieve their items back
Restore inventory when player leaves
Restore inventory on shutdown
Restore inventory on startup
Obviously you’d need to track what players need inventory restored
I guess having one saved in the database is one way to determine that
what if the server crashes
That’s why you restore it on startup
k
If a database write fails you obviously don’t clear their inventory
The only real issue would be if reading the saved inventory fails
https://paste.md-5.net/uwesolejeg.java
the AttributeModifier is red and idky
was this AI generated
is def structured like a human but it's over commenting
if youre referring to the code, its probably because youre using a deprecated constructor.
AttributeModifiers switched from uuid/string to NamespacedKey
also note:
You can hover over that red in your IDE and it'll tell you the issue
to fix the code that i had originally
god forbid i want to know what my code does
I mean, you do whatever makes it easier for you
yea ig
i never said ur code was ai or claimed it, i was just responding to javiers message
nah just the fixed parts
hello guys
Im making a crates plugin
and lets say i have custom items with pdc i want to put in the crate
how can i store these in like a crate.yml
like rewards
rewards:
item:
type: golden_apple
amount: 1
item-2:
type: special item with pdc here
amount: 1
like how does it work so they can keep their pdc etc
you can’t store custom items with PDC in plain YAML like that, it won’t keep the data.
you gotta serialize the whole item (with meta + PDC) into a Base64 string and store that in the config.
when the crate opens, you just deserialize it back into an ItemStack and give it to the player.
you can write a small util for that or use existing libs, just make sure you’re not trying to write the item directly as type: diamond_sword if it has custom data.
ah so ppl should only be able to add items to the crate via ingame command while holding the item ig
kk ty
yea confusion
you can also just serialize the nbt of the item instead
its fine ill just do the whole stack and have it a ingame editor
if you're going to store items regardless, make sure to store them with the data version
how so
otherwise they're gonna break on updates
oh its fine only targetting 1 version
also anyone know the equivalent of PDC in 1.7.10
if you're lucky, whatever fork is still maintaing that version will have ported over the PDC API
na im on craftbukkit
why not spigot
wanna support any 1.7 software
bro dont use craftbukkit 💀
also couldnt find a download
nah the server wont be just the api
there's also nPaper which is the 1.7.10 paper fork
is that hardforked
(even though paper didn't exist in 1.7.10, I assume they just ported patches over) apparently it did, the more you know
No one is gonnq use 1.7 craftbukkit
no one uses 1.7 for plugins to begin with
I don't know, I haven't used it myself
I just know it exists
i cant find a link tbf
nice
it's still actively maintained, surprisingly enough
damn thats perfect actually
think ima just switch to that
u reckon it has PDC
na it doesnt all good tho
doesn't look like it
but you could make an issue request about it
PDC isn't that hard of a patch to port over
well, just ask them if it'd be possible for them to port over the PersistentDataContainer API, at least for items
ah, that one with 1.7.10-1.8 support
I forgot that was a thing
most people just moved over to ProtocolSupport when it became an option since nobody wanted to maintain the protocol hack directly on the server platform
feel like its better on the server
everything is better on the server, since you don't have to inject code or deal with reflection, you just modify the server directly and that's less of an overhead
it is just harder to maintain as new versions come, however that isn't an issue for anyone staying on older versions anyway
yeah im kinda surprised theyre supporting it thats great tho
they replied to the issue
that was fast
your link is broken lol
it redirects to issue search for some reason
thx fixed it
he said use NBT tags
now what lol
whats a good counter argument
i need ur help here @sly topaz 😭
I replied to their comment
they replied with skill issue lmfao
nah im surprised he didndt veen know what PDC is
maybe if he tried it he would change his mind
Can anyone develop me minecraft plugin for free
people don't really develop plugins for free, you're better off just looking for a public plugin which somewhat meets your needs
I'm down to add stuff to my portfolio, but will only do small/medium sized projects.
if you want to add things to your portofolio then just make public plugins lol
I'm trying to silently open chests (open the inventory, no container animation), yesterday I asked here they suggested to open the block's inventory from the block's state.
I tried that this morning, and it actually just triggers the animation when I open the inventory
whats a good command framework/api for 1.7.10
usually i use https://docs.commandapi.dev/ but it doesnt support <1.13
Website of CommandAPI
1.7 in 2025 is wild shit
Minecraft 1.7.10 is 10 years, 11 months old.
Might be a bit silly, but I believe Brigadier should support java 8 (which 1.7.10 should be I believe)
You could easily create your own command framework with that :D
brigadier needs client integration
without it, it is pretty much pointless
They're on 1.7.10
The best that can do is maybe tab complete
You don't need client anything for that, brigadier is enough on the server
if that's all they need then brigadier is plain overkill for it
Ye, as I said, it's silly :D
do you even need a command framework for that version
commands weren't all that complex back then
you could probably fork ACF and fix the errors that come up
or a switch statement
my command framework's tab completion >>
this
although come to think of it, switch statements were quite a bit more bothersome back in java 8
sucks to write for a version that sucks basically
yeah well, still better than using a bloated api
the fork they're using supports java 22 so it isn't that bad
some of u know invui?
?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!
u know how to register a gui bottom gui listener (of the player) when a Gui of InvUI is open? there is outside click event but it is outside all the gui that the player see
I am not sure I get what you mean
do you want a button on the player's inventory?
InvUI seems to support the concept of merged and split windows which makes you able to use the player inventory as part of the window so, it'd just be matter of setting up one of those and then adding an item to it
I want when you click an item in the player's inventory, it transports it to the gui
it doesn't seem like InvUI has an easy way to do this
what I would do is just take the player's inventory contents and make ControlItem out of them so that you can use them as content of a Gui, and set the gui of the item in its handleClick behavior accordingly, from that then use Window#split to handle both Guis, the top one and the "player"'s one. Then just add a close handler which takes the changes made to the fake player gui and applies it to the player's inventory accordingly
another way I could see of doing it is creating a ReferencingInventory out of the player's inventory, then iterate from 0 to Inventory#getSize and create InventorySlotElements out of the slots, which then you can use to create a Gui which should reflect any changes to it to the player's inventory, if all you want is for them to be able to drop items on your upper Gui
though I guess it wouldn't work since creating a split window won't allow clicking and dragging events to happen
I am surprised they don't have more utilities for GUIs which interact with the player's inventory tbh
ok, so a Window#split, with lower that is the player inventory but with clickable items, okk!
where is stored the player inv? in the ram?
I assume so, yeah
that does mean that in the case of a crash, a player could lose their inventory if they have a split/merged Gui open
but then again, if your server is crashing you have bigger issues lol
HAHAHAHA
public class BlackWandCooldownManager {
private final Map<UUID, Long> players;
private final long COOLDOWN;
public BlackWandCooldownManager(long cooldownMS) {
this.players = new HashMap<>();
this.COOLDOWN = cooldownMS;
}
public void setCooldown(Player player) {
players.put(player.getUniqueId(), System.currentTimeMillis() + COOLDOWN);
}
public void removeCooldown(Player player) {
players.remove(player.getUniqueId());
}
public long getRemainingMS(Player player) {
long expiration = players.get(player.getUniqueId());
long remaining = expiration-System.currentTimeMillis();
if (remaining <= 0) {
players.remove(player.getUniqueId());
return 0;
}
return remaining;
}
public boolean hasCooldown(Player player) {
return getRemainingMS(player) > 0;
}
}
```how to call this class
Manager ???
Wdym by call the class?
new BlackBlahBlah();
Does anyone have any idea on how to keep track of player's armor changes? There should be an easy solution, right 😅? I've googled a little and didn't find a solution that works for me. The closest I got was by using this repo: https://github.com/Unp1xelt/ArmorChangeEvent. But it fails to notify me of the hotswapped armor pieces as well as the ones I shift click inside my inventory. Any tips or should I create it from scratch by myself?
paper has an event for it, though i think it's implemented by trivially comparing each armor slot against the item that was known to be in it the previous tick, every tick
You could add the checks for all click types to the change event/rewrite it yourself
https://github.com/PYZR/ArmorChangeEvent this guy forked that repo you sent is saying he added the missing parts you need
alex also forked it
Oh then use his
apart from inventory click types there's also other ways to change your armor, like right clicking with the item in your hand or having a dispenser dispense it on you
Does the dispenser actually equip it though? I thought it just pops into your inventory like regular
Well the plugin claimed to fix all this:
The events handle when a player
Equip or unequip item in opened inventory through
Click
Double click (collect to cursor)
Shift-click
Drop item (Q)
Hotswap with hotbar(1-9) or with second hand(F)
Dragged item
Equip item through hotbar right-click
Equip item by Dispenser
Unequip when Player dies
Unequip when armor item breaks
But it might have broke with updates tho, since it's not maintained for 2 years.
Where can I find alex's version?
can i make an entity completely unkillable
?
invulnerable means its only damageable from players on creative mode
Trying to find it
@remote swallow you have it by chance? I cannot find it
ArmorEquipEvent for Bukkit. Contribute to mfnalex/ArmorEquipEvent development by creating an account on GitHub.
Idk why it's not popping up in his repos for me lol
were you searching his account or jeff media org
His account
oh weird
dam
laughs on object*
Managed to work it out, thanks @worthy yarrow & @remote swallow for the help !
cant you remove items from map while iterating through entrySet?
depends on what type of map it is
hash
then yes, but are you using Iterator?
no
doesnt matter
o.O
what if class has a method returning a collection, and a method for deleting an item? how do i iterate and remove items?
it would look like this
for (Item item : Clazz.getCollection) {
Clazz.removeItem(item);
}
can't you just do .clear()?
like i cant use iterator cause im callin the method to remove
in that case
In this example you listed, (which won't work), it appears you are trying to remove all objects from the collection
which is effectively the same as the clear method
yeah doesnt matter, i wanted to explain it
lets say there is some condition
and you dont just remove it directly from the collection, you remove it throuh the method in Clazz
or from Collection
so not
Clazz.getCollection().remove()
but
Clazz.removeItem()
Yeah
could you give me a code snippet?
i dont think so
they are talking about where you can't directly interact with the collection
yes ;-; thanks that was so simple to say
Oh I see
its fine
some of us have memory loss and know how it is when you can't express what you want to say in words because your brain is like nope not cooperating right now
It depends on whats inside Clazz.removeItem
But i'm confused, can't you just use Clazz.getCollection.iterator()?
and then use the remove function from iterator?
Take a look at the Java iterators
;c not really , im just trying to write it ..
You use it from Collection
but
then when you look at the current entry
show what you have so far
you must have access to the collection to remove something from it
import java.util.ArrayList;
import java.util.Iterator;
public class Main {
public static void main(String[] args) {
ArrayList<Integer> numbers = new ArrayList<Integer>();
numbers.add(12);
numbers.add(8);
numbers.add(2);
numbers.add(23);
Iterator<Integer> it = numbers.iterator();
while(it.hasNext()) {
Integer i = it.next();
if(i < 10) {
it.remove();
}
}
System.out.println(numbers);
}
}
example for removing integers less than 10
No, he's having this remove method in his manager class which does more than just remove the element
yeah
so whats the issue there
there's none, just explaining
the issue was that in 1 method im iterating, and callin method 2 which removes the item + does some logic, and i cant use iterator.remove cause i need to call the method
idk
Why don't you separate the other "removeItem" logic to a new method
like for example, if you're original methopd is
call the method before you remove it?
numbers.removeIf(num -> num < 10);
That's literally not the issue right now
hah
i dont care tho
yeha im sleepy
She's trying to create a custom remove method
That wouldn't work at all
ill look at this tomorrow i bet itll make more sensse
im she
oh
😅
i need to add my pronouns
wait does iterator edit the map ?
Sorry, that was my fault
like when i call Iterator.remove does it remove it instantly from the actual map
Yes
no whyyyy
oh so i can just iterator.remove, then when i would call the 'custom remove method' it would remove nothing , so no exception
Yes
No like the custom remove method wont remove anything itself
but it handles any other custom thing you want to do with the removed thing
okhay
So basically, you use the iterator to find the object to remove. Then you call the custom method on the object you are about to remove
And then you make the iterator remove it
okay i have another thing. i have like a set of black holes, and whenevera player gets close to it it should like suck it, i just iterated through every player and every black hole every like 5 ticks, and then added vectors and disabled gravity,also when player is not close to any black hole i gave them gravity back, but is it really inefficient ?
so its better to do hole loop in player loop, than player looop in hole loop cause its easier to check if a player is close to any hole right?
that will depend on what your datastructure is like
but its micro optimization unless there are a billion black holes or players
oh..
it wont matter unless you break early from the inner loop
so even if its 2000 players, 200 black holes, and im checking every tick is it still not so unefficient?
well its 2000*200 iterations (unless you break early) regardless of which way you loop
wdym
you said 2000 and 200
it depends on what you need to do to determine the velocity
in this case it would make sense to loop over every player, and get the commulative velocity that all the blackholes are putting onto the player
ohh
like the distance from a player and then you have some curve with fall off and whatever, and its like "how far is the player from every blackhole", and so how much force does every black hole puton the player, and then add those forces together and apply it to the player
this would make sense if player.setVelocity was very expensive
but it probably isnt
so then it goes back to it not mattering
essentially, with nested for loops, you want to minimize the calls to the most expensive functions
everything else order wise doesnt matter
wait so what should i do if there are 2 black holes nearby
apply 2 vectors or 1 sum vector
will that work ?
i think it would be the best to apply the closest anywayy
thats what I was saying with this
if you onyl want to aply the hole thats closest its a different thing
yeah i know
because then your first order of business is deciding how far each black hole is from the player
which would be harder to do
mm octals
Mm trees
when i did something similar, spawner activation range, for my spawners plugin (which is a little different because my players do have billions of spawners) i grouped the spawners into buckets and then only looked for spawners to activate within any buckets that a player was within or adjacent to
faster than an octree and kind of easier to implement
What’s the difference between a bucket and a tree
💀
Not that I know of
I mean hashmaps have buckets but I don’t think that’s what they meant
bucket is more like just a concept
its not an actual data structure or anything
like think about many buckets on a farm
and then each bucket has their own water
instead of having just one huge barrel of water
Yeah but what the heck does it mean in this context :p
essentially the difference between hashmap and treemap, with hashmap being a table of "buckets"
e.g. a chunk is a kind of a bucket
with an octree/treemap to get the value for a key, or in the case of the octree, the region encompassing the coordinates, you need to recursively traverse deeper into the tree structure in O(log n)
but with buckets you just perform some arithmetic on the coordinates and then query a hashmap with them in O(1)
I believe @ivory sleet mentioned chunk coordinates weren’t the best for hashmap keys
for what are we talking?
depends on what you're doing
its kinda nice when u want spatial locality
it's a fairly convenient type in that it can be represented with a long primitive
block used to be too but then mojang made worlds taller and we can't fit it in 64 bits any longer
are we mapping chunks from Z^2 to something?
i don't even know what we're talking about now
ye im lost as well x)
the original topic was searching for things near a given location
specifically black holes near a player
You can still fit blocks in 64 bits iirc

i know wg uses pr trees
you can, if the server admin doesn't crank up the world height to 1000
i dislike worldguard's data structure because every query into it allocates memory
beyond that i have no opinion on it
26 bits for X
12 bits for Y
26 bits for Z
suuure but someone can always increase it past 12 bits
You can’t
do you reckon there exists a better data structure for their use case?
making it not allocate memory for reads will be a better data structure
@/me4502 wg mentioned
The max Y with custom height is 2032 and the min is -2032
That just fits into 12 bits
did they actually set a cap on it?
Yes
i recall it being unbounded, is that new
Don’t think so
maybe i just misremember
Chunk sections are indexed with a byte, so you can only have 256 of them
i mean yea, but iirc there is a good reason for it
coincidental but convenient
though isn't the index added on top of a "lowest section index" which is an int
the functional height of the world is still 4096 blocks regardless but two worlds might occupy different height ranges such that you can't use the same bit mapping for both
granted that is pretty contrived
All blocks still fall between -2048 and +2048
Actually it appears you can go to +- 65536 but anything past +-2048 won’t be saved
F
loses my 65536 block high dirt tower
i don't see anything about bytes or structural limits in LevelChunk or similar
if the limits are related to saving i'll take your word for it, i'm not touching that shit
I don’t see why anyone would have a world that contains un-saveable blocks unless they were making a hyper specific minigame
In which case they can deal with not being able to address them in 64 bits
yeah it's probably not a practical concern
When do we get 96 bit integers
though by the same reasoning we could probably cut the x and z coordinates down to 20 bits as well, i think the game is already almost unbearable that far out because of all the floating point precision nonsense
longer
theres 128bit integers
just vectorize your things and you can have 512 bit integers
when do we get 128 bit integers
damn
im going to find a reason to compute using BigInteger in my plugins
though i don't think avx implements actual 512 bit wide multiplication or other full-width operations
i mean that's the register width but i think the operations themselves operate on its contents as vector lanes up to 128 or 64 bits or something
the bigger the parameters get, the more transistors you need for e.g. multiplication
it's something like n^2
I havent touched AVX explictly, but when I studied SIMDs it was sth about 512 being max, but thats fair
yeah you can have e.g. 8 lanes of 64 bits each
but doing multiply between two of those is going to treat the lane values as individual longs
to get back to the block long shit, what we really need isn't a 128 bit integer but value based classes so we can stop having to bit twiddle shit into primitives that aren't supposed to go into primitives
ah I see
Anything goes into a primitive if you try hard enough
even you?
01000001 01000011 01010100 01000111 01010100 01000011 01000111 01010100 01000011 01000111 01000001 01000011 01010100 01000001 01000111 01000011 01010100 01000001 01000111 01000001 01000011 01010100 01000111 01000001 01000011 01010100 01000001 01000111 01000011 01010100
Java devs were praying Intel to add 128-bit atomic load/store so Valhalla works out nicely lol
Presented by Brian Goetz - Java Language Architect (Java Platform Group - Oracle) during the JVM Language Summit (August 2024 - Santa Clara, CA).
_Project Valhalla wants to heal the rift in #Java's type system between classes and primitives by introducing value classes, which "code like a class, work like an int" and offer a flat and ...
Around 42 minutes into the talk
Nerds
The human genome is about 3.1 billion base pairs, there are 4 possible pairs (A-T, T-A, C-G and G-C) so you can store them using 2 bits
2 bits * 3.1 billion pairs is 6.2 billion bits or 775 million bytes
So you can store the human genome in about 775mb
what if we use qubits!!?
imagine how many human genomes you could store on dna
or whatever it was they started using
is marking method with throwing exception really that bad in java? i mean if im building a static factory method which does sql connection using jdbc i cant just expect to handle the errors by the static factory method itself, i feel that should be delegated to the factory class which returns an instance of generic database connection wrapper interface
runtime exceptions or other exceptions?
SQLException specifically
it can be a leaky abstraction if u for example write against a generic database abstraction
another thing says one gram of dna can store 215 petabytes
usually you can formalize ur own exceptions tho like
DatabaseOperationException, DatabaseConnectException etc
and then wrap around etc
but i like throwing exceptions in java- obv errors as value is nice, but it works out fine w/o in Java
The way it is done in Java allows for both models to work
You want to store a humans dna… on dna?
Genius!
i guess but i want to make a factory class which returns you any instance of repository
so its more of a utility method in this case
If you want the “errors as values” feel then you can add throws clause to every method so the caller has no choice but to handle it
yeah
If not, then you can choose to silently handle it inside of a try
yeah pretty much
i mean u dont achieve the equivalent but u can roughly cave out
Of course, exceptions aren’t as cheap as actual error values but the concept is the same and the difference negligible for most programs
twr -> catch SQLException -> crash the server
errors as values has the advantage of that u can subtype an error type on some type which contracts a non error subtype
if you have 1 gram of dna you can store 277 419 355 copies of the human genome
the good thing w exceptions is that u can enforce consumer to handle it, but control flow can become messy
Me asf making a try(Consumer<Optional<Throwable>>) 🤑
i mean yea but thats completely independent to modelling ur own exceptions
i think id cry if i saw this
Tbf if value types were a thing, it’d be a non-issue for the most part
We have try catch at home
try catch at home:
value based classes??
"functional enjoyers" 🤓
Is that what they call them now
Consumer is kinda not that functional at core
They change the name every 5 seconds
lmao
idk
value something something
and then identity right?
or whatever they call it
Null-restricted types and value based objects iirc
basically im wondering to do something like this
public class PostgreSQLRepository implements Repository {
...
public static PostgreSQLRepository connect(string hostname, int port, string database) throws SqlException {
...
}
}
and factory method
public class RepositoryFactory {
private final DatabaseConfiguration config;
@Nullable Repository get() {
try {
return PostgreSQLRepository.connect(config.hostname(), config.port(), config.database());
} catch (SQLException exception) {
logger.log(Level.ERROR, "Failed to connect to the database: " + exception.getMessage());
return null;
}
}
}
that way repository factory would be the last layer to handle the exceptions and to log them
no i forgot that's its a static factory method for each implementation
Not being able to connect to the database sounds like a fallible operation to me, I’d crash the program given retries don’t work out
Ig you just do that by checking whether Repository returned null
I believe you are supposed to gracefully fail
the java way would be to propagate a checked exception upwards
But a good old putInt(0,0) is more fun
but yea check null prob is fine
I'm looking for a fix plugin for crystal PvP.
I want certain blocks to automatically regenerate when end crystals or respawn anchors explode.
Is there any plugin that can do this, or someone who can explain the logic behind how I could make it work?
it’d be the more clear option code wise, it makes more clear why it failed but yeah
Either my program works or nothing will!!!
how so?
i guess i can wrap exception to something like RepositoryInitializationException with message that was logged inside logger
and throw it
instead of returning null
you mean that u can pass some sort of cause object along w the result if fail? (javier)
you're replicating c-style errors in that case
i hate errors
i mean yea we all do
they always ass to debug
Checking for null doesn’t make it immediately clear to the user or developer why it failed, meanwhile a named exception will contain relevant context information for the user and developer to debug the issue
oh you meant null
Just returning null ignores the context, yeah
ye then we're on the same page
what's that lib which has null safety that's standardised across different ides again
annotation library i forgot
checkerqual
whoever said lombok 
nah something else
💀
won't anyone help?
it must be jspecify they mean
i still dont quite understand checker
im getting back to java after a while
after using it for a while
i've been using .net for like half a year
NullAway?
like the polynull stuff
Oh they already answered
ye polynull is fkd tho
i still feel like java has better syntax than c#
lol
C# is enterprise kotlin
i just saw that java and was like what the fuck then realised the type is the start not the end
You have all the language features you want, but we still have BeanFactoryFactoryProvider
the kotlin has taken over
bro generics w checkers framework can get soo fucking messy
holy shit, dont even get me started
It's terrible
what do you use nowadays
do you use like some from all of them
all modules from checkers or do u mean annot lib?
oh I use checker + jspecify + jetbrains 
o lol
@UnknownKeyFor
@NonNull
@Initialized
private static final Logger LOGGER = LoggerFactory.getLogger(MCAV.class);
@UnknownKeyFor
@NonNull
@Initialized
private final EnumSet<Capability> capabilities = EnumSet.allOf(Capability.class);
@UnknownKeyFor
@NonNull
@Initialized
private final AtomicBoolean loaded = new AtomicBoolean(false);
💀
u wrote that or is it after type system compilation?
I mean yea thats fair
Why not use all the nullability annotations
Oh wait that’s just DeluxeAsyncJoinLeaveMessages
runs
dbeaver is such a gigachad software for databases
i love it it supports every goddamn sql database you might need
and its free
haha yea u bet there are
i wonder if im developing a suite of plugins for a private server should i develop database in monolithic approach where many plugins might connnect to the same database and schema or is it better to make separate users with certain permissions for each plugin and do 1:1 relationships between tables instead
PolyNull NonNull UnknownNullability NotNull NullMarked NullUnmarked MonotonicNonNull, EnsuresNonNull AssertsNonNullIf
@young knoll
like its crazy
fr :,)
and then there's the fucking initalization framework that nullness depends on
drowns
I'm looking for a fix plugin for crystal PvP.
I want certain blocks to automatically regenerate when end crystals or respawn anchors explode.
Is there any plugin that can do this, or someone who can explain the logic behind how I could make it work?
think about IDE developers
That fucks me up so much
Realest shit i ever seen
I don’t even understand the purpose of @UnderInitialization
I spend more time trying to fix the error than like make it work lol
i fucking hate NMS
iirc has to do with like idiotic stuff like what can happen in a super constructor, or when u initialize two objects together, or if u by mistake publish an object before fully initalizing it (concurrency wise)
that's it
Yeah
write your own server in minestom, after that you will love it
😭
You’re using mojang mappings right
that so depends
🤷♀️ I've never really messed with NMS before
id say monolithic is fine in the domain of minecraft
I'm trying to update a plugin to use a more recent version of the API but the methods have changed
Is it just random A’s and b’a
for most part
Yeah
no wonder you hate it
use mappings
No wonder why it’s horrible lol
?nms
It’s obfuscated
again, it depends™
I remember using control F to try and find the method that’s obfuscated…
or like a microservice w a very small set of services
but then as u grow and scale, u need to redesign it more and more to be less monolithic
for stuff like reliability, regionality and scalability etc
but different users provide more security
and you can revoke permissions for data that plugin shouldnt read
less attack surface
but who tf cares
im talking about sql injection stuff
or other vulnerabilities
that might expose the db
oh yea I mean sure if we talk strictly about authentication and authorization etc
or do u mean like cyber security?
but I dont think it matters whether u modularized ur monolithic architecture into a set of modules
from an attackers pov
not signficantly at least? (im not a cyber security expert but just assuming))
well it doesnt matter much since if attacker is already in the system you're already kinda done
but its just another obstacle
before complete pwnage
lol ye i guess thats true
the main point is that if you did lots of 1:1 relationships you can separate what plugin reads and writes strictly within a database and if somehow one plugin has vulnerability that exposes db to the attacker, it cannot read anything besides plugin's data
since you can just revoke permissions to read particular tables from that user
Thank you so much, this is 10x better than trying to look through the obfuscated shit 😭
something like unix users already do with packages by creating app specific users to read write only specific directories within system directories
for example on linux whenever you install postgresql, user named postgresql gets created on the system to give the permissions to read and write only specific parts of the system instead of giving it root access just for the sake of security
yea
hello guys, i would need help w setting up bungeecord + luckperms
I cannot do commands such as /send in my hub (1 of 3 servers attached to the proxy)
if anyone can help me just reply/dm
nvm fixed it
I am trying to do true damage ignoring armor except my player is dying twice
event.setDamage(0);```
declaration: package: org.bukkit.entity, interface: Damageable
I looked thru that
are you getting two death messages?
I want help in plugin to view players password in https://www.spigotmc.org/resources/loginsecurity.19362/
the passwords are probably salted and hashed so i don't think its possible to see a person's password
If you don't know what hashing is. It's a way to map a value to a different value without the possiblity to do a reverse mapping: hash(x) = y, but unhash(y) = ???
So you can only check if the user's password is correct, but you can't check what the actual value is
What you could do tho is logging user commands to store their password in that way
With the PlayerCommandPreprocessEvent for example
@fathom dirge its out of my brain
Well why do you need to see someone's password?
There is no valid reason... They forgot it? Reset it
Bro i dont want reset password in my server just give them old password of them
Thats not possible
Bro my friend did
He got password of people
In his server
With the same plugin?
What you're asking is probably not even genuine, you're probably looking to do something nefarious, and you wont get help for that here.
Ofc