#help-development
1 messages · Page 1171 of 1
A moderator on fabricmc discord helped me resolve this
It would be required since those are modifications to the hashmap.
They would run into a ConcurrentModificationException if they are modifying the same map on different threads at the same time.
from what gpt told me no exception occurs
It only occurs if I iterate through the hashmap, but I would just use .get and .put
why better
so should i use sychronized
Maybe you should read the javadocs....
Instesd of relying on chatgpt
then help me
Note that this implementation is not synchronized. If multiple threads access a hash map concurrently, and at least one of the threads modifies the map structurally, it must be synchronized externally. (A structural modification is any operation that adds or deletes one or more mappings; merely changing the value associated with a key that an instance already contains is not a structural modification.) This is typically accomplished by synchronizing on some object that naturally encapsulates the map. If no such object exists, the map should be "wrapped" using the Collections.synchronizedMap method. This is best done at creation time, to prevent accidental unsynchronized access to the map:
Map m = Collections.synchronizedMap(new HashMap(...));
The iterators returned by all of this class's "collection view methods" are fail-fast: if the map is structurally modified at any time after the iterator is created, in any way except through the iterator's own remove method, the iterator will throw a ConcurrentModificationException. Thus, in the face of concurrent modification, the iterator fails quickly and cleanly, rather than risking arbitrary, non-deterministic behavior at an undetermined time in the future.
Note that the fail-fast behavior of an iterator cannot be guaranteed as it is, generally speaking, impossible to make any hard guarantees in the presence of unsynchronized concurrent modification. Fail-fast iterators throw ConcurrentModificationException on a best-effort basis. Therefore, it would be wrong to write a program that depended on this exception for its correctness: the fail-fast behavior of iterators should be used only to detect bugs.
then when sychronized is used lol
use a CHM
sychronized is making the thing accesible by one thread
at a time
its slower
pls just use concurredhashmap thats it
We love concurrent hashmap
concurrent hashmap gang
You do realize that is a direct quote from the javdocs itself. Not even gpt generated.
i wasnt talking to u
lol
Don't care
ok
Don't be stupid
dawg at least be respectful
Can you explain in your own words, please?
Its the javadocs.
If you cannot read them, thats a deeper problem
i will not always be here to re-transcribe the entire library
Can you tell me or not?
I can but I wont
If you knew you wouldn't have gone to Java Docs to help me
okay
tbh in this case I'd rather use the official explanation than my half-assed understanding of it
If I have a cache (hashmap) and I only do cache.put and cache.remove but both of these operations are on different threads, do I need to use concurrenthashmap or is the hashmap enough?
You need to use a thread-safe collection like ConcurrentHashmap
Using a concurrenthashmap will fix your problem, that's the simple answer. If you know what you are doing, then you might try alternative solutions, such as synchronized
But if using hashmap, no ConcurrentModificationException occurs in any case
you're not iterating the collection so no, it won't happen
But regardless of that the map isn't thread-safe and shouldn't be used in a concurrent environment
Because its internal state might not be accurately reflected in your put/remove calls
There's a reason why ConcurrentHashMap exists and it's for scenarios like yours
And when should I use Sychronized then?
is when the runtime doesn't matter ?
But what is prioritized is the use of processing?
Assume this is a movie theater and you have multiple people coming in and buying tickets at once
A synchronized collection would basically consist of putting everyone in a queue and processing one person at a time
A concurrent collection would consist of just having multiple ticket booths
The synchronized collection has the benefit of processing in a "first come, first serve" basis but loses on performance
the concurrent collection might process batch writes better but comes at the drawback of bigger complexity
most readable java stream
return new Recipe(
UUID.randomUUID(),
random.ints(25, 0, 255).collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append).toString(),
random.ints(random.nextInt(1, 11), 0, 5).mapToObj((i) ->
new Ingredient(new int[]{i, 1}, Registries.MEASUREMENT.random(random).orElseThrow())).toList(),
random.ints(random.nextInt(0, 5), 0, 1).mapToObj((i) -> random.ints(random.nextInt(100, 150), 0, 255).collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append).toString()
).map(Instruction::new).toList()
);```
wtf
like what you see 
wtf is it even doing
dont forget to sprinkle in a little aighneagohneaoghnuanuigf
where in the .m2 folder are the remapped files supposed to be going
i need to make a gui, that is editable, its one gui for server, so it should be not possible for 2 players to edit it in 1 time probably, if i do a boolean, and makeit true when someone opens the gui, and make it false when someone closes it, is it safe? are there no like cases when it wont work?
probably... its hard to imagine for me i need to make sure
.reduce :sadge:
if a players game crashes maybe but not sure if the close event is triggered then, you'd have to test
i think when he leaves its just close event
why crash? he can just turn of
also, will onDisable always happen?
is it safe to get data from config at onEnable() and save it back at onDisable() ?
just save whenits changed
cus it wont be cxalled if server crashes afaik
?
ill figure it out i need to test it
whenever summoning a nether star can i set it so it can't be burned or destroyed?
because currently i get this... 1.21.1 also is there a way to summon the item and drop in single spot, not in the diag spot it did lol
ok so if i have global inventory when should i save the items from it to config? every click event? every close event by any player (they can have it opened at the same time)
i think every InventoryCloseEvent is okay
should be right
I'm going to lose it
not once in my miserable life has this maven remapping bs worked properly in the first try
nothing ever works correctly
it doesn't recognize that the remappings are installed, it doesn't recognize updates, it can't find remote repos, it can't upload to remote repos, it can't resolve versioning for local repos
it categorically can't resolve anything if two plugins shade the same codebase but with different versions
how do i get actual distance between player and a block because normally player.getLocation().distance(block.getLocation()); returns location between player and a corner of the block.. ;c how do i get it from the middle of the block
subtract or add .5
yeah something like that
anyone
thanks
idk what that nether star shit is
i'm trying to figure out a way to make nether stars invincible to lightning bolts
but i just want to do for the specific item i summon...
i was hoping
idk lol
There’s a setFireproof on ItemMeta iirc
Otherwise I think you’ll need to use events and pdc
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
??
Ah it’s setDamageResistant now
You can even set it to be resistant to lightning damage
I'm using 1.21.1 so it's still ItemMeta#isFireResistant()
why is it fire if its damage
Weird that the damage resistant component only takes a single tag and not a list
I guess you could make a custom tag but still, kinda meh
Awesome that worked perfectly now i just need to figure out a way to drop it perfectly centered in the pentagram so when i set the gravity to false it floats straight up
I've tried dropItem and dropNaturally it drops and then floats diag
dropItem and set velocity to 0 mayhaps
where can i find the java docs for 1.21
?jd-s
How can I tell if a block is a #minecraft:crop
Check if the Block’s type is Material.CROPS
the only one I see is Legacy Crops but its depreciated
Ahh ya, are you wanting wheat in specific?
Just like the basic crops youd get "Carrot, Potato, Beatroot, Netherward, Wheat" I think thats all the ones that grow from seeds and are harvestable
Ima prob just make a list tho seems easier lmao
BlockData for Ageable
No problem, I’m not sure what other blocks besides what you stated Ageable includes so depending on your use-case might need some tweaking
yeah, I think ima do a list in the config and make a tag system so people can choose if they want all Ageable or just certain ones, prob a blacklist too
pretty sure blocks have tags
from what I could see in the Block Data for the weat I couldnt tell it but in minecraft they do have the #minecraft:crops tag
Oh... Ima have to learn more about tags. Thank you
is there any way how to add in-build shaders (post effects) to player via plugin, I managed to do it by mod, but is there any way via plugin?
aren't they just part of the resource pack
if so, you would just send the resource pack to the player
that said, I wouldn't personally recommend doing that since it sounds performacne heavy
yep, but it would take some time when the resourcepack would load
in the mod I could switch it instanntly
alright, thanks
that said, as long as you do it in the configuration phase, it is probably not noticeable at all anyways (well, beside from the prompt)
alright, maybe I could give the player mod that would listen to the server when to switch the shader
sure, that works. If you have a mod on the client then you can do pretty much anything really
i heard someone talking about timer in the resourcepack, so on specific world time the shader in resourcepack would enable
most people don't opt for that since it artificially limits the reach of the server by depending on mod loaders and what not
Uh, I'm aware resource packs can have conditional properties like that but I'm totally not informed as to how these work so can't help you there
i am trying create some plugins for my server, because my friends said it is better to dont install any mods
it depends tbh, say, there's mods like proximity voice chat which you do want to have, but if it is just a cosmetic mod then the user may think twice before installing it
if there's no gameplay value to it, it isn't worth the hassle. This is why people do modpacks, since it's easier to get the users to install a tons of mods without thinking twice (except when it starts affecting performance heh)
then again, I do believe most people do play with some kind of performance modpack nowadays so it isn't as much of an issue
there's also the rise of launchers like Prism which make it easier than ever
or like tlauncher, I could create modpacks
tlauncher 💀
I know I dont trust it either
just use Prism, that's the best there's around
I had it installed, but not all my friends bought minecraft
unless you play in offline mode, I don't know what launcher is popular for that nowadays tbh
offline mode mostly
-# shh don't say it out loud or people are going to bully you here
yep, I was once bullied on some mc moddin server for using mcreator :d
I gtg
is there a way to prevent player dater saving at all in a server
Eh
People usually say syntax is cleaner
But i wouldnt recode everything just to switch to kotlin
if they dont know java i gess
How many nulls do you have
I would do it for the experience
jspecify :>
you'll never know if it is any better if you don't actually try working with it
those are really menial things to worry about
when your code base is big enough, this is the least of your worries
?
then again, if it annoys you, just give it a try and see how it goes
this start annoying when you do same code again and again loop annoying cycle
especially on big projects.
it's no small thing on the bottom line
it really is
in the end it's just lines of code, for which most are auto-completed by your IDE
You don't have to oversimplify things
if you feel like verbose-ness isn't your thing, then go ahead and use kotlin, you'll probably have a better time with it. That said, the repeating part isn't the issue with verboseness, but rather the mental overhead it may induce
I for one find it good to keep consistency across a code base, which I honestly cannot get with kotlin. However when just prototyping kotlin feels 10 times better as it has a vast amount of utility functions which once you learn, can keep a good chunk of code very compact
does kotlin support java libraries?
yes, kotlin has good interop with java
same goes for the vast majority of JVM languages, since a good chunk of being a JVM language is taking advantage of the JDK itself and its huge ecosystem (i.e. Spring)
Too bad there are fewer jobs than java.
Eh, I wouldn't say that is the case, kotlin has a pretty good market within the android ecosystem
then you don't want anything to do with kotlin or java lol
well, not quite. They're both good backend languages, Java definitely has an edge when it comes to jobs
I made it up. I will use both java and kotlin lol
i hope this not will be problem in furture
I mean, if your goal is getting a job, it might be
ultimately what will help you get a job is building actual products/services so that you have something to show off
I'm mean about knowledge issues.
they're both JVM languages, they share a lot in common
well, Kotlin does branch off when it comes to KMP but it is still essentially the same
nice
Is it possible to get the crop from the seed? Like say I have WHEAT_SEEDS but the crop (block) is called WHEAT is there a easy way to get this through spigot or would I have to make a look up table?
Note: I plan to do this for all crops (ex. beetroot, carrots, potatoes. etc.)
Block.getDrops or something maybe? Idk the exact method name
nvm if u have the crop and need the block then idk
is NMS ok for you ? or only bukkit api ?
I haven't messed with NMS yet, however, I realised that I'm dumb and the way I was storing the data allowed for me to just access the crop part too :/ 🤦
Hello, how would I enable legacy pvp on 1.21?
My idea is to remove attack cooldown of weapons.
Give items in my plugin legacy attack/protection values. Is that all? The old sword animation doesn't metter. How about ciritcal hits? Do they behave differently?
i dont thinks so... there is a plugin that disables the new pvp system ^too
just use OldCombatMechanics
The thing is... I have a minigame already made... I cannot integrate it
Ok so specifically if I buy armour or weapons from my shop, will they automatically behave like old ones.
it should yeah, but try it out and see how it goes
you're better off making your plugin compatible with that one rather than dealing with bringing back all of these shenanigans by yourself
would it be unsafe to cast this? i dont really understand why it doesnt like this
bukkit api has "scared" function for mobs in 1.20?
should gethealth return absorption hearts?
im running 1.8.8 so its not avaliable
outdated
?1.8
Too old! (Click the link to get the exact time)
thats when minecraft was good
you mean empty, no content, to play a cool game you needed like 126 mods and the fps dropped to 10 ?
Wasn't that when you could crash servers with an anvil ?
Yeah, def good.
1.8 being good is hard copium
BlockPhysicsEvent ?
I turn on the lamps but the trapdoors get opened because they're powered by it
hmm
ty i'll try
How do you power the lamp ?
Via the API or just normal redstone stuff ?
with the api
I synchronized the server time with realtime and lamps turn on everyday at 6:20pm and turn off at 7:20am in the morning
XD
how to get full health including absorption hearts in 1.8
Is there a way to get all foods? like a tag or someting? I couldn't find any when I looked but I might have missed something. I know that you can accomplish something similar by looping through all materials and checking if its edible
Are you just setting the blockstate to lit ?
That should not power the trapdoors.
You could also just disable the blockupdate.
1.8
😿
yeah soz
use NMS
hmm
how do I cast Player to LivingPlayer
if the second one is NMS then
cast to CraftPlayer, getHandle() cast that
I think
yea it works now
perfect
what exactly did you do ?
i changed my code a little bit
Do all entities look at you as you approach them? Like villager
hmmm i would say yes but to be sure you need to check all entities if they have the same goal
I don't think Items would do that :D
I'm making npcs and if i disable their ai, because i dont want them to harm players or move around, they will just stay still
LookAtPlayer goal is part of AI so.. ye
how do I stop specific entites from moving? xD
like zombies and skeletons
and make them not harm players or anything
how do i remove their goals
If you don't want NMS
Use attributes, set their follow range to 0, set movement speed to 0
ohh
I am not 100% sure on the follow range tho
I know the other way is to set them to the same team as player
so eg in skeleton entity what methods do i use to set the follow range and movement speed... https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Skeleton.html
declaration: package: org.bukkit.entity, interface: Skeleton
no 🥄 from me
search for anything attribute related
ohh it's the attributes, ty
indirectly power it
where can i see new features for minecraft like display entites and #addCustomChatCompletions method
View the Bukkit, CraftBukkit and Spigot changelog.
// Check if player is online now.
Player player = server.getPlayer(playerUUID);
boolean isOnlineNow = false;
if (player != null) {
isOnlineNow = player.isOnline();
}
What am I doing wrong?
i think if you use getPlayer it is automatically an online player
Yeah it will only ever get an online player
if you use getOfflinePlayer it will try to get an offline player (who has joined already before)
Where are you running that?
Inside a command.
That might not be true in an event like PlayerJoinEvent or PlayerLoginEvent
Mk, then yeah, just a null check is fine
Player player = Bukkit.getPlayer(playerUUID);
if (player == null) {
// player is offline
return;
}
I tried that first. But it's never null.
Then you're either using a weird server implementation or you're passing in the wrong playerUUID
If I'm passing wrong UUID then particularly it should never be anything but null, IMO.
There's only me on the server.
That's what I mean. Maybe you're passing in the UUID of the sender
Because #getPlayer() returns null for offline players. Not sure what else to tell you :p
What's the difference of using the method from static Bukkit vs. from server?
Nothing. Bukkit mirrors all of Server's methods as static redirects. Bukkit holds the Server instance, so it's convenience
I'm using:
String playerUUID = server.getOfflinePlayer(arg).getUniqueId().toString();
Oh your playerUUID is a string. Okay, so you're effectively doing Bukkit.getPlayer("73c62196-2af7-463d-8be1-a7a2270f4696"), which is never going to yield a result
Bukkit#getPlayer(String) gets by name, Bukkit#getPlayer(UUID) gets by UUID, which is what you're trying to do
Remove the toString() and change your variable type to UUID
Why?
^
I read it, but it I didn't follow.
You're trying to call a method that expects a username, like Bukkit.getPlayer("2008Choco"). But you're passing a stringified UUID, which isn't a username
You said the value is never true
Player player = server.getPlayer(playerUUID);
boolean isOnlineNow = false;
if (player != null) {
isOnlineNow = player.isOnline();
}
Which in this snippet, the one you sent earlier, means the player is never online. Which is correct. It's trying to get a player that doesn't exist
Ah, I see. Yes. Ok.
So yeah, if you do this change ^ it should work
Hmm. Thank you. I think I can get it working now that I understand the issue.

choco should get the helpful role
Isn't it basically an api <-> impl bridge?

Yes
I'm a bridge
Yes ma'am it is
I'm making an random teleport plugin, i want to teleport a player to random place but it has to be bigger than some MIN value and smaller than MAX value
so the big square without the smaller square is the area,
my code does:
x = random(-max, max)
y = random(-max, max)
if ( -min < x < min && -min < y < min) generate x and y again
else we have result
do you think its correct?
it should be z not y but doenst matter
that would work but it also has the infinitesimally small chance of looping infinitely
i would just generate the coords as the difference between the min and max
and then offset by the min
no looping needed
when will food components be fixed?
Should be ok, u could also use vanilla command /spreadplayers btw
i am trying to come up how to do it but i cant, can you show code?
first familiarization with kotlin and project creation is already giving difficulties. build plugin for bukkit api not support kotlin?
just calculate a value between (max-min) and add min for x and z
what does "value between (max-min)" mean
value = Math.random() * (max-min)
min would still be the lower value
what im thinking about is to generate x, if its in a position when its impossible for y to be in that little square then just generate the y, if x is in position when y can be in the little square, then generate y so its not in the square , i dont know how to do it but yeas
5 - 3 = 2 and -3 - -5 = 2
i see what his problem is....
my idea was to generate a distance which is positive all the time,
you could then add a 50% chance to make x and 50% to make z negative
i didnt mean that,
to use your idea:
x = random(-max+min, max-min)
if(x < 0) x+=-min
else x+=min
so if x is in something like this black dot, then just generate the Y, if its in position like the red one, generate the Y somehow so its not in the middle square
sorry for poor drawing
yeah
but my solution
was workking
but it can repeat w few times before doing this
and can it be a circular range or is it specifically rectangular
idk
what about this
rectangle
but thats only x
do you do the same for y?
do the same for z ?
dont call it y xD
yeah but its like 2d llol
what
i think it will work
jeesus why so hard
all you wanne do is generate the distance which is max-min and add the min value to get a value which is higher then min and lower max
do it for x and z and add 50% to make it negative per value
but you know that they both (x and z) have to be between these coordinates for the (x, z) to be in the rectangle
yes.
if you solve it for either x or z, you literally copy paste it for the other axis
so instead this is a 1d problem
i dont think so
why not
i think his solution makes only this are possible to be generated (blue ones)
no because you are generating the x and y separately
i see
because i understood that these are possibilities for x an z
red ones are x blue ones are z
what about generating a value between
+minX and +maxX
and also -minX and -minX
and choice one of the results ?
(better would be to decide before if negative or positive before generating both)
but do you agree that your previous solution was not ok?
was i right?
i mean i already have the solution but its a little slower sometimes
my brain crashed while thinking about it ...
"not"?
its the same problem again
ugh
i already have the idea in my mind, i said it, but its complicated
i think i dont care that much
to fix it
circle would be a easier
yes i know xD
because x and y is the same way
okay z
wait am i dumb?
yes i am but im tired
of thinking
i got it... maybe ?
generate X like i said with
generating a value between
+minX and +maxX
and also -minX and -minX
but for Z you only generate between maxZ and -maxZ
Everything was wonderful with so many benefits until it came to kotlin syntax. I assure you it's just awful when you're a Java programmer looking at it.
For some reason the data type and the type name are reversed. some ? !! to work with null objects. Some strange creation, assignment of getters and setters. Compactness is good, but not to such an extent.

i dont know anymore
what does data type and the type name are reversed mean
we could generate any x, then y until its ok, OR find a way to generate it so its ok in the first time, which you just probably did
and the funny thing is that when people talk about the advantages of kotlin over java, they mention null protection, but they forget that you will interact with these nulls anyway.
nice jbrains love you
but the second way (after word "or"), we should check if x is already safe, if it is then just generate y, if its not, generate y in a way so its safe
ill just stick to my solution.. its not actually that big deal
because samller rectangle is too small
compared to the bigger one
Rubber duck debugging
well obviously you have to handle it, but it's a part of the type system, so it's clearly defined where it appears and where it doesn't
it's not about that, it's about how you deal with it. Wth this “?...” “!!” ???
why just not use annotation
!! is asserting not null
? is nullable, and is the prefix to a safe call
technically !! is casting to non null but similar for explanation purpose
this unconfortable especially when interacting with the api written in java
i can use kotlin with java apis perfectly fine
easer use lombok nonNull annotation then this
The other way around is pain
(if it's not intended)
annotations are just metadata, they aren't meant to enforce nullability restrictions
was just about to say that
Same goes with Scala code
and?
4<x<6
this syntax should work
Had to work with that decompiled
inteliji use annotation
for example
why kotlin not can use some class processor inside for checking
because java doesn't have such a thing built in, hence we have error detection meta in the form of annotations
having a null-aware type system allows the compiler to enforce more rules around its usage, so you don't get unexpected runtime NPEs
devs can add some more convenient syntax to indicate “can null” state.
but use sings...
can null is ClassName?
what?
Can I send my zipped world files from a minecraft server to a github repo via a plugin?
looks easy until you write down the conditions after "?"
"then","it"
etc
huh?
maybe with github API
???
sec
Yeah but I'm facing some issues
I think it's a issue with the host
L Moment
file?.let is a safe call for if its not null
the override is just removing the boiler plate and letting values be returned directly
override fun getValue(): Double = value is the same as ```java
public double getValue() {
return value;
}```
this terribly
why just dont return
If I wrote my getters like that rad would murder me
why "Class = value"
i can use this without var and val?
this will infer type of string as it creates a string
Similarly to java's var
so dont use kotlin
why do you use kotlin if you don't like it
It's just the average high level language lol
Javascript syntax is nearly identical lul
this is the point where the developers went overboard with the compactness
Or, well, typescript, rather
except that the developers made a java analog, not JavaScript. I don't know why they didn't make the syntax closer to Java. Why reverse the order of variables, why add : when assigning, etc. And I've only translated 2 classes to kotlin
It is not a java analogue, it's a JVM language
There is a difference
The developers themselves said it's an improved java.
Well, from the stories I've heard on youtube, at least.
Well, it's hard to explain
But basicaly
They are two seperate entities
Do not compare them
Kotlin is a language that gets rid of what some people see as redundant in java
And adds things that are too non-verbose for java
and with that they messed up the syntax when added javaScript lang niice.
is all you going to do is just complain about kotlin?
I mean just use optionals if your sole reason of using Kotlin is nullability
is it possible to get a player to play one frame / stick to one frame of the crossbow loading animation?
Is there any api to send a PlayServerEntitySoundEffect packet?
Oh I'm tripping, I already did what I was asking for help with
Thank you though haha
Haha na
Optionals are so not even close to kotlin null safety
i mean i wish, but its just not
If your whole codebase is optionals, you might as well just run now before I ban you
Improved is subjective, they wanted to address lacking features in Java and Scala
what about good optionals
There is a time and a place, and unfortunately for some developers, that place is everywhere
like Option.None and Option.Some
wtf
I do use these unironically a decent bit
sure, sadly you still deal with Java’s limited generics semantics and there’s gonna be some operation and memory overhead if u scatter around a wrapper for every nullable that you have to deal with
I mainly use kotlin so not a problem for me
I use options generally with registries and that's about it
But I do use registries a good bit
https://www.spigotmc.org/threads/sqlite-explained-on-example-updated.657967/
I follow this resource, but why we need SQLite as a dependency ? because all work good with java.sql.* import
okkk thxx
But for other cases, you need dependency because java.sql is just an API, you need driver implementation which you usually obtain with DriverManager.getConnection factory method
Guys, is there any discord bot that can automatically give role to my customers?
Not really an easy thing to pull off because spigot has no such API
You'd have to make something yourself and be smart about it
Found this thread https://www.spigotmc.org/threads/spigotmc-premium-resource-verifier-discord-bot.664397/ I'll check that out. I should've googled it first before asking here 🥲
If i have a working plugin for spigot 1.21 how can i use it on spigot 1.20.1?
What do i change?
entirely depends on what api endpoints it uses
change the api-version in plugin.yml to 1.20
I did
Didnt work
I changed it there and the pom.xml
When i do /pl
It says 0 plugins
so check logs for a start up error
some plugins work with multiple versions
what version should i put so it works with the most versions?
choose the lowest version you want to support
so if i choose 1.8
the older you go the less support you get
it will work with the all above 1.8?
we tell you to update, but yes
isnt this what they would call an array in other langauges??
no a map and array are two distinctly different things
other languages may call them dictionaries, but never array
i see
theoertically ifi had a key value for every online player with a value next to their name like
Zarif: 5
that is modified every few seconds
would the server get really laggy?
no not at all
ideally you should use player uuid isntead of username btw, it cant be changed
if the server is offline
but even for 10s of thousands of players, it would not lag
wouldnt the uuid be based on their username?
no clue
i see
i dont use offline mode
i see thanks
did you specify public?
I dont know
i followed the example
but the example never decalres default_cooldown
method 3
is there a way to have this world only save world data (region folder)
it did in method 1
looks like somebody copied rust
Does rust do them like that or something?
That is exactly what rust does
Oh
Well it's probably the best way to do it without it being a built in language feature
Java really missed with it's Optional impl
Why's that
you know what else is an overall meh experience at best
Not being able to switch on them just sucks
Rust?
Subjective
the fact that in rust it's just an enum means you can match it and everything
Because to the rust compiler the concept of null just does not exist
What's the difference between an optional and like a completable future? Just that the type of returned data or response as it were is different?
which is a good thing
Optional are guaranteed to exist at that point in code
CF is a future
CompletableFuture may not even properly exist
The code it's running could not even have happened yet
Ah
Optional simply encapsulates a values null state
Hmm what do you mean? I thought it handled null cases by just throwing or running another function
It basically forces user to make proper null handling
Wrong command when you are setting the executor
Show plugin yml
paper-plugin.yml😭🙏🏻
wll that not work?
Just put commands into plugin.yml
Just rename it to plugin.yml
why use Optional when you can use completablefuture and just complete null
@river oracle
same error @quaint mantle
oh bruh its auto creating paper-plugin.yml
:(
fixed
chat how do i get players item
idk how to access playerInteractEvent
in a command
player.getInventory().getItemInMainHand - get item in main hand
Returns the ItemStack
thanks works
but what do i put here?
it worked fine in my main file having it at "this"
1 params write the Class where extends JavaPlugin, then key from "String". Not use ",.-/" and other incorrect symbols, and the length should be a maximum of 12 characters
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
?learnjava! first tho
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
.
aight bro i get it
i fixed it last time
but this time its in a command not in the main file
so "this" does not work
Do it in the main class:
private static Again instance;
public void onEnable() {
instance= this;
}
public static Again getInstance() {
return instance;
}
then:
NamespacedKey key = new NamespacedKey(Again.getInstance(), "key");
And change the name of the main class so that it starts with a capital letter
Add in onEnable "instance = this"
ctrl + z
And change the name of the main class so that it starts with a capital letter
The name of the classes must begin with the main letter
oh okay thanks
🥄
how can i rename a players item?
player.getItemInHand().getItemMeta().setDisplayName("renamed");
does not work
Because you're not re-setting the meta
how can i do that
setItemMeta
first isolate the ItemMeta as a variable then set it back, you really shouldn't be doing those long strings of methods
what would i put in here?
._.
rust frfr ```rs
client
.get(url)
.send()
.await
.expect("Failed to receive response")
.text()
.await
(this is nothing)
uh
hm where have I seen this
ItemStack item = player.getInventory().getItemInMainHand();
ItemMeta meta = item.getItemMeta();
// do stuff
item.setItemMeta(meta);
see how much cleaner that is
dawg they don't give a fuck
who is this "illusion" person
i give all the fucks
chat i dont think im doing this right
that is so
That's normal
java is very specific with the way it wants things
it works!
😄
Is there a way that I can NamespacedKeys to save multiple values?
Like example the key is User and add in 2 values of say Player 1 and Player 2 would that work or would it override the NameSpacedKey
its saved as allowed-users just used User as an example one.
that sounds like it would be a list
what are you trying to do
idk how namespacedkeys help with that
because that sounds like xy
basically I want to save a list of allowed users to a container, and from what I found name spaced keys are a good way to do that for other data im just not sure about for lists
namespacedkeys are just strings which have a namespace attached to them, which is often either the minecraft namespace or the plugin's. You can use them for other purposes but a list of users isn't really one
ah, okay :/ I will find another solution for that one then
you can just use a list of UUIDs or something
you can do a list of UUIDs?
you can do a list of anything you want
for namespacedkeys?
I don't understand what you mean, why do you need namespaced keys
what is this allowed-users list used for? Where is it being stored?
im allowing users to access a certain chest that can be anywhere. from what I've researched a good way to do this is with name spaced keys, however, I dont think it will work with a list so I gotta find somethign else
so, you're storing it on the chest's PDC then
yeah with a namespaced key as the key for it
sorry its late for me I messed up not having that in my first message
I understand now, the namespaced key isn't mean to be the value that you're going to store, but a way to identify these values you're storing in the pdc
yeah, would it be overridden if I set another value to the same key?
you probably want something like this:
// screw this not being a default type btw
public class UUIDTagType implements PersistentDataType<byte[], UUID> {
private static final UUIDTagType TYPE = new UUIDTagType();
private static final ListPersistentDataType<byte[], UUID> LIST = PersistentDataType.LIST.listTypeFrom(TYPE);
@Override
public Class<byte[]> getPrimitiveType() {
return byte[].class;
}
@Override
public Class<UUID> getComplexType() {
return UUID.class;
}
@Override
public byte[] toPrimitive(UUID complex, PersistentDataAdapterContext context) {
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
bb.putLong(complex.getMostSignificantBits());
bb.putLong(complex.getLeastSignificantBits());
return bb.array();
}
@Override
public UUID fromPrimitive(byte[] primitive, PersistentDataAdapterContext context) {
ByteBuffer bb = ByteBuffer.wrap(primitive);
long firstLong = bb.getLong();
long secondLong = bb.getLong();
return new UUID(firstLong, secondLong);
}
}
private static final ALLOWED_USERS_KEY = new NamespacedKey(MyPlugin.instance(), "allowed-users");
var PDC = block.getState().getPersistentDataContainer();
// you *may* have to wrap the returned list into a new ArrayList since I don't know if the returned list by the LIST PDT is mutable
List<UUID> allowedUsers = PDC.getOrDefault(ALLOWED_USERS_KEY, UUIDTagType.LIST, new ArrayList<>());
if (!allowedUsers.contains(somePlayer.getUniqueId())
allowedUsers.add(player);
PDC.set(ALLOWED_USERS_KEY, UUIDTagType.LIST, allowedUsers);
hmm it seems I cant do PersistentDataType.LIST I will try to figure out why thank you very much for your help
then you are using an old version
declaration: package: org.bukkit.persistence, interface: PersistentDataType
oh that make sense, im using 1.20
What a neat class (I'm gonna steal it)
((it's literally in the docs, excluding the list and type))
was gonna say lmao
Tho I would be for a type that stores 4 integers instead of 8 bytes, to match vanilla MC
that'd be less memory-efficient, but more compact in the string representation probably
idk, its just what mojang decided is the most common way to store uuid in nbt
probably used ints 'cause of scoreboard manipulation for datapacks
I'd assume it was for when 32-bit ints were more common
it's an old game so I wouldn't be surprised
eh, now that I think about it, the JVM would've emulated the operations with longs anyway so it is pretty much the same
don't know why they went with that representation
you mean in scoreboards ?
That is a good question
yeah you brought it up
so I assumed you have an explanation
I just think they used 4 ints because its 2 longs
I'd like to assume they used an int array instead of a byte array simply because it didn't look as wonky on the string representation:
// TAG_Byte_Array
[55, 0E, 84, 00, E2, 9B, 41, D4, A7, 16, 44, 66, 55, 44, 00, 00]
// TAG_Int_Array
[550e8400, e29b41d4, a7164466, 55440000]
// TAG_Long_Array // not available until 1.13 apparently
[550e8400e29b41d4, a716446655440000]
idk it feels weird to look at without the dashes lol
yeah
Ints are still 32bit
Maybe i read your message wrong lol
no you read it right, I just got it mixed up in my head lol
I meant to say 32-bit longs, then again that's all handled by the JVM so it shouldn't have affected the UUID representation
Right
Just more optimal now
Instead of it using double width its single width since 64bit native stuff
Can the text on actionbar be moved lower through code
Or are the text coordinates on the actionbar hard coded?
any good resources for mongodb? hoping to use something like Morphia ( idk if theres any alternatives ) and also want to try for it all to be async for performance reasons rather than hug up the main thread (:
https://www.spigotmc.org/wiki/mongodb-with-morphia/
got this but idk how up to date it is
2023
so basically up to date
js frameworks:
the text coordinates are hardcoded
but you can use resourcepack with a special font to move it around
Gotchu
You can use custom fonts inside of a resource pack to change the text and its vertical shift
I am rewriting database mangement for my minigames plugin and wanted some feedback/ideas on how to lay it out
my plugin is split into a core plugin, running on every server, and then a lobby plugin and a matches plugin, and in the future I am looking to write my matches plugin so I can create addons to it for different types of minigames as currently my network only supports one.
I need to save uuid, title data (ie chat prefixes), friends, statistics (per type of minigame), minigame settings (for example hypixel will store a selected kit for games like skywars)
I am using mongodb and I was thinking I could have a main collection, that handles uuid, title data, friends and then a collectionfor each type of minigame, which will store the specific settings as well as statistics
sounds good
are you caching the data?
yeah
okay
I think the original system does let me check
yeah it caches it in a uuid to playerdata map
okay
it caches it every 100 ticks async
do you mean save?
yes sorry
i personally only save when the player leaves
altough really important data shouldn't be cached
this is how one of my tables look:
CREATE TABLE IF NOT EXISTS " + table + " (uuid CHAR(36) UNIQUE, name VARCHAR(16), options TEXT, wins INT, loses INT, beds_destroyed INT, kills INT, final_kills INT, deaths INT, final_deaths INT, levels INT, experience INT, win_streak INT);
what if server crashes
is my concern
I use mongo I cant read sql sorry
such as what?
data player spent money on (like currency)
true
I desperately need help, I've been trying to get Hot-Code-Replacement to work for over 4h now and it simply is not working... I'd be glad if anyone is able to help me:
I looked through a crap ton of sources to see how to do hot-code-replacement, but almost everything was for IntelliJ, which is not what I want to use, since I prefer Cursor (basically VSCode). (note that I do have IntelliJ, and yes it does work in IntelliJ, but I am stubborn and don't want to use it.. don't question it)
I've managed to install the JBR 21 (jbr_jcef-21.0.5-windows-x64-b631.8) and added the hotswap-agent.jar to it aswell. I've even managed to set up a tasks.json which runs my local dev server with the correct jar AND has the hotswap loaded (it appears in the logs)
{
"type": "shell",
"label": "Start server",
"command": "java -XX:+AllowEnhancedClassRedefinition -XX:HotswapAgent=core -javaagent:../.vscode/hotswap-agent-core.jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar ./paper.jar nogui",
"problemMatcher": [],
"options": {
"cwd": "./.server",
},
},
I've also installed the necessary Java extension pack in Cursor, and I have made a launch.json to connect to the debugger:
{
"type": "java",
"name": "Attach",
"request": "attach",
"hostName": "localhost",
"port": 5005
}
Attaching works.... even breakpoints work... everything, LITERALLY EVERYTHING is working, except that when I change the code, and even build it manually with gradle (even tho I don't think that should be necessary) and I click the Hot-Replace button, I ALWAYS get the message "Cannot find any changed classes for hot replace!". I've also tried adding a hotswap-agent.properties file (in multiple places to be sure that it is in the right place lol) and I've even gone as far as to provide the options in that file directly in the run command itself (see here), mostly to make sure that "plugin.classes" is set to the correct built classes, and yet it still does not work.
Does ANYONE have ANY clue how to get this crap working? PLEASE xD
sounds like something noone has ever done xD
I was mingling with this the other day, it was painful
no matter what I did, I couldn't get hotswap agent to recognize my classpath, the funniest thing is that even when I did get it to recognize my classpath, I couldn't get CommandAPI to work properly so I just gave up on it (it broke upon reloading, probably some code generation shenanigan changing the anonymous class order or something)
https://github.com/JavierFlores09/block-display-test here if you want to see my attempt
Testing block display behavior. Contribute to JavierFlores09/block-display-test development by creating an account on GitHub.
ah it doesn't have the hotswap stuff
where did you put the hotswap-agent.properties? It should be in your resources folder
@remote swallow knows about hotswap stuffs
then again, I don't think you need hotswap agent for basic hot reloading?
just using the debugger for java and JBR is enough
Im not gonna lie, I copied it... 5 times... I had it in my resources folder, in my project root folder, next to the hotswap-agent jar file, in the server directory and I even manually put it in the arguments of where i set the path of the agent jar file lmao
no clue, I just went with a tutorial I saw, which said I would need it
try without it and see how it goes
also make sure you have redhat's debugger for java extension working properly
if you don't change class definition, you don't even need JBR
If I'm at home yes
HotswapAgent is more for when you need a platform-specific plugin so that hotreloading behaves well with the system
i.e., there's quarkus and spring plugins for hotswap agent that fix issues around hotswapping these platforms/frameworks since they do a lot of dynamic stuff that needs to be properly handled when hotreloading happens
that said, you can still use hotswap agent if you want
alright, just tried, even without it I get the exact same behaviour... breakpoints work, hot-replace doesnt
does it work within IJ?
lemme try really quick
also what do you mean it doesn't work, does it not let you use the reload classes button or when you hit it, nothing changes?
it could potentially be an issue of where you are testing it too, since if you change code that isn't getting called, nothing will change until that code is called again (i.e., for anything in the onEnable, that will never happen until server restart/reload)
it just tells me "Cannot find any changed classes for hot replace!" and nothing happens (so the messages and everything being sent from the plugin do not actually update at all, they just stay the same, I assume nothing happens on the server at all)
im using it in a command, the breakpoint above it gets triggered, im just sending messages to the player (since that worked yesterday with intellij)
did you compile it before hitting hot-reload?
hot reload button should do it for you, given all integrations work properly but I maybe it just isn't lol
Is there PlayerChunkLoadEvent?
I need it when player loads a chunk or when a chunk loads for him client side
Same behaviour even with rebuilding
hm, let me try do it myself and see how it goes
yep, just tested intellij (without the agent, just a regular JDK even), hotswapping there works
so it only causes an issue in VSCode
I think when you hit debug the output console tells you what flags it uses, maybe check out which ones it uses and copy them over to vscode
my exact thoughts lmao
there is one in Paper, but not in Spigot
you'd have to use PacketEvents/ProtocolLib to detect that
When i use some external plugin api from maven rep, i need to get instance of this plugin to use its api? or how it works
I mean, the API should provide a way to get its instance, yes
I'm trying to reimplement it for spigot 1.8.8.
Is it possible to use nms for that?
they dont(
or im blind
if they don't it isn't an API lol
what plugin are you depending on
wild loaders
Caused by: java.lang.NullPointerException: Cannot invoke "com.bgsoftware.wildloaders.api.WildLoaders.toString()" because the return value of "com.bgsoftware.wildloaders.api.WildLoadersAPI.getWildLoaders()" is null
if you do get it working, share it here so I can recommend it to people in the future 😛
did you add WildLoaders to the depend/soft-depend list of your plugin.yml
version: '1.0'
main: org.midnight.midnightCommands.MidnightCommands
depends: [WildLoaders, LuckPerms]
api-version: '1.21'
commands:
getloader:```
well, dumb to ask but, do you have WildLoaders on your server?
kinda
what does kinda mean
yes
xd
if you have it shaded in your plugin or something weird like that, it won't work properly
what is shaded? im stupid
anyhow, it shouldn't be returning null, where are you calling the method? in onEnable?
Alright, I tried copying them over.... the same exact shit still happens, its again telling me "Cannot find any changed classes for hot replace!"
onCommand
even weirder, hm
welp, I'd just ask the WildLoaders author what's up with their API, because it shouldn't be returning null at this point
unless you got to do some kind of initialization which isn't apparent from their javadoc

❤️
you're using the WIldLoadersAPI artifact right?
<groupId>com.bgsoftware</groupId>
<artifactId>WildLoadersAPI</artifactId>
<version>2024.3</version>
</dependency>```
if you have the shade plugin in your pom as well, you'd indeed be shading
the readme doesn't say anything about shading and they don't seem to know what shading is anyway so I doubt it but yeah ^
im stupid, need to fix anything here?
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.midnight</groupId>
<artifactId>midnightcommands</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>midnightcommands</name>
<properties>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>bg-repo</id>
<url>https://repo.bg-software.com/repository/api/</url>
</repository>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.bgsoftware</groupId>
<artifactId>WildLoadersAPI</artifactId>
<version>2024.3</version>
</dependency>
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.21.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
paste your pom
enjoy
i need to remove it?
you should just slap a <scope>provided</scope> at the wild loader api
why are you using a plugin you don't understand lmao
all your APIs are provided, so you can just remove it instead
wdym
in your pom, you're using the maven shade plugin
what the maven shade plugin does is create a fat jar, which means all your dependencies which aren't marked as provided will be bundled into your plugin jar
so i dont need any other plugins in my serv?
i mean from deps
just remove the maven shade plugin from your pom
you don't need it right now, you'll eventually learn what it does when you do need it
ok
why he told me to write that
because that also works
you should do that anyway
no matter if you remove the shade plugin or not
that dependency is provided to your plugin at runtime, it should be scoped as such
i removed shade plugin and it works without <scope>provided</scope>
yes
why
because now there is no shade plugin?

shade plugin basically "merges" all your dependencies into your output that are not marked as provided
setting the scope doesn't do anything other than giving maven information about the dependency's well, scope
it does do something when there's plugins like maven shade involved, however
that being said, given that the dependency is in fact provided, you should mark it as such
from maven repo is provided?
thnks
if you don't understand what it means, feed it to chatgpt and ask it to reword it in a simpler way or something
not totally what I do myself with these kind of technical guides
just as an FYI btw, im currently going down a rabbit hole of commits made literally only a couple months ago, so I might not be going insane, it might actually just be some sort of bug or smth that it is not working xD
See this issue, this one and this pull request
uhh why don't you try downgrading the version as they did in that first issue and if it works
I'll have to figure out how, but I'll try that
you can downgrade extensions by going to the extensions tab, clicking the three dots for the given extension and it says install a different version or something
The plugin isn't workingEven I placed the files in the bukkit,yml and also deleted the previous world please help me
sadly didnt help, even tried going as far back as possible lmao
I'm making a test plugin myself right now, if I get it to work in vscode, I'll mention you
would be great, thanks a lot
?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.
I suppose I'll just use intellij for the time being, cuz i really don't want to have to restart the server every single time I make a change lol
I don't personally find that being that big of a burden tbh
but that's mostly because I test with a remote server and not a local one lol
otherwise my computer would be fried
btw isnt that grammar wrong shouldnt it be Does not work or Is not working?
it is wrong, now I can't un-notice it
That's intentional
Just as I thought

