#help-development
1 messages · Page 989 of 1
clicking the block where the prop arm is pointed at
since it doesn't trigger interact at entity i use interact event to get it in the line of sight
what prop arm
yeah
i click on the pickaxe
but it triggers all those 3
iirc that should be triggering an entity event and i have no idea how its calling left click
it seems right clicking a prop triggers left click animation
but the dump stack doesn't even call one such event
unless i'm missing something
yeah i dont think the dump would include that
i'mma add a delay and call it a day for now
Hey guys
got verified finally i need help with JPremium plugin
https://paste.md-5.net/buroliwaju.java Here’s the code, I have a problem at line 30 to 40, when I try to /setfree a player, I get an error in the console telling me that the position is null, no position was saved when I did /investigate player. Why didn’t the server get his position?
When I do /setfree player, that player should return to the position saved b4 he got tped to me
Are u talking with me?
no
Ah no
about my bug
how do i give items to players with respawn screen?
is there anything close to an entity covering half of your screen that follows you around clientside? i want it clientside so there isn't a delay
what are you trying to do
covering half of their vision
i guess display entities with billboard=center?
that doesnt follow you around tho?
i want it so if u move it follows your eye
i mean you could do that
it wont have delay?
no
aight
try it in singleplayer
also can i stop them from doing f5
probably not
just check on jd for some keywords
Any solution for this?
doesn't exist, im just gonna put a block on top of their head so its hard to bypass the half vision with f5
yeahh
does spigot have an api for fake display blocks (clientside)
use block displays and hide the entity for other players
guys
in your history with plugins that affect commands have any ever stopped data commands from working
data commands?
bc im running into an error where trying to append a book with data from a storage and it works on a normal world but not on a server
using esssentials plugin
like thjis data merge storage journal1:data {master_index1:['{"text":""}','{"text":"Locations:"}']}
Make sure you use /minecraft:data
minecraft:give @p[scores={update_journal1=1}] written_book{journal:true,title:"Journal",author:"John",pages:['[{"storage":"journal1:data","nbt":"master_index1[]","separator":"\n","interpret":true}]']}
lemme try that
or /minecraft:give
essentials overides these commands (at least give, idk if it also overides data command)
the confusing thing is the data is there in storage if i do /data get but wont be put into the book
Essentials does mess with the vanilla commands
like this specifically works on my world but not on the server "storage":"journal1:data","nbt":"master_index1[]" idk if theres reports of essentials doing anything
so yeah use minecraft: to force it to run the vanilla ones
ye im trying n I just have no idea why its not changing the contents of the book
hold on lemme check the console for errors
this is it on my world
i cant paste it rip
ill figure some tout
basically its "storage":"journal1:data","nbt":"master_index1[] this bit but inside the master index theres the data of the text that goes into it
sorry, how do I put the ranks like this? Is there any plugin or how should I do it...
thats a texture pack
are there any p[lugins that affect written books or their ability to hold information
custom fonts with bitmaps
how is display.getHeight() returning 0.... (line 24)
the textdisplay is being made but it has a height of 0 apparently, doesnt make sense
I believe that returns the entity hitbox height
for display entities this is 0 for both height and width
then how could i get the actual height of a textdisplay
By height, what exactly do you mean
how height the textdisplay goes (y axis)
as in the text ?
Display#getDisplayHeight iirc
just a quick little ctrl-f on the jd page can often help
@dusty herald send pfp
alr ty
im trying to make chat bubbles with seperation but rn only messages with little amounts of text seperate as seen in the screenshot, the bigger texts overlap, and i dont know what i should do to fix this, right now im doing
textDisplay.teleport(textDisplay.getLocation().clone().add(0, display.getTransformation().getScale().y * (display.getTransformation().getScale().y / 6), 0));
full code:
https://pastebin.com/SJBd1zEB
Anyone know if there's a way to have an entity class without spawning it? I'd like to have a way to temporarily store entity information (armor being worn, enchantments for that armor, etc.) and let the player edit it (in a menu), and then use like a wand to actually spawn the relevant entity.
wait chat bubbles with text entities is so goated im stealing this idea for my SMP
EntitySnapshot?
?paste
I'm making a custom enchants plugin and for some reason the enchants code doesnt work but i know it executes?
container.getKeys().forEach((key) -> {
if(modulesList.getList().keySet().contains(key.getKey())) {
modulesList.getHandlerFromList(key.getKey()).doAction(1, event);
}
});
So I know this code is executing, and the code in .doAction() with some logger checks, the prolem is: the code executes, and it logs correctly but nothing past that executes
Here's the code for one of the modules (enchant):
https://paste.md-5.net/femowinowa.java
the "Poison Module" is sent to the player, but the rest doesnt work.
Here's the full listener class:
https://paste.md-5.net/ejeludonur.cs
the same happens for all the other modules
why dooes display.getTransformation().getScale().y max out at 1.0? i have 2 textdisplays, 1 is 5 lines tall the other is 1, both return 1.0
completely unrelated, but why are you using Integer instead of int ?
Also, you're not following java naming convention with the MaxLevel variable
how do i make curved blocks (block displays) possible to walk on like this
Or shulkers riding some entity for more custom hitboxes
They can be scaled since 1.20.5 too!
wait what
shulkers can what?
shulkers can be scaled
since when
do you lack the ability to read
do i get to scale each position in x y z
no
no
crap
You can use several shulkers tho :D
No
this was before 1.20
Ye, but they probably did not use scaled shulkers for fancy hitboxes
I'm just sharing the possibility of this
on the picture you can see the guys it floating, they are using barrier blocks
you can spawn shulkers with different y offsets if you really want the correct hitbox
BDEngine is a 3D editor with many features for easy creation of Block Display, Item Display and Text Display models.
This can help you create this kind of display thing
ik abt this
https://youtu.be/aYi5wnCOXm4?t=101
at this second in the video you can see that it's def not barriers
CHECK OUT BLOCK DISPLAY STUDIO HERE: https://eszesbalint.github.io/bdstudio
Check out my profile on block-display.com for the commands used in this video!
https://block-display.com/author/daftcraft/
Comment which build was your favorite!
#minecraft
does anyone know how to get the height of a textdisplay
get its transformation then get the scale
that gets the scale but my scale is 1, 1, 1 yet if the message is long it makes new liens
that doesnt get the height of the display
just the original scale
get the y scale
idk then
since the original scale is 1
count how many lines it has, then do some math
Shulkers then
how do i get the amount of lines
ive tried
String text = display.getText();
int lineWidth = display.getLineWidth();
int numLines = (int) Math.ceil((double) text.length() / lineWidth);
return numLines;
}```
but it returns 1 no matter what
why do you need the number of lines?
so i know the height of the textdisplay to properly seperate my chatbubbles
you have to calculate when go into a new line, right?
yea
why not just count the newlines you create
don't use the linewidth then, create the new lines yourself ?
i dont think u can do that
if theres no way to get how many lines/the height of a textdisplay that seems like a massive oversight, thats something that should 100% be a thing
You can make new lines with \n
so id have to make new lines and do math to split the message just to get the height/how many lines there are?
If there is no better way of doing that, then ye, probably.
I don't think you can even get the line count 'cause it could be different for people with different fonts.
If it works in the way I think it does at least.
alright then thanks
You can split strings with ChatPaginator.wordWrap
ok thanks
how do I check if a creeper is a passenger? im making like a pickup feature where a player can pickup entities and i need to cancel a creeper exploding if its a passenger, so if its picked up
I alr have an array of all the picked up creepers and check if its in that array but that doesnt seem to work for some reason
also is there a way to listen for when the creeper starts to ignite?
I want to stop the animation from appearing
yeah but how do i check if an entity is a passenger
(if a player has the entity as a passenger)
how do I check players in range for that creeper?
like detect every player in a 3x3x3 radius
i would loop thru them and check if that creeper is a passenger to anu
any
nvm i figured it out with some math
Entity#getVehicle != null
Should've seen the monstrosity I did on Hypixel a couple weeks ago
gonna post this here for more visibility https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/1396/overview?commentId=12886
and did they ship it?
Entity passenger = entity;
while ((passenger = passenger.getVehicle()) != null) {
passenger.remove();
}
Or something like that lol
oh, this is fine
but can a vehicle be inside another?
Yeah you can have vehicles riding other vehicles. Honestly not entirely sure why it caused a SOE
One sec, lemme find the snippet lol
Choco broke hypixel
Ah, here it is
private void removeEntityAndRelatedEntities(Entity entity) {
entity.remove();
// Passengers
Entity passenger;
while ((passenger = entity.getPassenger()) != null) {
if (!(passenger instanceof HumanEntity)) {
passenger.remove();
}
}
// Vehicles
Entity vehicle;
while ((vehicle = entity.getVehicle()) != null) {
if (!(vehicle instanceof HumanEntity)) {
vehicle.remove();
}
}
}
I probably just did something stupid tbh lol
not the worst, probably best to have methods that do one thing
Is that hypixel naming conventions or you're just that specific haha
instead of a and b methods
you working at hypixel?
been
i wonder if hypixel would hire me
Choco best hypixel dev 100%
i think i have some code like this but like way worse
Yeah and see if you weren't the best you wouldn't admit to your mistake
Best and most humble dev right there
Hell yeah!
It was kinda sick ngl
what happened?
All props were invisible 😄
Well, "invisible". They were just a few hundred blocks in the air
ah yeah here it is
private void clearPassengers(Entity entity) {
List<Entity> passengers = entity.getPassengers();
for (int i = passengers.size(); i > 0; i--) {
Entity passenger = passengers.get(i - 1);
clearPassengers(passenger);
entity.removePassenger(entity);
}
}```
Oooo recursive 😄
it happens
I mean
why did u use recursion?
To prove a point
Recursive methods kinda depend on the context more eh?
I know I've got a couple looking the same
it was for my /sit command on smp
whats with people sitting on things theyre not supoosed to sit on
That's a question we don't want to be asking ...
is the 1.26 api out?
i dont even want to know what you mean with that
1.20.6*
Hey man you asked it
im fairly certain i didnt need to write the method becos it wouldnt matter in the end i think
since i just .remove() the entity
but maybe i had a bug from just that
Now you've got me interested in recursive methods... when to use them more or less
use them on things that are absolutely awful to implement non recursively
I guess I don't even really know how to apply it
ItemStack item = new ItemStack(Material.SPAWNER);
how can i do this to an Zombie Spawner
Uh you might have to do that after it's placed... don't quote me
Guys any solution for this?
You never stored a location
use block data meta iirc
Mmmh
ItemStack item = new ItemStack(Material.SPAWNER);
BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
if (meta != null) {
BlockState blockState = meta.getBlockState();
if (blockState instanceof CreatureSpawner) {
CreatureSpawner spawner = (CreatureSpawner) blockState;
spawner.setSpawnedType(EntityType.ZOMBIE);
spawner.update();
meta.setBlockState(spawner);
item.setItemMeta(meta);
}
}```
This should work
The update() isn't necessary. update() is only for in-world stuff
ah gotcha
can i Choco.update() pls
I didn't remember
to?
latest
I'm being asked to throw it back
I
youve heard of the cat distribution system now its the choco distribution system
If that is how you interpreted it...
I would like help on my spigot plugin. my problem is that I have 2 different special bows, and both of them are doing the same thing. should I send the code?
?paste
I like the sounds of special bows
what do i do at that website?
Paste ya code
click save and copy link here
should i copy the code of both bows there at the same time?
After you paste all the code, click this button and send the link
I clicked it but it just asked to open in browser 😄
Well maybe you should tell md to make a pastebin application instead
Then it'll still upload the paste to web and you'll still have to open in web... that is unless you also have the application 😄
What a great idea
Does nothing with a ; at the end
how do i make a creeper just never be able to explode/start exploding? I guess clear its pathfinder and target or something? its supposed to be a custom entity
lmao isnt this terrible practice because I can just rename an item
Yo, what should I tag as "Source" in my intelliJ maven project?
elgar you probably know this
src, main or java folder?
what is it supposed to do?
Oh yeah those have to have body's
if (xyz) {
//do something
} else {
//do something else
}```
@obtuse kayak, like this
You could cancel it's target event
its like a custom creeper that just does nothing. it still moves around but doesnt follow anyone, doesnt ignite
then cancel its target event
that would make it not ignite right?
like when a creeper starts the exploding animation
If there's no target to ignite on, then it shouldn't ignite
Just don't do anything too crazy in that event. From experience, it's just as bad, if not worse than, PlayerMoveEvent
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("Zombie Spawner");
item.setItemMeta(meta);
item.setAmount(Integer.parseInt(amount));
p.getInventory().addItem(item);```
how can i give the item like an "key" that i can ask for in an if?
He's got a custom creeper defined I think, so it should be good
like if item has key
So for meta we use pdc
^
What can't pdc be applied to?
blocks 🙂
Anything that doesn't have NBT
Gotcha
so what can i do
but then in most cases, like blocks, there are other libaries people have written to kind of still use pdc with those objects anyways
See the thread linked above
It explains how you can use the PDC to assign arbitrary NBT values to items
okay
use getItemMeta().getPersistentDataContainer() and add some string to it
and how can i add this to the item
:p
well its the itemmeta, so yeah same thing as with other meta stuff
Pdc essentially gives that item a key -> value state within your plugin. That being said another plugin with perhaps the same key -> value pair, they won't conflict because it's plugin dependent as it were, correct?
Yes, the keys are namespaced to your plugin
Ie: the namespace is held plugin dependent
If you're using the NamespacedKey API correctly, that is, it should be fine
i got my thing to work. thanks for the help!
itemMeta.getPersistentDataContainer().set(key, PersistentDataType.DOUBLE, Math.PI);
what do i have to set for key here
the NamespacedKey("KeyValueHere", plugin) string is your key
(missing a plugin arg)
public static NamespacedKey createKey(String key)
{
return new NamespacedKey(MyPluginClass.getInstance(), key);
}```
I just have a helper function for it
or whatever
That's better for like a lot of keys, which in your case would be nice as I assume you're going to have multiple custom bows
(yes I use my plugin class as a singleton, hate me if you like)
You could just make a constant instance for every class you need the main instance in:
Plugin plugin = Plugin.getPlugin(Plugin.getClass);
i dont understand can u explain
meta.getPersistentDataContainer().set(, PersistentDataType.DOUBLE, Math.PI); i have this
So the NamespacedKey object you put there
And it's good
Just make a different key for each item
a different key for each property you wanna save
NamespacedKey("TeleportBow", plugin) ,
NamespacedKey("TntBow", plugin), etc
meta.getPersistentDataContainer().set("dd", PersistentDataType.DOUBLE, Math.PI);
this dont work
i dont understand what this means
You put the OBJECT there
you need to create the namespacedkey
Not a "string"
it means you need to create a new namespacedkey
oh i undersnad
NamespacedKey teleportBowKey = new NamespacedKey("TeleportBowKey, plugin) -> meta.getPDC.set(teleportBowKey, etc, etc, etc)
the easiest thing is just to create a static one like new NameSpacedKey(plugin, "type") and then save the type of item as the value
you dont have to create a new key for every item if its just a different name
All the bows have different properties, you might want to put those into their own pdc's no?
yeah
but you should create a new key for each kind of property, not for each value
Oh did I say value
Just good clarification for sure
meta.getPersistentDataContainer().set(new NamespacedKey(Legacy_spawner.getPlugin(), "zombie"), PersistentDataType.DOUBLE, Math.PI);
i have it now like this and it dont gives errors
if you save pdc on an item like what kind of bow it is, it should just be a single key and specify the bow in the value
I don't think you want that
because rn the PI thing is just unused
Considering context, won't this try to create a new key every time a zombie spawner is needed?
And if one already exists, does that mess it up?
if the key already exists it's returned from the registry
I assume it doesnt get messed up xD
Cool then that should be fine
i wanna do an /give command and the item you get gets this key
Are you trying to use the vanilla /give command?
and what are you going to do with that information
no custom command
ok good
to an block that if you break it smth happens with it
Guys i need help
With
will it work like this?
So then the logic for creating this spawner should be in the command class, when you need to give that item to the player, just pass the ItemStack object rather then trying to get a random key from the namespace
it is in a normal class
Making a new namespaced key isn't that expensive
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/NamespacedKey.java#106
How many spawners are you trying to manage?
That being said theres no reason not to cache it
He a bit new coll
wdy,
im doing a plugin where by doing /investigate <playername>, he will get teletrasported by a base already setted with /setinvastigate and as soon he got tped there he is frizzed, but i want that as soon i type /free <playername> he gets tpd to the old position where he was
Well you've got zombie right? Are there any more?
there are 4 types more
And what are you trying to do after the fact they've been given to the player?
if you place them
and break them
if the have this key smth should happen
and i wanna do if you rightclick them smth should happen
Ok cool, so now that we've got this. You'll only need the key when they break/place the block. I forget the events for these, but if you look on the spigot jdocs you'll find em. Once you've got the events you just need to detect when its your spawner that broke/place which entails creating a new itemstack object -> getting the pdc -> checking for the key. After you verify its your spawner, you do whatever it is you want to do
I mean, loop through the list and check every x?
to check if a chunk contains an x coord you just do locX >> 4 == chunkX
do i gave the pdc with this line on the give command ?meta.getPersistentDataContainer().set(new NamespacedKey(Legacy_spawner.getPlugin(), "zombie"), PersistentDataType.DOUBLE, Math.PI);
You should just cache the key rather than create a new one every time
NamespacedKey keyName = new NamespacedKey(plugin, "someKey");
Then you can use that object when you need it
Makes it easier and maintainable
When you have the itemstack object defined, you just pass that itemstack to the player.addItem(itemStack);
Yo, what should I tag as "Source" in my IntelliJ maven project?
src, main or java folder?
I know I'm being very stupid right now but can you maybe write me these few lines of code 😅
if x = chunkX
<< 4 is * 16
I really can’t go further
I’m trying to save the location of the target when I try to teleport him to an investigation room. So when I do /investigate target, the plugin must save the current location of the target and then tp him to the interrogation room
I get method call expected on line 45
I don’t understand, I could drop the whole code if someone needs to check it
hi, how could I make it so that if I hit a mob that is in a boat, it gets out of the boat?
you can;t invent a method that does not exist savePlayerLocation
It does exist
In another class
not in that class it doesn't
You expect it to magically know where that method exists?
I told u, I wrote a private line 8
?learn j-
That’s why I wrote the method in another class
wtf bro
If I do so it gets messy
hi! How can I get trowed snowball custom persistence data using ProjectileHitEvent? Is it even possible?
Can anyone please explain me what I am doing wrong?
So much
field != method bro 😭
Like what?
i dont see the class you used to save data
private LocationSave savePlayerLocation;```NOT useable as its not even assigned and it's not a method
So what’s the solution?
learn java 😛
🥰
To this problem
And I am learning Java
How can I learn Java if I don’t excercise? Now explain
It looks like you want to use a method IN your locationSave class
I want to save the last location of the target in a yml file
to do that you need access to it
If I do the command
It's the first basic things you're learn, how could you not know?
does your LocationSave class handle saving the location?
then you need access to it. Rember DI you did for passing your plugin instance to this class?
DI?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Oh dependency injection
You do not initialize any value to the field
so you can use java this.plugin.getConfig()...etc
Where? In my Command class or LocationSave?
You need to be able to access your LocationSave class/instance the same as you do your plugin
Wdym?
where do you instance/initialize your LocationSave class?
then add a method in Main to getLocationSave()
make it public and it shoudl return yoru LocationSave instance
Will it return also in my Command class?
then in yoru command class you can use java this.plugin.getLocationSave().savePlayerLocation(target);
Would someone be so kind as to help me with a solution for this problem?
it has to return the instance not void
your LocationSave instance needs to be a Field set in Main
So public LocationSave getLocationSave() { return instanceof LocationSave }
closer, but no
So public void getLocationSave() { return instance; }
return this.locationSave;
basic things..
bro even missing ;
so long as you created a Field in your Main called locationSave AND intialized it.
where do you create your new locationSave instance?
Inside enable
At the very top of the class, you should have a Field called java LocationSave locationSave;
then in yoru onEnable you do java locationSave = new LocationSave(...
adding whatever args you already do to initialize it
your sql server stopped responding
It has nothing to do with any plugin, right? that would become my Mysql
it could be a plugin killed it, but unlikely
Which class main or command?
Which class is your getter in?
Wdym? getConfig?
You don;t understand what a getter is
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, "");
Why does ChatMessageType cannot be resolved to a variable?
getConfig() is a getter as it returns a Object/instance you want. Its not YOUR getter though
you just created a getter
This is my main class
looks like you didn;t and just ignored most of what I told you
What did I ignore?
creating the getter, creating the Field
If u look closer I’ve created the field
you are also creating FOUR instances of your InvestigateCommand class
no you have not created a field
you copy/pasted the assignment, but you did not create any field
I’m trying to figure out what should come inside those brackets
But do u see any getters here in the main class?
this line does nothing in your code (un-needed) getConfig().options().copyDefaults(true);
There is no getter as you ignored me and never created it
Where did u actually say something about a getter
U asked me where the getter was
Aaaah so that’s the getter
hi! How can I get trowed snowball custom persistence data using ProjectileHitEvent? Is it even possible?
?pdc
If you set it, you can read it
I didn’t write it bc I didn’t know where to place it
As u didn’t answer me and ignored what I asked
I answered every question you asked (when others did not)
Here
And I answerd you with a question
well a getter is a get method that returns something
I am learning
But that doesn’t actually answer my question
SO add your getter and teh Field that still have nto added
No
fields do nto go in methods
its a local variable if its in a method
you need a Field
Ok
a Field is a class level variable. It sits outside any method
You litterally have an error right now which when hovered over tells you there is no assignment
or something close
it will also suggest you create a field or a variable
Cannot resolve symbol locationSave
hover over it
it will give you suggestions
just look for the one mentioning a Field
Create field in MainClass
yes
It made a private LocationSave locationSave
Yea, that’s what I was doing
I added the getter and I got this error
That I corrected by hovering over it
ok
Now that I did all of this
If you did it all correctly thats all you need
Theres a LOT of bad code in your Main but you'll discover that once you begin to understand instancing
Since Java automatically "uses all the ram in task manager" how do i know if my plugin is bad optimized?
could use visualvm and see how the memory usage evolves
how can i tell if the last server close was a crash
check logs ?
Spark and VisualVM
That's the neat thing. You can monitor a lot of things with Spark
automatically in onEnable
Does anyone know a solution for my problem?
yeah but we're not here to spoon feed you
That’s not what I am asking lol
ElgarL has told you what to do
I literally did what he has told me but the problem persists
read log file from behind and check for keywords i assume
idk if there is different way
hm
Who’s that something that tells u that?
this is for ItemStack, I have throw a snowball with custom data but in ProjectileHitEvent this snowball is an entity
Entities have a persistent data container to.
best way is to dip into NMS and save the underlying NBT to bytes imho
you can also use Bucket's Object Output Stream which is worse for that but it works
is there any tutorial on that?
no the BOOS works like any other stream
for NMS you're on your own
if you can't figure out streams figure out how to use google the java io and java nio API has had probably millions of questions asked and answered about it
is there no other way to do it?
no why would you do it any other way
when you have the objectively best way to do it literally layed out for you
well I dont understand like 70% of what you are talking to me about
?learnjava
For Beginners:
Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/
For Intermediate to Advanced Learners:
Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/
Practice and Hands-on Learning:
Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/
Free Resources and Documentation:
Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/
Community and Support:
Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/
Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉
The BukkitObjectOutputStream use is basic java knowledge you should be able to use IO Streams by now. If you can't use IO Streams and are involved with databases. Go back and learn more. You don't know enough to effectively use a database
oh learn java updated
?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.
https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
mi favorito
I know enough to use sqlite database
doesn't seem like it considering you don't know how to use OutputStreams to put blobs in SQLite
yes it does, because all I needed to put was floats and strings
why would I learn excessively too much if I already know what I want
"learn excessively" the basics are not excessive
just to notice, iirc you can't just call setBlob on PreparedStatement as its not implemented in jdbc driver
Blobs are supported by SQLite
I just use setBytes
that's the wrong version
bukkit uses JDBC3
still, pretty sure you have to setBytes
I didn't even know setBlob was a method
sure but its a dog shit method
don't pursue a poor solution because you refuse to learn
that's defeatest attitude
Use BOOS or NMS with NBT
not to mention you'll have to turn the Map<String, Object> into a base64 string ItemStack#toString won't give you what you want
how to get nbt
with NMS
based on your java knowledge tho I'd reccomend BOOS tbh
IO Streams are not that hard man
so its literally just that and then using setBytes?
you didnt really say what to save inventory object as at all
what are Inventories?
object?
string
?
friendship?
YOU GOT IT
this doesnt even have boos
boos is just impl of OutputStream
Wth is boos
bukkitobjectoutputstream i assume
its just it?
How is it different to any other output stream?
Is it for like nbts
dk what is different in its impl to be honest
Are you trying to save an inventory to an SQL database?
It's just to help with serializing classes with the ConfigurationSerializable API
.
If you used another type of standard output stream, it'd have no clue how to use ConfigurationSerializable :p
as singular items?
You aren't passing any invetory data here tho, are you?
???
yeah
the entire inventory object or would the contents be enough
cause what else could u need from an inventory object lol
You don't need a database for that
yep
and take a wild guess who told me to make SQLite database
Is the inventory under any external influence?
I dont have anything else implemented and Im stuck with this
okay
ChatGPT?
no, someone in here
there could be reasons to use a db BUT
there's ConfigurationSerialization that deserialize
please explain what exactly you are doing
i've looked
do you need the invs cross servers?
I already told you
what I need
ksndownfowbfk
So you have full control over it
.
And it doesn't require any communication between servers?
Cuz you started adding a fuqing database
and we are trying to find out why
Yes, and the object streams use that class
yeah which is why I have them blocked
I'm just confused why you even listened to the guy
I asked like 5-6 months ago here how do I store my data and I everyone here told me to use SQLite
And why hou haven't questioned him
that question is so versile
a very very very vague statement
The help you get is based on the information we have. If you don't give enough information people may try to fill in the missing parts themsleves
that doesnt help with anything
They probably use it themselves that's why
„where do i store my data“ is even more vague
it would've been nice if configuration serialize required a map constructor
you already boasted about having me blocked so you dont even have to bother yourself talking to me
I just save my data with a text file
it depends on the kid of data
No
because it didnt solve shit lol
when handling user sensitive information cross server you should use a db
yes!?
I believe comments like this is why you're blocked. tbh I can't remember
wow
No need for a db
great argument
so you have me blocked just to open up every message I send and remind people of that, understood
db is actually a file 💥
That is a logical fallacy right here
everything is eventually a file sure
i mean just write it on paper and use ocr to read data into memory
I made SQLite database to store player statistics like deaths because thats what Ive been told to use for shit that changes over time
Then I was told to not use it for shit that doesnt change like custom enemy statistics or custom weapon data, so Im left with no implementation for that
Databases and files both have valid use cases
but you cant just say every data should go in either
and now I wanted to implement inventories into SQLite database and yet it will be referenced upon a lot
My point was: why would you need a database if you're system isn't spread out and isn't of great size
and yes no.2, each player will have their own set of inventories
It makes total sense to store player stats in a db
as GUIs
thats correct
okay so dusk
you should not store guis
instead
store the building blocks of the gui
and regenerate them every time requested
for example
lets say the inventory should display your deaths
just an example
every time they join you get their deaths
and generate the inventory accordingly
I would honestly just create a folder and in it would be files with the Inventory object serialized
and remove it after they leave
like what, yaml?
Just write the bytes you get into the file
ah i give up
do what ever you want
but dont complain about it being inefficent later
No need to define the extension
I would leave it empty
what the fuck
you literally give the most vague answer
and dip out in the middle of explaining it
?
how is this vague
i dip out cause you are straight up ignoring what im telling you
I am waiting for you to finish
He's just listening to his options
when you send one message at a time instead of entire explanation in one message I have no idea when you are supposed to finish
If it's just a binary file you can use the .bin extension
so im waiting for you to say when you are done
db for cross server or large amounts
files for small data that doesnt need to go across servers or be requested any elsewhere
can you tell me what exactly these inventories contain?
Is it like a storage, or a menu of some sort
the easiest example I can provide is look at hypixel's guis
because each player has their own data to be shown there?
then store the data
He wanna store it so that the changes apply
not the inventory
yh store the data not the inventory tf
great but how
ill trash it
Same thing
because its supposedly unnecessary to use sqlite for that
are you drunk and high?
What do you not get?
Inverting the question
WHY TF WOULD YOU STORE THE INVENTORY INSTEAD OF THE DATA
Back at you
If I want a GUI showing my stats I store my stats not the GUI
THANK GOD
SOMEONE WITH A BRAIN
^^ just an example
The Inventory contains the Items
so like what hypixel stores every single thing like "has X crafting recipe unlocked" in database that is 10000000000 blocks long or what
storing the inventory would be way longer.
not at all
no?
do you know how many bytes a single itemstack is
I would store the whole inventory because of custom names and the actual size
idc its in one place instead of being spread around god knows how many
okay then
how would I make an enderchest in that case
Id have to store the entire inventory
thats something completly different
no store the items
not the inventory
the inventory contains unecesarry information
whats the difference
wasting space
.
of course it would have custom names and shit lol
Yes, storing a few bytes more is such a waste of space
Ah, the 0.001 KB more
Oh man
Then do the whole inventory
Look whats easier to save:
siea has 10 kills
siea has 10 deaths
Or
Theres this gui its 20x3 wide it has 41 slots of them are 3 filled
for each of the 3 items
Name
Desc
Material
Size
Texture
Additional Data
Slot
just like that?
Wtf are you on?
Bro
all of the things you mentioned below are stored in a single inventory object
What is with you
yh and its still a million times bigger
Have you ever actually seen the Inventory object?
grasping straws with hyperbole
classic
"The source is that I made it the fuck up"
okay yk what
i will caculate it rn
it doesn't really matter
Will still apply
? no
Uh
integer is number
You could have like a few fields with values
You could also have it as a convertable String
Depends on how you save it
so how do I write it into SQLite database
Okay, still, why the database
Itemstack
Item ID: Assuming it's stored as a short integer (2 bytes)
Metadata: If stored as a byte, it's 1 byte
Count: integer 4 bytes
NBT Tags: say 50 bytes, for this example (could be much more)
``` Total around 60 bytes
Now for a normal Large Number (2 147 483 647 32bit limit)
Thats 4 bytes.
now 60/4
how much is that?
Or whatever, let's just stick with it
its
going
to be
changed
over time
why else would it not be database then
Not everybody has one
Item IDs are Strings
?
And requires a set-up
I dont care I have it
Uh
I've seen implementations with shorts
if u are trying to save it as byte array, same as anything other, just call setBytes on PreparedStatement
Back in 1.8?
It got changed in 1.13
Every packet-driven item implementation I've seen uses a short
Well duh-uh
Yep
helpful
we have no idea what is dataAccessObject.getInventory(), but we can assume its not returning byte array
how to do it as one liner
Just create a local var
Or a seperate method
Yeah that’s not gonna be a one liner
yeah I quit it
So that in the code it'll just delegate to it so that it's a one liner
Yeah the client and server sync the data to make that possible. Boos won't store the item id as a short
Well then too bad
A String
And even if you handled that yourself you'd need to migrate the data or ensure unqiue ids cross versions
Is natively a byte array since like java 9
even if its not a string an itemstack is at least 20 times bigger than a 32bit int
Yeah I’d just store the namespaced key
Coll you dont understand the pure insanity that is going on here
they are storing player data
in an inventory
Eh?
No
yes?
He wants me to look bad
how not to show your reading comprehension 101
a random message taken out of context
The guy is trying to save an inventory into a db
alr8ight sure give me context that makes this any better
Dassit
The only reason to do that
yh which doesnt make sense as the GUI only display the player data
the context is that its unrelated to your "they are storing player data in an inventory"
Would be to store stuff like the players inventory across servers
I didnt say that?
What else would you call played x unlocked x
I want a way to store interactive inventory GUIs for both menu and stash purposes
Yes
even if its a changing data
Don’t store a menu, just store what you need for the menu
that cant be saved by itself
my girldi-
have been saying that for ages
Storing an inventory for a stash makes sense tho
it fits in a byte :(
we all start somewhere
can you store it in yml file
true
