#help-development
1 messages · Page 990 of 1
I want a way to store this data:
-custom enemies, items
-menu and stash inventories
-player information (deaths, kills, etc.)
is there really no possible way to do it all in one type of data holding shit?
Okay look ima give you one final answer completly explained and you can disagree all you want anyone with a brain will be on my side
It depends what you are storing, there are 2 options:
A GUI displaying player personal data: deaths, kills, achivements, skills, friends, anything like that
-> Dont store the GUI store the data (kills,achievments,skills etc)
or
A Inventory holding actual items like an enderchest. Items that arent just normal GUI-Buttons
(Store each Item as an Itemstack)
For both you can use either a file or database. Databases are usually faster and more secure than your average file but of course also a bit more complicated. Either way both will work. Just make sure to store what you actually need depending on your case
how do I store itemstacks
you can serealize them for example
meaning
they get turned int a long String
or if you are using yml files
you can store it just as is
sqlite database
why
cant I just make it a string
its easier
than whatever that shit is
Okay, and how do you do that
.toString?
No
That won’t give you a valid representation of an itemstack
Kyori and then by hand deep to string
then how to do this
And even that might not work
You will not be able to get the actual itemstack back from that String. So yeah serialize it
give me a sec
maybe i have a method laying around
public static byte[] serializeItemStack(ItemStack itemStack) {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
// Write the itemstack to the stream
dataOutput.writeObject(itemStack);
// Close it
dataOutput.close();
// return the result
return outputStream.toByteArray();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
that should be it
Smh use twr
^
well it doesnt work anyway
You removed the try
^
why would I keep it
Because it catches the exceptions
No
not in this case
yep
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! 🎉
It’s not
invalid?
no its not
what xd
this is with twr if youre wondering. Both work
public static byte[] serializeItemStack(ItemStack itemStack) {
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream)) {
dataOutput.writeObject(itemStack);
return outputStream.toByteArray();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
Its not invalid you just have to use it properly
okay whatever how about the other way around
wdym how about the other way around
u need the same method reversed
i could spoonfeed but how about you try to do it youself
ill be happy to resort to blackbox in that case
no idea what that means lolz
if you dont try to do anything yourself and rely on us to do everything for you that isnt gonna get you far
its just a personal project
lol
nothing serious
I would never touch java to begin with but im forced because its minecraft
public static ItemStack deserializeItemStack(byte[] byteArray) {
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(byteArray);
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream)) {
return (ItemStack) dataInput.readObject();
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}
``` - here u go
finally
if you dont want to touch java and dont learn it properly pay someone to do it for you
blob
I have a command that I set the permission default: false because I only want specific players using it, but it is denying permission to console, how can I give console permission?
default: op
In this case I do not want OP to have this permission
console has every permission
what
you dont want op to have the permission?
okay so step 1 to debugging is look at what getBlob returns
(or just use getBytes/setBytes)
smh lynx stop 

so which one is it now
I do not want OP having a certain command for my project, but I'd like Console to be able to.
use getBytes
i dont think you understand what op is
you simply shouldnt give people OP if they arent supposed to do virtually anything
OP is the supreme
I get that, I just want to know if this is possible or not?
well sure you could test onCommand
allow op to use the command but check inside the command if they fullfill what ever else you are looking for
You probably want to check the command sender. I don't think setting the permission default can do that
0 bytes would be nothing
That’s how epics brain is stored
real
i share a boolean with @quaint mantle
lets hope that it works
2 negatives is a positive yk
i love the explanation of 2 negatives = positive
the code i provided 100% works now its just on you using it propperly
why would I trust you
average helpdev interaction
go ask gpt then
then trust the hivemind of spigotmc
spends 2 hours trying to get spoonfed and then comes back 10 seconds later because they failed to copy code
epic how large is a boolean
why are you so butthurt that I didnt say that I submit fully into your guiding skills
im not buthurt i made a joke what r u on
wdym type bytes
i would also recommend you to seperate stuff into different tables
no
nah i store all my data in 1 table
its not my server suffering
im only testing it
everything i ever store is 1 table
dude you are so butthurt lmao
I want to check a single thing and you already act as if you just jumped out of boiling water
it aint that deep
where did I ask for help in that
where did I ask about that
i understand why eveyrone wants to block u geez
well then do
oh i will
voss i thought you sent a bug gif but there was an actual bug on my screen
lmao
haha of course
gotta show everyone how you blocked me just to then talk with me even more
classic
I have a configuration file layed out as so:
data:
- key1: value1
key2: value2
- key1: value3
key2: value4
I'm currently trying to read in the ConfigurationSections with conf.getList("data"), and casting it to a List<ConfigurationSection>
However, when I attempt to loop through the ConfigurationSections with
for(ConfigurationSection section : sections) {
```I get thrown an error:
> class java.util.LinkedHashMap cannot be cast to class org.bukkit.configuration.ConfigurationSection
I haven't been able to find a solution or post on the spigot forums, so thought I'd ask here. Sorry if I'm interrupting a conversation
thats a map list
you need to loop through the configuration section data
and add it to the hashmap
she linked on my hash till i map
use getMapList it returns a List of hashmaps with the data
didnt know that method exists lolz
how do you add commands
for that case it would return List {Map{key1 to value1, key2 to value2}, Map{key1 to value 3, key2 to value 4}}
read the docs
bro didnt read the spigotmc.org plugin tutorials
that outline how to get started
why would I remember it after 6 months of not touching java
i go months without touching java and still remember
why would u not check the docs if u didnt know/remember how to do something
But wouldn't the retun type of List<Map<?,?>> only permit one datatype for the value or is my Java knowledge inaccurate there?. I'm storing both strings and integers
iirc it should be Map<String, Object>
I dont remember where shit is
Im on new OS so I have most of my things wiped
Well if you just did it for 3 months and then stopped for 6 you might forget it. At some point you are never really forgetting it lol
woah
His new OS wiped google
dont act like I owe you anything
most specifically saved pages
Why don't you sync your bookmarks with your google account?
Helps a bunch especially since they are available on all your devices
and who are you to magically care about me out of nowhere lol
I didnt do it and thats the end of the story
You sure are a fun person to be around huh? Fine, I'll ignore you
any1 know where to donwload the spigot 1.20.5 dependency
1.20.5 got replaced by 1.20.6
you are the one to start it
Are you using maven or do you need an actual jar?
taunting people and then acting surprised when they talk back
i need the jar
tysm
is byte[] itemstacks or itemstack
?
if I want to store several itemstacks do I neeed to make array of array of bytes
or what
well, you'd flatten them into a single byte array presumably
but yea, you serialise each item stack into its byte[] and then combine them all into a format you can read later
byte[][] would go crazy frl
how to read it

