#help-development
1 messages · Page 1958 of 1
Better question is, what tf is that theme
alright sorry to be a pain for the millionth time but my loaditems method causes an error that disables my plugin if it restarts after an item is added and saved into the items.json file
public static void loadItems() throws IOException {
Gson gson = new Gson();
File file = new File(MagnificentMenus.getPlugin().getDataFolder().getAbsolutePath() + "/items.json");
if (file.exists()) {
Reader reader = new FileReader(file);
ItemStack[] m = gson.fromJson(reader, ItemStack[].class);
Menu.menuitems = new ArrayList<>(Arrays.asList(m));
System.out.println("Loaded Preexisting Menu Items Successfully!");
}
}
this is the error i get
You cannot just use gson to serialize an item stack
oh
what would i use then, bukkitinput/outputstream?
An item stack contains item meta which is a hidden server implementation
Yea that's one way
ok
If you goggle I think someone made a gson adapter for item stacks
Tho idk the quality
My library has a method to convert an item to a string and back
Is there a way to overwrite the getUniqueId method? If so, how?
alright i have been browsing the internet for around 40 minutes now and i cannot find a single resource/tutorial on how to output this to a .json
Make your own
bruh so your saying make my own tutorial on something i dont even know how to do, thats logical
In what scenario would you need this?
There is no possible scenario where this is necessary lol
why
how could I stop a player from entering nether portal? Is there like a portal enter event or something?
declaration: package: org.bukkit.util.io, class: BukkitObjectOutputStream
oops
there
does this work with json
like how would i output it to a json
I'm trying to make a profile switcher which switches a player's data and by overriding the getUniqueId method, this will be compatible with most plugins as they store data in uuids.
doesnt a profile switcher require... a login
onLoad run before onEnable?
yes
this.getConfig().exist is not valid code. how to check if config.yml exist?
saveDefaultConfig will copy the config from your jar if it doesn’t already exist
So you can ensure it will exist
getConfig() will return config.yml from the plugins folder if one doesn't exist it will provide the one embedded in the jar
saveDefaultConfig() suggested above should be in your onEnable() and it will silently fail if a config.yml already exists so no need to add additional checks for it
if you still want to check if a file exists, use File API from Java to do so
ok
Could do “new File(getDataFolder() + File.separator + “config.yml”).exists();
You don’t really need to use file.separator
this is what I was saying when I said File API from Java 😛
only I just didn't type out the relevant code for such
Oh does it add the /?
Not on all systems
Yes you can
I used to have that and it worked on my computer but didn’t on a host
The file constructor will convert it
Well it’s always better to
I am making a auto update config.yml on plugin update.
like if I add new keys on config, it will auto generate. admin's don't need to remove old config.
also java don't support yml.
anyone can tell me best process to do it?
What?
Java don’t support yaml?
umm. I mean is it officially support by java?
Define official
At the end of the day they are just text files
But java does not have any built in libraries to parse them, afaik
Which is why spigot uses SnakeYaml
alright. then ignore that part. can you tell me a best way to auto update config?
Load both the one in the jar and the one in the folder
Copy any keys missing from the jar one to the folder one
And then save it
I mean technically all the API is there to parse almost any kind of file you want
snakeyaml is a library that is already geared towards the yaml spec
but I mean it makes use of all the java API to do what it does lol
Yeah you can parse anything you want manually
as far as making an auto-updating code for your config.yml that is relatively easy to do
I can show you an example of just how easy it is it lol
those lines there is all it took to do an update to a file 😛
feel free to browse the repo for anymore useful code
it is open source after all 🙂
It’s basically just looping over the keys in the new file and copying any that don’t exist in the old one
Although I’ve never actually done it, probably because I didn’t want to yeet comments
But that’s not an issue now
never been a fan of comments throughout a config file lmao
Gotta explain things somehow
generally config files should be structured in a way that it for the most part should speak for itself
Is there a way to make sure my plugin's join event fires before every other plugin?
The most you can do is set it to LOWEST priority
But even then other plugins using LOWEST may still fire before yours
probably would help if you stated why you need this to happen
because while although you could make your event fire first, that means it will have the last say in what happens
if this isn't what you want then instead you would want to have your plugin handle the event last
I need to change the uuid of the player before any other on join event so if any plugins cache the player's uuid they will cache the right one
not sure why you would need to do such things unless you are using offline mode
in which case such things are not supported here
however I suspect you are running an outdated server version as well
ConfigurationSection section = this.getConfig().getConfigurationSection("tutorials"); will return null if tutorials key don't exist?
yes that is why I do a contains check first
if the config contains the section I seek, I go ahead with the object creation/assignment, otherwise if it doesn't exist no need to do anything anyways 😛
that specific code, moves a section from the config.yml and puts it in the data.yml
and then clears the section from the config.yml
I do need to update that plugin at some point, but anyways before it was popular most everything could fit in the config.yml
then the features expanded and the data it was saving didn't make sense to have in the config.yml
so, that bit of code moves the data for the user without any fuss 🙂
however, as you can see it didn't take much to update configs though
shower thought
lets say we restart the server whenever player clicks on the inventory slot and the item is transferred to cursor
what happens to cursor item after the restart
where does it go
but how would it know which slot he was in
i can hold cursor item for hours
what if the cursor item is set via the method
so many questions
😄
if they didn't release the click it will be in the same spot as it was before
player data is written whenever players leave as well as when the world save happens
world save happens on normal shutdown as well or should
You don’t even need a plugin to test it
Just pick up an item and then run stop in the console
declaration: package: org.bukkit.inventory, class: InventoryView
what if you set the cursor via player.getOpenInventory() tho
now thats impressive
It's still not perfect but it is definitely taking shape.
I've fully reworked & abstracted the texture system to allow correct texture loading & displaying for special cases like blocks with multiple textures or turned on redstone lamps. The sky also changes color based on the ingame time.
@mortal hare do you need spigot help? If not, then dont spam youtube links
don't play a moderator
noice
don't play a moderator
who are you
Hm im really wondering how this was made. The server doesnt know anything about the players screen. And the curvature makes me believe that this was done using a lot of ray tracing.
yea its raytraced fully
breh is correct
i shouldnt post things like this here
dont know how they made it
Nobody needs help here... its not the end of the world.
Why did you delete your message ?
Dont know what you mean 
You are a server booster so act like one
Instead of helping you are just being really immature
I have every right to be as immature as i feel like 
No. I do not play fortnite, and i do not write plugins in skript.
You know nothing about me
That is right. Im just making assumptions.
Ok come on... im just going for the memz. Its simply a burden for the community when people hang on older versions.
Another 1.8 debate?
I'm pretty sure it's not "another" debate, it's just the same debate that's been prolonged for years.
Nah. But im still convinced CVE-2021-44228 would have been a good opportunity for a cleansing.
%%__USER__%% will replace with username where I will add this in my code?
how spigot will know where is the placeholder?
bytecode scanning
You can add it wherever
There’s this one gradle plugin called blossom if you want to replace %%USER%% to something else when compiling
Login has to be done for premium plugins anyways...
It's by Kyori (Adventure devs) and it works very well.
I use it pretty often for replacing a "version" token.
Yeah same
My plugin in free. so if I add %%__USER__%% and anyone download it without login, what will be replaced?
This will only be replaced for premium plugins
oh ;-;
The thing is that this can actually be used to monitor users. Im astound that they even managed to handle light correctly o.O
Hi all
salutations
😀
7smile7 is very immature, and he doesn't help?
Not sure about that bud
just drop it
He was not helping -- instead talking about 1.8 for no reason and making unnecessary rude comments that then he removed afterwards, plus talking about off topic things in this channel
?kick @neon minnow stop already
Done. That felt good.
For people who might read this, just block the user if you can't be in the same channel as them without starting a fight
😦 i didnt get to witness the drama
didnt miss anything important probably :]
oh hes already back
hey guys, i'm struggling big time with papermc/purpur, okay here is the issue
I have an Advancement, i need to get its title description and type
(Also please lemme know if I can do that without spigot because i searched spigot docs i really didn't find any methods for Advancement)
As a start, I made Advancement.getDisplay(), but then i'm kinda stuck on what to do
.title() and .description() of it are Component class; i'm really a retard but i can't get this class convert to string (didn't test the .toString() but idk im kinda sure it wont work)
If you really have an issue with someone, first and foremost block them, secondly DM us about it, do not publicly shame them.
that's kyori adventure
you would do
Component.text("text here")
to add color you would do
Its alright. I can see where you come from by defending the version you like. Lets just drop it.
no i want to retrieve the text, not set the text
I hereby publicly shame Conclure for telling me not to publicly shame people.
😔
sure thank you 🙂
PlainTextComponentSerializer
They switched to adventure. You should probably ask on their discord for help with their software.
:peepoShake:
might be PaperComponents idr
isn't it
PaperAdventure
declaration: package: io.papermc.paper.text, class: PaperComponents
oh u mean this
Thank you guys for your answers, am I the only one to find these kind of changes useless irritating & toxic btw?
I feel like devs looove to rename their classes and keep adding abstraction but in the end it breaks our code
myeah
nah they just didnt like mojang's component system i think
hm okay
i believe kyori is also able to retrieve nbt data and stuff as well so it's more like advanced in a way
it's tedious and annoying i agree
but it's not too hard to get used to once u use it
i see
si
Alexis well I find it disturbing that they deprecated the existing stuff
yeah 😔
Because honestly, It would have been just that easy to not put @Deprecated and just delegate a serializer call
yeah just tedious asf
for instance this class is damn god ascend https://javadoc.io/doc/net.kyori/adventure-api/latest/net/kyori/adventure/text/LinearComponents.html
(assume you staticlly import stuff) something quite succinct is still possible to write
why did i not know of this 😢
linear(GREEN, BOLD, text("Hello"),RED,text(" there!"))
yeah
&a&lHello &cthere!
basically
🙂
ah yeah that too 🤣 everytime i wanna update versions i keep getting more & more depecrated stuff xD
ye
I don't see why just having some quick string methods would harm anyone at all
like sure its not the most convenient way to represent the way mojang is dealing with their shit
but at least it makes it easier for users if they just want to send something simple
pov @Deprecated ChatColor
PlainTextComponentSerializer.plainText().serialize(some Component object)
does that look good to you?
And also I assume I could create only one instance of a Serializer instead of calling .text() everytime right?
instead use NamedTextColor
🙄
😔
yes alexis
ya
iirc the plainText() is a singleton
gl
glhf
i like kyori for its hover and click events more
i feel they did it better than mojang
sorry
not mojang
wait yes it is mojang
wait no its bungeecord's api
right
it's more simple i feel because u can just one line that shi
compared to bungeecord
yeah in the end it depends on the user
indeed
but i was told u dont need NMS to get NBT data from certain things using kyori now
or smthn
by paper devs
Hmm its simple kind of
theres probably like a forum post for it but i dont really go in depth into nbt a lot
in kyori
certain existing interfaces such as Entity, ItemMeta now derives PersistentDataHolder which has the method PersistentDataHolder#getPersistentDataContainer which gives you a PersistentDataContainer instance (that basically acts like a map [which persist any change made to it])
hmmm interesting... but is it modifiable
yeah
entire purpose is for devs to just store custom key:value things to entities, tile entities, chunks and some other stuff
without exposing nbt
as thats too close to implementation in some devs' view
ahh i see
i was having a discussion w these other people the other day on how "spigot is outdated api" or whatever and that fabric is superior
and im like 😕
dont understand what u can do w fabric that u cant w spigot + nms besides mixins
You can even use Mixins with spigot if you want
well people are kinda overreacting to spigot not taking advantage of some of the newer java features and design principles
me giving up on my mc server java implementation as soon as i saw that chunk data packet xD
interesting.. how though
however, highly discouraged as that could break the api pretty reckless
What can you do with Fabric that you can't with just Spigot though?
md_5 says you shouldn't use NMS, so don't use it 😉
Same goes for Mixins in Forge and Fabric
well nms isnt as much of a pain to break now since we have mappings
Yeah, well they don't make as many promises in terms of an api with a set of interfaces as opposed to spigot Olivo
fabric encourages it but u'll see modders telling u to not use it because it can have api changes
True
Well
conclure, do u understand the chunk data packet actually?
I don't concern myself with the opinions of the Fabric community
from wiki.vg/protocol
Considering they're all fucking retarded anyway
and how it's written
havent looked at it too much
I am enjoying the abstractions way too much
i was writing a java implementation (it's my most recent github project if u wanna look) of the protocol and bro
i was so lost
looking at that packet
lol
How so? I've only used Forge
PinguFramework?
yessir
That is a lot of folders
bro i was getting people on my ass the other day for using forge over fabric
i was like
man
give me a break 😭
i hate modding purely cus they dont have any documentation
but i still like learning it bc its fun
but so annoying
They do have documentation on their apis
yeah but it's quite little
Mojangs code not so much
wish mojang came out w javadocs 😩
is it still considered mojang's mappings if the game is owned by microsoft
or is it still a mojang game
Well Mojang develops it
Microsoft just (technically) owns it
ah
So yes it is Mojang's mappings
They are the devs
But yeah the reason why they likely don't have javadoc mappings
oh microsoft bought mojang not mc specifically
Is due to the ProGuard format being shit
Aaaand also
They likely just don't value writing docs
Since Mojang does not care about the modding community
They do actually
;)
Datapacks!
If they did care, they'd do more to help
among us :]
among us :]
sus :]
among sus :}
when the imposter makes a spigot plugin ;]
susgot >:]
lol
org.susgotmc ?
stop
Forge >> Fabric, solely because Forge sounds cooler
Forge is on its way to dying out
Is it possible to change the name of the anvil?
Repair & Name
On 1.12.2, the name is not visible, but on 1.16.5 it is visible. Is it possible to somehow change the name to 1.12.2?
should i be going into fabric modding instead of forge then? are there any pros to fabric vs forge? im actually curious bc idk
dont u just rename the anvil item
what's the name of the § symbol
fabric is faster to update and easier to use imo
Forge is quite easy too and has better intermod compatability
Personally I prefer Forge for most things but if I want a clientside only mod I use Fabric
section
@ voodoo and @ olivo ah ic
isnt fabric like newer so it doesnt have everything that forge does
makes up for it with mixins
allowing you to edit code of other classes
Forge has mixins too
PARAGRAPH
xD
kyori taught me
xD
adventure api
always using that damn legacy component serializer
legacyAmpersand and legacySection
also thought it was just called paragraph
i guess it's just the "fancy" word for section sign
I can't run maven build I don't understand why
Could we store enums in PDCs?
Store the string
Sure. You can store everything in PDCs.
Gotcha, thanks!
What makes you think that you cant? Just start the lifecycle you fancy.
well as you can see on the screen I can't maven build
Press the m button
Just run mvn <goal> in your terminal. Like mvn clean install
or click on them in IJ
Question, is it possible to use brigadier over the standard spigot command system
Because nesting subcommands and optional arguments is just a pain
With over do you mean prioritize or 'via'
Prioritize
Or via, either works
As long as I can use brigadier for my commands
I've seen that there have been plenty of prs and feature requests since 1.13 but nothing ever came of it
You can use brigadier but thats not supported by the API directly.
2 Options are available.
- Use a command framework. For me its ACF at the moment because i like the completions and context resolvers.
- Use brigadier directly without API support
Because it all has to be abstracted. And making this backwards compatible is quite difficult.
The old backwards compatibility trap
It‘s a shame
But even so, brigadier is a fully standalone library, all that would be needed is a event during command registration that passes the dispatcher
And aside from that, it is fully isolated minus commands registered by the vanilla server
So what else is there to be abstracted
And I'd argue making a feature require 1.13+ is not unreasonable
Never looked into that. But spigot grows with every PR :D. Maybe with version 1.21 people will be fed up with spigots command system and
write write a proper PR that can be merged.
I personally didnt use spigots command system for ages now
Considering that there are 2 prs since 2020 which are very much „proper“ and have gone completely ignored since despite constant upvotes, I don‘t think that is really a option
Not to mention the multiple feature requests for it
🤷
How do you make GUI button operations o(1)? Currently, my implementation is to store a string in the item's pdc and when that item is clicked, it'll get the string and run it on a switch statement to find it's designated effect. How would you guys make it so that it doesn't affect performance and take constant time?
there are libs for guis, i think redlib has one
Hmm I'd prefer creating my own, but sure I'll look into those. What are some you suggest?
Perhaps having your own wrapper object for the inventory, with a map that maps items to slots?
Then have a separate class for "buttons" or clickable items, that would be looked up from that map, and actions stored inside would be executed.
I'm looking into public GUI APIs too, though to get some inspiration for building my own API specifically for my plugin. One of these APIs that I thought was pretty good is IF
More OOP than having a large switch statement.
Hmm this seems interesting, I'll try this approach as well
Thanks for the suggestion, it's the first I saw too when I googled for gui libs
I mean that is kinda what you already have to do, to check what inventory a player clicked, so why not store data inside of that object as well?
I added Vault API in my plugin but when I compile it doesn't find the Vault package
Did you add it as a dependency in your plugin.yml so that your plugin loads before Vault?
yes
And it does?
After* lol
I've been playing around with callables too, and my idea is to create a HashMap<Enum, Callable<Object>> and load it on startup with various callables, and now all I have to do is set the appropriate enum in an item's PDC and when it's clicked, it'll get the enum and get the callable from the hashmap using it as key. Seemed to work, but I'm kinda worried about the memory this would take up as the hashmap gets bigger and bigger
don't roast me I am beginner
When you look in console, does Vault actually load before your plugin? Do you really have Vault installed in your plugins folder?
Why the PDC?
Can you show the full error?
package net.milkbowl.vault.economy does not exist
It would be better to make a class that holds an array of Slot classes, and delegate click events to the Slot class that was clicked on. That way you can get the class of the clicked slot quickly and have better control over how the slot should respond to the click.
Full stacktrace, please
So that each item would work independently no matter what gui it's in, for dynamic purposes
Also as far as I remember, when initializing Economy object of Vault, you have to load it first from the bukkit's service manager
I did it
if(!setupEconomy()){ System.out.println(ChatColor.RED + "Vault n'est pas installé !"); getServer().getPluginManager().disablePlugin(this); return; }
private boolean setupEconomy(){ RegisteredServiceProvider<Economy> economy = getServer().getServicesManager().getRegistration(Economy.class); if(economy != null){ eco = economy.getProvider(); } return (eco != null); }
Isn't that an IDE error and not a server error?
True, work on the entire inventory instead and not the items. That's good too
I don't unfortunately know much about IntelliJ
But you should have errors before compilation
If you try to use a library that you do not have
Afaik
Well I'll double check on Google for plugin Maven Build with IntelliJ
but thanks again
whut
you are using maven
so add your dependency to pom.xml
NEVER EVER use intelliJ directly to add libraries
you are using maven, so use pom.xml
otherwise your IDE sees your libraries but of course maven won't see them
An additional idea to what I've suggested, each Slot class can decide what item to display in its slot. So when opening the GUI for the player, the GUI class can loop through the array of Slot classes, get the item to be displayed, and draw that.
Iirc IF API has similar structure, so I'd suggest taking a look at its source code.
Yep, I'm looking at it now. Thanks for the ideas
NP
I'm still looking for people to improve my discord quizbot
anyone bored right now?
i have set and save my custom .yml files and they have a lot of text, but when i load the plugin, my custom .yml files are empty, why?
Hi I still have compiling errors , the API that I use is still not recognized
package net.milkbowl.vault.economy does not exist
Is there a way to have 2 action bars?
Like sending 2 different texts at the same time
Subtitle I guess
any1?
I found the solution to my problem : I added the jitpack repo and VaultAPI dependency
in my pom.xml
anyone can tell me how can I add world list?
okay. thanks ;)
can we normalise using TabExecutor :)
lol
i have never seen people use it but its <3
Hi
What's the best way to parse a yml map?
i.e. the yml's structure is
whatever:
item1:
data: defq
item2:
data: eughf0wu```
I only need the actual keys of the map, so item1, item2 etc
Get configuration section("whatever").getKeys(false)
Many thanks
I can't make the loop🥲
my brain is so small to get it. anyone can help me pls?
Just type worlds.for and it will autocomplete for you
I did. but can't understand what I need to type ;-;
world.forEach?
U could do that too, but a normal for loop is probs better for u
What are you trying to achieve
this worlds
Oh you are trying to get a list of worlds
yes
From the config
yes
So you loop through worldList and put them in worlds using Bukkit.getWorld
I already told you I can't understand use of loop in spigot. ;-;
1st time using loop in my plugin ;-;
can you give me what will be in ()? and explain it?
pls
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
more like java general question then
🤦
Yea im not here to teach you java, il happily answer api questions
hey uh anybody down to answer in #help-server
i know how shitty i am right now but im desperate
for (World world : worldList) {
its basic java, learn
Has anyone an idea how to update multiple values in mongodb?
My current code looks like this
Document original = (Document) param;
Document updated = new Document("uuid", uuid.toString());
updated.put("trashAmount", trashAmount);
updated.put("fishAmount", fishAmount);
updated.put("treasureAmount", treasureAmount);
updated.put("mendingAmount", mendingAmount);
Bukkit.getScheduler().runTaskAsynchronously(instance, () -> {
--------> collection.updateOne(original, updated);```
But i receive an java.lang.IllegalArgumentException: Invalid BSON field name uuid
in the line marked by the arrow
what's wrong here?
is there a way to just stop an event? Like telling it that you dont have to check if this event is happening anymore?
You are casting a String list to World
You probably want to get them using Bukkit#getWorld(String)
How can i include some additional data in a messaging channel request (for example with getServer and i want to get back a integer i sent with)
Its important for my project that i can differentiata between the requests
anyone know a good free way to obfuscate plugin
Hello, could someone explain to me how to obtain the name of the inventory that I am clicking on?
https://www.spigotmc.org/threads/rule-changes-re-obfuscation.420747/
This includes a list of the ones you are allowed to use.
getView().getTitle()
Okey. thanks
is it ok now?
no error in console
but not working
is the list not null?
OK, going back to my previous question:
whatever:
item1:
data: defq
item2:
data: eughf0wu```
How would I get a map of whatever, so that I can iterate through them as a key value pair
(yml parsing)
the for-loop should iterate through all worlds from the strings in the config.
yes. the list was null first. thats why it didn't work 1st time
thanks for help SCHLAUBI & CuzImPhilipp <3
from the whatever section try getKeys(false) and then get their respective values
Might I ask if hack clients are capable of reading an inventory's title and automatically clicking a slot in an inventory?
They're like built-in mods in the launcher, right? I'm fairly certain they're capable of doing so, but I just want confirmation
but why it don't work in list == null?
shouldn't just ignore it then?
can someone help me a bit with concurrency logic
lets say i have a single core machine
how laggy does using an event listener like on any move have on the server by itself?
running minecraft server
event itself is not that costly
code inside it can be
ah
it really sounds mind boggling that the event being called lots of times per second
but when you dig down deep into NMS
you can see minecraft catches thousands of packets via netty
at the same second
sent from the client to the server
that means if the movement packets are being processed so fast, event calling shouldnt be that costly either
but its a speculation
ok moving on
Lets say i have a single core machine with minecraft server one it
and i run heavy operations on the separate thread
would that impact minecraft server's performance
even if the task is async
😂
Nooooooooooo @hasty prawn this is still not the day :(
it should lag, since threads are only an illusion from code's perspective
if you dont have more than 1 core
you cant do "real" concurrency
right?
😳
it may have a slight impact but it likely won't be that noticeable
async just does not block the main thread
it still lag
it seems like you know the answer to your question already lol
but i mean if you have a single core machine then it's not like you can avoid running other stuff on that core
yes, in a single core machine all the threads have to share time and therefore the more tasks you have running the less time each will get
Can you tell me why it don't work if list == null?
but where are you finding a single core machine these days
KVM's
shouldn't it skip?
you can't iterate through a null list in java
you'll get a NullPointerException
Null is literally none
zero
empty
void
that's like trying to setup new graphics card, but its null because scrapers selling it for 3k
you dont have it
but it exists
also tbf i bought mine at a scalped price
the scalped price is irrelevant
it's just trying to set up a graphics card that doesn't exist
not trying to set up a graphics card that exists but isn't in the place you expect
honestly i'm not going to get into NFTs but i understand the idea
i don't think it's terrible
it would be ok if you would buy copyright ownership to that picture
it's just like buying any art in the real world, sure anyone can get a copy of it but only I can own the actual thing
getDataFolder() return server dir or plugins dir?
i don't get copyright to the mona lisa if i buy a copy of it but if i bought the mona lisa i would still be the owner of the real mona lisa
but if i bought the real one you could still buy a copy
plugins
also i have mixed bag of opinions about cryptocurrencies
looks how they're inefficient
7-8 transactions a second
yet they use Terrawatts of power
sure decentralization is good
but it hurts environment more than it does good
for comparison:
1 Bitcoin transaction costs 2264 kWh of power
while 100,000 VISA transactions cost around 148 kWh of power
thats a huge difference
is there a built-in method to fill an inventory with n items, seperating them into stacks? cuz im pretty sure just adding a new itemstack with amount n would put them all in one slot
.setItem(int slot, ItemStack itemstack)?
well, if you have an itemstack over max size it may not behave as wished, but idk
i want them to seperate into stacks
so that wouldnt work
Why wouldn't that work
wouldnt that just cram everything in one slot
depends on your point of view, if decentralization is that important to you then you might not care
Ah yes, not caring about the environment, that seems like an intelligent thing to do.
No but you can divide itemStack.getAmount() by inventory.getSize()
Floor, add a stack of that size to each slot, get modulo of same product, handle that however you so choose. Either add one to each stack sequentially or just throw the remaining into the first stack
setItem() would literally set itemstack at specified slots index, ignoring everything that the inventory had in that slot previously
To everyone else, bear in mind that we are in #help-development 😛
How do i remove the item that player is holding
PlayerInventory has a setItemInMainHand() method
or OffHand() if that's what you want
how do i correctly DEserialize ItemStack without getting an error on restart
Can itemstacks be serialized?
yes
i used gson and i got a nice serialized json
Oh it is what error ate you getting
just a sec ill make a hastebin
so something like this
public static ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
ItemStack[] items = new ItemStack[dataInput.readInt()];
// Read the serialized inventory
for (int i = 0; i < items.length; i++) {
items[i] = (ItemStack) dataInput.readObject();
}
dataInput.close();
return items;
} catch (ClassNotFoundException e) {
throw new IOException("Unable to decode class type.", e);
}
}
Will I get an error serializing itemstack in a hashmap not using BukkitOutpit stream but rather ObjectOutputStream
so how would i implement this into my loaditems method?
public static void loadItems() throws IOException{
Gson gson = new Gson();
File file = new File(MagnificentMenus.getPlugin().getDataFolder().getAbsolutePath() + "/items.json");
if (file.exists()) {
Reader reader = new FileReader(file);
ItemStack[] m = gson.fromJson(reader, ItemStack[].class);
Menu.menuitems = new ArrayList<>(Arrays.asList(m));
System.out.println("Loaded Preexisting Menu Items Successfully!");
}
}
dont make te method static
yes you will
there is a way to change the 'Sky' on a world?
For example the overworld has like a nether sky without the nethere biome
since ItemStacks dont implement Serializable interface
it has a serialize method
mhm ye
BukkitObjectOutputStream internally wraps these objects
in order to serialize to bytes of data
BukkitObjectOutputStream = Bukkit object serialization + any other object serialization
(Object oriented progamming is a thing
also, you need a custom gson adapter for itemstacks. You can't do it directly
mmm not necessarily
you can just read the object map
and then ItemStack.deserialize is a thing
but you are right bout not just being able to directly doing it
Hi there, I am trying to create a small plugin that justs stops tnt from creating block damage, atm I have this code :
@EventHandler(priority=EventPriority.LOWEST)
public void onExplosion(EntityExplodeEvent e) {
if (e.getEntity().getType() == EntityType.PRIMED_TNT){
e.setCancelled(true);
Location l = e.getEntity().getLocation();
l.getWorld().createExplosion(l.getX(), l.getY(), l.getZ(), 0F, false, false);
However I can't get this working, if someone could tell whats the issue I would be very happy so that I can change it, thanks, btw no errors in console
is the explosion which you made, creating the damage?
I tried adding a broadcast before the new explosion to test if the first part was working, no message
so the first part
Theres prob somthing wrong with the first line or the second line, after that it should work
Add a debug before the if statement
Ill try that sec
would this work
it also deseralizes it
Alexis is typing...
this doesnt appear to work
ok here's what it gives me:
io.papermc.paper.advancement.AdvancementDisplay display = event.getAdvancement().getDisplay();
PlainTextComponentSerializer serializer = PlainTextComponentSerializer.plainText();
String title = serializer.serialize(display.title());
String description = serializer.serialize(display.description());
title outputs "advancements.adventure.kill_a_mob.title"
description outputs
"advancements.adventure.kill_a_mob.description"
@ivory sleet @maiden thicket do you guys know if I can turn these strings to sth readable?
Those are keys, but where can i find the human readable description and title?
I mean, it works. So if it doesn't work you didn't use it right or it's not being called 😛
idk seems like a very ugly nonscalable procedure
If setItemInMainHand() doesn't work, we'd have a lot of angry developers on our hands lol
Added but no message showed up
?
Means you didn't register your listener probably
@EventHandler(priority=EventPriority.LOWEST)
public void onExplosion(EntityExplodeEvent e) {
now translate it
You're using Paper API
This is not Paper
Paper has their own Discord
Alright thank you smh I shoulda known
Use the PlainComponentSerializer from PaperComponents
it will translate keys to server's default locale: english
But.. In what case you need that>
no that converts a component to a plain string
With what method
What are you trying to do alexis
So sorry, actually I talked about it earlier this morning no one complained so i didn't know it was really offtopic here, i pinged those guys cuz they very nicely helped me this morning
Does someone know how I can get the a angle between to Y points?
get these two https://i.imgur.com/yfwp5ts.png
Whats that?
Trigonometry
TranslatableComponent
It's stuff to do with triangles
But how exactly isn't there a formula ?
sorry wait no it may not be that
actually no i think it is
TranslatableComponent.key(string)
Component::translatable perhaps?
But you would want to do "arctan of (y2-y1)/(horizontal distance (cuz it's in 3d, so you need some more triangle stuff)" I believe
(iirc)
Any other way? xD
No
Oof
As far as I know, anyways
You could also take a google
Or you could use cos
Or sin
?paste
after using this
my method:
public static void loadItems() throws IOException{
File file = new File(MagnificentMenus.getPlugin().getDataFolder().getAbsolutePath() + "/items.json");
if (file.exists()) {
ItemStack m = JsonItemStack.fromJson(String.valueOf(file));
Menu.menuitems = new ArrayList<>(Arrays.asList(m));
System.out.println("Loaded Preexisting Menu Items Successfully!");
}
}
ItemStack m = JsonItemStack.fromJson(String.valueOf(file)); this line supposedly causes the error
here's my item serialization class
its not fancy but it works
it serializes items in nbt form to Map object
because jsonitemstack.fromjson needs to parse a string
oof
serialized chest (old photo, there's new keys for specifying data type, to make it compatible with any configuration format)
would i use a getter then
here's the accurate representation of serialization
you dont need to specify dataType for int and list data types
nvm i think i got it
How do you check if the players inventory is full/they cant hold an item
iirc there's a a search method
inside inventory interface
that lets you search items through the inventory
There’s a firstEmpty method
is that vsc
doesnt look like vsc
Hello, when I spawn an armour stand and setVisible(false), I can still see the armour stand for a split second, does anyone know how to prevent this?
Probably is, just windows 11
sublime text 4
There is a spawn method that takes a callback to run before the entity is added to the world
CLion?
CLion paid and im i dont wanna send them those documents
is it good tho
i have it for free (maybe a trial)
lemme open it
i thought code blocks was outdated
stand.setVisible(false);```I'm using it
https://www.youtube.com/watch?v=WmzUNm8ChaQ&list=PLtrSb4XxIVbpbkchzQgt5tjCfHyGV2q4O&index=2 im watching this
Join the Discord: https://discord.gg/4tHeAkxNg7
In this episode I describe what this series will go over. I explain that I assume you are familiar with several different programming concepts (if you are familiar with C# or Java, you should be good), then I discuss installing MSVC, coding your first C++ program, compiling/linking your first C++ ...
No you aren’t
ah
he is using vsc
first cpp program
std::endl or endl
Thanks for the help
is "using namespace std" bad
or is that better
c++ :booo:
if that's what you're talking about
Idk I don’t know C++
dont think it matters
Seems like import vs FQDN in java
fqdn?
it doesnt have one by default
if you allocate memory
you need to delete it by yourself
Right
does it affect performance?
Does an int not allocate memory
well you can use smart pointers
instead of using imports
No
stack memory you dont need to clean up
heap memory
I see
new int[50] would require delete var[];
I was told to just learn rust instead :p
in headers, yes. Pure Cpp files? Not really
eh i prefer to mark namespaces
its just so much readable
for me
its like declaring this.var and super.var in java for me
Agreed, but it isn't that bad if you omit it
it makes declaration easier to read
However in header files it may lead to chaos from what I heard
also primitive arrays do not hold array length values
I just use whatever makes more sense
is std::vector as stupid as java.util.Vector?
int var[] = {0,1,2,3,4};
int size = sizeof(var)/sizeof(var[0]);
its equivalent to arraylist of java, its not bad
it is a dynamic array
Cool, seems like they don't repeat the same mistake as the java people
btw sizeof() returns the byte size of the value/reference
usually you wouldnt need to use primitive arrays
since those are used for c compatibility
Is it really repeating a mistake if C++ came first :p
C -> C+ -> C++
like in js
I mean, with lambdas we also have this to some degree
you can literally execute functions by only having memory adress of the function
Woo consumer
that's how hackers execute game functions
they get the memory address via some dissasembler
and execute it
so java is safer?
that's a bad comparison
Security manager
java is used for general purpose programming
Aren’t those deprecated
*deprecated for removal
while c++ is only used today to support legacy programs or have performance first programs
or used for game dev
i hate hytale for making their server software java
hytale is out?
They have a bunch of java devs
hopefully someone replicates the server softwate in c# 🤞
Makes sense
Not until 2076
its a dead project
but their client is c# and server will be java
it supposed to be in beta since 2017
which is dumdum
iirc
It’s not dead
why client is in c#
idk ask their custom game engine
while server is in java
It’s supposed to come out in 2023
that's just stupid
is it possible to store an entity inside an item
it was supposed to come out 2 years ago
then last year
now its next year
nbt tag serialization/deserialization
¯_(ツ)_/¯
if i execute a method after an CompleteableFuture#whenComplete, will it get called after that method?

