#help-development
1 messages · Page 1126 of 1
AnvilInventory and really all the non block entities should only be obtainable from the correct subinterface of InventoryView, AnvilView#getTopInventory() returns an AnvilInventory, BeaconView#getTopInventory() returns BeaconInventory, etc.
after my initial MenuType PR is merged I'm going to work on moving forward with introducing a more advanced MenuType API and what you proposed. I really don't see an issue with it tbh
A little bit of education and proper documentation with the replaced methods will go a long way here
To handle custom names, there really should be a paramter added to the openInventory method that takes a custom name. The name is only part of the open packet
yeah agreed will be that way for inventories
I think the name of a chest inventory comes from the name of the block, so could set it that way, but its really unintuitive to do like Chest#setCustomName("name")
if it comes to this, it would be nice to have an utility method like ItemType#createInventory if applicable (that is, the ItemMeta is BlockStateMeta and it is a TileState/InventoryHolder?)
it applies to too few blocks for a shorthand to make sense imho
I was going to say the same thing but really how often would it be used
it would be more common for the people moving over this new way of doing it though
though that would also mean they would try to create shareable inventories by accident, given most people actually want inventory views anyway
also some blocks that have an "inventory" wouldn't "work"
I think it'd cause confusion
e.g. someone might try BlockType.Anvil.createInventory
and complain oh that doesn't work, when in reality they just don't understand ItemType.Anvil has no inventory
yeah, I can see people thinking it would work the same as the current Bukkit#createInventory when it really wouldn't
I have so many big PRs on my plates honestly the thought of not really having to do much but write some extra docs makes me happy.
incidentally, this is now a GREAT way for people to identify inventories. Add some PDC to the tile state, check the inventory holder's PDC
cause the inventory's holder will be a Chest or a Barrel or smth, and those can have PDC
all this should already be possible, its just about telling people to use it instead of InventoryType
would be nice if BlockInventoryHolder had direct access to the PDC
no, its not gonna be that
oh nvm thats in the inheritance tree, but you want TileState, not that
I mean, is there a difference
yes
are there any block inventory holders that aren't tile states?
composters (in spigot)
oh forgot that was even a thing
lots more in paper cause spigot doesn't use them correctly
yet another thing on my checklist 🥲 getHolder without the snapshot
can't decide in which order to do stuff
wonder how many things would break if this was made the default 
lol
I have so many Prs bending on ItemType actually being added to spigot
we'll see if it ever happens kekw
I thought ItemType was already in
or do you mean because it is still experimental
its not even in
its like we like half did it
and decided nahhh
I have no clue why or what the reasoning was
Commodore rewrites can always be improved as far as performance goes later, they're slow as fuck right now but like if you wanna maintain compatibiliy 🤷♂️
oh it is marked as @Internal
yeah.... :(
Once ItemType gets added, I'm going to try to remove Bukkit ItemStacks
Another big PR I have planned is removing Recipe classes
what's wrong with them
it's been forever since I looked at the recipe stuff, I did always know it was kind of a mess though
it makes adding API for recipes a pain in the ass
vs adding a builder method you need to add constructor legacy support and so on
literally just copying paper
don't need ItemType to do that
it would be ideal if both platforms have more in common, so supporting both of them is easier for plugin devs 😛
true but if I want ItemStack#create or something along those lines I'd rather cut the fat of materials
if its already legacy less I have to worry abo ut
clearly we're just annoyed by the same things xD
I'm curious to see if spigot or paper dies first with the exclusivity changes. i cant wait for my 20th year of plugin development when im building for WoodenSpout, the 3rd fork of paper finally fusing with the 2th fork of spigot
I'm just writing all my janky inexperienced code upstream from you 😂
heh, apparently not. We've got like a 2000 line patch fixing all the itemmeta stuff that's broken from components
O
I'm trying not to have too many PRs open at once
its annoying to rebase like 10 big PRs when they take ages to get merged anyways
I don't think either platform is going to die just yet, though it depends on the rate Spigot gets more contributors, Paper struggles on this part too
not in the getting more but rather, managing all of them would be better to say lol
Also the popularity contest. One major plugin getting popular could make one be favored over another
then again, if they ever hard-fork I do wonder how many people will stick with Spigot or Paper will suffer the same fate as Sponge
It won't die soon or fast, I'm not that worried
open source is hard without good processes to help maintain the motivation of the aspiring contributors, I've suffered with this as a project manager
I genuinely want spigot to improve because I use it. I feel like a lot of people just switch down stream where I'm assuming many things are fixed
more so with a software like Minecraft server platforms where people seem to be scared to even touch the codebase with all the patching shenanigans
which I can't really critisize anyone for if its already fixed why spend the time?
but idk I just find it more enjoyable to use this software and change what I don't like
as a dev I gotta say patching initially seemed a lot more intimidating then what it actually is
if anything it helps one to git gud
I'm still not a great dev I've simply graced the top of the coding iceberg
I think if I could allocate all the hours in my day to coding and getting better at it I would
I have a love so deep for learning that doing monotinous plugin development is boring
I rather be learning networking or something kekw
or atleast work on my java weak spots like ASM or heavy multi threading
I took a networking course and it's kind of crazy to think your devices do all this stuff so quickly
I had to do some low level networking for my embedded systems class, but its kinda boring
I wanna learn more about packets sending etc
We basically just learned about all the OSI layers
Kind of in depth
The course had cyber security in it, but it was just setting up passwords for Cisco switches and routers
You could make your own proto buffer
isn't a proto buffer just send stuff locally over a port
that's a fairly simple project no?
Not necessarily
Maybe
Hm
I'm pretty sure they're not restricted to the local network
then that's more complex because you need proper encryption
since you can't just load it out to be middle manned
I think it can be used for back end to back end communications
if you handroll your own encryption I can think that'd be a decent project
when it comes to the base of byte communication tho its not that hard
What did you mean networking then
Kinda mean higher level stuff vs the low level sockets
I probably couldn't handroll my own sockets though
so I could try that out
I met these developers who hand made their own protobuffer
They made a backend in Go to interact with the database
and would use a protobuffer to receive and build the data on the Java backend side
Yeah I still don't understand why they did all that
Team died in 5 days
They did all that because it was "more scalable"
making your own encryption is incredibly difficult
oh yeah definitely
those functions are insane
well other then optimizations or thinking how slow or fast it will be the most difficult part is making it so that it can't just be cracked within a short period of time
Someone can help me with messages bungee - spigot?
https://www.spigotmc.org/threads/spigot-message-received.662184/
Replied
Ok thanks
hey, how can i check if a player is right clicking an item in their inventory?
I have an expensive supplier operation and i want it to be done in an async context and then process he result in a sync context, does this make sense? https://paste.md-5.net/osubiwacur.java
is it legal to copy paste original functions from ender dragon code in spigot 1.8 where the code is obfuscated and uses SPIGOT mappings because I can just paste the whole code and modify it to my likings
seems ok, there's also an inbuilt method which is kind of similar https://hub.spigotmc.org/javadocs/spigot/org/bukkit/scheduler/BukkitScheduler.html#callSyncMethod(org.bukkit.plugin.Plugin,java.util.concurrent.Callable)
declaration: package: org.bukkit.scheduler, interface: BukkitScheduler
though thats more the other way
i still would have to call the get into an async block
so better straight up have a class that handles that no?
yeah your runTaskAsync method seems fine
alright ty
How do I specify the Audience for MiniMessages (Adventure)?
i can't find anything for spigot :(
u mean how to obtain an audience or?
yea
Do I shade adventure in my plugin or do i have to add the plugin to my dependencies and download a release?
shade
its kind of a dilemma for me. cuz paper servers don't require it
heyy
Connection Lost
Internal Exception: io.netty.handler.codec.DecoderException: com.google.gson.JsonParseException: Don't know how to turn
{"extra":[{"color":"yellow","clickEvent":"action":"run_command","value":"/friend list 2","text":"Next Page >"}]} into a Component
Back to server list
wth is that
Can you show your code?
That click event doesnt look right
Try and comment out the setClickEvent for a sec and see if it still happens
It’s giving invalid JSON
guys
Part 2: https://www.youtube.com/watch?v=WMTb_g6rsxY
New Instagram: https://instagram.com/real_nikocado
New Twitter: https://twitter.com/real_nikocado
Business Inquiries: info@nikocadoavocado.com
no way?
how
is this possible
im legit like
this gotta be like
naww
...
nikokado avacado
he lost 250 pounds
apparently
its fucking crazy
Hey is there any better way to get nearby players?
public List<Entity> getNearbyPlayers(Player player, int range) {
return player.getNearbyEntities(range,range,range).stream().filter(player1 -> !player1.hasMetadata("NPC")).toList();
}```
1.1m dislikes lol
player.getWorld().getNearbyEntities(player.getLocation(), range, range, range, entity -> entity instanceof Player player && player.hasMetaData("NPC"))
?
It only works in paper
It does not take supplier as a parameter
huh
*Prediate I mean
declaration: package: org.bukkit, interface: World
dunno what was added when
vulnerabilities, amazing innit
yes answer my question if u can
Anyways, I think this will do
public List<Player> getNearbyPlayers(Player player, int range) {
return player.getNearbyEntities(range, range, range).stream()
.filter(entity -> entity instanceof Player &&
!entity.hasMetadata("NPC"))
.map(entity -> (Player) entity)
.toList();
}```
Does spigot loop through every entity on the world if we do getNearbyEntities?
idk probably tries to optimize it to as chunk local
does not imply any of that
?
idk look at nms
could you hyphothetically load 3d models with block entities?
yes
they're "stored", when server is actually running what about then?
when they move their chunk status is changed then?
Afaik yeah
is that good or bad? i mean its prolly good
better than looping through every alive entity right?
Yeah
implement what
is it possible to get nearby players in AsyncPlayerChatEvent ?
Not async afaik
I've tried it but I get this exception:
java.lang.IllegalStateException: Asynchronous getNearbyEntities!
i mean if you need to mutate the event from the sync task, you'd use the sync PlayerChatEvent instead
TextComponent nextPage = new TextComponent(ChatColor.translateAlternateColorCodes('&', " &8[&d&m─>&8]"));
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/friend list " + (page + 1)));
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{new TextComponent(ChatColor.YELLOW + "Go to next page")}));
navigation.addExtra(nextPage);```
Here is a code and a new page appears on each click on the friends list.
Is it possible to disable the clicking action on the previous page when a new page appears?
There was a method but I forgot it
I didn't understand, can you explain a little more?
Just make the command use a session id as argument, keep track of the session id and invalidate it once it’s used
anyone know why my intellij is saying it doesnt know what JavaPlugin is
You havent imported spigot correctly
Are you using maven?
And have you run bt
didnt work
send the error
send the code
?paste
Guys what would be good usecases for redis?
Hmm, would it be a good idea to put minigame data on it?
Heard it's pretty dang fast since it uses memory for storing of data
What minigame data do you want to store on it?
I want to detect, if a player jumped / pressed space bar. But PlayerJumpEvent does not exist anymore 😦
How can I overcome that
You can use the statistic event
with the jump statistic
Do note that it can be spoofed by the client
Any other way?
wait until the next release (?
where they send key pressed to server
and how do you access that through the api
We could do a PlayerInputKeyPressedEvent and PlayerInputKeyReleasedEvent
And of course Player#isInputKeyPressed

what if I'm using a controller and I am not pressing keys?
how to check if player is hooked on fishing rod?
what if im staring at the screen?
Still nothing
public static Map<String, Object> yamlKeyToMap(ConfigurationSection section) {
Map<String, Object> map = new HashMap<>();
section.getKeys(false).forEach(key -> {
map.put(key, section.get("key." + key));
});
assert !map.isEmpty();
return map;
}
i've crated this method to put in map the key and value of the configuration section "key", but the keys are ok, but the values are null. How can i solve this?
{amount=null, material=null, lore=null}
"key."+key is nto going to be the key
just key
map.put(key, section.get(key))
however you could just return section.getValues(true)
Perfect finally a safe event to do sync db queries on
thx
Let the client send the entire keyboard state every tick so we can be sure when a key changes. And pad it out with some info about their OS and browser cookies.
Most browsers store their passwords plain text
Just ship those over too
Just incase the server needs it
PotionData is deprecated and marked for removal however PotionType doesn' allow me to give a player streght 2+, work arounds?
2+ meaning strength like 3 4 5 100
strong stregth is strength 2
come on there is gotta be a way around this, i doubt someone woke up and said "why have potionData when we can hardcode everything into PotionType"
You can set as many custom effects on your potion as you want
wait where
declaration: package: org.bukkit.inventory.meta, interface: PotionMeta
Those have to be custom yeah
You can even set any RGB color you can think of
setBasePotionType is really just a method to get exactly the basic potions
do entities like area of effect have it too?
iirc potionMeta is for potion items only
Yes AreaEffectCloud also has a addCustomEffect method
better if i share some code for more clarity also
so for AreaEffectCloud i can use addCustomEffect, SpawnPotion looks deprecated
both Splash and LingeringPotion interfaces are deprecated
I would highly recommend you splitting that switch, case statement up into several methods...
and i see no method to add custom effect there
yeah i probably will once or later
i didn't write most of that code lol
before it was worse
declaration: package: org.bukkit.entity, interface: AreaEffectCloud
Do you mean the actual thrown potion bottle entity, or the ItemStack in an Inventory?
You can set their effects by passing in a modified potion via setItem(ItemStack)
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/ThrownPotion.html i can just change the itemstack of the potion it is throwing maybe?
declaration: package: org.bukkit.entity, interface: ThrownPotion
ok yeah
ty
i would still have to check if it is a spash or lingering potion using instance of, still a better way to do it, unless there is way around that too
You wouldnt do that in modern versions anymore. The impact is completely determined by the underlying ItemStack. You would
unwrap that and check its type instead.
Hello, does anyone know, how i make a chest look like a playerhead to make a "mini chest"?
You would do it the other way around. Create custom behavior for your mini-chest head by utilizing the fact that you can store arbitrary
data in the PDC of the Skull block, and by checking events like the PlayerInteractEvent and BlockBreakEvent
That sounds like an idea, yes 🤔
thank you
I have a plugin that works on 1.20.4 (Java 17) but stops working once I update the server to 1.20.5 (Java 21). Is there a way I can change this to function on newer versions?
Here Is The Basic Console Output:
Enabling Plugin
Your Server Version Is Incompatible
Disabling Plugin
The plugin developer stopped supporting it a while ago and released the source code as well.
you know what'd be sweet
an actual stack trace
also #help-server if you aren't a developer
@young knoll MenuType time 😈
twas merged now I can really start cooking
✨ twas ✨
got a problem with "twas"
did the forgotten ' trigger your grammar brain
indeed I am hurt
I figured as much
time to upstream update it I guesss
mmhh, how do i store things in the skull?
i started like following:
class MiniChest(private val plugin: CraftedHorizonCBSystem) {
private val communityChestInventory = plugin.server.createInventory(null, 54, "Community-Kiste")
fun getMiniChest(player: Player) {
val head = headDatabaseAPI.getItemHead("71810")
val itemmeta = head.itemMeta
itemmeta.setDisplayName("§6Community-Kiste")
head.itemMeta = itemmeta
}
}
is this the right starting? and how do i use the PDC? never did that before
I think you mean its time for me to post a spigot thread on this API and farm more reactions
let the client send a copy of every disk and RAM for the purpose of checking if there are any cheating tools loaded
Make sure to do it every tick to see if they're installing cheating tools mid game
?pdc
Nah, the server sends a kernel-level anticheat to the client as a packet in the login state
ahhh got it, thanks
All console says about the plugin (Stonks) is that the server version isnt compatible
https://mclo.gs/YpDxReW
and tcp
and java
and jvm
and binary
and cpu
and alu
and semiconductor
and transistor
?whereami
no transistors here
frr
outdated technology
Nah I Use BerryByte And They Export COnsole To mclogs 😛
Just another host, Basically Another Bloom
Is there a way to edit the source code to allow it to function on newer paper versions?
Yes, so long as the source code is available and you have all the dependencies required to compile the plugin.
And actually know how to update it.
Alternatively, you could commission someone to update it if you don’t know how to do it yourself.
does any1 here have a public example of a plugin util framework thats built as seperate modules? so like a gui framework, command framework
Source Code Is Available and Ive been looking at it trying to understand what to update for a while, But thank you for the info
Is it on GitHub?
GrindingLevelManager glm = PL.getHashMap().get(player.getUniqueId()); anyone know why the return value of getHashMap() is null?
return levelManagerHashMap;
}```
private static HashMap<UUID, GrindingLevelManager> levelManagerHashMap;
That is declaration
^
wheres the initialization part
How could we know
shouldn't you know that
probably
Hey, that’s my question!
what would the initialization part look like
would it be in the GrindingLevelManager class or just in onEnable(0
?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! 🎉
this.levelManagerHashMap = new HashMap<>; kek
ok so added that now lol
It is indeed on GitLab
You got a link to it?
can i somehow catch multiple entities with a raycast?
I dont think directly
Oh, I think I know what happened. Paper recently changed how they report the version string and the plugin only uses the old method of detecting it.
you can start a new ray casting from where the previous one ended and filter out the entity that was previously hit
im doing that except im duplicating the raycast with filter
but im getting a stackoverflow idk why
You can also check the angle of your ray and calculate the exit position to start a new cast from there. Thats how i created piercing arrows.
PS: Just realized that this might miss if two entites stand insitde each other and one entity has a hitbox which is completely engulfed in the
original entity. So starting a new one right from the hit pos and aggregating the Predicate makes the most sense.
This just sounds like you are not filtering properly.
actually i messed up somewhere else
because i removed the loop and its still happening
yae and im breaking as soon as either cast or entity is null
im also adding the entity to a list and filtering based on that
Which looking at this it seems the only reason they have the version check anyways is for different sounds.
They are using their own impl for version sounds instead of just bundling XSound from XSeries.
(It covers all cross compat and all you have to do is update the dependency every once and a while)
return levelManagerHashMap;
}```
i got this to work and it worked fine but then i edited a different area of code and it decided to return null again anyone know why
private static HashMap<UUID, GrindingLevelManager> levelManagerHashMap;
this.levelManagerHashMap = new HashMap<>();
atleast yall aint dumb like me
- Dont make mutable objects static (especially not Maps, Lists, Sets etc)
- Never directly create getters for your collections. (Rather write code which mutates your collections instead of exposing them)
If you are making getters for collections make sure to return an immutable copy
And the only valid scenario for this, in my opinion, is either in debug code or encoding data
Yes, read-only views is the only thing you should hand out
nvm fixed it thanks
i was being dumb
it wasnt the hashmap that was null
it was the key
Nu uh, you better go back there and remove those static keywords.
Ill let it slip for now, but the next project you create better utilizes dependency injection instead of making everything static.
Ill remember your name.
yes
here's a hint:
We’re tracking your location as we speak
@vagrant spear The code responsible for it not starting isn't even needed. :kek:
So it is an easy fix.
good 2am everyone
Yea, the rest of this code seems pretty platform-agnostic. I wonder if this was legacy code that they just forgot to remove once they implemented the new system.
Hey how can I detect armor stand break event? somehow BlockBreakEvent does not work
AS is an Entity
Thanks
What was the fix for you?
I just ended up removing the VersionSound class and the corresponding check in the main class.
I also updated some of the dependencies for good measure.
Ill try that to the best of my ability 👍
say on skibidi
?paste
Anyone knows why EVERY freaking NIGHT at exactly EXACTLY at 7:30 (19:30) PM when i play in minecraft servers It start lagging ping.. 2000 + sometimes and 12000 ms... I have good pc and i don't think thats problem..
by the way. my internet is good. i don't have any problem with that. also in other games is perfectly fine.. only freaking minecraft
Same server?
every servers.
I'll say that i tried to deinstall minecraft and installed feather client. that was the first night that i got like 20-60ms . sometimes 200ms. and then the next night same problem...
likely your ISP altering routes to use cheap data at specific times
idk, it happens like the last 2 weeks??
if its alway at teh same time its most likely your ISP
run a tracert at a good time and bad time
yep, it comes 7:30 th esame second 1k+ ping
sorry, wdym?
ohh well wait a damn minute
I play 1.8.9 version now ( before 1.20.1)
Now my ping is good ?!?!
so i think is version problem??
Maybe the packet size changed?
For it to happen at exactly the same time every day it has to be somethign thats triggering on your PC, IF launching a different version can fix it
You might be able to use wireshark
i'll need to download it and to test it? i have never been used that before
Hi, i develop a plugin to create custom items. And i want to know, ToolComponent override Enchantements ? Because i have a item with efficiency 20 and it's work. But when i change de default mining speed in ToolComponent efficiency enchant doesn't work. I using 1.21
how can i get a zombie spawner as a itemstacK
ItemStack spawner = new ItemStack(Material.SPAWNER); ItemMeta meta = spawner.getItemMeta();
how to check if player has fishing rod hook in them?
EntityType type = EntityType.ZOMBIE;
BlockStateMeta blockStateMeta = (BlockStateMeta) itemStack.getItemMeta();
CreatureSpawner itemSpawner = (CreatureSpawner) blockStateMeta.getBlockState();
itemSpawner.setSpawnedType(type);
blockStateMeta.setBlockState(itemSpawner);
itemStack.setItemMeta(blockStateMeta);```
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
yo uwant to remove an item?
also we can't help you if you dont show the whole method for starters
method work but after adding item in player inventory item is not added (no errors just not added)
empty inventory
item just disappears
anyone who knows trick to where i can make a menu bar with text in an inventory
Can someone of you guys please develope a plugin for me? A plugin that would make me unable to pick up items except mobdrops. I think it wouldnt be to much effort but i have no idea. If someone has a bit of time that would make me grateful
?service
wdym
?services and i believe you have been told that already
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
To post in that section i need to make 20 posts and my account needs to be 1 week old. Dont want to wait that long
check pins in general then
Someone have an idea ?
While you're waiting a week you could probably just learn to make it yourself instead of paying someone
Sounds pretty simple
org.bukkit.configuration.InvalidConfigurationException: Global tag is not allowed: tag:yaml.org,2002:org.bukkit.GameMode so uhm, spigot saves it and then cant read what it saved?
what are you pushing to the config?
so I save a bunch of fields
one of them is a gamemode field
then I retrieve that config
change one value (not the gamemode one)
try to save it again
and it throws this.
do you save to string or the enum value
enum
to string it
when
before you save it
when you call set() set it as a string then load it with valueOf
yeah ik how to
not sure whats the point of allat tho lol
ohh, is it because im saving null?
wait no
I aint even saving null
you can't save an Enum
💀
none of the enum are config serializable
so you save the String of the enum
welp alright
why r like all enum classes missing on 1.21 spigot server
update IJ and use java 21
updated ij so ig it’s a java issue
but i seem to remember trying that and it not working
I have a task that absolutely 100% has to be done async, since it's fully blocking and will immediately crash the server if done on the main thread (if it matters it is a MongoDB change stream listener). Basically I'd like to somehow have the async thread say "hey something happened!" and the main thread say "okay!" and do stuff on the main thread in response.
My only idea for this is having a flag that is checked every tick by the main thread, so the async thread can set it and then the sync thread would know something happened. Is there a better way?
but you cant access the main thread that way, no?
with the scheduler, yes
how would i either create or update a sqlite record based on data already existing or not
datapacks stuff
what
spigot jar?
server jar
maven w intellij if that’s what ur asking
?paste your pom
Make sure IntelliJ is updated
version of what
intellij
worked great thanks again :)
make sure to update ij
i have
2 years out of date
💀
yeah current version is, like, 2024.2.1 or something
What
yeah just what
vollx absolutely stoned rn /hj
If you make a variable, that's non-volatile and update it from one thread, what defines when other threads will see that change?
it just won't update on other threads
it won't
I've observed it many times
or well, better: It is not guaranteed for the update to be able to be seen by other threads
the JIT may optimize it away or optimize things because it knows it shouldn't be altered by other threads, the JVM itself may just not allow for other threads to change it or may even make different copies per thread, it's up to the JVM if you don't define volatile
Well I'm asking, because I've forgotten to define volatile from time to time in an environment where, for example, two threads read/write on a single var
And only noticed it after some time
Thus my question of why it worked
I believe it’s CPU dependent
Here’s a read on it
He looks very scared
What does he see out his window
.net
choco
His wife doing the gardener. I've seen it.
When reading this I remembered another thing
while (something) Thread.yield();
Like I get it, you signal a hint to the cpu that you're willing to yield the usage of the current thread
But when exactly should this be used?
And is timed waiting more efficient or is it just for different situations?
This is why immutability is pro
But I’d understand it’s not always possible
...but you can't always have that
Actually not necessarily for example you could always create a new object like String
But ig many people still don’t choose to try to make their stuff not as mutable
And also, when should Thread.onSpinWait(); be used?
Ah yes
Now create a counter
You can’t always have immutability as said above (or you can but it will be too inefficient), but the better option in this case is AtomicInteger which would help maintain the state across different threads
And what do you think AtomicInteger does?
It has a mutable, volatile int
Yes it’s just a mutable integer volatile
I do
wasnt that an easter egg once?
I'm actually upset by how many people don't do it
i remember there was a comment on it
Even packet events
In their src for reflections
Everything is mutable xd
i mean Thread.yield has more scheduling overhead than Thread.onSpinWait
so prefer the latter if youre doing a spin loop
Worse for performance and more potent to bugs
literally a loop that eats your whole cpu core if you dont insert a pause instruction in there or yield the thread
// modified by another thread
volatile int flag = 0
while flag != 1 {
// loop
}
will eat your core
The heck is onSpinWait
so you can insert a Thread.yield or Thread.onSpinWait in there
the latter got recently introduced
I've only ever seen ForkJoinPool use it
I normally do while (!condition) { sleep(x) }
I think it was outside any loops
as a better alternative for yield, which induces more os scheduling overhead
Uhhh
Like sleep(0)?
Also, how do you wake up a sleeping thread?
onSpinWait explicitly hints the cpu that a spin loop is occuring
and that it should not eat the core
fun open(
player: Player,
callback: (T) -> Unit = {},
) {
GlobalScope.launch {
inventory.open(player)
while (selectedItem == null) {
delay(100)
}
callback(selectedItem ?: return@launch)
}
}
hehehe
No you need to sleep a positive amount
wait and notify?
I meant a constant sleep
Man hasn’t heard of completable futures
man hasn't heard of coroutines
Never had to use those
kls moment 🗿
Co routine?
Object::wait and Object::notify
Like Object#wait and Object#notify
More like no routine
some people have routines
we are not those people but they exist
man hasn't had to mix weirdass coroutines with weirdass thing
Yeah, how do these work?
i might be wrong on this one
Does anyone have that image with the staircase code and the Hadouken
Who’s code
well lets say it the simple way, wait blocks the execution of some code and then notify is supposed to be invoked from another thread on that object to resume execution again
i feel like by having received that comment i should not be saying whose it is
listen man
sometimes you gotta do what you gotta do
i can share the entirity of this class if anybody wants to see some shitty cursed code
Ohhh
That's pretty simple
Why does Object implement it tho?
Would a specialized class be better?
but a thread may sporadeously (dunno if this word exists) awake from a wait call
Why tho
Why does a builder look so bad in Kotlin
:(
Or is that just trash formatting
trash formatting
LockSupport.park also has that problem
fucking ktlint shit
os scheduling related or smth, idk
it hates lines longer than like 2 characters
what kind of shit is that
My builders look like
ItemBuilder.of(material)
.name(name)
.lore(lore)
.etc()
.build();
item(Material.BARRIER) {
name = "egg"
}
buildItem {
type(material)
name(name)
lore(lore)
...
}
wtf is this C#
what
Smh
no this is kotlin
builder thing
fun buildItem(block: ItemStack.() -> Unit)
You can do this type of thing when constructing an object in C#
it's legacy code tho so i'm never touching this again
good for you
Never seen with before
oh ye
f string?
?
the comment
okay but at least have it be an fstring and not a moneystring
ive dealt with more awful stuff
configMenu.AddTextOption(
mod: this.ModManifest,
name: I18n.Config_AmPmPosition_Name,
tooltip: I18n.Config_AmPmPosition_Tooltip,
allowedValues: Enum.GetNames(typeof(AmPmPosition)),
formatAllowedValue: this.TranslateAmPmPosition,
getValue: Config.AmPmPosition.ToString,
setValue: value => Config.AmPmPosition = (AmPmPosition)Enum.Parse(typeof(AmPmPosition), value),
fieldId: "am_pm_position"
);
You can also do named params
kotlin can too
The ones you don’t specify need to have a default value tho
kotlin can do that too
make it lua and do
configMenu.AddTextOption {
mod: this.ModManifest,
name: I18n.Config_AmPmPosition_Name,
tooltip: I18n.Config_AmPmPosition_Tooltip,
allowedValues: Enum.GetNames(typeof(AmPmPosition)),
formatAllowedValue: this.TranslateAmPmPosition,
getValue: Config.AmPmPosition.ToString,
setValue: value => Config.AmPmPosition = (AmPmPosition)Enum.Parse(typeof(AmPmPosition), value),
fieldId: "am_pm_position"
}
Hello, I have a plugin, it is a chest plugin, I arranged the contents of the chests and it is renewed every 10 minutes. The problem is that this plugin has to be personal, just like the ender chest. Is there anyone who can help me with this?
for anyone searching this discord for information -- yes, the cookie-based kicking issue is fixed now, using the same workaround I ended up patching into papermc manually (not ignoring kicks triggered during login phase) https://hub.spigotmc.org/jira/browse/SPIGOT-7876
@azure zealot since you were also asking about this ^
yes i reported that issue
yes
I'm making a ridiculously generic transfer plugin, one that uses JWTs and has an API to register transfer handlers (to handle transfer initiation commands triggered via command or API, and to accept the transfer at the other end), and middleware (functions that generate and tack on additional JWT-signed cookies pre-transfer, and handle extra cookies at the destination)
so I'm curious what others are doing
its not finished or something i just did it for fun
i encrypted all cookies with a private key
that every backend server knows
What are you sending via cookie
whatever data you want
no it cant
Encrypting it is an interesting idea, but it’s still not perfect
You just gotta break the encryption
as long as it's authenticated encryption it's probably fine
if you break the encryption you get kicked lol
because of invalid cookie data
What makes it valid
that it cant be decrypted right
JWT isn't perfect but I plan to use java-jwt to simplify this aspect of it -- each server will have a private and public key, public key is used to verify transfers
it is server bound uuid bound and timestamp bound
the cookie expires also after 10 seconds
its secure
Still, if you manage to break it then you can put whatever you want in as long as it meets the validity checks
Easier just to send the data directly to the other server
you cant
its encrypted lol
what do you mean by break it?
do you have any idea of how crypto stuff works?
bro are you slow?
client has cookie, client figures out how to decrypt cookie data, client waits for next cookie client changes cookie data and server doesnt notice cookie data is wrong
bro wtf
you cant decrypt it
yes you can
if the server can decrypt it so can anyone
i also can say i can crack the mojang private key and verify sessions i generate
wat, the server can decrypt it because it has a key
its the same with my encryption
your point is invalid
bro is in 1848
and thinks encryption is pattern
bro has a nasa pc
it's AES, the CIA uses this algorithm to encrypt top-secret data
There’s no point since you can skip the middleman and send the data directly to the other server
and can break encryption
you can do it
but you can also use the cookies
its equaly secure
2 transfers is technically still less secure than one
just dont shit talk me with invalid points like "no dont do that with a quantum computer you can crack the encryption"
!??!?!?
is that implementation using authenticated encryption though? if not, it's vulnerable to getting corrupted and opening up the door for rare attacks (that will probably not be feasible anyways)
can't tell if it's authenticated because I'm not familiar with java crypto functions
only the servers have the key to decrypt
spigotmc discord live comedy
yes but the bytes could be modified to produce attacks based on corrupted data
if it isn't authenticated
oh god corrupted data
bro knows the base concepts of encryption
security, authenticity, integirty
that's the only attack I can think of, though... so it's really fine
server crypts data -> sends to client (client stores it) -> client sends to server -> server decrypt data -> server verifies the cookie header for player uuid expiration time and server the cookies was created for
you cannot corrupt data like you think of, that's not how encryption works
if you corrupt the data it will fail, if u remove blocks it would fail
in encryption without authentication it's definitely possible. Like, modify one byte and the rest is garbage data
yes the server tries to decrypt the data
broken data
hammer it with many attempts and it could stumble upon valid data
if u want to be sure then add a hash
ye
bro its an invalid point again
it should be fairly easy to add this
Hello, quick question, are chest boats unable to be spawned via Bukkit/Spigot?
should not be needed
they can be, what specific issue are you facing
I'm "revamping" some code on Skript, and for some reason chest boats are not able to be spawned. Someone told me to come here and ask to make sure,
you could do it for an extra layer of security but it's very unlikely that there'd be any data that might be seen as valid
I mean... it's fairly standard to protect against this attack whenever possible. Old SSL/TLS is considered utterly broken due to implementing this wrong
what happens when you try to spawn them?
Nothing happens, they just dont spawn and nothing in console
okay i will add a checksum or something
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/ChestBoat.html are you using this
declaration: package: org.bukkit.entity, interface: ChestBoat
they're using Skript
oh
skript is so much harder than java
doing a quick search, this is probably a sane implementation https://gist.github.com/patrickfav/7e28d4eb4bf500f7ee8012c4a0cf7bbf
just use AES-GCM as it has authentication
yeah above gist is aes-gcm
ah
thanks
dont even know why it's not a standard for every encryption-kind
any new use of symettric encryption should most likely be aes-gcm these days
so if you use java's AES impl is it AES gcm?
no, java has lots of aes types
oh i see, thanks
I think the original code is just plain AES
if you know what the data should look like and what gets stored you can definitely break it
you just only need to store a large enough data AKA rainbow table
you mean with plain AES
the reason AES-256 or most encryptions are secure is first not knowing the key but the second is that you don't know what the data is before hand
i dont know the exact internals of AES, but for me it seems that it's chain based and that the bytes are dependant of the previous ones
so I think you cannot craft payloads yourself that easily
but if you know the data before hand or even most of it, you can determine how to decrypt, this is why in the military changing keys is a frequent thing. Depending what is being encrypted and its purpose keys change pretty much daily or weekly
you can also change the key in the plugin daily if you want to
which should be recommended if your goal is to be top notch secured
proper nonce usage avoids these issues, doesn't it?
i want to be reasonable secure
i dont need to be above military standards
right you don't need to be it just all depends on what the data is and its purpose
and why someone would even bother with it
but having the public key of a keypair faces the same risks u are mentioning now
its minecraft plugin data lmao
no having the public key is not enough otherwise HTTPS would be useless
i am not sending my brith certificate via minecraft cookie packets
it can be cracked
so its alright
but how would you determine how to decrypt the rest of a data where some parts of it are known and some of them are unknown
two way authentication is different from one way
so would you say if you put the timestamp & uuid which are known data into plain text and sign it with the key, would it be more secure?
two way authentication isn't meant to keep the client out of the loop instead its to keep other devices/clients out of the loop between the client and server
JWT + JWE really is the way to circumvent all these complicated decisions... well, as long as your library disables all the cursed algorithms, such as null digest and null cipher
lol
!?!?
yeah i see the point but why
if you could just encrypt + sign it
only if someone can't just arbitrarily sign it or copy the signature to another thing
harder to make mistakes, standardized across many programming languages that implement the same JWT standard
how would he be able to arbitrarily sign it
the private key is not leaked
and reuse isnt possible too
well you are talking in a broad sense
java -> java!
not all algo's or methods are ideal. Hence I said as long as copying the signature to something else isn't possible
then yes
one might wish to write a minimalistic transfer server in a language other than java
idc
but, I don't see why you need the data in a cookie to be secure though
if security is what you need you would store that somewhere else not on the client
my implementation will also have "open ended" transfer handlers that either only handle accepting transfers, or only handle initiating transfers, with the idea that it could be interoperable with something else
but you can store it in the client
it's not that we are putting it in a cookie to be secure
we are putting it in a cookie to put it in a cookie
and
encrypt + validate it to be secure even tho it's in a cookie
we just want the data to be in the COOKIE!
then what is the usefulness of encrypting it?
thats why!
clients dont need / shouldnt have read acc the data
the client should not see the data
and what harm would come if it does?
how knows what data is tsored inside
could be anything
so it should not be readable
it's just for the server to ensure data is just stored over one session
and it should still be secure
most transfer cookies will be rather mundane, like just specifying the coordinates and world you end up in, so a signing-only scheme would probably be fine
if I am not mistaken the cookies don't persist
but in theory it could contain something sensitive
that's the point
yeah that's what we want
if you're transfered they are
we want the cookies just to be on a session
and cookies are there for a storage over a client session
so we can ensure the data is only available as long as the client is in a session with the server
and it shouldn't, this would be quite dumb
if you would want to store any persistent data you would need something like a db
the protocol already ensures this
why if its secure enought
yeah thats how the protocol works
and thats why we use it
we want to prevent spoofing / clients accessing the data
so far neither have made really good arguments for the encryption
yes
why would a client need intel to server intern data
that's just a security flaw
and you would leak internal operation procedures
its a security flaw already that its in a cookie
nah
not realy
well neither of you I would accept as experts in security or encryption
so I will disagree with you
tell me a way to spoof ur cookies without bruteforcing for 200 years or having a nasa pc on our current systems
but there's just no possibility of it ever revealing anything if it's been encrypted (properly)
if its insecure proof it please try to crack the cookie spoof the cookie data on my test server
so why not treat it as a secure domain at that point, for the rare things that do need a stateless transfer of some sensitive state
as far as you know, anything that goes outside of your system you no longer have control over and anyone else is free to do as they wish with it
You could just have the client send nothing back when asked for the cookies
That would be interesting
in that case you cannotz login
and will be kicked
so we go for AES-GCM just to make sure that noone tries to do some bruteforcing and achieving almost nothing with it
Then how do you connect the first time
^
(the reason this seems useless... is that it's really hard to think of something that is both sensitive and benefits from statelessness / no centralized database to manage things)
Since when first logging in you’ll have no stored cookies
allowed servers / lobby servers
you need to join through a server that allowes that
well the cookies disappear anyways
unless we talking about transfers
please look at my implementation
there you can see how its verfied
so you dont need to question everything anymore
I guess at that point it’s basically just a proxy without the proxy server itself


