#help-development
1 messages · Page 960 of 1
how do I do that lol
how do I give a player a uuid without having a uuid to store it
should I just use their username to store it
the pdc link should have a snippet of how to save a uuid with pdc
as I went over before u can't save pdc data with a player it gets cleared when they rejoin
which is the entire reason im doing this
I think the getuuid command SHOULD work
based on what the docs say
It doesn't make sense that the players pdc is reset
The whole point of pdc is so that it persists the data...
And you mean reset in context of the container still existing just being cleared of data
That's my point
is it doesn't make sense that the data is poofed
Ah more api advancements to look forward to ig
hmm
well
honestly I dont wanna go back to pdc
Id rather have a class I can serialize
At this point I'd say save whatever playerdata you need to a flat file
I swore that was true too, there has to be something else happening here
then whats the deal
Also pdc is held by the server, so given the player joins/rejoins that should make no difference in the persistence
Time to show code
code is gone
breh
i replaced it
With serialization for a file?
tbf you can just do that, given pdc is somehow breaking for ya
dammit
it still isn't working
it worked when i rejoined finally
but it didn't save
ill get there
You might have to preimtively save the player data before they actually leave
ie: prePlayerLeave(custom)Event or something of the sort
^ note thats not a real method call
Also you could just make a key manager class that will register all your keys on startup and just query from there
that also sounds annoying
Less annoying then having to define a key in every class
and was the second idea I had
its like
idk its not letting me create the file for some reason
im like hey write to this file! and its like that file doesn't exist
and im like i KNOW
You initialized a new file correct?
idk I just copy pasted from herehttps://www.spigotmc.org/wiki/save-load-data-files/
imma try absolutefilepath rather than filepath
nope
private File dataFile;
private FileConfiguration dataConfig;
public DataManager(JavaPlugin plugin) {
if (!plugin.getDataFolder().exists()) {
plugin.getDataFolder().mkdirs();
}
dataFile = new File(plugin.getDataFolder(), "data.yml");
if (!dataFile.exists()) {
try {
dataFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
dataConfig = YamlConfiguration.loadConfiguration(dataFile);
}
public FileConfiguration getConfig() {
return this.dataConfig;
}
public void saveConfig() {
try {
dataConfig.save(dataFile);
} catch (IOException e) {
e.printStackTrace();
}
}
public void reloadDataConfig() {
dataConfig = YamlConfiguration.loadConfiguration(dataFile);
}
public void setPlayerData(String playerName, String path, Object value) {
dataConfig.set("players." + playerName + "." + path, value);
saveConfig();
}
public Object getPlayerData(String playerName, String path) {
return dataConfig.get("players." + playerName + "." + path);
}
}```
So the point is to create a new file & fileconfiguration, when you create the file you define the path ie: plugin.getDataFolder, then use the fileConfiguration to edit said file
Usually you create a new(fileName).yml in your plugin's resources and write it out in there in order to keep it clean
You can easily make a custom adapter for PDC that goes directly from/to a class
He just switched from pdc to a flat file serialization and I dont think he wants to go back lol
^ more or less it's just pdc is a bit easier
sounds like I should use the one I already wrote most of then
Fair
pdc is just better because it's basically the same thing just held by the server rather than your plugin
I just wanna get this working so I can actually add features 😭
try {
BukkitObjectOutputStream out = new BukkitObjectOutputStream(new GZIPOutputStream(new FileOutputStream(filePath)));
out.writeObject(this);
out.close();
return true;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}
}```
heres my code
I dont really know what most of this does but in theory it should work unless that wiki is lying to me
Use this example haha
Oh
In the usage methods, you can obviously parse the data however you want
That's apart of the fun
Well if you want to just save binary data
She was using this example @young knoll
I think she probably wants to use file & fileconfiguration but thats my opinion
Couldn't tell you kek
Given that you use this example, the file & fileConfiguration are quite simple to get a handle of. Just mess around with it a bit @proven musk
so you have no idea why my code isn't working
The standard java serialization just requires an ObjectOutputStream
I would start with that
Your code isn't working cuz you copy pasted from a goofy looking example lol
so u think it wont work
Should cover the basics
alr ill use ur method
I think it will when it's written properly, however I only ever use file & fileConfig so I probably wouldn't even be much help with base java serialization
Since coll is a G, you can also do a bit of reading if you're up for it... certainly could just use file & fileConfig but still good knowledge
Yaml is more standard
Or you could do gson since spigot shades that
But binary serialization is certainly an option
yaml is easiest / mainstream so probably just do that lol
how does you example work
so its loading on object into yaml... how?
also what do I put in as the path
Essentially it's just plain text, but when you take that data back out of the file it will mean something in your code ie: String petName = file.getString("path.to.petname")
The path is preference, should probably follow concern orientation
im honestly so confused
so I can't save my playerdata class
I have to save individual values
this is what I was trying to avoid lmao
It's never too late to go back to pdc
why would that be better
I was so close to having it work now I gotta start from scratch again
and now ur telling me ... what to start over again again
Because in the essence of pdc, it's essentially the same thing as serialization to a flat file rather it's held by the server instead of your plugin
but id have to rewrite that again
So you're doing the same thing just along the lines of how pdc work, it's still saved in a file format for the server to use iirc
im like this close to just crtlzing back to serialization
because if I did pdc like
I have to do so much extra work to get the values out of the container
So then just continue with flat files
I already deleted all that to try to use your code
If you want the lazy method of being able to go directly from object -> file
Use gson
and now ur telling me NOT to use your code use pdc
What you had before was binary serialization
What I sent you is yaml serialization
Not that it's a whole lot different
all this to save whats essentially a scoreboard value
Take a break, no reason to be stressing you can always come back to it
is there a way to disable files in intellj
lmao
just delete a file without having it gone forever
i just changed the extension
// or \ * commenting... otherwise I don't think that's a thing
ok
I went all the way back to pdc but better this time
works when I rejoin
works when i restart!
idk what was going on with that before lol
hello, does anyone know how do i change this from main to say Version Control i want to bring it back
on top left of the screen
is there supposed to be an image
There was one
what would be the best way to have a event run exactly at sunrise every day?
Depends
on?
Sunrise ingame?
I mean you could do some little math and just schedule a task for sunrise and then schedule it again in that task
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/world/TimeSkipEvent.html to check for things that skip sunrise
declaration: package: org.bukkit.event.world, class: TimeSkipEvent
A scheduled task with period=1 is 'on tick'
But 1 tick is overkill for this
Maybe every 100 ticks at most
if this is depricated then what do I use
oh
it just wants a runnable not a bukkit runnable
yup
ok well how do I start a runnable from the runnable
i couldnt send the image but i dound a fix thx
( you need to be verified to send images)
nevermind the error wasn't accurate
whats wrong with intellj
normally its just alt up
im switching it to alt up
is time skip event run when /time is run?
it should
weird
See pdc isn't that bad
Are you using a key manager?
Do you even have enough keys to warrent a key manager?
rather than storing it in a class im just doing PlayerData.getSoulPoints(player) basically
you didn't do that before?
breh
I copied the values into a class
well I thought pdc was going to be slow to call every time
but it probably isn't
The way it's called upon again within the ?pdc example is kinda meh, there are workarounds to make it a bit more robust
er robust isnt the correct word
easier is fine
Rather than having a constant itemstack, it just tells you to make another each time you want to access the custom item
ok
sooo
this is weird
the gametime doesn't actually reflect the time of day
how do you get the time of day of a world
right
.getTime
long getTime()
Gets the relative in-game time of this world.
The relative time is analogous to hours * 1000
Returns:
The current relative time
See Also:
Returns an absolute time of this world
@proven musk
Should work fine, what are you having an issue with
public static void load() {
var item = new ItemStack(Material.FLINT);
NamespacedKey key = new NamespacedKey(Main.instance, "flint_from_gravel");
ShapelessRecipe recipe = new ShapelessRecipe(key, item);
recipe.addIngredient(Material.GRAVEL);
recipe.addIngredient(Material.GRAVEL);
recipe.addIngredient(Material.GRAVEL);
recipe.addIngredient(Material.GRAVEL);
// Finally, add the recipe to the bukkit recipes
Bukkit.addRecipe(recipe);
}```
it just does nothing
idk what to troubleshoot
I can't craft it and theres no error
im pretty sure its running lol im calling .load onenable
Any reason its static, just curious
why not
But, pretty sure for shapeless you can enter an int
I just want the code in its own class
wdym
I'm on my phone so gimme a sec to type it
`` recipe.addIngredient(4,Material.GRAVEL);` u mean like this
Yes
I mean thats cool but does it matter for it working
It does
addIngredient() essentially does addIngredient(1, Material)
which sets a value in a Map
wouldn't it work if I just put one gravel in tho
bc it doesn't
trying the new way
doesn't work
no errors
var item = new ItemStack(Material.FLINT,1);
NamespacedKey key = new NamespacedKey(Main.instance, "flint_from_gravel");
ShapelessRecipe recipe = new ShapelessRecipe(key, item);
recipe.addIngredient(4,Material.GRAVEL);
// Finally, add the recipe to the bukkit recipes
Bukkit.addRecipe(recipe);
}```
thats the idea
heres the new code that doesn't work still
Are you loading this in on enable?
mhm
Show
ItemStack item = new ItemStack(Material.FLINT, 1);
NamespacedKey key = new NamespacedKey(this, "flintGravel");
ShapelessRecipe recipe = new ShapelessRecipe(key, item);
recipe.addIngredient(4, Material.GRAVEL);
this.getServer().addRecipe(recipe);
alr
why are the tutorials so uhm
If its in another class
bad
im confused hold on
new Recipe(this)
And make the Recipe a record
Use an instance of the main class
yes
You shouldn’t be accessing that with a static method either
Also why do you use var instead of ItemStack
:)
For the record, this works just fine for me
dont worry about it guys
lol
its weird how bad the spigot resources are
almost all the articles are outdated or have misinformation
Same code choco?
Its hard to learn what do to do basic stuff
Identical
weird
var item = new ItemStack(Material.FLINT,1);
NamespacedKey key = new NamespacedKey(this, "flint_from_gravel");
ShapelessRecipe recipe = new ShapelessRecipe(key, item);
recipe.addIngredient(4,Material.GRAVEL);
// Finally, add the recipe to the bukkit recipes
Bukkit.addRecipe(recipe);
So if it's not working, it's for some other reason
Been using plugin.getServer() over Bukkit for forever for some reason
And I still have no clue the difference besides access
No reason to at all. Plugin#getServer(), Bukkit.getServer(), Bukkit.x(), all does the same thing
Bukkit statically mirrors all of Server's methods for convenience
then why did it do different things
@proven musk you sure your compiling and uploading to your server
And then restarting your server
I would hope
Add a debug message on Onenable to confirm
Either b/c the itemstack was casted to var
I didn't change that
it works now
Didn’t upload correctly?
Unsure if it works for furnaces. Could always try it
Same thing
MaterialChoice
pdc is pdc
Lets you pass a Tag or a Collection<Material>
Might be a Set or List. Can't remember. The Tag constructor I added recently
that can't be right
all it gives me is RecipeChoice.MaterialChoice
Yeah that's the one
how do I use that
Same as the exact choice. You can create an instance of it
oh
new MaterialChoice(Tag.PLANKS)
why did I think it was an enum
how would I remove/replace a vanilla recipe
I think I got it
it would be NamespacedKey.Minecraft
I'm unsure if it would replace it. You may have to remove it first
Ideally you'd remove the Minecraft recipe and add one under your namespace instead
Bukkit#removeRecipe(NamespacedKey) before you ask :p
ok thats what I have
and yeah it seems like my plugin wont always update
I build in intellj and then restart the server
Best guess is that IntelliJ could be incorrectly caching your compiled code, or maybe it's refusing to replace a .jar file that's been loaded by a JVM
So you could stop your server, build and export, then start your server
nope im stuppid its just an error
That's also a possibility :p
@worldly ingot question for you
Do you just do the generic install compile option? I've never had an issue with that before
this is weird
it uhm. doesn't?
is it something about how im doing like a 2x3 recipe
or do I have to set the shape first
If I export using an artifact it over writes the jar in the jvm. But if I build with maven I have to stop the server, add it then start it
Probably that haha
Shape first, then ingredients
I mean one way or another you'd have to either /reload or restart your server so that the Bukkit class loader actually loads those changes
Is it not possible to load the changes during runtime?
Or perhaps just very dangerous
I mean some people have managed to spin up a server via IntelliJ and setup some hotswapping but it's never been officially supported, nor do I really know how to go about doing that
Oh right I remember seeing stuff about that haha
I mean it's quite annoying to get the 20s delay on outdated spigot version
You can skip that for development purposes if you'd like
java -jar -DIReallyKnowWhatIAmDoingISwear server.jar nogui
Don't use that on a production server, obviously, because keeping the server software up to date is important. But if you're just working on a local dev server and testing things, it's fine. Skips that 20 second delay so you can boot your test server quicker
im honestly just gonna ask here bc google is really unhelpful
how would I change (and can I) change block properties like how hard it is to mine and the tool required
You can definitely do that
how
the best I can figure out right now is like
giving haste to the player using on damage and on damage abort?
is there a better way
PlayerInteractEvent
then what
I’m about to sleep so hopefully someone will help you more with that, but go through the javadocs on playerInteractEvent to gather what you need
rip
You can get the block, and modify from player interact event iirc
gn!
Goodnight good luck with the project!
yeah I have no idea what they were trying to tell me
idk how I would actually change the mining speed
iirc the way hypixel (and other servers) do it is they give the player haste -1 to prevent breaking blocks, then just listen to on damage and damage abort events like you said
depending on how long they break the block, you change it's damage or like crackedness
i know there's a spigot method for that but i cant remember it off the top of my head
you would have to handle haste differently, yeah
ill figure something out
thankfully it should be alright
maybe ill just not do it if the player already has haste because it shouldn't really matter past that
yeah that would work
does anyone know how you'd register a command? I'm very confused. The wiki sais one thing, doesn't mention the registration progress though, my IDE sais that the CommandExecutor class doesn't exist and cannot be imported, and I'm really confused what I'm supposed to be using.
So I have a class ready that extens Command - what now?
it should extend CommandExecutor
yeah that just does not exist
no as I said I cannot
Do you use maven or graddle ?
what ide are you using
well anyway, now I have a CommandExecutor extending class, what now, how do I register taht?
just garbage intellij
the wiki should tell you
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
the wiki just tells you how to create the class and not how to register it that's why I'm here
this has every step
the spigot wiki is meh
why are there 500 different wiki pagse for the same thing
I was on a different wiki page that just didn't have the registration part -.-
I think you are meh if you cannot find the information and struggle with java development
Just fight and trust yourself
you can do it
I've tried fabric, I've tried kubejs, I've tried spigot all to get the same project working and I've not had a successful start yet
in any of those
well thanks
I mean
tbf all I looked up what "spigot custom command"
idk how you didn't find it
I searched the same thing and all I found were wiki pages talking about the same thing but without the registration part
and the search bar in the wiki just searches posts not the wiki
no
bc thats weird
I'm using everything at once, literally
skill issue
https://imgur.com/a/iEcxFpH mostly stuff like this
the wiki is definitely not SEOd
bro I hate imgur
why are image uploads not enabled here
whatever, anyway just a bunch of random plugins and libraries
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
var itemMeta = event.getItemInHand().getItemMeta();
if(!itemMeta.hasEnchant(Enchantment.DIG_SPEED)) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
itemMeta.addEnchant(Enchantment.DIG_SPEED,3,true);
setPdcValue(itemMeta,PersistentDataType.BOOLEAN,"copper_wooden_pick",true);
}
event.getItemInHand().setItemMeta(itemMeta);
this doesn't hide the glint. Isn't there a way to hide the glint? I could've sworn theres a way to do it with commands normally
I ain't creating an account for a wiki that annoys me with cloudflare on a regular occasion
I cannot even use that properly
I mean suit yourself
oh well then just no screenshots here
they could just use a normal verification system
What does life did to you?
You seem so unhappy
I'm annoyed that java is so disgusting to set up. I've wasted so much time on setup that I cannot even count it anymore
Which language do you come from?
development aint easy
any other programming language is the easiest to setup, and then there's java with maven, gradle, and all that garbage
It took me 15 minutes to setup eclipse, 20 minutes to setup IntelliJ so idk
I used typescript and C++ recently. All very compliant. Java just isn't
and I cannot use vim because the language servers are all having issues
You should clearly take a walk
same
talk a walk get some water
been at this for several hours because nothing works
I just want to get this over with
the issue is always the ide
anybody know whats up with this
but if the best ide doesn't work then no idea
intellij as I said
It should work fine.. Does the item have the enchant?
yep
And the issue is that?
Ahhh
oh
on fabric it wasn't picking up like half of the fabric libraries, and on spigot it's also struggling to find the most basic libraries on the first attempt
weird
I coulda sworn there was a way to hide the glint
but ig not
thats frusterating
whats the point of hiding enchantments then 💀
the glint is done client side when used with enchants afaiik
So you can add a glint without enchants
I think the glint is client side. That means you need to remove the enchant from the packet
you can do that already
??
yeah
which would kinda defeat the purpose of enchants
Depends the kind of enchant
When you create a project you're using the minecraft "preset" correct?
but for the dig speed yeah
yes...
at least with datapacks
McDev plugin
Jut checking
wouldn't be so nice for stuff like efficiency
literally it doesn't matter lmao
I'm pretty sure the client needs an enchanment in the items nbt to render the glint
im just trying to make it so certain blocks are easier to mine than normal
but whenever ur mining it it adds a glint
idk how to remove that but ig its not a huge deal
@proven musk for the dig speed there is no work around. You can however change the client attribute (maybe) when he holds this item, but the render wouldn't be that great
Can you describe struggling? And also what you're trying to do
Just get the ide to a "usable" state as it were?
theres no dig speed attribute
anyway its fine
its not worth fucking around with packets
I dont beleive you
You called my bluff
is there an event for like
switching the item ur mining a block with
or just switching ur hotbar item
In any case removing the dig speed from the item will remove it also from client side
haste doesn't work
sometimes it works, most of the time it doesn't, and in the case of fabric it wouldn't do it at all
wdym
I wonder if you can remove the glint with coreshaders
Or you can apply your own block break packet (don't do that)
Just keep the glint, it's not a big deal ahah
yeah
You'd have to describe what that event looks like ie: when a player is mining a block and if they change items while minging it
Maybe but then all glints would be :/
thats exactly it
I need to remove the enchantment when that happens also
Core shaders allow you to do lots of funky stuff, so no
bc you can swap items and keep breaking it and keep the enchantment
So take playerInteractEvent and build your event logic from there, use the fact that player interact event returns the block interacted with, this way you can actually engineer that logic
idk how that would change anything
i already know the block that the player is breaking
Then you can just trigger your logic from the interaction of that block
again tho
that doesn't change the issue
when you switch what item ur using to break it
unless im misunderstanding
You have to detect the fact the player switched items and then handle that interaction as it were accordingly
I mean
I know that
thats what I asked about in the first place
I need more info idk what ur trying to tell me
I’m pretty sure if you use playerInteractEvent, you can get the necessary information to listen for the player switching their currently active item whilst that interaction is occurring, I don’t have any examples of this
so it would fire if they switch the active item
You just need an event to occur ie: player switching items while breaking a block
Idk how you’re gonna get the block from that
i dont really need to honestly
what
I thought you needed the block the whole time
.
ur good
but thats what I said in the first place
hmm
I was trying to help the other guy with the ide issue I hadn't read that
nw
any idea how you make intellij rescan the maven dependencies? Now it's not able to find anything about the worldedit libraries I just added
why is everything so annoying
because you are a girl
lol xd
🤣
my humour is good right?
leave the server
🚱 this is literally is the most useless emoji
If you click the lifecycle tab, theres a nice little double arrow button
ok leave
there is no lifecycle tab
there is no maven button
how would I make block drop when it shouldn't normally (ei: broken with the wrong tool)
The right side of the ide
ooh that
do I just have to manually do the drops
thank you very much.
I'm not used to complex uis anymore
Yes ofc, that's prolly the issue you've been having with the libs... just click that and usually it starts working
u would have to manually determine the drops and add them. since minecraft will determine no to drops for those
damn
if I had known that earlier...
can I just drop from a loottable
i mean. u can pretty easily get a block's default drops
I thought you meant default spigot api lib was like half working lol
yeah fabric was causing me issues, and taht was probably the solution too
same issues on spigot and it's all just this tiny button
theres no such thing as default drops with ores
yep
it depends on the tool
I could just say I dont want fortune to matter but I also plan on editing the loot tables
A lot of times the ide just needs a lil refresh... that's not to say 95% of the times I've put a dependency into the build path and it just works but yk
stuff happens
so id rather just have it drop the loottable
last time i did that stuff i just calculated the fortune myself
Better way sure but thats for later optimizations, you just have to get it working first!
it would be easier just to get what would drop
ok its just getDrops from the block ig
getDrops
@NotNull
Collection<ItemStack> getDrops()
Returns a list of items which would drop by destroying this block
Returns:
a list of dropped items for this type of block```
kek
One thing you'll learn from asking questions here is that a lot of the time it can be answered by a (thorough) search through the jdocs... given you want to put the time into that
the answers on google for spigot are kinda ass
those dont super help when the question is how do I do x
How new are you to programming?
Then docs will be your best friend, you'll just have to put a bit more time into searching / testing
so i never know the best way to do x
since most of my questions should be really basic stuff I assume people would know here when google doesn't give me what I want
The best way to do x is hard to determine as theres a lot of ways to achieve x
So imo the best way to do something comes down to like 2 factors: speed / efficiency
the most important factor to me is stability
Stability is important but that should be saved for optimizations mostly,
theres alot going on in this game and doing something the first way that seems possible usually has side effects
so long as the foundation is solid, then just save the premature optimization for a better time
Just get it working first then improve
Are you an experienced mc player?
yeah
for the most part
theres still alot of little mechanics that I dont remember tho
I mean a lot of what you can take from that experience can be applied to the spigot dev work, that's how I learned
I know alot about datapacks
But as programming is virtual there are limitless possibilities, and with the freedoms of minecraft I mean that's a pretty cool environment to learn in
ill be honest the main reason the jdocs aren't super helpful is the descriptions aren't very helpful
like
You're not wrong
The amount of health an entity has iirc
total amount
Or wait no that changed, I'm pretty sure it relates current health
the number by which health gets scaled e.g multiplied
nope im wrong
why would it be multiplied
cuz its a scale
so you can change each heart to be more than 2 points?
I think you can change the size of the scale
so its health / max health * scale
thats is often the case as well btw. that stuff is better explain on a related method of which ur looking at. so they dont bother explaining again
Tbf it just comes with time like most things, you'll pick up some good tips and tricks here that's for sure
it's finally done 😄
What does your @Setting annotation do?
ew annotation based settings
it marks the field to be processed and also carries the id that has to be put in config
The id...
You mean the path
Alright, what is your generall approach to serialization?
i made this
i have a type registry where you can add your custom type
this is for map for example
i'm gonna attempt to deyamlify it eventually
but for now yml is all i need
oh yeah, it supports recursion, which took me the most time
as in map inside map
Hard coding a HashMap is probably fine for configs
it is for yaml
But it might mess up the ordering of your config every time you throw it back into yaml
afterall yml is just a fancy hashmap
May i suggest a LinkedHashMap
How did you handle ConfigurationSerializable? Becaus the deserialization needs to infer the runtime type
i don't
i use mostly MemorySection get and set
and the extra is configuration section
the problem with my approach is that you have to parse it
i'll try to add itemstack as well, it can't get more complicated than that
You might also try serializing any ConfigurationSerializable as they all end up with a Map<String, Object>
ohh
yeah, i can just serialize that
this is for my custom interface
like how events has Listener
classes have to implement it in order to be considered a section
or node
overall, i'm really happy with this
there's a problem with configuration serializable, i can't see how to deserialize all of them
can anyone help me,
i need that if a player is holding a candle in offhand and u have 64 off a block u get a commpressed block
on rightclick:
if player off hand is holding a '%candle%':
loop items in player inventory:
loop-item is a block
if player has 64 of loop-item:
remove 64 of loop-item from player inventory
give player 1 of loop-item named "&{#E8E64A}&lCompressed %loop-item%"
set {_compresseditems} to true
if {_compresseditems} is set:
send "&eCompressed Blocks!" to player
else:
send "&aCouldn't find anything to compress!" to player
can anyone fix this for me
itemstack has it like this
that is skript
yes
this channel/server is for java plugin help
yes
oh
anyways my 15 year old copy of effective java just arrived
it's slightly modern
I can't bother spending more than 5$ on a book :)
Hi , about making code in a better design , so i have a question so iam trying to make a multi user - table system , so :
- UserStats : uuid , kills , ...
- UserData : uuid , name , color
- UserPrestige : uuid , prestige
.. etc
what would be the best aproch?
and i tried ormlite before it didn't really work for me fine , allot of bugs ..
yea seems fine to me no?
but i didn't finish it , this is only the starting ..
yo, i think i have configurationserializable working
how would i load the PortalUser , and User inside the SkyUser? like i want to make a refrence for them
i'mma test it
like inside SkyUser , i will have privite User , and privite PortalUser
but idk how would that can work :0
and iam using mysql , but can use other database too
why not put it all in 1 user object
but it is convenient
ur aproach with multiple different classes like that is not going to save u space. its just going to quickly get very annoying to work with
as u add more of them
i would keep all the data in 1 user object
a friend of mine took exactly that approach ur taking now
now they have over 60 user classes 😂
daam xD
and its pain to work with
but does not other big servers use this aproch?
it's bad design
The big servers I worked at worked with modules
Each module had its own user class
well yea they have a big server
yea thats what they have
but its a mess
is there a toutrial for that?
i just wana learn more aproches , not only 1 .. xD
so what i mean is this
but , how would i load them in therE?
i was thinking about something like this , but not sure!
Yeah so
At this project we just made our own little ORM with mongo and some gson and annotation magic
And I ended up making codecs on top of codecs on top of codecs
💀
Having it all in a single class is a bad idea and let's start with that o_o
Same minus the annotations. What annotations besides gsons do you need?
i would like to make something a bit more simpler
@Id @Repository(name="123")
why is it
Because you need to have some separation of concerns
It also takes forever to encode and decode
i mean both approaches would take just as long
If you separate it into several classes then it takes even longer
yea
Well if you need fine grained data you aren't loading all of it
Its just a question about your design strat. Is your data relational or not.
If you're encoding maps and metadata all in the same big object then you need to load all of the maps into memory for a map list menu
If you keep metadata separate from the map contents themselves you get the benefit of only picking the data you'd like to read
You can allways do that with a query
me , yes
For fine grained individual plugins it's whatever
so i want to have 1 global user , that i can get the UserStats , UserPortal .. etc from
But for monolithic cores you want things separated
The server I worked at had prison and skyblock
If I loaded your skyblock island while you were afk in the lobby because it happened to be in the same pojo as your stats it'd be a concern
I dont understand that. You can query into mongo objects as granular as you want
One day all the spigot wizards gotta get in a call so I can take notes
Yeah but your example is no longer a huge monolithic user class
Unless half the fields are nulled
Which is extremely degenerate
You can have a monolothic user class in mongodb, with a ton of filled fields and only get a single field from mongodb.
Why do the others need to be "nulled". You can just get a single field.
Type safe even.
The whole argument is like
A big user class with data for each gamemode or individual user classes for each gamemode
Not how many tables you have
its 1 gamemode , but diffrent user classes , one for user stats , one for user prestiges , one for user protals ..
etc
was about to say pretty sure its 1 gamemode
You could have
{
_id: ...
kills: 20
deaths: 30
a ton of other props
}
In your DB. And then just get the kills without loading the entire object into memory.
And if the player joins, then you load the entire object into memory.
@lost matrix i've implemented configuration serializable too 😄
Yeah that's a whole diff argument
K key = ...;
String property = "kills";
int kills = mongoCollection.distinct(property, Filters.eq(key), int.class);
Gets your the "kills" property for the given object key, as int. As an example.
I'm aware smile

