https://paste.md-5.net/wogewitiga.cs <- Error - Class -> https://paste.md-5.net/uboyicovet.java // So the commands for /crewadmin "set", "add", "remove" all work no problem. The /crewadmin check <player> isn't working along with the basecommand, although the basecommand is working but returns error. I'm guessing it's how i declared the target variable and amount variable? Don't know any other way of declaring as if I declare seperately inside the case's i will get errors as it's in scope
#help-development
1 messages ยท Page 311 of 1
okay thank you so much
Just trying to make my code cleaner so using a method for the args check, I know I can just not use the method and my problems would be solved but yeah
oh i think i misunderstood something too, i thought a library was the same as an api
Yes and No. A library is more of a set of code, like a resource you can use to improve coding. An API is more of an interface that connects code together.
Like I have my own private library that just contains lots of methods and stuff to make things easier.
if I add the depency to my pom.xml file, as explained in the docs of citizens, intellij underlines it and says: Dependency 'net.citizensnpcs:citizens-main:2.0.30-SNAPSHOT' not found. How can I fix that?
pom.xml: https://paste.md-5.net/varuwopove.xml
<dependency>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-main</artifactId>
<version>2.0.30-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
Restarting IntelliJ fixed it
yeah intellij caches are something
Switch statement variables
If i do something like this:
a +=1
proxy.getScheduler().runAsync(Plugin, () -> { a+1})
//do more stuff with a
Will a second call of the function change the output of the first call (if the first async stuff is still running)?
Will the do more stuff wait for the async stuff to be finished and therefore probably the hole plugin ?
the do more stuff won't wait
i assume its kinda of pseudo
if its a field, it will change again
brr now youre ending up with race conditions
well actually ig it runs the next tick
idk the impl of the bungeecord scheduler
in proxy there's no ticks
so its ran instantly?
Yeah it was more a technical question how the scheduled stuff work than working java code ๐
sounds like concurrency issues
as two threads may possibly change the value of a at the same time
as you said "will it change the ouput if the first runnable was still running", it really relies on luck
first runnable will probably scheduled earlier too
So it's not using a copy of the objects and just get's pointer ?
there are no pointers in java
and primitives are used by value anyway, not by reference
Okay my example was bad...
ServerInfo si = proxy.getServerInfo(serverName);
proxy.getScheduler().runAsync(JoinMeBungee.instance, () -> {
si.ping((result, error) -> {
if (result.getPlayers().getMax() <= result.getPlayers().getOnline()) {
playerSender.sendMessage(TextComponent.fromLegacyText("ยง8ยป ยงcDieser Server ist voll!"));
} else {
playerSender.connect(si);
}
});
});
I have this code and now I was worried that si may change.
does the lambda gets si as a reference (pretty much seems to be like a pointer) or a copy.
Try to change si.
as a reference?
im wondering what the question actually is
so whatever happens in si in sync, will also be visible in the async stuff
Copy as in what? There is no such simple thing as "copy" in Java world - be it implicit and explicit
std::copy 
.clone()? Yes, that exists, but it is quite complex. And it is always invoked explicitly
So if there isn't something like a copy how do i even get my stuff thread save? If two players use the same command with different values nearly at the same time?
You can compare and swap
Hi, I'm using this snippet of code (https://paste.md-5.net/ikuyumuvoj.cs) to get a player skull, based on profile properties
Atomically
hoping the amount of players is correct ๐ฅฒ
Actually it didn't work, so I'm wondering if I'm doing something wrong or I have to recreate the whole online player with nms
pre 1.18.2 or something?
wait cant you ping async and connect sync?
theres a better way for that after 1.18 or whichever version
I guess I've to recreate the player based on json profile prop
are you 1.18 or higher
Therefore I would need to wait for the async response ?
1.12.2
ah, havent got any idea about that
I mean there is a .setOwner() method for the SkullMeta
so based on my NMS knowledge, I've to paste the json profile prop. on a player, and then do the .setOwner() method
i can give you what the player skull stuff looked like on 1.17
im guessing it would go backwards
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "");
PropertyMap propertyMap = gameProfile.getProperties();
propertyMap.put("textures", new Property("textures", texture));
try {
Field profileField = ((SkullMeta) meta).getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(meta, gameProfile);
profileField.setAccessible(false);
} catch (NoSuchFieldException | IllegalAccessException ex) {
ex.printStackTrace();
}
``` texture is a variable it accepts, url is `http://textures.minecraft.net/texture/`
I'd just put the base64 hash thing
so yeah, that
the textures thing is often just a base-64 encoded json with the textures URL it seems like
I finally got the motivation to actually code for once
got the idea to remake my image board system
ImageFrame
like the plugin?
yeah i use it on my smp lol
images on maps :p
oh that plugin
yeah no I'm doing something a bit more advanced
It's that concept
but like
you can click on them
and do stuff
custom shapes
placeholders, animations
ill have to switch over when ur done with it...
I'm like the lead engineer
I basically get paid to do cool shit I come up with
so... no

I can share the basics