does that even exist?
no
no idc about that
aight, gl 💪
?
You don#t seem to have any clue what is happening
thats why im asking questions
dusk please just leave the server
That is too much for me, so I am just gonna go
I dont expec tto have something thrown at me with "here, take it or leave it"
and wished you good luck
well if you would put a little bit of effort into your question it would be easier to help you
no, I just don't have the energy to walk you through this
maybe someone else will
a binary format is a tedious topic
why even start it?
"How do i do x"
sends link on how to do x
"NO!"
you attempt something ure not capable of for no reason
I mean, I started with just "what is a byte[]"
We solved that
and then you asked for more
I get thrown random solution with no context
at which point, I dipped
no context lol
Its a gist that spoon feeds you exactly what you asked
how do I load inventory with itemstacks that are in byte[] form
^
No context??? The code is entire commted
but that should not matter
from top to bottom
He's encoding item stacks in base64 even though I said that'd be idiotic earlier...
it is yea
Nice glad to see he needs to be thrown the code
im not even doing anything
because people just throw code at me with no explanation and expect me to be thankful for that
its a somewhat popular gist for ItemStack[] -> base64
what are your bytes then?
I don#t expect you to be thankful 
Why would you ever need an item as base64
how would I know?
the code is fully commented
It should still give you an idea on how to write a full array of items
I dont give a shit about that code its out of context and I wont be using it at all
also its apparently shit
loop over the array
.
write each of them into the bukkit output stream
well the code is not shit, the idea is stupid in the first place
(okay but y2k_ is an idiot /s)
I guess like, storing it in a config but non readable?
Idk why you’d need that but yeah
It was accurate till you added the /s
sorry 
Hes still trying to store them to a database
no clue how we ended up with bas64 though
i blocked him at some point
write each ItemStack[] into the BukkitObjectOutputStream
lynx
for your sanity
go to sleep
as seen here
make sure to write the length of the array first, so you can reconstruct that too
i spoonfed it an hour ago
you misspelled "stfu"
They got that working
they are on ItemStack[} now
stfu