the whole fight is big class vs lots of small ones imo
they are talking about having a big pojo class with everying nulled but the kills field
iirc
Yeah, no. That would be schtupid
but i still think its fine to have 1 user data class per gamemode
cross gamemode is dif story
When is spigot gonna release a book
You mean configuration serializable?
oh yeah sorry
Show me what you did. Bc it can get messy af with the deserialization
Wait, you just delegated to spigots FileConfiguration, didnt you
yeah
and in case there's no element, it'll pull it up
wait, i think i have a bug actually
field.getType() ?
in this case field gettype is ItemStack.class
Ah
really a manager for every user object & loading / serializing each invidivually
do u realize the pain that is :<>
using sql for that ,-,
why is it pain? is there a better way?
field.getClass() 

pretty sure the way it could work is to have a base class that extends all the user objects, then u can get the userdata as a certain user class
Could use a facade class
why does googje shopping suck so much
it's a facade class yeah
it has some other stuff other than field
just use List
abstractlist has only internal methods
did you write a whole annotation processor?
maybe configregistry and when registered the annotations are processed?
instead of an annotation processor
It's just basic reflections
it's processed at runtime
but anotation processor :(
i don't generate configs on compile time
the harder part was writing the serializer
nice
or you can make your object implement ConfigurationSerializable
imagine serializing to byte and your customer has to define config values in byte arrays
well, you only put in configs what you want your customer to see
i can't think of a reason why you'd need a byte array, but you can do it if you really want to
^ == joke
ah lol
Im thinking about how to make plugin witch will add weight (material based for now) to every item and inventory. So that will add weight limit for iventories as well. Would be big problem if I will recalculate actual weight of inventory on every inventory click?
I will use this code:
public double getInventoryWeight(Inventory inventory) {
double weight = 0;
for (ItemStack item : inventory.getContents()) {
if (item == null) continue;
Material material = item.getType();
if (material.equals(Material.AIR)) continue;
weight += this.getItemWeight(material)*item.getAmount();
}
return weight;
}
added arrays too 😄
which for yml it's just fancy lists
nice
I would recalculate the weight only when the inventory changes
No hashmap????
its easy
i did those earlier today 😄
item pickups
check
api?
The fork has an event for intrinsically detecting when slots in a players inventory change
Shmaper
he's a mod he can't say the word
really? is that against the rules
lol no
I have literally never used a spigot server
I just run paper
Im here cuz the support is essentially the same
Because im doing very low level shit
?whereami
no
Facts
paper kinda the same as spigot
It is
paper has just a little bit more api in some cases
But sometimes they introduce scuffed features that feel experimental
Yeah, but that almost every click so 😄 I was thinking about calculating the weight best of inventory change but that would not be that eazy to not miss any action what can change items in inventory
Thats the fun part
it is easy trust me
you need to track 3 things
picking up
dropping
and changes when the player closes and inv
What about death?
death too ig
What about plugins removing items?
Gamerule keepInventory true
what about data corruption?
And you have no problems anymore
Yeh just slap a listener in there for that
What about interacting with an item in your hand (like placing a block)
What about an ItemStack breaking because of durability?
ezy yep lmao
which event does the "fork" have ?
PlayerInventorySlotChangeEvent
marek
I mean detecting inventory changes would be probably better but... So should be rly bigg issue to itarate, if yes fck it, there is no better solution lol
you can choose the easy way or the hard way depending on the scope of your project and how many players are expected the easy way might not be bad
On today's episode of Illusion's scuffed past work
Even if your iterate over all players every tick and sum up their inventory weight, you will probably be fine.
Even with 20 players thats below 0.1ms
Did you know I made my own slot change event by legit just having a task running every tick and comparing?
classic
Can even delay it by a few ticks and they won’t notice
prob every 2 seconds is fine
Be a menace and iterate async
I expect it will be heavier for performance so thanks, I will keep that. but there are more possibilities that can change the inventory than I thought lmao. I was thinking I will just update on every inventory click and when player close inventory and just adjust player speed or some effect to player based on weight... Looks like not I will just check all players inventory every seconds or something like that. Thanks guys
Yeah create 5 buckets and split your 20 players into them. 4 players per bucket.
Then tick one bucket each tick and repeat in a round-robin fashion.
Each player will be checked every 4 ticks. That 200ms and barely noticable.
shouldn't be an issue to do it every tick since all player inventories are opened at all times anyways. You could just use inventory objects and have a snapshop where you just compare the objects for any change, if none then do nothing otherwise do something.
sounds like a plan
you don't even need to do the whole bucket thing either, with object comparison you can iterate a list super fast that for you to notice your iteration being slow you would need to be in the hundred thousands or so
So like save the copy of their previous inventory to some map and compare them?
exactly
yeah you can compare and only when changes where made you recalc
then its comparing inventory objects
if the before object doesn't equal the now object
it changed
I mean I can still try to make system witch will perfectly reflect any remove, pickup, drop, broke or what ever.... I can do it that the task way for now and in future develop system what would count with every possibility of inventory change and then base on that change weight of that inventory. To check if system is correct just use Task method and I will know what I didnt handle, but thats probably long time project lol
But while this is not heavy for performance I will do it this way then, Thanks
well, even if it was heavy
you still wouldn't notice unless you were doing some extreme complex task
or doing something that would halt the main thread for some long period of time
modern cpus are extremely fast that many simply don't understand lol
you can easily run unoptimal code that you wouldn't notice any issues until you hit something like a thousand players
I would only check if item can fit the weight limit of inventory. Probably PickupEvent, InventoryClickEvent, DragEvent would be enought so.
point is, don't worry too much on the optimizing or performance until its actually an issue 😛
I mostly care about that... bcs idk if u trow item away basicly... You will be "punished" for caring too much items with slow or something.
tru, thanks for that
Im trying to learn and do the best lol
as you should 
i was thinking about making something like this :
and then i use this and implement it where i have my sql code :
save should return a transaction or smth
any ideas why minecraft is still using the old world generator instead of mine? https://imgur.com/a/TjjaBKy
Did you specify that you are using a custom generator in your spigot.yml?
Well yeah but this is all in the main thread
I'm trying to override all chunk generation code with just empty methods so it shouln't generate anything. I however still don't see the plugin enable early enough even though I set it to STARTUP in the plugin yml
well I set it to STARTUP, I didn't see any other custom world generation options
Illusion are you the whenComplete guy