uhh idk, i was thinking about pinging async, then checking out the player count sync and connecting sync
This is used for an individual frame
And this is the main class
anything else you're on your own
inch resting..
Yeah but I would need to wait for the Ping results ?
For an explanation into how to get performant raycasting, follow the method 3 on https://github.com/cerus/maps/issues/6
put a sync call in an async call
ServerInfo si = ...
scheduler.async(() -> {
si.ping().then((result, error) -> {
scheduler.sync(() -> {
if (si.getPlayers() < si.getMaxPlayers()) {
player.connect(si);
}
})
})
})```
So I'm going through an old code thst takes core protect data, and gets the total amount of blocks broke in total by a player in x time...
The value is called "GesamtAbgebaut" .
This is by no means an important question but for my own sanity can anyone figure out what it stands for ? ๐
Gesamt Abgebaut is german
google translate
in English its TotalMined
why dont we ask a german
ye if i put a space it translates correctly
total dismantled
Ahhhhh
Hi, i want to make an ATM and save inside the last transaction inside the block, how can i do it?
Why didn't I think of that haha
have you atleast tried something?
is the block a chest
no an iron block
you would have to store it in the chunks pdc or uses alex's custom block pdc lib
true i was thinking alexs pdcs
doesnt alex' lib also stores it in the chunk pdc?
this one does
or even world pdc
probably
But last transaction sounds like something temporary
You could as well just store the data in memory
yes
but how will i know how much money i transferred in/out from 2 years ago?
???
That's not what was asked
If you're looking to make a larger history then it won't be efficient to store that in pdc
but why ?
total mined
just pretend i read anything that gets sent idk
i look at like 3 words and make a reply based off of that
chat gpt karma farmer auto reply ahh bot type beat
beep boop
Is it possible to use a worldguard region in my plugin? Like have my plugin use a region created in worldguard.
love it how something so simple has so many assertions
Use the Worldguard api
๐
wtf is the point of using labels btw?
the loop: part
otherwise it breaks out of the switch
Just use flag
yeah but then thats 1 more variable... and who likes those
yes its the only reason to ever use labels in java since we dont have goto (thank god)
is there a way to know if a block was placed by player other than creating a list of blocks placed by players myself?
this is also valid
its rare practice 
if you need them you use them
Hello, i'm trying to make custom items slightly better than netherite but when i try to edit the damage of my sword with AttributeModifier my attack speed is changed too somebody know why ?
How do you make a cuboid?

well typically cubes have 8 points...
cuboid/regoin
get a min location, get a max location, create a bounding box with , boom, region
when you add attribute modifiers to sword, their default ones don't work anymore, so you gotta add them by yourself, the default value is 4, so if you, for example wanna attack speed of 1.6, then add attribute modifier of attack speed with amount of -2.4
Is theire a wiki page when i can see all base attribute value ?
5 levels of indentation omg
bwt why not use Character.isDigit?
cuz it does some internal bs
wdym?
One more question is theyre a way to now show "Damage +9, attack speed -2.4" cause it seem that the sword is slower than other sword cause other sword say "Attack speed 1.6"
it acquires a CodePoint instance, searches for its properties in a big ass multiple dimensions array and does some bitwise operations
ItemFlag.HIDE_ATTRIBUTES
add it via ItemMeta#addItemFlags
yeah but doesn't seem like any of the operations are heavy
just a few bitwise operations
its about speed my man, a switch can be 90% faster than an if
i tested it and case '0', '1', ..., '9' was 90% faster than if (c >= '0' && c <= '9')
wow learned something new ig
depends on what youre checking but whatever
when are defaults parameters in C++ style a thing in java ๐ฅบ
im tired of writing 5 methods that just call eachother with different arguments
Another qol kotlin added
then make a better design
whats a qol
Quality of life
oh true i fucking love C# for this
why do some much ppl hate kotlin here?
C# really is a better java in so many cases but it lacks so much from Java too
cuz its cursed
like idk a decent fucking excuse of an enum
๐
C# enums r such a joke theyre just glorified primitives
yeah c# enums suck
and its also a fuunny language ๐
at least in Java theyre glorified Objects
where's std:: tho?
mans using std
using namespace std; ๐คฎ
something i agree on
Please i just want to see my family again
i think everyone agrees that using std is simply terrible
me tbh
does anyone know if there's anything alike https://api.spigotmc.org/legacy/update.php?resource=id but for github releases? Spigot takes several hours to update its version which is kinda annoying if you have latest version it tells u there's a newest version for a older one because it's not updated yet....
what are gh releases tho?
and search for tag_name
ye but whats the point of it? giving the end user downloads?
yup, checking it out now. thank you
also have to push tag when making release ^^
basically
yeah i have the tag as the version.
well, on releases u can put the jar file for the latest release and it stores all the releases, just like on spigot
but github will return instantly your latest version released, unlike spigot which has like 6+ hours of delay
hmm
also its cool cuz you can make it pretty much automatic with gh workflow
also im starting to use more github so trying out this new small things is cool. specially if they improve something else.
What's wrong here? look like generateIsland is not working?
tf ๐
๐ค
well, that is awesome , first steam account i saw that is this old
i wish i had my older discord account, it was also one of the oldest ๐คง
Bump!
someone help me pls :")
;-;
why bump something right in front of us still
people will help when those who know open channel.
okay ;-;
how do i get item defautl display name?
itemMeta#getDisplayName returns empty string
and item#getType#name returns something like POTATO instead of the name player should see
it depends on the language
you can get the corresponding language file onhttps://assets.mcasset.cloud/1.19.2/assets/minecraft/lang/[locale].json, where [locale] is player#getLocale
client side, but I saw somewhere you can use nms to get it.
not sure if this still works, but maybe start there if you haven't
quite old thread
While the two things above probably work I recommend using translatable components. Which is how vanilla does it
The downside is that you cannot specify a specific language with them so it will always use the client language
i see what if i just want it from one specific lang
you can probably embed it inside of your plugin's resources, tho im not sure if that's legal
i just query it at runtime
@vale ember can you help me pls?
what exactly isn't working?
are there any errors?
cant you replace random.nextFloat() < 0.5 with random.nextBoolean()?
generateIsland method should add some blocks. but its not doing it
umm, tried random.nextFloat() < 0.5 thats not working too
why are you using deprecated createChunkData tho?
have u considered that maybe every time youve ran the method, nextBound(101) was < 50
by sheer (un)luck
I loaded about 50+ chunk ._.
try removing the if and check again
i guess i could make it work for per players lang with packets
but not worth it for what im doing
you don't need packets
^^
I was trying to paste schematic on chunk generator. but it stuck on world loading. any idea why?
Hello i'm trying to do item with custom durability i try to use some DataContainer everything work fine i just dont uderstand why my item lore dont get updated:
no, i am not very experienced with chunk generator stuff, sorry
If I have a Material object, how do I get the material name?
thats the enum consta,t name
if you wanna the name as it is displayed in game ,than that's client dependant
use TranslatableComponents or https://assets.mcasset.cloud/1.19.2/assets/minecraft/lang/[locale].json to get the name
For context I've got all the data for every block broke (I.e. it's Material) and wanna be able to print the names of the materials
And say like X Block broken this many times
?
im not sure but i guess something like this should work
player.spigot().sendMessage(new TranslatableComponent("block.minecraft." + material.toLowerCase()));
what's this thing that when you hover over the black glass pane nothing happens, no item is being shown as if it is one
this is hypixel's sb menu
the normal one would be like this
nothing to do with packets
they probably just have an empty name / lore
it makes a very tiny box
i thought it was a (bigger than tiny) black box
whatever
I'm having trouble with my config.yml. it says "top level is not a map", even though my config file is valid yaml (i put it into a yaml checker).
Here's my config:
npcs: 200
npcNames:
- "ghost_rider1"
- "LithiumKid"
- "nvdes1ara"
- "Warmin22"
- "sw0ii"
spawnCommandsnpc: # need a slash '/'
- "/msg IKEWW HELLOOOOOOOOOO"
spawnCommandsconsole: # need no slash '/'
- "msg %npc% hello, bot :)"
whats that supposed to mean
org.bukkit.configuration.InvalidConfigurationException: Top level is not a Map.
at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:107) ~[pufferfish-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:160) ~[pufferfish-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(YamlConfiguration.java:334) ~[pufferfish-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPlugin.reloadConfig(JavaPlugin.java:165) ~[pufferfish-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPlugin.getConfig(JavaPlugin.java:134) ~[pufferfish-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at cc.ikew.acf.BukkitCommandManager.<init>(BukkitCommandManager.java:136) ~[extendableSpoofer-1.0-SNAPSHOT.jar:?]
at cc.ikew.extendablespoofer.ExtendableSpoofer.onEnable(ExtendableSpoofer.java:51) ~[extendableSpoofer-1.0-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[pufferfish-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[pufferfish-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:542) ~[pufferfish-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:565) ~[pufferfish-1.19.2.jar:git-Pufferfish-39]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:479) ~[pufferfish-1.19.2.jar:git-Pufferfish-39]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:638) ~[pufferfish-1.19.2.jar:git-Pufferfish-39]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:424) ~[pufferfish-1.19.2.jar:git-Pufferfish-39]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:308) ~[pufferfish-1.19.2.jar:git-Pufferfish-39]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1102) ~[pufferfish-1.19.2.jar:git-Pufferfish-39]
at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:307) ~[pufferfish-1.19.2.jar:git-Pufferfish-39]
i've made a few commands using Command executor and registered them from plugin.yml etc. the commands work as intended but everytime i try to type new argument player names show up for autocomplete how can i disable that
do i add that to command executor?
ok thx
sure I'll try
Does somebody know why the exact same custom item, is fine when i create it with a CraftingTable recipe but dont seem to get custom attribute, name and lore when i use a smithing recipe ?
Is that because it get data from de base objet ?
Can i change that ?
can i remove auto listed bukkit and mc commands like /about /ver /trigger
How to protect a specific area
Sounds like a #help-server question
Try negating the command permissions
No I want to write a plugin
Then listen to an event check if it happens in an area (using an aabb) and cancel it if it is
is there a good source to look up for permissions and how they work, what can be achieved with them etc.
Already clear but how do I determine the range
Range?
yes
What range
For example, I want to protect the spawn
You save the corners
And then check if the coords is between them
Spigot has this method for doing so https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/util/Vector.html#isInAABB(org.bukkit.util.Vector,org.bukkit.util.Vector)
declaration: package: org.bukkit.util, class: Vector
Otherwise it's just 3 if statements
Create a BoundingBox for the area then call .contains
^^ that works too
and if you're on 1.8 this api won't be available
so keep that in mind
do i have to manually give permissions once a player joins or does the permissions in plugin.yml automatically given how do they work?
i dont understand permissions
for example i would like to disable the autocompletion and usage of /ver /about /trigger for normal players and allow them only for admins
do i need groupmanager to do that
Thats what permission plugins do
Hey guys is it possible to give modded item in my plugin like using ID ?
Okay I understand but do you think that I can give an item to a player with the id 3921 ?
(That's a modded item)
Wait your using a server software that supports mods and plugins
Who the fuck knows those are always shit just make it in the mod
Okay
Don't bother with the plugin and mod bs they are fundamentally different
If you need essentials equivalent use the FTB plugin
Okay thx you
is there a way to implement Iterable<E> but for primitives so i can use for (char c : myObj)?
File file = new File(packageURL.getFile());```
how could i get package as a file? i have sth like this.
error:
```java.lang.NullPointerException: Cannot invoke "java.net.URL.getFile()" because "packageURL" is null
at me.placek.rdcakelib.RDCakeLib.registerAllListeners(RDCakeLib.java:36) ~[RDCakeLib.jar:?]
at me.placek.rdcakelib.RDCakeLib.onEnable(RDCakeLib.java:22) ~[RDCakeLib.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:542) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:565) ~[paper-1.19.2.jar:git-Paper-260]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:479) ~[paper-1.19.2.jar:git-Paper-260]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.reload(CraftServer.java:1025) ~[paper-1.19.2.jar:git-Paper-260]
at org.bukkit.Bukkit.reload(Bukkit.java:930) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:54) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]```
new File(getClass().getPackage().getClass().getProtectionDomain().getCodeSource().getLocation().getFile())?
the closest you would get would be auto unboxing Character
this will get me.placek.rdcakelib, yea?
not me.placek.rdcakelib.listener
just check stackoverflow
at me.placek.rdcakelib.RDCakeLib.registerAllListeners(RDCakeLib.java:35) ~[RDCakeLib.jar:?]
at me.placek.rdcakelib.RDCakeLib.onEnable(RDCakeLib.java:22) ~[RDCakeLib.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:542) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:565) ~[paper-1.19.2.jar:git-Paper-260]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:479) ~[paper-1.19.2.jar:git-Paper-260]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.reload(CraftServer.java:1025) ~[paper-1.19.2.jar:git-Paper-260]```
uhh idk
Hi, does someone have a library to create menus ?
?bing
Bing your question before asking it:
https://www.bing.com/
thx god, i'm asking dev, not search motor
bing ๐
?yahoo
Yahoo your question before asking it:
https://search.yahoo.com/
np flo, i am dev. advicing to use the search motor
?duckduckgo
still waiting for ?ecosia
uuh, thx for your advice, i will wait for other advices to have multiple sources of
google it
as another dev, advising to use the search engine
maybe am i colleceting 5+ advices to get the better one
Bing your question before asking it:
https://www.bing.com/
Google your question before asking it:
https://www.google.com/
?yahoo
Yahoo your question before asking it:
https://search.yahoo.com/
maybe not
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
thx
SpiGUI, GUI Utilitiy, Inventory Framework, Tubing Framework, MilkGUI, ... ...
I personally don't use any of those
i use my own stuff
what are u using so ?
ok
I use my own its Open Source, but its not very complex
Do you know if any of these have proxy support (protocolize)?
not sure what you mean with "protocolize". GUI's are always made from the backend servers
well at least in 99.999% of cases
not with protocolize
oh yikes, ProtocolLib
kind of
its not ProtocolLib
just proxy sided
but protocol manipulation yes
I doubt that ANY gui library has support for that
you can send inventories to the client without having to mess with raw protocol but its kind of limited in terms of functionality
i have a plugin for bedrock form (geyser)/inventory menu support and the main thing that is stopping me from dropping inventory menu support is not knowing if there is notable and well maintained inventory system for proxies
so i just keep on with it
the main thing that sucks is that there is no established placeholder system for proxies or im unaware of it
@wet breach Since you suggested storing some data in NBT last night I'll ask you. I should store all the block data in one NBT file correct? Also how should it be formatted? Do I just start with the compound tag than do Map<String, Tag> for all my blocks String being location, Tag being the blocks data. Seems most logical to me just gotta make sure I don't fuck this storage up xD
I mean I could, but as frostalf was explaining last night pdc doesn't exactly clean itself up nicely. Also blocks don't have PDC
custom block data by alex
I see
I use that :)
I just also want to try out NBT as it seems like a pretty good storage format and its not messy
not really JNBT is quite a nice api
nbt is confusing lol
its really not all that confusing
oh yeah I was going to ask I just use one NBT file with a compound containing all the keys right
yep
okay ๐๐ฝ
and then you can separate NBT stuff with end tags
wdym by end tags
end tags are an indicator that you have reached well the end of the data
since this NBT file is your own
you could place 2 end tags together to mark that its the end/beginning of another NBT section
you are not restricted or must follow how MC stores NBT data ๐
I was just thinking of using 1 NBT compound. than each key (string) would be a location and each tag would just be the data within that location
do you think that is a fair technique?
Yeah that should work
?paste
okay I just mocked something up curious on if you have any critiques
https://paste.md-5.net/uvomimaruq.cs
this has a code sample of what I am kinda going to end up doing than the NBT output. Still not quite sure on what you'd use END and START tags for, but it seems like I can pretty much ignore them
looks fine
START and END tags are for arrays IIRC
oh btw /data get block is probably ur bestfriend'
damn thats fairly time efficent saved 1 million blocks in 3 seconds. And Its very unlikely numbers get even close to that big as well
or to denote the separation of compound tags
or to denote you reached the end of the file
in the TAG_Compound is over, and indeed all of the NBT file.```