okay I cleared my project out of every single idea that has been passed there
and now I will ask again
return null 💀
how do I save inventory (menu or stash) into a persistent data holding structure
any1 have any reasources on updating my plugin to 1.20.6
i didnt want to make it more complicated that it has to be
what
?
U go to ur pom.xml or what ever
im tryna get acsess to the new attributes
and change the number
thats it?
yeah
im tired of getting an answer, someone goes and says that its shit so I need to clean my code off it
Convert either the inventory or stash to ItemStack[].
Create a BukkitObjectOutputStream.
Write the length of the array
Write each item in the ItemStack[]
Grab the bytes the from the OutputStream the BukkitOutputStream was based on
Profit
I don't know of a better method on spigot
Dependency 'io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT' not found i get that error
sir, this is spigot
Write the length of the array
Write each item in the ItemStack[]
Grab the bytes the from the OutputStream the BukkitOutputStream was based on
what does that mean
?whereami
When you go the other way around, create a BukkitObjectInputStream
Read the lenght
Create a new ItemStack[readLengthHere]
Read length times an ItemStack from the BukkitInputStream.
Set it to the created Array
Return it
Well the first step is a writeInt with the length
and the second is a for loop and a write object
Pretty sure those things can just take an Itemstack[]
coll
I would not pray on it
can you convince md to automatically send the gif every time someone mentions paper
but how the fuck do I write length of array
what does that even mean
you call writeInt on the BukkitObjectOutputStream
Okay but what does that mean
what does that mean
what does that mean
do you know what a method in java is?
what does that mean
smh so true
if this was paper you'd be demoted
what if someone is talking about minecrafts paper item?
isnt there sizeOf kind function like in C
they deserve to die
real
if this was paper we would all have been banned long time ago
luckily it aint
you need to chill
who are you
Dust out here trying to clutch a 10vs1
dust?
i think its more a 10vs1 trying to deal with somebody acting like hes still in puberty, be more respectful man
I like how you blocked me AND had to show it to everyone, ending up with still talking to me
you cant even show that you are better than that lol
cause u said something along the lines of "youre bluffing anyways"
so yeah
for me it seems like lack of java knowledge
why do I need it
because only that thing is able to write your ItemStack to a byte array output stream
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>```
im sorry this is my first time doing something like this how would i swap this to 1.20.6 since if i swap the number 1.20.6 it errors and if i swap the paper to spigot it still errors i have the spigot 1.20.6 api in my dependencies alrdy
?whereami
did you do maven reload
perhabs even maven clean install
is output into or from database
ik that thats my im trying to swap to spigot though idk how
i did
ah ok 👍
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.6-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
here u go
Output would be writing to a Byte Array Output Stream, which you'd use when writing to the database down the line
ty
Also make sure that you use spigot's repository as explained here https://www.spigotmc.org/wiki/spigot-maven/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
tysm guys ur the best
Smh voss stop spoon
Grab the bytes the from the OutputStream the BukkitOutputStream was based on
what does this mean
basically just using the outputstream
how do I know when itemstack ends and when starts
if its right on another place
is itemstack just one byte
so what, I get byte[] array and for each element I get ItemStack[] array element or what
?
why the fuck do I need to convert into byte[] if I WANT itemstack from OUTPUT
?
oh
well the other way around is described here
.
if my byte array has 3 itemstacks in it
Presumably because you didn't ask for it?
?????????
I was literally asking for making it for INVENTORY, not one singular itemstack
again, both a single ItemStack and an ItemStack[] are represented in a byte array
once again giving half assed help
You didn’t understand
and how do I split that array
that byte array
^
into itemstacks
Appreciate free help or go 🤷♂️
Yea
im not even hour into coding after several month break and I dont know what I hate more
java or you all
I mean, we can only do so much here :/
Well you are making it hard yourself
I already laid out the method logic above
I don't think I can really do more that isn't just "here you go, spoonfed code"
how so?
You are relying on spoonfeeding, do a java course and refresh your memory and use google before coming here
lack of java knowledge, you ever heard of serialization? also helper laid out full logic for your question
I dont work 24/7 with java
or object oriented shit
well thats fine
I work with C if anything
but it will make it harder to create java projects then
what?
its not my fault that minecraft is in java
i mean using byte[] is just a way of representing a stream of bytes, or well bits yk
and I want to do minecraft oriented project
well no, but you need to accept it
Yea but relying on strangers to walk you through every little detail with the attitude of "I don't work in java, idc about learning it" isn't really nice towards said strangers
and either grab some java knowledge or you wont get far
I dont like you all since beginning so I didnt expect anything less
I already got far enough in my project
oki 👍 I guess you are free to leave
well I wont, I want help, not appreciation
but why? spoonfeeding wont give you anything, and the questions you asked got answered
I love thr fact that this is hour 3 of him wanting help
so what dont u understand from what lynx said?
if I so may ask
now nothing
did u solve the issue, or is there still something left that u're confused abt
issue is still
so what is stopping you?
is still?
I still dont know if I should SQLite database for it
or anything else
because everytime I get a different answer
well what did you initially want to do?
persistent storage for:
custom inventories (GUI, storage)
custom item and entity data
player statistics
Anyone here fuck with custom world generation? Im trying to find a way to modify the trees on world generation
but I assume you're a bit lost regarding which persistence storage type to pick?
But i was yet unable to find a way to retrieve where trees are usually spawned
yes
is this project merely for learnings, or do you have any more formal "business requirements"
its my personal project
well I mean, obv different storage types have pros and cons, if its ur personal project you get to decide 100% on which one to pick
:>
ik there is a tree feature
of course
thats the answer im getting there all the time
the most vague and useless shit
yea, well its hard for me to dictate which one you should pick
in what class :0
well if you want examples
flat file, that is using raw files and store it in json, yaml etc
file database, like sqlite
an actual database service, like mongodb, postgresql
i think are most common
nms wise, there is a TreeFeature
ah damn
replace trees with custom ones
yeah
and I dont know pros or cons of any of this
afaik they dont
you ever heard of google
nobodys forcing you to answer, dont act like you have to and try to come up with most vague answers possible
I dont care what some random sites say about it
I want answer based on experience specifically from minecraft servers
but you care what some random person says?
Well, the best solution is a proper database service, list postgresql or mariadb
But that'll be overkill for a small personal project
and has a steeper learning curve
SQLite works too, has some of the SQL advantages but is a flat file, less setup for you
YAML/Json are probably the easiest, but terrible for long term plugin maintenance or any form of data analysis down the line
when I write a larger project I always write a mock persistence system using flatfiles just to make it integretable w other modules of my project
The bukkit yaml api is dead easy for it, iirc even has getItemStackList methods
or something close
0
Then probably stick to yaml
How do I send packet bundles using NMS? I cant seem to figure out and no one has made any documation for it.
ClientboundBundlePacket just takes an Iterable<Packet>
Bundle packets my beloved
that thing is responsible for de and encoding the bundle packet onto the network
I wonder what happens if you send a bundle start but never a bundle end
?xy
death
I assume the client will just give up after a while
yea, at the timeout kick 
e.renderer((source, sourceDisplayName, message, viewer) ->
Component.text().append(
Component.text(),
Component.text(ChatColor.WHITE + e.getPlayer().getName() + " : " + ChatColor.WHITE), message
).build()
);
It is not work on 1.20.4 spigot. how to fix it?
it is using in AsyncChatEvent
The AsyncPlayerChatEvent
but yea, setFormat it would be
make sure your thing is registered as a listener
e.setFormat(ChatColor.RED + e.getPlayer().getName() + ChatColor.GRAY + ": " + ChatColor.WHITE + e.getMessage());
Just like it?
no that is not the format
see the setFormat javadocs
String.format(String, Object...) compatible format string
if (!customConfigFile.exists()) {
customConfigFile.getParentFile().mkdirs();
saveResource("custom.yml", true);
}
java.lang.IllegalArgumentException: The embedded resource 'custom.yml' cannot be found in plugins\plug
hmmmm?
shouldn't this work?
setFormat() will use a string format where the first argument is the player's display name and the second argument is the message. So ChatColor.RED + "%s" + ChatColor.GRAY + ": ' + ChatColor.WHITE + "%s" is the format you would want
Yes, it would work, if you have a custom.yml file in your plugin's resources
well if it doesn't exist it should create one by itself
Are you trying to create an empty yml file? Or are you trying to copy one from your plugin?
onEnable it should check if there's or there's not a "custom.yml", if there is.. fine. else make one
Okay, so you just want to make a file. saveResource() copies one from your plugin folder
Here I do saveResource("categories.yml", false)
Choco you use eclipse?
But if you wanted to just make a yml file without copying one from your plugin's resources directory, you can make a new File object and use createNewFile() instead
File file = new File(getDataFolder(), "custom.yml");
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}```
createNewFile() already checks if a file exists so you don't have to do it yourself
Yes
And your eyes don’t hate you?
Nope 🙂
maybe that's the secret
does he work in hypixel?
That's the fun part. Most of them don't know 😎
WHAT THE F***
2 eyes in exchange for wisdom
a user with white mod and eclipse
I have a system that adds fake entities as passengers to all living entities. How would I go about showing their nametag? It hides it, and currently I have a bukkit runnable to manually detect for it, but is there an easier / more efficient way?
Bro, I got so cooked when I joined into the onboarding and I had to say "I uh... I don't use IJ"
ba* him
So that’s how he keeps the job
that doesnt look like ide
FIX HYPIXEL ANTICHEAT
I'm not on the anti cheat team!
its just a colorful notepad
i'm using online ide
“I actually use netbeans”
REVIVE FOR INVADERS
Haven't seen any NetBeans users yet
Though I don't tend to ask
md_5
Maybe they’ll hire MD
Choco how long have you been programming and how much time since you started developing plugins?
I think hypixel should revive invaders. it is fun. or make server pack for us.
BECAUSE I USED 500 dollar in hypixel
Since I was like 9, plugins since 2015

