#help-development
1 messages · Page 1973 of 1
Why using Socket?
using sockets
i asked
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
yeah guys verano is working hard to make us all happy /s
Yeah not sure, havent seen an error like that before
echo %JAVA_HOME%and post results please
ok
C:\Users\Lieonel>echo %JAVA_HOME%
%JAVA_HOME%
okeh
some guy answered with: "Your config has a custom object without the type being specified" but what the actual fuck is that supoosed to mean????
Is that what it resulted with? Can you show a screenshot?
y prank
@next stratus
You've not set your java home correctly
Why is he having that issue? I never had to setup Java_Home for using an IDE on Linux
Your config has a custom object without the type being specified - what does this mean
please
DevBukkit?
It's a Windows thing
No, the issue is a windows thing
He is having issue on windos right?¡
Yes..
Ah that why lmao
The java home thing is a issue on Windows....
I see the console and thought he was on Linux
What does the String part mean?
Nah, it'll be terminal if it was Linux
soldier
Java isn’t useless still
Best language for learning would be Python
yeah when i am done this plugin i am never looking at java again, so many terms you need to know, the dumbass CoNvEntIons, people explain error solutions with a bunch of gibberish terms. there is nothing motivating me to learn this "language".
The only real problem with Java is nullability and type erasure
still the sae
Java is not dying lmfao
One of best minecraft developer for servers told me that. His custom license panel for java app is design there and have never been cracked their license. And the jars never got deobfuscated. Cuz he use a +$512 dollars obfuscator. hahaha
same
it says that I am supposed to input a char sequence
What have you done to try fix it
your inability to understand a language does not make it a bad language, it makes you bad at that language
i add JAVA_HOME
player.getdisplayname
only a poor craftsman blames his tools
oh sorry. But learn java i dont wanna be rude
to user variables
And you refreshed it?
Yea Java and its enterpriseness is actually a really good thing that has been evolved
ya
You already said that once 😐
not once in that message did i say it was bad, even though i feel it is, i said what i hate about it.
Try rebooting your pc if needed
I dont wanna sound rude. But im getting mad
Java is fast, it's powerful, and it has very wide adoption, it isn't going anywhere
I am not talking to you so why would you be getting mad
you sus
I mean almost every language has conventions Magnumsrt
And in fact a lot of modern languages incorporate terms Java hasn’t even touched
your use of "language" suggests that you're saying it's bad
I'm trying to help you
Python or javascript?
okeh
Rebooting your pc will load in the new system variables.
Learn Scala then
oh never heard it
Java is still widely used in backend web development, the two aren't mutually exclusive
well yeah but in java people get mad that you didnt lowercase the first letter of a variable and it's so fucking stupid
I only know that website backends, where Php, Python and JavaScript
like it has no functional value
Java web servers are incredibly performant
and if i did that is my opinion
Which one? Serverlet? Spring-Boot?
you'll find people have that opinion in many languages
You’re generalizing a collective now, I am pretty sure not everyone gets mad over that, and well you still have conventions in almost every other language needless to say
done
Even in maths, or in any normal language such as English
and i'm telling you that that's a dumb opinion, which is what i said i was doing from the beginning
now it say
I have raged and break one keyboard because i lost 4 hours of work cuz intellij auto-save was not working
you'd be surprised
Java is also really fast
Java is crazy fast these days
I think there's another folder within it you need to point to is it lib? I can't remember try googling it
And i dont tell you how many times raged when playing bedwars
Yeah, and the difference is negligible
bin i thonk
ActiveJ, Rapidoid, Jetty, Jooby, etc
What is the best way to make a player undergo the spinning riptide trident animaton?
Over and above all, if you really need a low level language you probably wouldn’t go with golang, moreover rust would be what you’re looking for
then why even bring up speed?
Go eliminates too much verbosity imho
Like most other “modern” programming languages
if you just like Go better that's fine, but that doesn't mean the industry as a whole is going to agree
What would be better Vue.js? Next.js? Python? for backend dev (website)
.
Vue is frontend
My bad
But vue is nice
I suggest trying different backend and frontend frameworks to find out which one you favor the most
I need to chose a powefull and good language for doing website
Im between Python and Javascript
the real answer is that the framework and language you're going to use is whatever the person paying you says you're going to use
lmao
#translator moment
Yeah Alex, but that’s what’s nice about personal projects, you can choose and reconfigure at any moment
js is better
Learn Python
?
It’s incredibly powerful in spite of it being somewhat slow
true
I haven't had personal project time in a looooong time
but js is nice for websites and api's
Many people told me that forget getting a good job with php, so i thinked about Js and Python
That why im asking
You probably wanna learn TypeScript over JavaScript, and then Python as its quite popular
Personal project time has to come after my actual work obligations, so I don't have any time to expend on that at the moment
easiest way to learn js is just memorize every line of the docs for it 🤷♂️
if I have a content update needing work I can't just tell my boss "hey im taking a week to dabble" lol
i listed points why i think it is bad, i guess java's weakest point is the terms that beginners are just "supposed to understand" and i don't have "an inability to understand it" in fact i know the language decently, but it's just so unenjoyable to sit in front of a screen and get error after error. i am really considering stopping my plugin since mojang decided to go with java when something like c++ exist, ig thats what bedrocks for
that's not a feature of the language, that's true in any language community
Spigot is an advanced API, it's not intended for beginners
anyway i am not gonna argue i am just fucking annoyed that my plugin that i have spent a month on won't even save items
Tbf, to learn anything you have to oversimplify before diving into the rabbit hole
the only time I handhold somebody through programming is when a university is paying me to do so
So the “supposed to understand” can to some degree make sense
Hehe
but they are really nice compared to others
I can look at an error and figure out exactly what is wrong, and where it's wrong
That’s besides the point I’d say
whereas with C++ it's a case of "oh look, something's fucked"
^
"Now to look at all my code line by line for an hour and figure out what the issue is"
for (UUID uuid : gInter.members) {
if (Bukkit.getOfflinePlayer(uuid) instanceof Player player) player.sendMessage(u.f(message));
}``` would removing the .getPlayer() not work conclure?
c++ shit language for people that dont like any language beside typed ones
Wally I am unsure
i don't hate c++
I don’t remember the implementation
i can be productive with it, but Java will always be my favorite
dude, i'm not saying it is, i'm saying that if someone asks what passing an instance is, you don't say "well that is a basic of java" or "well you take a TYPE and make a method and then return the type" like a beginner is not gonna know what that a return or method is and i'm not saying spigot should make it beginner friendly, just the way people answer my and other beginners questions makes me wanna explode.
But using OfflinePlayer::getPlayer returns a player object if the player is online (specified by the docs also)
because spigot development is not intended for beginners
ah yeah looks like it worked
that's like asking someone how to write a concurrent webserver in c++ and not understanding the basics of the language
Yeah, well maybe learning the fundamental basics of Java would be a better initialization then?
you don't understand the language at a level high enough for me to even explain to you what you want to do without writing out every step
and i'm just not going to do that
programming requires some self-starting
you should understand the basics of the language before you try and play with all the advanced toys
you wouldn't walk into a Calc II class and ask the teacher to write out all the steps for basic algebra, the same applies here
well i have spent a month of my life on a fucking menu plugin that won't even work, i guess i was a bit stupid but fuck this is annoying like i am red in the face right now
sorry for the dumb statements tho
i guarantee if you just took even a few hours and watched a beginner java tutorial you'd be at a level where someone in here could actually help you
fair
😂
I'll tell you what my professor always tells students struggling in his class: "If programming was easy, everybody would do it, and then you wouldn't be making so much money"
he has far more patience than i do
lol
oh absolutely it is
i just don't think all the people he says that to will make money
some people will never be good at it lol
yep
Magnumsrt I very well know what you mean by your arguments, it usually becomes this awkward case where some beginner is asking a lot of questions that really wouldn’t be asked if the user would have done their homework. It appears as quite toxic when you get thrown “oh learn this before doing that” but in reality people tell you that because it’s the best way for you to actually teach yourself and learn what you need to learn. I guess some people are being mean about it, but generally we tell beginners this because knowing the basics first is truly crucial. It helps you not to shoot yourself in the foot all the time and it saves others time.
Who mentioned was using a custom Http request system?
when I was 13 Algebra 2 was "advanced math", now I'm sitting in groups and rings proving that 3^-1 = 7 in U(20)
Do you rember who was using a custom htto library?
Wasnt something like Ara4n?
the simbol before 3
that small coma
That one
watch this madness:
U(20) is the group of integers under multiplication mod 20
the identity for that group is 1
Oh you’re doing group theory?
3 * 7 = 21
21 mod 20 = 1
so 3 * 7 produce the identity for the group
therefore 7 is the inverse of 3 in that group
isn't that horrifying?
groups and rings yeah
https://paste.md-5.net/yukihocayo.bash anyway back to what this channel is actually about, how would i fix this error
java.lang.IllegalArgumentException: Args doesn't contain type key ('==')
thank you captain obvious
I am still extremely confused
@quaint mantle
Like why are you combining the spigot serialization api with Gson serialization
🥲
so where do i type ==
sorry i am dumb
you put that into the hashmap
with "==" being the key
and the type of the thing being deserialized as the value
the reason this part seems unintuitive is that this is an internal part of craftbukkit and wasn't intended for people to be using manually if i'm reading this correctly
this is giving me an invalid http response
how can i fix this
show us the error
invalid http response
the actual error
that but with _
i fixed it btw
i just needed more \r\n
ok
this would be correct and is also how mc serializes items
wasn't originally intended for people to use, but people always insist on using things they are not supposed to 😛
?learnjava
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.
Lovely shit, intellij its getting more bugs than mi life
I first get bug my projects, now i have bug the dependencies
I restarted linux, invalidate cache, nothing works
Only problems cause :/
I wanna rage LMAOO
This are the moments when i wanna break my keyword
ok
Hi, anybody know what should be the value for Damegable#setDamage() for a leather leggings to get the same durability as Netherite leggings?
i tried 555 (as indicated in the wiki as the durability of netherite leggings) but it gets broken in 1 shot
Isnt setDamage deprecated on newers versions?
setDamage just set how much damage the item has taken; it doesn't change the item's max durability.
oh.
is there a way to change the max durability?
I'm not sure, im using intellij so its supposed to show a strikethrough text if its deprecated
Nope.
That said: if you set the damage to a negative value, it will increment as normal
Not even with reflections
It just won’t show the bar until the negative values become positive
So it’s kind of a yucky solution
what do i have to change in my gradle spigot links to go from the api to the full server
thats a good solution
When it comes to custom durability, I like to throw a PDC on the item, listen to damage events and such, and display the fraction basically
You cannot use Spigot-jar from remote repo, just the api
The bar won’t show up until the negatives become positive
Itemstack#setDurability could work? (but its deprecated)
in maven, you just change spigot-api to spigot to use nms and whatnot, what is the equivalent for gradle?
Cast the meta to damageable, and you’ll be using setDamage
i see.
so for leather leggings, to make it have the durability of netherite, im going to do setDamage(-555)?
That should work
In gradle you have the Spigot-Api and for using NMS, you have to install the Spigot-Jar via buildtools
thanks
That said: I only know negative damage values work because I’ve messed with it with vanilla commands
And what about intellij bugs?
Not sure if Spigot is going to throw you an exception for trying to make it negative
i hope it does work
I’m the last person to ask about Intellij issues
Oh my bad
I prob will have to ask another
Thanks!
I just throw google at my intellij issues until intellij does the thing
what do you need verano
Im having this issue on top
a
Idk what happening, i invalidate chace, reload files from disk, restarted linux
Nothing works
yeah i already got buildtools but what do i put in the build.gradle for my plugin?
did you try to delete the lombok folder in your maven folder and reinstall?
Have you install the Spigot-Jar using build tools?
otherwise try to force it
thats what god is for
Let me know if it throws an exception or not, I’m quite curious about whether that works
Do you know about maven? (Personal question)
depends on what you need
No just to know, if you know how maven works
The repo let say
I have been told its a simple web-server which has a straight parameter url and that all. Do you agree?
more or less. just stuff i personally needed
Because my plains for first week of vacations its to make my own maven repo system
i would not say that maven is a "simple web-server"
Oh
I have seen that many of them are just a simple webserver that serve the files
And people told me that
It didnt work the maven thing
I dk what happening
so delete the lombok-dependency folder out of your maven folder
then invalidate caches
and try to force install it
Oh ok
Thanks
I will try
Can be caused by the project itself?
Cuz i have another module using lombok and works without problems
BTww
hm, did you reload your maven?
Yes
Its a multi module project, im every module lombok works, but on the new module doesnt work
Idk what happening
Okay so does anyone know how to get written book pages to work? Cause we're trying to program a custom craftable book however whenever we open the book. It always says * Invalid Book Tag *
Does anyone know how to fix this?
can you send the pom of the new module? Havent been paying attention to the convo, so lmk if I miss/repeat somethin
code
Code?
send code
send code
Ah okay.
have you tried restarting intellij?
Everything, i done linux reboot and nothing
what is exactly not working?
that has fixed about 63% of my intellij issues
Lombok dependency
How is it not working
Okay, here it is.
here
s
not sure why you are doing that in ur onenable
ok so
you need to set up the pages before you build the recipe
so just throw that whole "set up the book" part above creating the recipe
Okay
or really you need to put that inside there before you apply the meta
what needs to happen is this in this order:
- create book
- get book meta
- apply pages to book meta
- apply meta to itemstack
- create recipe
Okay
We'll try that.
Hopefully it works.
Time to wait five years for the launcher to finish updating
Not working
I cannot find the solution
I tried everything
Lmao it 1000k time i count to 10 until i broke my keyboard
I hate this shit problems
This problems make me loose money 😡😡
something is fucked on your side then
Maven prob?
prob, considering it is related to dependencies
It worked
5th i have rebooted
And work, as agent one said reloading/rebooting always works
intellji decides on boot if it wants to work today
it has a random chance to not work and randomly break some function of the program
Is there a way to get the Visible name of an ItemStack? And I don't really mean the display name because if the name is not modified the display name returns null. For example, birch leaves would say Birch Leaves and a stone block would say Stone Block would say Stone Block. How would I get that name?
Any good class for simple reflections?
Okay so we did that, and it still says invalid book tag.
So... what else could be causing the error?
With pantient you fix everything
I said it because i was annoying with an inssue and i stay quiet and calm down and fiex the issue
Alright, im brand new at this so dont get mad at me. (Please)
How can I make it so the player is set to the player running the command? Ive looked all over google and I cant figure it out :(.
Using Player object
You should first check that the Sender is Player instanceof sender, and then cast sender to player object
:D
And yeah i would recommend before starting with spigot api, learning the basics about Java
I went through a crash course, I might need a little bit more. The whole object oriented thing is confusing me D:
prob you are comming from not a non object oriented language
yea
Which one?
Python
the beginner language
Player player;
if(sender instanceof Player) {
player = (Player) sender;
}
my one free spoon feed for the month
This is what i told you in different words. if you didnt understand there you have an example
I swear Java supports naming the variable in the instanceof now
amazing
if (sender instanceof Player player)
it might, I haven't taken the time to really dive into updated versions of Java
Player player = (Player) sender;
since you know its been relatively the same for quite some time lol
Actually I know I’ve done that so yeah new Java does allow it
Any good class for reflections?
you mean tutorials?
Think he means a util
best way to learn reflection is just to actually do it on a random plugin
Yeah
Im creating my simple class for reflections
So i want to see some examples
Oh I don't know of any utils off hand to help with it
I don't usually require its use
Okay, so we tried implementing the suggested fix, but the book still keeps saying * Invalid book tag *.
At this point, we have absolutely no clue what to do.
anyone know how to "disable" a bungeecord plugin? getpluginmanager() on bungee doesnt have a disableplugin method
Tecnically you wouldnt be able to do it
But you can do it via reflections
clarification?
Yeah have you seen how Plugman disable plugins?
would it be possible to "force" a player to take a screenshot or somehow take a screenshot at a location in a world then use the image so its uploaded/sent to the server?
And try to understand
Prob without custom client wouldnt be possible
wdym custom client
you can't force the client to do quite a bit of things
A custom implementation, like a mod or client
ah
take a screenshot at a certain place in the world then upload it to the server so i can then send it to a discord
what you could do
is get the view the player is looking at
and then take the screen shot server side
That’s a lot more complicated
i have an alt account if that helps
The server doesn’t have the rendering or assets that the client has
?
You’d have to recreate all of that
ive seen a server do it with an invisible mc account facing the area with the photo
they use a mini client
I have seen they transform the vip games into a video
You’ll need a mod to get that client to record
ah
And they dont ask for a custom mod or client
There is no way to force a client to take a screenshot from the server
can the server not take a screenshot at a location? doesnt need to be specificly a client can be anything
No
The server doesn’t render the world graphically
i cant open spigot.jar
Hypixel most likely just records each server similarly to the replay mod.
well technically it can, just need some client code and assets to make it possible
Right
They probably have a custom client that records all of the chunks.
But they dont use nothing on client side, i can play with wichever client and the games get saved
So i dont agree with you
because it is done on the server
@sterile token is it saved to a video or playable in-game
An ex developer told me that it saved into game and then they have the posibilities to transform it into a video
idk how
there are different ways to do it
how do I make it so chunks don't go to sleep if there is a hopper moving items? I keep having to go back and forth to get all my stuff to move to the end of the hopper line
Yeah so presumably they save all the actions and then just render it
Like it is possible
It’s just a lot of work
granted its a LONG hopper line. lol
because you can't figure out how to go from an action to an mp4 container etc lmao
if you are making a plugin it is a matter of listening for chunkunload events
and if it contains one of your hoppers, cancel the unloading
Imagine just trying to replay custom sounds on minecraft its really difficult
No plugin. Just on my server.
Wha thappening?
thought they werent supposed to go to sleep if there was hoppers moving stuff through
For server support #help-server
You basically just have to take all the user-facing stuff from the client and make it a task that outputs to video encoding
oops. sorry. thought thats where i was
Hoppers don’t keep chunks loaded
chunks unload when players are not around unless something like a plugin keeps it loaded
^
which reminds me, I think I might update that wireless redstone plugin
now that its officially defunct
Has anybody else have any difficulty with books not working? Or is it just us?
probably just you. You are trying to give a written book correct?
You need to first make the book, and then seal it after you put what you want into to give it the author tag
You seem like a rusty tape recorder, saying that all the time
I have counted that message like 3-4 times
We made the book, added the pages, set author, then added crafting recipe. Exact order you stated.
between the book types
We followed the exact order listed on reddit, youtube, and the forums. Even copied the code, and it still hates us.
you created a written book instead of just a book. Written book is when it is finished/sealed with the author tag
That is what we want.
A written book containing certain information.
ok, but written books can't be edited though, it has to be a book to edit it
Are you using Material.WRITTEN_BOOK?
Yes
To edit it in the code?
You need to use Material.WRITEABLE_BOOK instead.
yes just like in the game, it is the same in code
thank you, I couldn't remember that one
anyways, you need to use writeable book first
add your pages
then you can turn it into Written_Book which lets you add the author tag
If this works... we're going to throw something.
How do that?
That seems incredibly strange if true
Sounds like someone screwed up when making the API
Well, Mojang are notorious for strange things
And exactly opposite to most posts online.
let me see how we do it and get back to you
Can I see your code as it is now?
yeah we definitely do not do it that way lol
Here is as a writable book
well that is how I remember it needing being done, I could be outdated then and need to update my knowledge lmao
Two ways you can make a book.
ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
BookMeta bookMeta = (BookMeta) book.getItemMeta();
BaseComponmenent[] page1 = new ComponentBuilder().append("Your Text Here").create();
bookMeta.spigot().addPage(page1);
bookMeta.setAuthor("The Author");
bookMeta.setTitle("Book Title");
book.setItemMeta(bookMeta);
ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
BookMeta bookMeta = (BookMeta) book.getItemMeta();
bookMeta.addPage("Your Text", "Goes", "Here");
bookMeta.setAuthor("The Author");
bookMeta.setTitle("Book Title");
book.setItemMeta(bookMeta);
Second method failed for us.
what minecraft version
1.18.1
try the first method with the base components
Okay, it's throwing an error with the basecomponent.
You imported net.md_5.bungee.api.chat.BaseComponent correct?
what's the error
Thanks
i'm looking at the client code to see if I can spot something obvious
Nope, still doesn't recognize the basecomponent.
show us the error
Are you depending on the API then? BaseComponents have been in the API for a long time now.
How are you managing your dependencies? Also, what version are you trying to compile against?
It was just a misspelling.
😛
uh... what
does it work now @mighty bane
Starting up the server.
Some people depend on the wrong jar file or use the wrong imports sometimes. Wanted to see if you did that by mistake.
Our computer did at one point swap to java 8. But we fixed that.
Yes.
Why did our original code not work though?
somebody probably broke something converting between String pages and BaseComponent pages
I haven't ever used the method with strings, so I can't say for certain, but I would lean towards an issue with the API. I've always used BaseComponents when it comes to books as it's what the wiki recommended.
Now time to figure out how to run code in books when certain lines are clicked.
Something we're still learning how to do. But hey, it's why we started this project in the first place. To learn through practice.
I'd recommend reading the wiki page on them. There are more than just BaseComponents, but they are pretty flexible. Most projects can get by with just them.
https://www.spigotmc.org/wiki/the-chat-component-api/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Thanks
yeah that's right, spigot doesn't call them all base components
that's just the easily memorable name lol
Okay
Although our brain hurts enough as is. Probably going to take a break for the day. Who knows? Maybe our wifi will finally stop messing with us tomorrow and we can actually watch youtube tutorials.
We do. We also learn best when hearing it said aloud with visuals to follow.
Air bubbles as thirst bar
I agree, but I don't like to follow a whole tutorial. It just makes it more complicated.
We generally just load up a playlist of how certain things work, and let it play in the background. Skipping around whenever we need to.
What are you planning on using it for
Getting the CommandMap
But i think i dont need it
its really clean
Adding a class for reflections would be to overload it
I mean you’ll have to handle exceptions when you call those methods
I know
Also you should create a class extending PluginCommand rather than reflecting it
Hmn why?
Why extra clases?
Better than janky reflection
Oh ok
How does this prevent the need for reflection?
Because the constructor of PluginCommand is protected
But you can make the constructor in your subclass public
Right but how do you register it
You still need to reflect the command map
Okay
Lmao
Im fascinated with builders HAHAH
Command test = Command.builder().name("Test").aliases(Arrays.asList("test", "testCMD")).permission("command.test").description("Test command").executor(new TestCommand()).build();
🤔
Why would you even do Arrays.asList
Why not just take a String... for aliases
Then you could do .aliases("test", "testCMD")
Honestly though I find builder-style command libraries to be the least enjoyable to work with
Var args are fun
They are
It’s funny looking at some older java libraries that were made before them though
Just a million overloaded methods each with one more parameter
String str1
String str1, String str2
String str1, String str2, String str3
Ad nauseum
Sadly that's still what Map.of looks like because no tuples
cringe
I dont like varargs
Because i need to lost strings (have extra strings of code)
Doing the anottation
what
You just aren’t ready for my genius
Tuples are amazing and java should add them
tuples are just a set of attributes, but some languages treat it as a pair i think
can be more than a pair
it has huge benefits
Java calls records "nominal tuples" but proper tuples would be much better
Object instantiation has a non-negligible overhead, whereas tuples can essentially be primitive
So it’s an arbitrary length group of objects
Yes
Mhm
basically java expect you to create a class if you really need to enforce some kind of typing
don't see how they can be primitives
Well we are getting value types soon™️
If you can make value records that would be incredible, they would basically be proper, effectively native tuples
is there an event that listens for trident throw?
ProjectileLaunchEvent most likely
^^
i have made a plugin that basically allows you to spawn a mob that has an inventory with mob drops and whatnot, so instead of killing them, they'll drop loot depending on how happy they are (they have their own mood scale) and a few extra things.
when my plugin disables all the CadiaMobs which is the name of the object which contains the bukkit entity's UUID, get's written to a database, with one of the main columns being the entity's UUID.
when loading the plugin back up however, when iterating thru the MySQL uuid columns, the return of Bukkit.getEntity(uuid) is null no matter how much i delay that piece of code.
how can get the Entity object thru Bukkit.getEntity without it being null? i've tried loading the chunks before calling the getEntity method but it still returns null...
How can I implement custom block breaking speed, e.g:
Changing the speed at which a block break?
I fear that that may be clientside
uh
weellll
give em mining fatigue
and handle everything serveside
:))
a fricking nightmare to do
but powerful
is a neat guide
but you will need like a lil bit of experience in nms
This happens because the entitiy with that ID might be in an unloaded chunk.
You cant just expect that all the thousands of entities stored in the chunks are accessible at all times.
They get loaded when their chunk gets loaded.
So you need to listen for the ChunkLoadEvent, then get all entities from the loaded chunks and see
if one of them is a special one of your mobs. You need to also listen for the WorldLoadEvent and
when your plugin is enabled then you need to iterate over all the spawn chunks because no events are fired for them.
I think using a database was the worst possible approach here. PDC and chunk events are way more reliable.
A DB would only make sense if you wanted to access the entities from a website or some external service or
if the mobs would be shared between servers. But they are strongly bound to their chunk which makes using a PDC
the far superior solution.
I think this does no longer work as of now because mojang made the break animation for the players own damaged block client side.
u can send custom break states
*Also spigot now has api methods for that
But they are only valid for other players blocks. The own block animation is no longer server determined iirc
Everything for 1.8 is a nightmare...
well
but wouldnt that look the same on the client tho
if the server tells you someone else is breaking the block youre breaking but you cant actually make a dent yourself because slow digging
oh you are speaking of the hacky old way that uses slow digging...
Problem is that it messes with guardians for example
true but if you wanted it to work in a closed environment like "custom ore miningrealm" or smth it is still useful
Actually ill look into that. Maybe there is something in the protocol that could be exploited.
I agree that using a database is a bit redundant here, however using a PDC would mean that would need direct access to the special mob for retrieving their UUID, and then accessing the special mob data. my plugin makes it so mobs drop loot in their inventory (every 5-10 mins, controlled by a runnable), and to access this loot, players need to right click the entity
using a database means that I can consistently loop thru the UUID's, find the bukkit entity matching it, and then do my special mob stuff, but with a PDC, some sort of direct access would need to be establish (probably via event) correct?
this is not correct, i did some testing the UUID stays the same iirc
try #getEntityID
I onced made a staff that can move entities and store its id in the lore, once a server restart is initiated that ID is not the same as before so thats just what I experienced
in case of UUID, its diff ig
This is a very expensive approach. What you should do is add a timestamp when the mob gets unloaded and then when its loaded
again, calculate the delta time and compute the drops that the mob generated since that time.
Using a runnable for only the live mobs and computing the drops based on delta time when they are loaded is far more efficient.
Even a runnable for live mobs might be overkill depending on what you do. Just compute the drops when they are accessed.
hmm, thank you for the suggestion! i highly appreciate that and i will look into it
how can i let the npc look at the player if the player is in a 8 block range. I use this code to look at the player:
public void move(PlayerMoveEvent e) {
Player player = e.getPlayer();
NPC.getNPCs().stream()
.forEach(npc ->{
Location npcloc = npc.getBukkitEntity().getLocation();
npcloc = npcloc.setDirection(player.getLocation().subtract(npcloc).toVector());
PlayerConnection connection = ((CraftPlayer) player).getHandle().b;
float yaw = npcloc.getYaw();
float pitch = npcloc.getPitch();
connection.sendPacket(new PacketPlayOutEntity.PacketPlayOutEntityLook(npc.getId(), (byte) ((yaw%360.)*256/360), (byte) ((pitch%360.)*256/360), false));
connection.sendPacket(new PacketPlayOutEntityHeadRotation(npc, (byte) ((yaw%360.)*256/360)));
});
}```
This is an extremely expensive approach. You should not determine this in the PlayerMoveEvent. Also stream() and then using just forEach is unnecessary. Just use foreach directly.
For distance estimates you should def. use the distance squared instead of the distance because root math is also very expensive.
This method alone will lead to lag eventually.
Doesnt make much sense as he needs a separate packet for each npc...
but how should i do that if i dont use the PlayerMoveEvent
You should use a runnable that determines the distance of the player to each npc which is in his world.
Make it evenly distributed. So not all players at once every 20 ticks. But some players every tick so that the time delta between two ticks
of the same player is 20 ticks. Then put those players which are near an npc in a Map<Player, List<NPC>>. From there on you can use the PlayerMoveEvent.
Section 3 of this thread explains how to do even distribution:
https://www.spigotmc.org/threads/guide-on-workload-distribution-or-how-to-handle-heavy-splittable-tasks.409003/
i'll try this thank you
Another Thing to note is the dedicated Data structures can be used, unfortunately I forgot the Name of them
Multi map?
Quadtrees and Octtrees
It only helps If the npcs are at the same position the entire time however. But it can reduce the costs of Iteration by a lot by Splitting down the npcs into batches
Graph
Do you know how a LinkedList works?
Eh. You will get there. Plenty of tutorials out there 👍
No
its like
a deque
i think?
but it allows null values
Guava has graph data structures btw
and slower than an arraydeque
thats mostly what i know
cant i just make something similar to
a hashmap of a uuid, arraylist<uuid>
Sure. But you will quickly realise what a hustle it is to maintain this properly.
Yes the structure you described can easily be serialized.
cool
then what's the husle
hustle
You can use nio and distribute the work so it doesn't cost that much performance
?
maybe it's laggy
bi directional references are hard to maintain
what exactly is laggy? The serialization?
Yeah but nevermind
I guess its not laggy
What i was thinking is
writing on files might've been costy, but it probably isnt a lot of text
You should never do any IO on the main thread anyways. Doesnt matter if its 10ms or 100ms
Nothing to distribute. Just do a fat single batch.
You wont get better writing performance with multiple threads. Your hard drive has a very limited throughput.
but the thread resources will be taken from the system resources though
o
then do i just use nio
Sure. Whatever you fancy for writing files to disk.
w h a t
Hm, what exactly do you want to serialize?
HashMap<UUID, ArrayList<UUID>>
or is there another data structure that has better performance
Like mutual friend uuid <-> friend uuid pairs? Or is it asymetric?
You might want to go ConcurrentHashMap<UUID, ConcurrentHashMap.KeySet<UUID>>, but that may be overkill
want to keep things simple
o
why Concurrent
So asymetric? Then yes, Just go with Map<UUID, Set<UUID>>.
async saving
Async saving?
you mean distributed, or multithreading, and what do you mean by async saving
"ConcurrentHashMap: It allows concurrent access to the map. Part of the map called Segment (internal data structure) is only getting locked while adding or updating the map. So ConcurrentHashMap allows concurrent threads to read the value without locking at all. This data structure was introduced to improve performance.Sep 6, 2016"
Sure, File IO is kinda fast these days, but if you have a lot of data, saving the database in an off-thread manner can save a small lagspike or two
alr that made sense to me
This is just the tip of the iceberg
The actual cool thing that goes for CMH is that you can iterate over the keyset/entryset while modifying it
wdym
so the purpose of this, is to access it off thread safely, I see
but dont threads take some amount of resources?
running every small task in a new thread would make performance worse, or better?
Depends
thats why you use a thread pool
You can do that with a normal hashmap too
Map<Object, Integer> hashmap = new HashMap<>();
// Put some stuff in the map
for (Object key : hashmap.keySet()) {
hashmap.put(key, 100); // ILLEGAL!
}
Map<Object, Integer> concurrentHashMap = new ConcurrentHashMap<>();
// Put some stuff in the map
for (Object key : concurrentHashMap.keySet()) {
concurrentHashMap.put(key, 100); // LEGAL!
}
ConcurrentModificationException
ic
Well, it is illegal at runtime, you can fully compile that
yeah
Map<String, Integer> stuff = new HashMap<>();
stuff.put("1", 1);
stuff.put("2", 3);
stuff.put("3", 1);
stuff.entrySet().removeIf(entry -> entry.getValue().equals(1));
If you use the iterator then you can also do that with a normal hashmap
Love that method
Me2
That requires that the iterator removes it and not something in the background. But yes, this is a valid way of doing things like that
but uh
can someone explain thread pools
I want to understand them more
I know they like help you manage your threads life cycle and stuff
but how
Its like every other object pool.
You have a bunch of threads.
If you need one then the pool gives you a random free one.
Thread creation can be expensive. Objects with expensive
creation methods get pooled.
so it doesnt exit the thread??
And you dont need to manually go through all the threads to see which one is free right now because the pool gives you one.
how does it give me a free one, doesnt it eliminate free ones
No. If all threads are occupied then you get a random one and your execution might need to wait until the previous workload is done.
it parks it to some degree
sun.misc.Unsafe ftw
so does it exit free threads
so it has a fixed amount of threads,
It probably parks them via the unsafe class
what is parking
Thread pools are used for threads that have short lifetimes.
For example -> you give it a task like calculate 1000 fibonacci numbers. After the thread is done, its parked for the next task.
Or "write xyz to disk". You dont occupy threads from a thread pool for tasks that have a non deterministic lifetime.
For that you would create a single thread.
so there is a fixed aamount of threads
or does it create a thread when you need one, but it doesnt eliminate it
instead it parks it
after some time if u never use it it eliminates it
otherwise it uses it next time u need it
It creates N threads when you instantiate the thread pool.
Those are always the same N threads.
It depends on the nature of the pool
Oh righ. You can define Thread factories
so a fixed amount of threads, damn that must suck resources though
what if i need only one
The fixed thread pool has N threads, however others may create more threads as needed
But usually you would use a fixed thread pool.
Yes
Then you create a single thread executor
Unless you plan on using the thread indefinitely. Then you just instantiate a new Thread object.
i see
so if i wanna use way too many threads i use a thread pool
otherwise just make a thread on my own
You can have hundreds of parked threads lying around. Not that big of an issue.
parking is basically lik
sleep mode
right?
u just put it to sleep, then wake it up if u need it
right?
To some degree yes, though it depends on the underlying OS
You make one on your own if you have a single task that has an indeterministic lifetime.
and when its on "sleep mode" it doesnt require many resources
ic
what if its a small task
a threadpool?
i know it wont last long
https://postimg.cc/cg2Ksnym
How can I remove the one free space at the beginning? If I add an rank there is no such problem?
Add the whitespace to the formatting of the prefix?
I think you want to ask here: #help-server
what is better, returning an object that can be null and if so return null or return a collection that has an element which is the result object, or an empty one if its null
i want to check == null later, but i think isEmpty might be better or smth
Just return null if its one object
If you want to compare objects or string its recommend to do it using .equals()
Yeah it doesnt
Collections should be used sparely. There is an object called Optional<T> if you want to wrap your nulls. Actually really useful.
^
i want performance
Smile how it was call the option that let you check if player exists or not?
Wasnt Predicate?
is optional good for tahat
I cannot rember hence
If you need performance, use null
btw whats the fastest collection for reading and writing
Predicate<T> is just a function that takes T and delivers a boolean
Usually a self-made one
Avoid nulls if possible
And what about for checking an action and returning it?
Lists have good random access times too as they are based on arrays
Isnt used Predicate<T>?
However as soon as you work with primitives, type erasure is going to kill performance
Depends. If we are speaking of random access read/write without growing and with fixed bounds then ArrayList because its directly backed by an array.
Types (T, E, K, V, U, etc) are not used at Runtime, they just are used at compiling
(it is subtle, but still noticable on the gc and the likes if used often enough)
exactly, useless auto-boxing may impact performance
But if we are speaking about, contains, add, remove, remove while iterating etc. then there are a lot of different options.
What its better doing a foreach or iterating over it?
Because there is a big discussion with that
foreach is an iteration. You would have to specify what you mean by "iterating over it"
They are likely going to be the exactly same thing
Some guys said that Optionals shouldn't be used.
Here what they said (I use Google translate because there's things I can't translate properly, sorry if it's a bad translation...):
Not forbidden but heavy for what it is. In java we always say not to use nulls because if you mismanage your code it leads to too many npe problems. But the use an optional, so create an object that has a strong reference to another object just to replace a != null with an isPresent (or all the alternatives), well it's not even folichons to make the code more readable
for (var object : iterable)
is equal to
var iterator = iterable.iterator();
while (iterator.hasNext()) {
var object = iterator.next();
}
Yes. And i think foreach compiles to the same code in most cases.
Wait
Would have to double check on that
Idk what's your opinion 7smile7
Who said that?
Its possible to take a check into your http client lib?
foreach has a slight overhead
A french developer, tbh I don't wanna give a name because I don't want him to get harass for some reason, I just wanna understand things
Dont you made your own http client? or wasnt you?
I do not think so
Why would you even do one?
java 8 with that i tell you all
Temporary objects are really optimized by gc
having a strong reference is not an issue because Optionals should only be ever used in volatile scopes anyways.
But its true that it has a slight overhead. Generally speaking i would value the robustness of my code over a little
bit of perfromance gain. In really really hot code i can see why optionals arent used. Otherwise they are totally fine.
It is better to create a new optional every time rather than keeping it as field or reference idk
Thank you for your opinion
What do you mean by "volatile scopes" ?
But optionals are not just null checkers. They have a really rich API of dealing with empty content. Thats the main strength.
Let me find an example of a plugin i wrote last week.
My personal opinions about null:
- In environments where developers know how to use null checking tools and nullabillity annotations NPEs are a non-issue
- The same can be said about Optional (as you can add annotations to generics params - even if tools such as eclipse will have an heart attack due to it)
- Null can be ambiguous from time to time (no value, or null value?), Optional usually is not
DW I use optionals too :p
Just someone told me I shouldn't and I didn't really understand why, because it's really useful in APIs
This saves me like 15 lines of code.
Who uses eclipse?
That has made me the day
And optionals that contain no value point at a single object anyways.
There is an uber Optional that is used to basically remove the whole overhead if
the element is null.
Let java handle that. Also optionals are immutable anyways. So re-using is not an option.
And read the message above that ^^
I should point out that the flatMap, map etc methods are from Optionals. Because you can stream that single element 😄
Hm but this is one thing i have not benchmarked so far. I should do that rn.
Hi, how can i make an armorstand look at a specific player?
This would teleport the armor stand to player
You can take it as an example
Prob you should set the armor stand location to player location
i don't want to teleport it to the player i want to have an armor stand head pose to make it look like if it is looking at a player
Oh
but ty btw
yes
i have this now, but that's broken
i think i'm wrong with something mathematically
Oh
private void lookAtPlayer(ArmorStand armorstand, Player player) {
Location armorstandLocation = armorstand.getLocation();
Vector playerVec = player.getLocation().toVector();
Vector armorstandVec = armorstandLocation.toVector();
Vector facingVector = playerVec.subtract(armorstandVec).normalize();
armorstandLocation.setDirection(facingVector);
armorstand.teleport(armorstandLocation);
}```
Credits to Choco#9999
Hey, does anyone have some experience with the worldedit api and knows how to do relative location stuff? I've been told iterating the region "isn't fast enough" by someone although I thought 18ms to iterate a region is pretty good
ty
Hello, so i want to make cancel multiple events, when they happen, and i have this long piece of code:
@EventHandler(priority = EventPriority.HIGHEST) public void on(PlayerInteractEvent event) { event.setCancelled(true); }
@EventHandler(priority = EventPriority.HIGHEST) public void on(BlockBreakEvent event) { event.setCancelled(true); }
@EventHandler(priority = EventPriority.HIGHEST) public void on(BlockPlaceEvent event) { event.setCancelled(true); }
Is there any better approach, instead of typing all of that?
but this is not using the head pose
and
private static EulerAngle convertVectorToEulerAngle(Vector vec) {
double x = vec.getX();
double y = vec.getY();
double z = vec.getZ();
double xz = Math.sqrt(x*x + z*z);
double eulX;
if(x < 0) {
if(y == 0) {
eulX = Math.PI*0.5;
} else {
eulX = Math.atan(xz/y)+Math.PI;
}
} else {
eulX = Math.atan(y/xz)+Math.PI*0.5;
}```
then pass in facingVextor
i cant math
is there some way to detect when a end crystal is placed?
hmm entity spawn does seem likely
is there a way to prevent dupe uuids?
what are dupe uuids o.O ?
i have a feeling UUID.randomUUID could generate smth duped
That is rather unlikely
but still possible
Bruh
"For example, the number of random version-4 UUIDs which need to be generated in order to have a 50% probability of at least one collision is 2.71 quintillion"
you'd probably die from a lightning strike while coding spigot first
lol
my mac mini was fried
when a lightning bolt hit my house
sockets burst out the wall
and somehow still no uuid collision
yes
yeah but it is POSSIBLE
so would a meteor striking the earth
probably more likely that that happens than a uuid 4 collision in your closed system
are you hiding your server in a meteor safe data centre ?
if not, start with that risk
i am