although when I stated about the 10 millions blocks from helping that one developer, we came up with a custom binary storage where they used a character of their choosing to denote separations. And they just straight saved the bytes of the data
this was needed because they wanted redundancy
well not redundancy
they wanted error correction
which at some point you are going to want to have if this is a public plugin
this plugin is for a server that I doubt will ever have a large scale of players
Reason being when servers crash they don't get to save data or are in the middle of doing so, and you don't want your users being stuck with a corrupted file lmao
only being corrupt because its missing data or only has partial data
but yeah this isn't too bad
given what you are doing
and the file size should be relatively small too
like no more then 10mb depending how much information it is storing
it was 2.4mbs for 10 million entries
and that is super easy to load into memory ๐
only other caveat of memory mapping files is making sure you have the memory to do so ๐
so at 2.4mb that is no problem lol
How can i spawn a falling block with no gravity?
and how do i specify the block type that i want
if you want it to be faster btw
just remove the compression you are doing
caveat is it will be a slightly larger file but not that much more lol
can't you just do setGravity(false)
was even faster reading it only took 20 seconds to read 10_000_000
nice
setGravity(false) works fine
by tossing in BlockData into spawnFallingBlock
yo alex
uh idk how bungeecord works, doesnt that file yml files support?
wondering the same thing
serialize it and save it
IE turn it into base64 save that
then you can easily pull the data somewhere else
or do like geol and praise binary
same way you serialized
you would use Base64 to decode instead of encode
and then you would just re-create your itemstack object from the data
Hey guys, I want to open an inventory and in the tutorial I watched they used ItemBuilder(), but for some reason, ItemBuilder() is not existing and it's underlined ||Cannot resolve symbol 'ItemBuilder'||. My Code:
Inventory inventory = Bukkit.createInventory(null, 3*5, "Select Map");
inventory.setItem(10, new ItemBuilder(Material.OAK_SAPLING));
i hope your itembuilder is not extending itemstack
ah you dont have one ๐
thats more a mapping than a filter
what's ItemBuilder supposed to be? Just create a new ItemStack
dont collect a stream to stream it again
ItemBuilder is probably their item builder class
what do you actually want to sort
but they dont have any
well the tuts itembuilder class
and a ServiceInfoSnapshot is a server?
sort(Comparator.comparingInt(server.getPlayers().size())) or sth
@tender shard Hey! I was just in the middle of a discussion about your CustomBlockData resource! Crazy to see you here
but how can I set a custom display name, because this is not working: ```java
inventory.setItem(10, new ItemStack(Material.OAK_SAPLING).getItemMeta().setDisplayName("Island"));
it says 'setItem(int, org.bukkit.inventory.ItemStack)' in 'org.bukkit.inventory.Inventory' cannot be applied to '(int, void)'
I was trying to store a object with 3 List<> in a PersistantDataContainer but I wasn;t able to do that so now I'm trying to store a JSON string of the object but I'm still having issues with accessing the data
wdym, can you give me an example
I'm always here lol
use MorePersistentDataTypes
Oh my man
6 hours searching for resources and never saw that
Let me give that a try!
Do you think I should continue with my json object approach
๐ that's unfortunate
Or change to entire class
spigot help dev is great
what objects are you trying to store
package me.tomisanhues2.deepstorage.utils;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.entity.Item;
import java.io.Serial;
import java.io.Serializable;
import java.util.*;
public class ItemInformation implements Serializable {
private List<String> itemName;
private List<Integer> itemAmount;
private List<UUID> playerUUID;
public ItemInformation() {
this.itemName = new ArrayList<>();
this.itemAmount = new ArrayList<>();
this.playerUUID = new ArrayList<>();
}
public List<String> getName() {
return itemName;
}
public List<Integer> getAmount() {
return itemAmount;
}
public List<UUID> getUUID() {
return playerUUID;
}
public void setItemName(List<String> itemName) {
this.itemName = itemName;
}
public void setItemAmount(List<Integer> itemAmount) {
this.itemAmount = itemAmount;
}
public void setPlayerUUID(List<UUID> playerUUID) {
this.playerUUID = playerUUID;
}
}
oh that's no problem
gimme a second
::comparingInt i said
Thanks a lot I've been stuck in this for at least 6 hours had to even get some sleep I was stressed out
just use DataType.CONFIGURATION_SERIAZABLE
or, if you wanna store a list, use DataType.asList(DataType.CONFIGURATION_SERIAZABLE)
e.g.
pdc.set(myKey, DataType.CONFIGURATION_SERIAZABLE, myObject);
.sorted(server -> {
int onlinePlayers = server.getProperty(ONLINE_PLAYERS).orElse(0);
return Comparator.comparingInt(() -> onlinePlayers);
});```?
Ok amazing let me tryto hook that up rq
Appreciate the help!
oh wait, a better option would be this:
PersistentDataType<byte[], ItemInformation> itemType = new ConfigurationSerializableDataType<>(ItemInformation.class);
@regal scaffold
Wait I think what my issue might be then
what about Comparator.comparingInt(() -> /*your method*/);
Cause this is very similar to what I've been doing
afk 5 mins
I'm trying to make a class with a lot of static methods to access and change the data
Could that be the problem?
does someone have an example how to work with permissions?
use Comparator.comparing
then ServiceInfoSnapshot::compareTo afaik
wait Comparator is weird
@tender shard whenver you get back. In the example you have your class extending SerializableConfiguration but the method you have is using a map<> for the data. I believe I need to implement the serializable method correctly in my class to make it work and I can't figure out how.
Specifically I'm trying to make a create() function like this
public static void createNewStorage(Player p, Chest chest) {
//Call location persistence also
ItemInformation itemInformation = new ItemInformation();
List<String> itemName = new ArrayList<>();
List<Integer> itemAmount = new ArrayList<>();
List<UUID> playerUUID = new ArrayList<>();
playerUUID.add(p.getUniqueId());
itemInformation.setItemName(itemName);
itemInformation.setItemAmount(itemAmount);
itemInformation.setPlayerUUID(playerUUID);
chest.getPersistentDataContainer().set(STORAGE, DataType.CONFIGURATION_SERIALIZABLE, itemInformation);
Location location = chest.getLocation();
chest.getPersistentDataContainer().set(LOCATION, PersistentDataType.STRING, location.toString());
chest.update();
}
doesnt comparingInt work with amount of players?
show
put the players field in the comparingInt body
also IntFunction is x -> int not () -> int
do not use the ConfigurationSeriazable datatype, but create a custom one
like this ^
pings alex when he was here 30 seconds ago
can you send that as text?
Sorry I'm lost now mfn
PersistentDataType<byte[], ItemInformation> itemType = new ConfigurationSerializableDataType<>(ItemInformation.class);
everyone needing help from alex
ayo has anyone here ever worked with mongodb / pojo before?
because i am running into this problem and i dont know why:
problem: ```
Caused by: org.bson.codecs.configuration.CodecConfigurationException: Failed to decode 'SavedPlayer'. Decoding 'role' errored with: readStartDocument can only be called when CurrentBSONType is DOCUMENT, not when CurrentBSONType is STRING
db creation:
```java
ConnectionString connectionString = new ConnectionString(uri);
CodecRegistry codecRegistry = CodecRegistries.fromRegistries(MongoClientSettings.getDefaultCodecRegistry(),
CodecRegistries.fromProviders(PojoCodecProvider.builder().automatic(true).build()));
MongoClientSettings clientSettings = MongoClientSettings.builder()
.applyConnectionString(connectionString)
.codecRegistry(codecRegistry)
.build();
mongoClient = MongoClients.create(clientSettings);
mongoDatabase = mongoClient.getDatabase("mining_simulator");```
me reading it:
```java
public SavedPlayer getPlayer(UUID uuid) {
MongoCollection<SavedPlayer> savedPlayerCollection = mongoDatabase.getCollection("players", SavedPlayer.class);
return savedPlayerCollection.find(Filters.eq("uuid", uuid.toString())).first();
}```
the "pojo-class":
```java
public class SavedPlayer {
private ObjectId _id;
private UUID uuid;
@BsonProperty(value = "role")
private String role;
private Map<String, Integer> currencies;
private Map<String, ObjectId> inventories;
}```
private PersistentDataType<byte[], ItemInformation> dataType = new ConfigurationSerializableDataType(ItemInformation.class);
// then later
pdc.set(myKey, dataType, myItemInformationObject);
whats the code
But how does this assign the data to a specific block?
Nowhere does it say anythign about the block
sorted takes a Comparator
pdc is a PersistentDataContainer
not a lambda
you get the container from where you would need it
I'm even more confused now lmao. So does that mean the data is not actually stored directly on the block itself but like a global container?
then no (snapshot -> return Comparator.comparingInt)
you would need to use custom block data by alex for pdc on singular blocks
only one lambda
That's what I'm using
Wait so
Can I actually store an object using morepdc on a block using blockpdc?
lol
what are you trying to do?
sorted(Comparator.comparingInt(server -> server.getPlayers().orElse(0)))```
of course
you would need morepdc to save the info as a config serializable to make it easier to store, then you would need custom block data for storing it on blocks
what is sent, does that work?
just proves how good alex's stuff is
it better not
private static class Something {
int value;
public int getValue() {
return value;
}
}
// later:
final List<Something> activeServers = services.stream().sorted(Comparator.comparingInt(Something::getValue)).collect(Collectors.toList());
hes trying to use sorted with a lambda which returns a comparator which is not how it works
so if you wanna sort a Something list object by their values, just do COmparator.comparingInt(Something::getValue)
since always
you better be kiddin me
'a' + (char) 1 == 'b'
how would I get a potion effect to last forever, and show "xx.xx" for the duration in the inventory?
i already tried Integer.MAX_VALUE and -1, neither worked
How did you try integer max value?
new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 2)
Did it return true when you added it?
it's a constructor, idk how it would return true
How are you adding it to the entity
ohhh
e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 2));
That returns true if it was applied
i can confirm it's applying
it just shows the integer value
in the inventory screen
What does it show?
lemme get a screenshot
it's just the 32bit integer limit instead of xx.xx like i want
And in survival?
same thing
I'm pretty sure the xx.xx potion effect timer was patched out in 1.19.3
^^
Ah well there is the problem then
fuck, ok
thank you!
did you get it working?
Still working on it
Having Caused by: java.lang.ClassNotFoundException: com.jeff_media.morepersistentdatatypes.datatypes.serializable.ConfigurationSerializableDataType
After correctly shading
But figuring it out
Not possible in recent versions
That explains
a lot
like, a lot
Probably why my gson didn't work either before then
๐
So prob could've done this 7 hours ago
im pretty sure spigot ships gson with it
it does
np lol
Oh nvm then I'm just an idiot
xd
Unsupported class file major version 60
So we begin
upgrade maven-shade-plugin to 3.4.1
btw for VaultAPI in your dependencies, set the <scope> to provided
like you did for spigot
because you do NOT want to shade vault
โค๏ธ changed it
Would be fun
Let me upgrade my maven
doesnt intellij ship its own maven?
the included version should be fine
are you by change using java 8 to run the server
which error?
did you reload maven
?paste your pom again pls
this button
Are you running maven with the correct java version?
this should also get you more familiar with NBT too which I think should be learned for mc ๐
erm
line 15 is irrelevant
^^
change maven-shade-plugin to 3.4.1 and itll work
it is not
why would the maven-shade-plugin care about language level 8
Fixed
intelliJ will use it, Netbeans ignores it as it should
the solution is to change maven-shade-plugin to 3.4.1 in line 33
already told you
:kekw:
remove line 15
Can I automatically export the maven jar to my plugin folder?
Changing the maven working directory>
line 15 doesnt even do anything frostalf
it's just a property and it isnt even used anywhere
yes you can change the final output directory
but first lets get it working
.
Addding rn
Eclipse and sometimes IntelliJ ends up using it. While it should be ignored these two IDE's especially eclipse do not
my brain isnt braining so im just gonna check, would if ((HEX_PATTERN.matcher(color1).matches() && HEX_PATTERN.matcher(color2).matches()) || (VALID_NAME_VALUE.containsKey(color1) && VALID_NAME_VALUE.containsKey(color2))) check if the arg color 1 and color 2 are either correct hex's or correct valid names
do you want my color code
from my project it should help you
what are you tryna to do
it wouldn't check if they are correct hex's per-say rather it would check if it matches anything based on the pattern you supplied it
check if a color1 and color2 are either valid hex or a valid colour name
Still not working @tender shard
Caused by: java.lang.ClassNotFoundException: com.jeff_media.morepersistentdatatypes.datatypes.serializable.ConfigurationSerializableDataType
you need to shade
and relocate
We did that
well the regex is "#[a-fA-F0-9]{6}" so it should mean its valid
:P it would work if that were true
how are you compiling
to check for valid hex you need a regex to check for that its at least 6 characters and within the appropriate ranges of characters
then you should be good ๐