I was so proud of my Lua calculator
my only touch point with lua was ehh
ummmmmm......
what are they called
ComputerCraft?
YES
the dumb turtles
damn xd
fr though
@EventHandler
public void onChat(AsyncPlayerChatEvent e) {
Scoreboard b = e.getPlayer().getScoreboard();
Team team = b.getEntryTeam(e.getPlayer().getName());
if (team != null) {
switch (team.getName()) {
case "RED":
e.setFormat(ChatColor.RED + "%s" + ChatColor.GRAY + ": " + ChatColor.WHITE + "%s");
break;
case "YELLOW":
e.setFormat(ChatColor.YELLOW + "%s" + ChatColor.GRAY + ": " + ChatColor.WHITE + "%s");
break;
case "GREEN":
e.setFormat(ChatColor.GREEN + "%s" + ChatColor.GRAY + ": " + ChatColor.WHITE + "%s");
break;
case "AQUA":
e.setFormat(ChatColor.AQUA + "%s" + ChatColor.GRAY + ": " + ChatColor.WHITE + "%s");
break;
default:
e.setFormat(ChatColor.WHITE + "%s" + ChatColor.GRAY + ": " + ChatColor.WHITE + "%s");
break;
}
}else {
e.setFormat(ChatColor.WHITE + "%s" + ChatColor.GRAY + ": " + ChatColor.WHITE + "%s");
}
}
It doesn't work.