It's what alex said lol
selecting package is appropriate, it encompasses everything before it
install is handy if you want it to have it in your .m2 directory
like you want to use it as a dependency for something else
But still getting error with the class
deploy is used if you want to do everything but also upload it somewhere
Caused by: java.lang.ClassNotFoundException: com.jeff_media.morepersistentdatatypes.datatypes.serializable.ConfigurationSerializableDataType
what does your pom look like now?
just remove it
It's outputting correctly but when I load on server that's what it comes
Do you guys suggest to register a plugin messaging channel for each chat conversation between helper and player for something like a party chat or idk?
which SDK did you setup in File -> Project settings?
it should be 16 or higher
it does compile fine, right?
Yes
wait 1 sec
change this <pattern>com.jeff_media.morepersistentdatatypes</pattern>
to
<pattern>com.jeff_media</pattern>
they would need the morepersistent stuff
if they dont include it but had mutliple com.jeff_media deps it would relocate to 1 location and probably break something
well they only have 1 dependency
@regal scaffold you messed up the outputDIrectory
you are NOT supposed to change it in the shade plugin
but in the .jar plugin. I sent you a blog post earlier
That would explain a lot
Clearly didn't read it correctly
yep that is the other thing
or compiler
no
not in the compiler plugin
otherwise it breaks the shading
the maven-jar-plugin is the only proper way to change the output location if one wants to correctly shade stuff
not exactly true
How would I use the plugin?
the solution from my blog post will definitely work
yes it will work
OH I see what I messed up
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<outputDirectory>C:\MyServer\Plugins</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
<relocation>
<pattern>com.jeff_media.morepersistentdatatypes</pattern>
<shadedPattern>me.tomisanhues2.deepstorage.morepersistentdatatypes</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
like this @regal scaffold
alex are we gonna handle nicks or do we just leave that to cmi
should add finalname at the top for them too ๐
I'd leave it to CMI
cmi is so bad
I'm kinda fucked up by CMI, I opened an issue in 2021 and still didnt get a reply from the dev
lol
if i say anymore conclure will bonk me
#shit-talk-plugins when
once you get that working, do you want me to show you how to update the version number in the plugin.yml without having to edit it all the time?
Sure, anything would help!
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
then in plugin.yml, do
version: ${project.version}
that doesn't always work
if it doesn't work for you I will show you how I do it
Moment of truth
why would that not work? how else would you do it?
google replacer? to filter a simple property?
Yes because sometimes I have issues with Maven not doing it
just use mvn clean once, then the {project.version} will always work if filtering is setup
especially when shading
seems very un-necessary
it does not always work
to a different error now
always worked for me
always worked for you doesn't mean that no one else has ever encountered the problem
it is the very reason I use replacer plugin
otherwise I wouldn't use it
what's Keys line 49?
it really just depends on what you have going on in the pom
public static void createNewStorage(Player p, Chest chest) {
//Call location persistence also
ItemInformation itemInformation = new ItemInformation();
List<String> itemName = new ArrayList<>();
List<Integer> itemAmount = new ArrayList<>();
List<UUID> playerUUID = new ArrayList<>();
playerUUID.add(p.getUniqueId());
itemInformation.setItemName(itemName);
itemInformation.setItemAmount(itemAmount);
itemInformation.setPlayerUUID(playerUUID);
49 chest.getPersistentDataContainer().set(STORAGE, getDataType(), itemInformation);
chest.update();
}
private static PersistentDataType<byte[], ItemInformation> dataType = new ConfigurationSerializableDataType(ItemInformation.class);
public static PersistentDataType<byte[], ItemInformation> getDataType() {
return dataType;
}
Is what epicebic and I did
which is line 49?
wrong reply be like
I thought the static would screw stuff up
public static final NamespacedKey STORAGE = new NamespacedKey((Plugin) Plugin.get(), "infinite.storage");
not sure if I would be using statics
Haven't had issues with the namespacedkey at all
is your main class called Plugin?
Yes
how would you prevent data loss with crashing using something like NBT since its memory. I am kind of just curious at this point lol even though I don't really need it
also having the ability to recover data is just a not a loss of time at all
You gonna flame me for this one mfn
you identify what is the minimum amount of information needed to know what it is supposed to be and then fix it appropriately. Once its above that, the only solution is either to remove it when its detected or use generic defaults
Ok yes so i'm not even gonna send it lol