That'd do it
@worldly ingot My dream is working in hypixel.
Can you give me some advices?
Just get as much practice in as you can :p The more experience you get, the better. I've worked on like 5 different networks before applying to Hypixel
Each incrementally larger
dedicate a year of your life to doing the 23 different interviews required

fax
It literally took a month
I'm not even exaggerating. My whole October was interviews lol. I had 6
Shit's like the NSA
I scheduled my interviews as soon as I possibly could though, so I kinda sped through them
hi, how could I make it so that if I hit a mob that is in a boat, it will get out of the boat?
At one point I had 3 interviews back to back to back
Smart move xD I always let them cook, gotta annoy people
@worldly ingot Hypixel closed anticheat development applications. do you know the reasons about it?
The only reason it took as long as it did is because they do it in waves of people, so even if I did my interviews quickly, I had to wait for everybody else
Probably just have enough people is all ¯_(ツ)_/¯
Yeah they're always open
ah fuck
Deep understanding of CraftBukkit/Spigot

thats it for me, craftbukkit is a mystery
Choco ever worked with forge?
Plenty, yeah
Harder than spigot api? xD
Much, but very fun 🙂
Why hypixel updates only skyblock so many times?
Profit margins 🫰
coems 🤑
how to fix it
Use a Material?
If you want an ItemStack, you're looking for ExactMatch
how to use yml
RecipeChoice.ExactMatch
Oh
FileConfiguration
Dang the terminator requires a trident and a netherite block now
New skyblock update is wild
im not hypixel admin...
...
I wont be using it for stuff that doesnt change
I can't understandd this code
so you just want to get some elements from it?
Then what are you asking for?
How to use it?
That's just writing the data to the file no?
I want to check if a player has executed a command thru a boolean value.
I would add this player to a list in the command's class and let the code execute only if this guy is not in that list. What happens if another player executes the command? doesn't another instance of it get called?
Depends on your code. :p
during server runtime
that's what a config is used for
Realistically, as long as your list is a global variable it shouldn't be creating any new instances.
so everytime a command gets executed it goes to check the same instance?
Every time a command is executed, the command logic is triggered.
So if your list that you are checking against has already been initialized outside of the command logic, then yes. Your command code would be checking against the already created instance.
Can I use caching for yaml just like for sql database?
the bukkit config API is in memory once loaded, so caching shouldnt be super necessary
So what I can just open and edit yml files in demand?
I dont quite understand
@ionic thicket
public class MyCommand implements TabExecutor {
private List<Player> players = new ArrayList<>();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
// Do your instanceof check beforehand here.
Player player = (Player) sender;
// This is an access method.
// The List has already been initialized and won't be reinitalized unless you assign it to another list.
players.get(player);
}
}
Alright, but what if i wanted to clear this from another command in another class
I should be making it static
You can either make a getter method for the list or have the data live in another class that you can manipulate.
Multiple ways to do it really.
wut?
Or, at least, not in the way that you've described it
You probably wanted contains()
If I want to update player kills
I can just save it immediately to yml file?
you mean a static getter?
You can do that, yes.
cuz if i don't make it static and create a new instance in another class to erase that list - that wouldnt have effect since the new instance would have an empty list
I guess the list could be static in this case, but static is seldom used in spigot plugins.
that's why I was trying not to use it
If you need to do it frequently, then you can periodically write the updated data to disk.
Spigot's yml files are basically cached already, so you would just need to delay the write to disk by putting the save method on a timer.
There are other caching strategies that you can use, this is just one of them. (Known as Write-Behind)
what do you think? should I do that? or is there another way?
It has no sense
I want it to be updated as soon as it can
Then put a .save after each .set
Well, in this case specifically, having the list be static would cover your cases. Clearing is easy and adding/removing would be just fine. Unless you are creating multiple instances of your command class (which you shouldn't be) then having the variable be static wouldn't be an issue.
You can make the period short. It doesn't have to be a long delay.
You can save directly to disk after each update, but that will have an impact on performance when scaling up.
Thats literally what I meant
So I will cache
And save only on server restart/disable
That's all well and good, but you have the potential problem of server crashes and if you only save on restart/disable then you risk losing the data.
Which is why it's a good idea to periodically save on top of saving regularly.
I dont care about it for now
Will you care about it eventually?
If yes, then just implement now. No reason to wait
Hey all. I'm trying to run the BuildTools GUI but I'm having trouble getting it to detect the right java version. It can detect versions 1.8 and 18, but not versions 17 or 22. Even when I manually select the java.exe for either 17 or 22 I still get the error saying that BuildTools could not find the necessary Java executable. Does anyone know why it would detect only those two versions? My 1.8 install is in program files (x86) and the other three versions are in program files
Are you using the Detect & Choose button, Select button, or writing the path manually?
No log shows up from what I can tell. I click build and this error pops up
BuildTools could not find the necessary Java Executable to build latest.
Java 17 or Java 22 is required to build latest.
You can download the necessary version using one of the following links.
The provided links have downloads for all operating systems.
Make sure you install the executable file and not the .zip / .tar.gz!
Windows (.exe / .msi)
Mac (.dmg / .pkg)
Linux (.deb / .rpm)
OpenJDK
https://adoptium.net/temurin/releases/
Azul
https://www.azul.com/downloads/#zulu
Oracle
https://www.oracle.com/java/technologies/downloads/
Once you have installed the necessary java version, please restart BuildTools and try again.
If you believe this error to be a mistake and already have the required java version installed, please follow these instructions:
1. Go to the Options tab
2. Enable the `Override Java Executable` checkbox.
3. Provide the correct java path.
4. Try again. :)
Detect & Choose only shows version 1.8 and 18, so I used the select button and chose at first version 17, then went through oracle and downloaded 22 which is what I've been trying to debug with now
Dont order me what to do
I cant be arsed with it right now
Hmmm, this may be a bug then.
That's unfortunate. Let me try removing any references to other java versions and setting JAVA on my path to version 22 and see if that helps
https://www.oracle.com/java/technologies/downloads/#jdk22-windows I tried the exe install first, then re-installed from msi and neither seemed to work
It’s only like 10 lines
I got it fixed 🙂
Previously I had my path setup so that when I ran java from the command line it was version 1.8. I updated my path and JAVA_HOME to version 22 and now it's detecting and I got it to build
is there a way to make this better because every single crafting shape has its own crafting table book recipee
https://pastebin.com/4qsaZQs1
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
im using bash script for producing spigot server apis.
for mc 1.8-1.12 -> java 8
for mc 1.13-1.16 -> java 11
for mc 1.17-1.19 -> java 17
for mc 1.20+ -> java 21
Java 21 is now required for 1.20.6
oh you have that
you just left it out of your message lol
thanks for the correction
Please tell me how to forcefully change the player's item durability.
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand();
Damageable old = (Damageable) stack.getItemMeta();
old.setDamage(old.getDamage() - 1);
stack.setItemMeta(old);
e.getPlayer().getInventory().setItemInMainHand(stack);
It doesn't work
It does work
1 is just very subtle
Almost not noticeable
Use f3 + h in game to see items durability
DeluxeMenus use inventory holder, is this a problem?
Does it work?
Yes
Then it has no problem.
Now that I think about it... How is it fine? There's no check if the ItemStack is Damagable
What item is it
And do you have any errors in the console?
Or maybe, does your item have the unbreaking enchantment?
they're currently all damageable, but yeah would be good to check
was it always like that or just in the newest (1.20.6) version?
why section.contains(path) works so crookedly? If a section has a path with a value, it finds the path, but if there is no value despite the presence of a path in the section, it returns false
and even if I put "null" in the section path, it still won't find the path.
isn't this YAML specification?
its yml
can give link?
so, based on the YAML specs, it should return 'true' as a valid path
i see null this mean "empty" but it still doesn't answer the question obaut section.contains(path)
this shold return true if there is a path regardless of its value
afaik yaml preprocessor in snakeyaml doesn't support null values
even tho its supported by yaml specs
even if there is no null there but just an empty path it will generate false documentation bukkit does not follow the logic of the method should not look at the value in the path it should know if the path itself exists.
if there is no null, it means that path isn't even parsed -> path doesn't exist
as it contains no value
RayTraceResult rayTraceResult = p.rayTraceBlocks(distance);
When looking at an entity (within the distance), rayTraceResult.getHitEntity() is null always null
new fixed it
every yaml is parsed to key-value in memory and is read from it
if value doesn't exist, path will not be parsed
btw snakeyaml is responsible for parsing, not bukkit
why doesn't he see it as an empty value?
afaik yaml preprocessor in snakeyaml doesn't support null values
bruh..
hello im new on developing plugin and ihave some issue about this? any idea?
C:\Users\reyro\IdeaProjects\sampleplugin\src\main\java\net\ghostplays\template\api\Parser.java:17: error: cannot access ServerPlayer
return Cobblemon.INSTANCE.getStorage().getParty(player.getUniqueId()).get(slot - 1);
^
class file for net.minecraft.server.level.ServerPlayer not found
this is reporsitory from abandon developer and i cant reach the developer and i already debug some of the error but the nms is my issue
this is the code from that error
package net.ghostplays.template.api;
import com.cobblemon.mod.common.Cobblemon;
import com.cobblemon.mod.common.api.storage.NoPokemonStoreException;
import com.cobblemon.mod.common.pokemon.Pokemon;
import org.bukkit.entity.Player;
public interface Parser {
String getID();
void register();
Object parse(Player player, String[] args) throws NoPokemonStoreException;
default Pokemon getPokemon(Player player, int slot) throws NoPokemonStoreException {
// Handle NoPokemonStoreException if necessary
return Cobblemon.INSTANCE.getStorage().getParty(player.getUniqueId()).get(slot - 1);
}
}
So the answer to my question would be that you don't know?
yes because when i check the dependencies theres no any dependendcies for nms
any idea how i add it? becuase i cant see any info on internet?
What version? Maven or Gradle?
1.20.1 gradle
(With the --remapped flag)
after i this? what i need to do, sorry for bothering
what even is the end user of that parser supposed to do with an Object?
To your project
Cobblemon player data
Always
i already add and run the rebuild again on gradle
any alternatives for paper userdev for gradle?
For Spigot? Like do you just want remapping?
?whereami
yeah whatever is enough to easily work with nms
Damn like
read up half a page xD
when i was writing my original message discord scrolled me up a lot so i didnt see it
Yeah I sent that like 4 messages above your question

after i done Olivo there any need to add or i can try to test it if it gonna work now?
Try and see if it works
how do i open bt gui from the jar?
iirc a --gui flag was added
oh yea
i try and still get an error ```
class file for net.minecraft.server.level.ServerPlayer not found
Double click should also work
I presume you are going to have to run the reobf task and grab the correct jar
there's no double click for java files in my file manager
Who even has a file manager 
not sure if its nautilus fault
idk if you even get javaw on a linux installation
I doubt it
or well, something the like
Anyway, just use the gui arg then
Ubuntu at least associates a double click in nautilus
probably depends how the package is installed
(The official packages)
What kind of java installation do you install that is a snap 
Deb, apt install openjdk-17-jdk or whatever
many packages like this are snaps for whatever reason
Damn bro be using java from 2039
common ubuntu L
debian 
what happened here
Trying to wrap my head around the potion-related changes in 1.20.6. Previously I'd look to see if a potion type startsWith("long_"), for instance, and then set the extended boolean in the PotionData instance accordingly. Same with strong_. Is there a backwards compatible way to do the same thing now? The 1.20.6 post says to use API that's been around since 1.9, but the only such API that seems remotely compatible between versions is the custom effect methods.
pretty sure .5 isn't a version
which makes sense given that well, it aint a version on mojangs end either with .6 instantly yanking it
lol ok
Uh I’m pretty sure what you described (startsWith) works fine, there are long and strong types still https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionType.html#LONG_SLOWNESS
declaration: package: org.bukkit.potion, enum: PotionType
But these weren't in 1.19 for example. Like, they didn't exist as PotionType enum values from what I can see.
Even in 1.20.4 it seems.
Me, running fedora on servers: No you f-ing don't.
I guess maybe for full context, the syntax my code tries to parse is potion:<type>:<amount>, where prior to 1.20.6 I'd do the startsWith stuff to "chop off" part of the <type>, like long_swiftness would just become swiftness with the extended boolean set to true. It seems like now I can just omit the chopping, but then I break backwards compatibility. Even if I do a bit of "try-catch juggling", I still end up with a PotionType that I don't know exactly how to deal with without some form of reflection-based approach when I need to set the type on the PotionMeta, because the old setBasePotionData is now replaced with setBasePotionType.
backwards compatability just isn't a thing
If there is no backwards compatible way to approach this without reflection, I will just have to live with that, but I'd obviously prefer to not have such a hard cutoff between versions.
@lone jacinth might have some ideas about forwards compatibility
Yeah, forwards compatibility is what I'm looking for, thanks.
Or well, whichever way you turn it, really. I'd be happy working with the newest version of the API if it is backwards compatible, but working with 1.19 API that works with 1.20.6 is also fine.
Though I also have an issue with the whole sign open event vs. player interact event that requires a bump to 1.20.2 at least, so it might be a good time to make that hard cutoff.
Thank you!
it would only be temporary though, the API is deprecated
Yeah I noticed PotionData has been deprecated for a while. A lot of my code is just little maintenance tweaks on top of a messy code base that's been mostly "stable" for over a decade. With all the things that happened in 1.9, 1.13, etc., it's really starting to crack 😛
But I'd also be perfectly happy to move away from PotionData to something non-deprecated that's available in the pre-1.20.6 API that is forwards compatible.
it's compatible 1.20.2+
Right, there's a setBasePotionType in 1.20.2, I see.
And that's also when the open sign event was introduced, right?
is there no 1.20.3 either?
nope skipped like .5
note: not currently fully compatible, in that they use null rather than uncraftable, but you can work around that
Ohhh exciting! Do I just run BuildTools with --rev 1.20.6 to get a build with this commit?
Thanks!
ok should be up, use --rev 4156 if you get cached and it says its building an earlier build
any issues probably best to make a bug report https://hub.spigotmc.org/jira/ . Thanks!
I'll give it a whirl. Thank you 🙂
Then show me
I did a bit of testing and have asked the person who reported the issue to me to give it a whirl on his end as well, but so far it's looking very promising! Thanks so much!
any idea why the drop click type isn't triggered in an inventory? I'm using event.getClick(). do I have to use something like event.getAction() instead?
middle click doesn't work either
Which inventory?
an inventory inventory - one that I opened using openInventory and a Bukkit.createInventory
Show your code
else if (action.clickType == ClickType.RIGHT) { // works
...
else if (action.clickType == ClickType.DROP) { // doesn't trigger
...
return new WidgetActionResult("block.note_block.bell"); // falls through to this instead (just plays the bell soudn)
enums in java are stupid
Just pressing Q
So you're not holding ctrl or anything else
How so?
you cannot just switch enums easily
print the click type name instead
you have to do some random stuff around it
?
[STDOUT] DROP
I don't get it
You can switch an enum just fine
no you can't
I used it before and intellij complained about some bs
so I just ignored that
you need to do some funky garbage
Sounds like you did it wrong
try it out and show us how you write.
switch(variablewithenumvalue): {
case EnumValue.Something: -> { // just doesn't work
}
}
ClickType type;
switch (type) {
case DROP -> System.out.println("You dropped smth");
case RIGHT -> {
System.out.println("Right clicked smth");
System.out.println("This does work just fine :)");
}
https://stackoverflow.com/questions/6391777/switch-on-enum-in-java this poster is just as confused as I am
Also do note that this syntax is for newer versions of Java
I know
not Java 8
java 8 isn't even supported for newer minecraft versions anymore
and they also got an answer that shows how to do it
(in the old java 8 way)
you know what I figured it out.
you can't case Myenum.VALUE, you can only case VALUE
for whatever reason
It’s implied
first case is how C# does it
it does seem more sensical to me since you know exactly what you're switching
even at a glance
rust match my beloved
They're quite simillar to the Java ones, no?
hm does look like the rust one support ranges and such
is this approach redundant in java? ```java
public Boolean readFromBytes(byte[] bytes, Charset charset)
{
return false;
}
public Boolean readFromFile(String path)
{
if (path == null) return false;
String[] pathDelimited = path.split("\\.");
if (pathDelimited.length <= 0) return false;
String extension = pathDelimited[pathDelimited.length - 1];
if (extension.equals(String.valueOf(this.settings.fileExtension)) != true) return false;
File file = new File(path);
if (file.exists() == false) return false;
String content = "";
try
{
content = Files.readString(file.toPath());
}
catch (IOException e)
{
e.printStackTrace();
return false;
}
return this.readFromBytes(content.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8);
}
trying to get the data into a common format before processing it
Boolean?
If readFromBytes always returns false, why call it in the first place rather than returning false directly?
because its not implemented yet
ill approach it with regular expressions and theyre annoying to write
what are you even doing
and the reason to read from byte array is because i want to be able to read encrypted data on the harddrive, decrypt it and then read from the decrypted byte array
And what is "content" for? You don't seem to be doing anything with it
ini file reader/writer using regex
because its not yet implemented
parse Files.readString(Path.of(path)) ?
split every line on = ? (i assume ini syntax is like x=y)
thats what i will do
the question is
does it make sense to cast it into a byte array
if i want to read decrypted data in memory as byte array
bruh looks like toml
?
^
if you wanna have fun reading bytes, sure
how is it decrypted? the whole file content or what
with an rsa and aes algorythm usually
i think you missed some explenation
but why is that relevant how exactly its decrypted
decrypt the file first and then parse it?
im looking for a generic way to read data from different sources
from harddrive
from memory
thats the question
if it needs to be decrypted, accept a byte array
its supposed to be decrypted before passed to the reader
the decryption process is its own thing
not implemented in the reader
what reader, the parser?
yes