I asked about this I think the reply got lost somewhere
it cant be worse than what ive wrote before
How do I return a map with 3 List<Objects>
class ItemINformation iimplements ConfigurationSeriazable {
int age;
public Map<String,Object> serialize() {
Map<String,Object> map = new HashMap<>();
map.put("age", age);
return map;
}
}
basically, everything you want to save has to be in the map that you return
Oh my
So the String, Object is just a key system
It's not the actual data
The example on your page makes it seem like it's the exact data
String is the key, Object is the data
an example for a block is this. Does it really matter what material it is? If not then if material information is missing you could default that to dirt or grass for example if everything else is fine, like location and the sorts.
Here we go again
I thought you were going to try just storing as NBT in your own file ๐
public class ItemInformation implements ConfigurationSerializable {
private final int age;
private final String name;
public ItemInformation(int age, String name) {
this.age = age;
this.name = name;
}
@Override
public Map<String, Object> serialize() {
Map<String,Object> map = new HashMap<>();
map.put("age", age);
map.put("name", name);
return map;
}
public static ItemInformation deserialize(Map<String, Object> map) {
return new ItemInformation((int) map.get("age"), (String) map.get("name"));
}
}
Here's an example for a working ConfigurationSeriazable class @regal scaffold
yeah no chance
you need both the serialize and desertialize method
ahhh so in my case it'd be like well I need its Location and NodeType (correlates lots of other info other than material)
So if we are missing Location or NodeType its best off of just chucking it out of the NBT instead of repairing it. If I have those two I can just repair the other data
How can I cast to List<String>, List<Integer>
exactly. This is the most ideal way other then just storing minimal duplicate data elsewhere
IE redundancy
makes sense and pretty much aligns with everything I learned in the IT class I took about making sure your storage doesn't fail
cast what to a List?
map.get("age")
it isn't just about it not failing but it should be created in a way that requires minimal input from the user as well
List<String> someStrings = (List<String>) map.get("someStrings");
and it shouldn't be the cause that your plugin just fails completely
And then I need a constructor for 3 parameters to create object right?
if the storage is corrupted it should just make a new one, and then notify the user about it if the plugin isn't capable of repairing the damage
or if the user has it set, repair what you can, remove the damaged stuff
yeah kinda
basically your deserialize() method takes a Map, and turns that map into your object again
can you show your ItemInformation class again? I'll show how I'd do it
1 sec I wanna figure this one out
HOLY CRAP NO MORE CRASHES
Ok now I need to test that it's working
Lets say I wanna add data to the pdc right?
yes?
Ok little error
But unrelated
public static void createNewStorage(Player p, Chest chest) {
//Call location persistence also
ItemInformation itemInformation = new ItemInformation();
List<String> itemName = new ArrayList<>();
List<Integer> itemAmount = new ArrayList<>();
List<UUID> playerUUID = new ArrayList<>();
//This line adds the current player UUID to the list
playerUUID.add(p.getUniqueId());
itemInformation.setItemName(itemName);
itemInformation.setItemAmount(itemAmount);
itemInformation.setPlayerUUID(playerUUID);
chest.getPersistentDataContainer().set(STORAGE, getDataType(), itemInformation);
chest.update();
}
But then ```java
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.List.contains(Object)" because the return value of "me.tomisanhues2.deepstorage.utils.ItemInformation.getUUID()" is null
alex what do we want the chat format of, im guessing rank: nick ยป messag
package me.tomisanhues2.deepstorage.utils;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.entity.Item;
import java.io.Serial;
import java.io.Serializable;
import java.util.*;
public class ItemInformation implements ConfigurationSerializable {
private List<String> itemName;
private List<Integer> itemAmount;
private List<UUID> playerUUID;
public ItemInformation() {
this.itemName = new ArrayList<>();
this.itemAmount = new ArrayList<>();
this.playerUUID = new ArrayList<>();
}
public ItemInformation(List<String> itemName, List<Integer> itemAmount, List<UUID> playerUUID) {
this.itemName = itemName;
this.itemAmount = itemAmount;
this.playerUUID = playerUUID;
}
public List<String> getName() {
return itemName;
}
public List<Integer> getAmount() {
return itemAmount;
}
public List<UUID> getUUID() {
return playerUUID;
}
public void setItemName(List<String> itemName) {
this.itemName = itemName;
}
public void setItemAmount(List<Integer> itemAmount) {
this.itemAmount = itemAmount;
}
public void setPlayerUUID(List<UUID> playerUUID) {
this.playerUUID = playerUUID;
}
@Override
public Map<String,Object> serialize() {
Map<String,Object> map = new HashMap<>();
map.put("name", itemName);
map.put("amount", itemAmount);
map.put("uuid", playerUUID);
return map;
}
public static ItemInformation deserialize(Map<String, Object> map) {
List<String> someStrings = (List<String>) map.get("someStrings");
List<Integer> someInts = (List<Integer>) map.get("someInts");
List<UUID> someUUIDs = (List<UUID>) map.get("someUUIDs");
return new ItemInformation(someStrings, someInts, someUUIDs);
}
}
do we need ranks? I thought showing the server name is more relevant than any rank
Wait I think I know
ive got no idea
If you see it don't tell me just yet
im willing to use lombok at this point
btw you cannot serialize UUIDs, you need to turn them into strings. and yeah, your constructor should not allow null values or uninitialized variables
you could serialize the UUID using base64 and then it would be a string
but its just easier to store the UUID as a string itself
because you can do UUID.getString()
or toString()
forget which it has
Ok let me change that
should i just grab the server id from the config, judging that it gets changed per server
and then you can do UUID.fromString(UUIDstring)
and that gets you your UUID object back
serializing an uuid to base64 ๐ค
package me.someone.myplugin;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.stream.Collectors;
public class ItemInformation implements ConfigurationSerializable {
private List<String> itemName = new ArrayList<>();
private List<Integer> itemAmount = new ArrayList<>();
private List<UUID> playerUUID = new ArrayList<>();
public ItemInformation() {
}
public ItemInformation(List<String> itemName, List<Integer> itemAmount, List<UUID> playerUUID) {
this.itemName = Objects.requireNonNull(itemName);
this.itemAmount = Objects.requireNonNull(itemAmount);
this.playerUUID = Objects.requireNonNull(playerUUID);
}
public List<String> getName() {
return itemName;
}
public List<Integer> getAmount() {
return itemAmount;
}
public List<UUID> getUUID() {
return playerUUID;
}
public void setItemName(List<String> itemName) {
this.itemName = itemName;
}
public void setItemAmount(List<Integer> itemAmount) {
this.itemAmount = itemAmount;
}
public void setPlayerUUID(List<UUID> playerUUID) {
this.playerUUID = playerUUID;
}
@Override
public Map<String,Object> serialize() {
Map<String,Object> map = new HashMap<>();
map.put("name", itemName);
map.put("amount", itemAmount);
map.put("uuid", playerUUID.stream().map(UUID::toString).collect(Collectors.toList()));
return map;
}
public static ItemInformation deserialize(Map<String, Object> map) {
List<String> someStrings = (List<String>) map.get("someStrings");
List<Integer> someInts = (List<Integer>) map.get("someInts");
List<UUID> someUUIDs = ((List<String>) map.get("someUUIDs")).stream().map(UUID::fromString).collect(Collectors.toList());
return new ItemInformation(someStrings, someInts, someUUIDs);
}
}
note, I dont save the UUID as UUID, but map them toString. Then in deserialize, we do the opposite
I don't think server id is even used
that's required because UUID doesnt implement ConfigurationSeriazable
not that UUID needs to given it has methods to turn it into a String lol
custom config
Changing List<UUID> to List<String>
yeah that would ofc also work
oh thought you were talking about server config and methods
Caused by: java.lang.NullPointerException: Cannot invoke "Object.getClass()" because the return value of "org.bukkit.configuration.serialization.ConfigurationSerialization.deserializeObject(java.util.Map)" is null
Still error
full stacktrace pls
you have something null
oh alex can i get invited to be contrib on bungeecore so i can commit this when i finish
public static ItemInformation getStorage(Chest chest) {
return chest.getPersistentDataContainer().get(STORAGE, getDataType());
}```
sure, what's your gh name?
The-Epic
did you register your custom class to be config seriazable?
in onEnable() on the first line, do ConfigurationSerialization.registerClass(ItemInformation.class)
do you still have any ItemInformation objects in your config that might still be null?
where did you save the data? in blocks using CustomBlockData?
chests are tile entities iirc
you could just destroy the chests or use a new world for testing or sth
or just place a new chest
show your PlayerInteractEvent code
public void actionRight(PlayerInteractEvent e) {
Chest chest = (Chest)e.getClickedBlock().getState();
Player p = e.getPlayer();
e.setCancelled(true);
ItemInformation info = Keys.getStorage(chest);
Bukkit.getLogger().info(info.toString());
if (info.getUUID().contains(e.getPlayer().getUniqueId())){
p.openInventory((new Utils()).getMainMenu(info.getName(), chest));
} else {
p.sendMessage(Aliases.NOT_ALLOWED);
}
}
?interactevent
The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.
For example, only executing code if the main hand was used:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
return; // do not progress past this point |
}
// provide functionality
}
what does Keys.getStorage do? It looks like you simply don't have any data at that block
public void chestInteract(PlayerInteractEvent e) {
if (!verify(e))
return;
if (e.getAction() == Action.RIGHT_CLICK_BLOCK)
actionRight(e);
}```
also your utils probably shouldnt need to be initalized
public static ItemInformation getStorage(Chest chest) {
return chest.getPersistentDataContainer().get(STORAGE, getDataType());
}
How I'm able to edit or remove stuff with the the bukkit FileConfiguration? And does I'm able to for each the whole File?
do getOrDefault(STORAGE, getDataType(), new ItemInformation())

