#help-development
1 messages Β· Page 2151 of 1
yeah
show error
needs to be within a scope
i wanted to say that >_<
...
or well at least not where you put it, so where did you put it?
package me.deveroonie.discord.commands/Discord.java (class)
just drop a screen lol
package me.deveroonie.discord.commands;
import org.bukkit.configuration.file.FileConfiguration;
public class Discord {
private final FileConfiguration config;
public Discord(FileConfiguration config) {
this.config = config;
}
System.out.println(config.getString("discordLink"));
}
yeah exactly
in this case you might just wanna move the sysout to inside the constructor scope
that code will not even compile
package me.deveroonie.discord.commands;
import org.bukkit.configuration.file.FileConfiguration;
public class Discord {
private final FileConfiguration config;
public Discord(FileConfiguration config) {
System.out.println(config.getString("discordLink"));
this.config = config;
}
}
this looks like it will work, it isnt throwing dreaded red line
under the this.config = config;
else if(customRes.length() == 7) {
if (Character.isDigit(customRes.charAt(0)) && Character.isDigit(customRes.charAt(1))&& Character.isDigit(customRes.charAt(2))) {
if(customRes.charAt(3) == 'x') {
if(Character.isDigit(customRes.charAt(4)) && Character.isDigit(customRes.charAt(5)) && Character.isDigit(customRes.charAt(6))) {
System.out.println(customRes);
break;
}
}
}
break;
```π₯΄
This code will throw a NullPointerException. Reverse teh two lines in your constructor as Conclure said
isnt it gettin the config passed as parameter?
package me.deveroonie.discord.commands;
import org.bukkit.configuration.file.FileConfiguration;
public class Discord {
private final FileConfiguration config;
public Discord(FileConfiguration config) {
this.config = config;
System.out.println(config.getString("discordLink"));
}
}
yes
are you able to teleport an armorstand while someone is riding it with stand.teleport(loc);
Guys, I need to do a votifier plugin. But i dont know how they (server lists) send the data. Do anyone know?
have a server list send data to a test server ig
what does ig mean
i guess
No
is there any other way to set the posistion of this armorstand, or should i just use an other mob instead
You can't teleport entities with passengers. But you can dismount the passenger, tp both and remount
or you move it with velocity
guys if i send a forward message through bungee messaging channel to ALL server
will it be sent to the sender too ?
I've got a skull head item stack with custom texture.
How would I place that down instead of creating an item?
you have to try this out
?paste
Is there a pair data type in Java? I made an enchantItem() method which takes (ItemStack, EnchantData...) where EnchantData is a data class I made specifically for storing the Enchantment and an integer value
you mean a HashMap or something of the likes?
Does Files.move block until the file is properly moved?
Every second time one of my files is deleted when I try swapping them
Files.move(backupFile.toPath(), temporarySwapFile.toPath());
Files.move(nbtFile.getFile().toPath(), backupFile.toPath());
Files.move(temporarySwapFile.toPath(), nbtFile.getFile().toPath());
how can i spawn a silverfish and make them only have one target that they are able to hit?
if you dont wanna use nms I suggest using the EntityTargetEvent
and cancel the event for any targets except the one you wanna allow
thanks
but i'm making an ability so it spawns like a few silverfish and multiple players can use the ability at once, soo how is that gonna work
edit each silverfish on their PDC. maybe make a namespacedKey which has the players UUID in string form
and then you can check that data and decide whether you want it to be targeted
you put the ownign players UUID into the entities PDC. Then in any target event you check for an owning player and cancel if its the owner
what is PDC
?pdc
Is it possible to force a blockstate client-side? I am currently trying to force the distance blockstate on leaves without any luck
Not really, I want to do
enchantItem(
item,
new EnchantData(Enchantment.SHARPNESS, 2),
new ...
)
do a forEach
and pass in a list of EnchantData
alternatively to get closer to what you want, pass in an array and you can put the EnchantData objects into {} as a parameter I believe
I already do that, I'm asking if there is a better way
is it not good enough?
you could do it with a stream but its unnecessary in this case imo
It's alright, just thought it was weird to create a class for a pair
had the same thing
weird how java doesnt have a builtin tuple type or pair type
True
records are the closest thing we have to that atm i believe
how do i get the X amount of stone in a player's inv
how you get the amount of stone a player has in their inv?
ye
loop through the inventory and add all the amounts of itemStacks which are stone together
if i have an event and i have multiple if statements in it, if i add return; at the first one, it won't go through the rest?
Hello !
I'm looking for an event where an entity die, so I can get the entity and the killer ...
What's the event ? I'm using the EntityDeathEvent but I can't get the killer π¦
if a return is called the method is basically cancelled
NVM, i'm dumb
EntityDeathEvent
it works
Yeah, I though it was something like event.getKiller but it was event.getEntity().getKiller() xd
just be aware that the killer may not exist if the entity was not damaged by any players
Oh well, just understood that a killer is always a player
What if a snowman kills a zombie so ?
(That's an example)
if the entity which dies was never damaged by a player the Killer will be null I believe
Okay I see, ty
maybe listen to entitydamangebyentityevent
check if the damage will kill the entity and make sure its not cancelled
probably have your priority at highest
You're right
Lowest you mean ?
Ah yes mb
EntityDamageByEntityEvent you mean?
Actually I can use EntityDeathEvent, it's all good to me because I need a Player killer ^^
I was just curious, but ty
the Killer is always set to the Player who last hit the entity. If it dies by a block or falldamage the killer is still that player that hit it down the cliff or so
in case that helps
Ty π
Hi, I have a question. I am a complete newbie to minecraft plugin development and fairly new to Java. I have followed a few lessons. I followed a tutorial for event-listeners but it wont recognise. See screenshot: https://imgur.com/a/Ragvwgz
I dont think thats really how you make a listener
Usually you would make a separate class that implements the listener interface along with an eventhandler method
Listener
try typing capital L
its really bad practice to do it in the main class tho no?
depends on teh size of the plugin
Another problem π I am getting this: [20:20:26 WARN]: Nag author(s): '[Ruubbie]' of 'BestPluginEverMade' about their usage of System.out/err.print. Please use your plugin's logger instead (JavaPlugin#getLogger). error when running this: ```@EventHandler
public void onPlayerJoin(){
Bukkit.broadcastMessage("A player joined the server welcome them!");
}``` piece of code.
so how can i get the entity that damaged other entity in EntityDamageEvent? i found ENTITY_ATTACK and ENTITY_SWEEP_ATTACK and some other damage causes that i want to keep track of but idk how to get the entity that actually damaged them
I am pretty sure it's actually this what is causing the warning
System.out.println("Plugin enabled!")
wrong event
lmao i just had to look for other similar events...
thanks :D
use getDamager() to get the attacker
is there a way to set the color of a wool, on bukkit?
(1.7 btw π)
u forgor?
1.7
not 1.17
Wool color in 1.7 is the data/damage value
before 1.13 color was a blockstate
which it is a big no no for bukkit bc NMS is simpler, and doesn't use that.
(on 1.8+)
btw asked this because maybe NMS has some type of enum with the colors and their data values & stuff
dunno
line 46 onwards either delay 1 tick using the scheduler, or cancel the click event
Tried, im getting full of errors such as plugin cannot be null
So currently i have an issue where when i do the spawn command the first time it tps me too spawn if i wait 5 minutes then do it again it pulls this
Error: https://paste.helpch.at/enebuhiwux.md
CoreDatabase: https://paste.helpch.at/qeremibaku.cpp
SpawnTable: https://paste.helpch.at/ororobeken.cpp
SpawnCommand: https://paste.helpch.at/ufoviziseq.java
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
ucant find a find the fix as i cant see no errors anywhere
constructor should be public
The constructor Summon() is undefined
summon(this)
` @Override
public void onEnable(){
getServer().getPluginManager().registerEvents(new Summon(), this);
new Summon(this);
}
@Override
public void onDisable(){
}
}`
please for the love of god use three of `
okay sorry
getServer().getPluginManager().registerEvents(new Summon(this), this);
Thank you im gonna test it
Works perfect. thank you very much @eternal oxide
imagine not escaping your backticks !!! ```
How can you create a Content object? net.md_5.bungee.api.chat.hover.content.Content
Thatβs not spigot
Newer versions of the API has more utilities
Youβre using 1.8 yah?
?pdc
aight
Hey !
Is there an easy way to check if a block mined is a crop ?
I mean, another thing than
Material blockMaterial = event.getBlock().getType();
if(blockMaterial == Material.CARROT || ...)
return;
Just change his drop on death
What's the question exactly ?
if i create a listener and a class that extends it, will the listeners from the parent be registered too?
you want to stop the decay?
leaves calculate and update their blockstate distance to the nearest log
I want to prevent them from updating their blockstate distance
because?
because I want to use them for custom (translucent) blocks
so you want to stop them decaying then.
if I reimplement the decay logic with a plugin and use 1 blockstate I free up 6
however
when I set the blockstate it just returns back to its original value rn
im not rlly aware of a way to stop blocks from ticking
I couldnt really find anything on the forums either
you could look into BlockPhysicsEvent but im not sure you can use that eiher in the way you want.
im not sure if that fires tho
yh no idea either
?stash
else you might benefit from just looking into mc code how they are being ticked & see if its possible to do somethn with reflection.
yeah that was my 2nd idea
I already downloaded the build tools
but lets hope this works first
thank u either way!
π
It seems I may have struck gold as my pc is burning down and my terminal is filling up with numbers I'd like to see
How do i teleport/move an armor stands wich has a passanger?
If anyone knows ^^'
Crop class is deprecated
what I did for leaves was just have a set of all the leaf types and check if the current material was inside of that set
Oh I didn't know about this block data, ty
why EntityInteractEvent is not triggering? i tried player interact event and it worked perfectly now i just replaced it with entity and its not even triggering
or is it for something else?
no
trigger a event when a skeleton tries to shoot with a bow
or similar things
this works for players
also not when shoots
when tries to shoot
in another saying i want to block it
other than the standard block place/break/destroy & player interact events, is there any other events i should listen for and run location based checks for an antigrief?
what would be the best way to change the blocktype of newly generated trees? Preferably I want to add on logic/code when a tree is generating its leaves. Would anyone know to point me in the right direction please?
prettu sure you can use this for that https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/world/ChunkPopulateEvent.html
declaration: package: org.bukkit.event.world, class: ChunkPopulateEvent
when it comes to trees being generated from sapplings. you can use StructureGrowEvent
if that doesnt help. you can also make a custom tree generator i believe
I see
there is yes
thank you. I will check if using this event is performant enough for me and otherwise will use custom tree gen
take a look at this https://www.spigotmc.org/threads/how-to-set-blocks-incredibly-fast.476097/
thank you will take a look
I am processing multiple chunks and setting blocks in each of those most of the time and I was wondering if doing it multithreaded would improve anything?
uh u can only change blocks from the main thread tho
you could probably divide the load tho. and proccess over time.
can any devs volenteer to help me with this problem
i need it fixed quick
pls dm me
dontasktoask
nah. i mean you could devide the load. like if you have a task instead of doing it in one tick do it in 5
oo I see
thats how i make big block operations lagg free at least
wait so how does async work then?
u cant change blocks async
I mean doing the processing part
Send the problem don't ask if you can
dm
I was thinking perhaps I could process it all async and then add to a queue and then on main thread go through the queue
Why?
or would that be worse for performance?
just ask your question here
you should read this article. it explains it very nicely https://www.spigotmc.org/threads/guide-on-workload-distribution-or-how-to-handle-heavy-splittable-tasks.409003/
thank you! Youve probably noticed already but im a bit inexperienced π
@lost matrix im pluggin ur stuff 
If everyone was experienced this channel wouldn't have to exist. So don't worry about it
:)
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Better question: Who writes a method stub with one argument like that?
public void setPlayerScoreboard(
Player p
) {
there were more
but i cleaned it
good that u mentioned it
The thing is, it sets it when a player join, but then, doesn't change it.
Did you make sure the method is actually called?
Add a sysout at the beginning of the method and see when its being called.
I still have no clue what to do
Do you want to use CraftBukkit or NMS with maven in 1.17+
Craft
https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-2-release.534760/
Scroll down to "Developer Notes" and then read the "NMS" section
so is this saying that I can still use the 1.17 stuff?
anyone could tell me is this bad approach
I'm just trying to access CraftPlayer but it says that this class doesn't exist
so I think that I need to import smth, using maven or depending on it? and even after reading this I still don't know how to
Is serializing data (like custom enchantments) into PDC's with, strings, for example better or should I make a plugin file that records item stacks and associates enchantments with them
My only real question is why you're putting a blank line between every single line of code
I got problem with reading when lines are to close
so I need some spacing
It's fine and respectable but I'd rather just increase the spacing in the IDE settings, that way it will help you read other one's code
and help other ones read yours more comfortable ;P
will look in to that thanks
To the main question, what are you trying to do?
So I am spawning mobs with PDC from custom spawner.
Now question is about performance is it good idea to check does entity has specific PDC key on every single damage event?
Other idea would be to add UUID of entities to HashSet
on there spawn
If you're already using PDC why don't keep using it then?
Concerned with performance on EntityDameEvent
This
I mean PDC is rather close to a plain hashmap
I actually don't know how different the PDC API is compared to the NBTApi, but I don't think there would be hardly any noticeable different so you're probably fine with either
you have a bit of overhead
?
One is a HashMap the other one is Reflection based and I believe it has to constantly parse the NBT string back and forth
^^ PDC basically converts to nbt when you call set
no IO or anything but object conversion
They're basically the same, I'd say one has a higher Memory footprint while the other one is more CPU intensive
I think you're fine with either tbh
well I will try it out this way then will see on live server will there be any laggs
Thanks for info
If you see any lag, I don't think it's related to using PDC API or NBTApi, imo ;P
How do I make a pattern that has a certain start and end string but unknown mids? Like this <<Hello>> and <<Something>> are valid as they start with << and end with >>
You mean regex pattern?
Yeah
I know you can do this [a-fA-F0-9]{6} but I have no clue of how to set the characters to an unknown amount
<<(\w+)>>
you can use {1,} or + which is the same but abbreviated
Omg I'm stupid, I tried googling it but for some unknown reason my brain thought a matcher and a pattern is the same. Which I know they are not lol
Ahh, I see. Thank you!
you can always go to a regex tester, they are very helpful
https://regex101.com/ for example
That is very helpful indeed, thanks!
^<<.*>>$
Thanks π I think Imma stick with <<(\w+)>> tho, as it's easier to read imo :>
They are different
That one will only match alphanumeric characters + underscore
Mine accepts all characters
\w is closer to this
Mine also will only work if the << is at the beginning of the string and the >> is at the end
I also just realize you used from a to f
Hmm, yeah. Forgot that lol, I only really use latin chars, digits and underscores so \w is fine. I found this really useful, https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html.
Doesn't <<(\w+)>> require << and >> at the start and end tho?
It will match anything surrounded by those
So abc <<something>> def would match
But only the middle part there
If you want it to have to be the entire string you need ^$
Ahh, I see. I only use it for placeholder-ish type of stuff. So it should be allowed anywhere in a string
Alright
Really good to know though
https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/#forward
I am reading through this wiki page, specifically the Forward section. I want to know if i NEED to specify a subchannel. I would like my plugin to communicate with other servers with the same "server name" which is set in the config. so i registered the outgoing and incoming channels as pluginname_servername. I feel as though this is better than just registering the channel as pluginname and having a subchannel for servername as messages will only be sent where they need to go to
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
thoughts^?
I mean itβs probably for the best if you write a sub channel
Assuming you use the default channel
Else itβs pretty much not needed
" so i registered the outgoing and incoming channels as pluginname_servername"
i registered my own channel
Yeah you probably donβt need a specific sub channel, but like itβs convenient for letβs say format identification
i saw someone on a forum say they could send players custom notifications using the tip gui, like the one which tells you you have new crafting recipes i think
how do you do that with spigot, i couldn't find anything in the docs
Here is the post where someone declares they can send notifications using the tips window, but they don't provide any proof of it
What's good practice when saving an inventory to a database like mysql
whats a good way to do it
you could serialize it and then store it as a blob
how you choose to serialize is up to you, I recommend just serializing to binary though
then you can just unserialize easily
yeah, only minor problem is that it makes a web api for viewing inventories pretty much impossible
its surprisingly difficult to serialize any other way though besides yml (or binary), which yml isnt really supported to save to sql
it doesn't make it impossible
I'm having a problem with plugin messaging. I've set it up as shown in the Wiki but it doesnt seem to work.
because php is capable of deserializing the information? just because you use a different language doesn't mean you can't deserialize the same way you serialized
storing to binary using the bukkitobjectoutputstream, it cant deserialze it without having a server running or else the itemfactory breaks
wasn't talking about using bukkit methods to serialize
but you can implement the bukkit method into php easily though
well i was using java
i was storing it in a database as binary with bukkitobjectoutputstream, tried using json but it wasnt able to deserialze on the server
im not too sure what other way to deserialize a bukkitobjectoutputstream would be, seeing as it uses methods that require a minecraft server being run
see how the methods work internally and reimplement it
it uses configurationserializable, the problem is will deserialize it to an item, and making an itemstack without a server running causes many issues
you don't need to use bukkit methods to serialize
especially the way I am talking about
which way are you talking about?
im not sure what other way there would be to serialize to binary without using object output streams
not really
what way do you have?
most of them are strings, just pass it through json
it will take time to do it manually but not that much time
but theres item nbt as well
its stored in a json-like format, but using something like gson doesnt work for storing the nbt tag
you can EASILY put data from Java to json or other stuff
ik
i tried serializing the nbt of an item to json, however youll get problems when you try to deserialize it because it doesnt know the type of the nbt compound
I feel like you are spending more times making excuses on why it wont work rather than figuring out how it will work
spent a couple hours working on it over here π
you can read through the messages if you want more detail on the things i tried
still never resolved the issue, finding a solution would be great
heres the wrapper class i tried making as well, still never worked though because of how the item meta works https://paste.md-5.net/famikeroxi.java
make a custom deserializer
nbt is something that can be implemented in PHP
I think there is php libs already for NBT
Is this what you want deotime?
well, i dont think you're understanding what im saying
first of all, im not using php for anything
class MyItemStackDeserializer implements JsonDeserializer<ItemStack>
{
// ...
}
secondly, the problem wasnt making the itemstack, it was deserializing it again on the server
tried this as well for nbttags, problem again was that nbtcompound is abstract so im not able to know what the type of the compound is
maybe look at some nbt open source library, then work your way there.
i looked through a few
I mean
like i said, the main problem wasnt serializing and deserializing the item
if you're using CraftItemStack.asNMSCopy(item), why not use the nms directly?
it was making it compatable with a web api
What problem do you have making it compatible?
you stated you wanted a webview
therefore there is no issues then
...
look
reading the nbt is not a problem
i do that just fine by serializing the item to binary
can you show us what's your itemstack json structure file looks like?
like the actual nbt of it?
sure
ill find an item somewhere one sec
somewhere you are having an issue that none of us experience
i sort of think we are one two different pages here
I have serialized MC data before and have displayed it on the web without issues as well as transferred that data to other applications
great, could i ask how?
the method in how you serialize your data is what is important. You have multiple ways of doing it to include using base64
which base64 works the same regardless of application or it is suppose to anyways
if its serialized to base64 then all you have is just a string
but it depends on how you decided to serialize everything, whether you serialized it all together as well as if you took out the info you actually needed
i used gson (on many different things, itemstack, nms itemstack, item meta, nbt tag compound), however it is not able to deserialize back into an item on the server due to nbt compound issues
not sure why you are using NMS for this
you might not be able to deserialize back directly into an item
instead you might have to manually create the item again using the data you have
newline before braces π€’
so you would deserialize the data and then go through the data reconstructing the item using the API methods
here is the current code i have right now: https://paste.md-5.net/heyesocufe.java
this works fine for saving items in a database, and loading them back again when neccessary. however, its not possible to deserialize this on a server (the api) that does not have essential things setup such as the itemfactory
plugging in as you go the pieces of the data
yeah because you keep using bukkit object output
after I told you not to
if you don't know how to make your own serialization methods, then this is probably beyond your abilities to make
https://paste.md-5.net/famikeroxi.java (custom serialization wrapper class i attempted to make)
i know perfectly well how to serialize things
its just that it is not able to properly serialze the nbt without causing a multitude of issues
it is, because almost everyone here has done it
This is in my main class.
Bukkit.getMessenger().registerOutgoingPluginChannel(this, this.channelName);
Bukkit.getMessenger().registerIncomingPluginChannel(this, this.channelName, this.playerManager);
https://paste.md-5.net/uhedofokat.java
In my PlayerManagerClass
I call sendMessage on playerinteract event to debug
I have 2 servers on bungee, server and lobby with one player online in each. I see "Sending plugin message" on the server that's sending but nothing on the server that's supposed to receive it
please use the paste site
editted it
then could you show an example of how to serialize an itemstack directly into json and deserialize again, without using any external apis? thats really all im looking for
nbt data isn't magical to where you can't deserialize it regardless of application. As I said, you might need to implement something depending on the application you are trying to import the data
I don't know deotime.
But here is what I'm thinking, I think you're trying to make your code as elegant as possible.
If you're serialize thing your way.
Then you have to deserialize it your way too.
Including deserialize NBT in your way. I don't think you can expect NBT to work as you like
hence why I linked JNBT, allows writing and reading NBT data without needing NMS
that is called implementing
why nit use BukkitObjectOutputStream?
without external API's is easy but requires you to implement what external API's have already done and thus make it easier
i am currently, lol
so why are you wanting gson
so that it can function on a web api
because we don't want an object, because they want to store the data to be transferrable between applications
objects can be transferred between applications but only if the object is also valid in the other application as well
at some point i was thinking of just making two different storages, one for the api and the other for the actual server loading, although that would be horribly inefficient
well you are just over thinking this
since we are using Java, the only thing you really need is just the data that describes the item
correct
base64?
and not sure how you are not able to get a valid json object from a string
yes, but what "serialize" method are you talking about? thats the whole thing that im trying to do here
i dont really think im up to making an entire json api thats as good as one created by google
well, it is up to you. the point I was making is whatever way you decide has to be done in reverse exactly how you did it to serialize regardless of the application
hence you might need to pick out the data you want serialized instead of serializing the whole thing
web api might not know what the heck an itemstack is for example
but all of it is essential though, i cant just have the items on the server losing nbt tags that define important properties about them
getting the information using API methods isn't different then getting the raw information via NBT
but if you want the NBT raw data then go with that, but don't combine NMS NBT with API methods
dont think i ever did that
however, since you have an issue with NBT compounds somewhere, I linked you a library that will allow you to arbitrarily create them
i switched a lot between bukkitobjectoutputstreams and json, trying to find something that would work, but never used both of them simultaneously
anyways ill think ill just be done here
not even sure how a 1 month old issue for a server thats pretty much dead now even got brought up again lol
idk you talked about having issues with serializing
which so far as you explained shouldn't be that difficult
here is a link in how easy it is to create a json object
I used json simple for that
not super elegant or whatever, but it gets the job done lol
yes, serializing it is very simple
the combinations of things that worked at some point:
bukkitobjectoutputstream:
serializing: β
deserializing: β
api compatable: β (not able to deserialze on a server not running minecraft)
json (using the gson library):
serializing: β
deserializing: β (gson doesnt save types of jsonobjects, nbt tag gets converted into a treemap and doesnt work)
api compatable: β
if i ever come back to this, what ill probably do is just make some method to convert json types into nbt compound types
thoughts?
you do know you can serialize the individual stuff and then serialize it all together right?
to avoid breakage like the last bit where nbt tags get converted to something you don't want converted to
not really about serializing it, more about it deserializing which i why i said ill probably make something that individually deserializes them
i would create a wrapper from scratch
does getLineOfSight() return a block as a string?
why would it do that lol
Docs will tell you what it returns
you could use nbt for serialization and deserialization
there are a few libraries that allow you to work with nbt outside mc too
only problem is having some serialization/deserialization system for objects
i made something similar
only problem is that the client deserialization doesnt work
but if the data isnt sent to the client it works fine i think
it also stays as a runtime object in memory until it is serialozed
Um is there any recommendations for libraries that make menu guis eaiser.
I haven't touched bukkit since the very early days of minecraft.
Yes
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
that suggests some libs
Player velocity reduction on attack
java 8 minimum
How should I use "nms"?
I downloaded buildtools and ran it in Desktop/NMS (created NMS folder)
so imma use 11
now use the jar it created in ur IDE
which IDE r u using?
IntelliJ
?bootstrap read the full post
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
How do I depend on jar file?
if you read teh linked post it tells you all about it
Oh thanks
is this the case for 1.15.2 as well?
no
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar (download), or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
How do I use maven to do this? I don't know the repository link (like
<repository>
<id>papermc-repo</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
)
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/stash/projects/SPIGOT/repos/spigot</url>
</repository>
did not let me use spigot dependency
you are wanting to use NMS. You clearly have not read the link that was posted
Is there a way I can increase the intensity of a lantern using nms or smth
i want to create a glowing effect around a player
and also make the light follow the player
Run build tools for 1.18 and then the dependency is the same although without -api for the artifact id
?paste
I'm having trouble making objects out of config sections. Ive been troubleshooting and I found out that the map I pass into the deserializer doesn't contain the keys at all. https://paste.md-5.net/rahusucori.cs Here is my relevant code and config, This is the first time I'm trying to parse objects like this from the config, so beginner mistakes are possible
Does CustomCreatureData implement ConfigurationSerializable?
yes
Because the config does not look like its saving ConfigurationSerializables at all.
what do you mean?
If you use ConfigurationSerializable then you can no longer write your configs by hand
that config just has a data set. theres no serialized data in there at all
I mean you can but you need to be precise
How do I save a double or int to a config.yml halp plz
Create a list of 3 CustomCreatureDatas and save them in a config. You will see how it looks like.
?configuration
will do! Thanks π
Is there a way I can increase the intensity of a lantern using nms or smth
i want to create a glowing effect around a player
and also make the light follow the player
Whatever. Its FileConfiguration#set(String, Object)
This means you can just use any java object.
getConfig().set("Coins." + e.getPlayer().getName() + "coins", 1000);
Just use a light block
I am using 1.15.2 unfortunately
and i m using lantern so i can change the colour of the light
I dont think that supports lanterns
As I want to change colours (Red/Aqua, the two lanterns)
okay so it seems i can use the LightFlag enum, but I cant know if theres a lantern entry in it. neither am i able to find the docs
It says failed authenticating when adding the lib using mvn
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.BeYkeRYkt</groupId>
<artifactId>lightapi-bukkit-common</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>
Cannot resolve authentication failed for https://jitpack.io/com/github/BeYkeRYkt/lightapi-bukkit-common/master-SNAPSHOT/lightapi-bukkit-common-master-SNAPSHOT.pom, status: 401 Unauthorized
If I encode an Inventory to base64, how long could the string get?
i need to make sure i have a datatype in mysql database long enough for them
i do plan on not allowing books into the inventory
text should be good enough
havenβt had any issues when encoding inventories in base64
i feel like that is kinda long
64kb for one player?
i want a smaller one but idk which one to choose, unless 64kb is recommended for the entire inventory
this is a 9x6 inventory btw
you could also use json or whatever
No, I use a task scheduler to repeat every few ticks a message
im talking about the database
is mysql
yes, obv. how long the base64 string could get, what we cant tell you.
right, ima have to test soon
but if base64 is too long for you, you could dodge to another way to store it
like json
but i dont think that you will save much there
i think ill be fine
one million players taking up that mucb space would be about 65 gb
not a lot
would VARCHAR(65,535) be good? i dont want to use a fixed length as thatll take space
base64βs output will be different lengths right
thats big
not what i want
i can create a filter
to block books
item with big lores go brrr
medium text is 16,777,215 characters
thats way longer than 65535 characters
π
all right
first time dealing with databases π
thank you
how'd I create a switch statement with pex to check the group?
Gradle
Ah ty
What do I need to change in an IntelliJ project to change Maven to Gradle and the other way?
You can use the gradle wrapper if itβs from maven to gradle at least
whyyy
Where do I get that/research about it..
maybe getBestPlayers return an Object[]
whats pex, whats the group?β¦
nvm didnt saw the pic that is 1 px above lmao
list of objects?
idk thatβs pretty weird
maybe just try casting it
is java 17 compatible with plugin development?
for newer versions yes
ofc, in fact minecraft 1.18 requires java 17
ah alr
belive there are some libs older versions use that make j17 incompatible with them
1.18: java 17
1.17: java 16
1.16 and below: java 8 (and java 11, but im not sure)
the method returns a List<GamePlayer>
but when i do for, it thinks it is Object i guess
ik, itβs weird that it would want object
I mean is your class that has the getBestPlayers method on your compile classpath?
does unLoadWorld() work properly? i mean since unloading worlds is iirc not known to the vanilla server
did not work
and no class is protected / packpriv such that it by definition is inaccessible to that other class of yours?
wdym
the getBestPlayers is public
bro
like
the problem is with List<GamePlayer>
because every for with that is giving me errors
is GamePlayer public?
yes
Are you deserializing GamePlayer
wdym
Oh are you importing the correct class?
pex = PermissionsEx
group = the player's group
yes
What is the best way to load a user from database? This is my current way https://paste.md-5.net/paqiruvumu.cs
Utils.getidentifier and not just the players UUID?
ask PemissionEx devs
I want it able to save data with player names too
what if they change names
you want to save by uuid internally
then you cna build that data with stuff like Bukkit#getOfflinePlayer
I was thinking using CompletableFuture like this to make it more flexible but idk If this is correct or not https://paste.md-5.net/aguxeyabag.cs
would probably use placeholders instead of concatenation for the identifier, to prevent unlikely but potentially possible with your identifier system sql injections
placeholders like what?
yea
it starts with 0 right?
Indices for statements start at 1
I'm not so sure about that implementation though
I don't even think it will work as you expect because it's just going to return the default user every time, defeating the entire purpose of a CF
If you insist on going that route,
public CompletableFuture<User> loadUser(String identifier) {
CompletableFuture<User> future = new CompletableFuture<>();
Bukkit.getScheduler().runTaskAsync(plugin, () -> {
// Obviously rewrite this to use PreparedStatements. I'm too lazy
String query = "SELECT * FROM `" + SQLDatabaseInitializer.USER_TABLE + "` " +
"WHERE name=\"" + identifier + "\";";
SQLHelper.executeQuery(query, result -> {
if (result.next()) {
double coins = result.getDouble("coins");
future.complete(new User(identifier, coins));
}
});
});
return future;
}```
Though in an ideal world, your SQLHelper would also return a CompletableFuture against which you can call chained CF methods to map it to a User
You then call that method and call upon its future
whateverInstance.loadUser("2008Choco").whenComplete((user, e) -> { // or thenRun() if you don't care about handling the exception
user.doSomething();
});```
Yeah
I use hikari right now
There you go, even better
Thank you for the explanation Choco, I'll try it.
tbqh, depending on how your SQLHelper is implemented, the scheduler probably isn't necessary.
It might already be done async. idk
You can return the default user if that user doesn't exist though. But ye, returning the default user every time like you were doing before would just never work ;p
Would return null if the user doesn't exist on the database is fine?
personally i would make it return an optional instead of null, but it shouldnβt make too much of a difference
Sure. But what i usually do is create a new instance of the user and return it instead.
Then i call my methods something like loadOrCreateX
My main idea is to create something like that too.
After writing some stuff in Kotlin and Rust i find handling null values quite cumbersome. So i either wrap them in optionals
or dont allow null values anywhere (which is a bit harder to enforce on compile time in java)
heeelp
So If I want to create the loadOrCreateUser method, should I use AtomicReference or what?
maybe just try casting it in the loop and seeing if it works? iβm really not sure why it would be giving that error, maybe itβs something with intellij somehow and not the actual compiler?
question
i somehow made my plugin able to crash a persons client but not the server itself
how
fixed
the Game had a type
Game<M>
the classes that were using it, wasnt using atype
i added a <?>
and worked
i implemented a kind of bleed mechanic thing and whenever something dies of said bleed the client shits itself and the cpu usage jumps to 100%
i guess theres an error in the console?
and what does 'the client shits itself' means?
im honestly amazed like i didnt know plugins were capable of that
crashing the server sure but not the client
not responding + 100% cpu usage
gotta shut it down
you gotta be doing something in order to make that happen?
i mean obviously
i just dont get what could be causing the client alone to crash
i just know it happens when an entity dies of my bleed damage
Check the client log?
it has to do with the impl of your bleeding stuff then
well, yes
figure out what you are doing wrong then or paste the code
the log doesnt go any further beyond saying what entity died
i mean thats the thing i dont know what is going wrong, im just assuming it must be some kind of bug with minecraft i exploited
are you using any mods?
how else could it make sense that the client alone suffers from it
only optifine
oh wait i think i know, sec
i think its because i made the amount of bleed particles scale off the damage dealt and i have a custom damage system that has to cause entities to die manually if custom damage were to be fatal to them
so it deals about 10 billion damage to them
πΏ
Why not set health to 0 instead of dealing billions of damage 
because then the death message becomes "entity died" instead of naming their cause
didnt want that
making a custom damage system sucks, too damn hacky, but you gotta do what you gotta do
Set a custom death message? Idk lol
i mean thats just a big workaround
i could also set their health to something really really low so its basically guaranteed the usual damage would kill them
can i check motion Y player?
sure, just get their velocity
do keep in mind velocity in the Y direction is always a bit negative due to falling
Is there a way to override the default world that is created on startup?
so even when standing on the ground Y motion will be negative
ik
you might be able to use getFallDistance as well but i havent tried
but obviously this would only work if moving downwards
event.getPlayer().getVelocity().getBlockY()
?
or getY
getY
thats their Y motion
add the falling negative velocity and you approximately got your true relative velocity
any ideas on why i cant summon a mob on my server at all?
no console errors
[16:22:57 INFO]: Boncke issued server command: /spawnmob zombieBoncke issued server command:
/summon zombie ~ ~ ~
[16:23:25 WARN]: Skipping Entity with id zombie
[16:23:25 INFO]: [Boncke: Unable to summon object]```
essentialsx spawnmob command btw, so nothing i've made
spawn eggs dont work either
difficulty is on hard
mobs disabled in server settings?
nope
can you spawn a sheep?
how can i got Z coords and compare 3 secong after this 2 ints?
Another question about nms, im sure these are loved by now:
If I extend the LivingEntity class how would I make an entity spawn from there? do I just have to call the constructor and call the teleport() method?
bump
is there really no way to damage an entity with a specific damage type
why is there not a LivingEntity#damage(double, DamageCause)
that takes in an EntityDamageEvent but i guess it'll have to do
Anyone here familiar with EssentialsX and their api? I am trying to listen to one of their events, but for me it doesnt work, if someone else compiles my code, it does work
ill dm
Hey, i'm trying to use this util class https://github.com/Sunderia/SunderiaUtils/blob/main/src/main/java/fr/sunderia/sunderiautils/utils/ItemBuilder.java for setting an item in a inventory. I use ItemBuilder like that :
inventory.setItem(index, new ItemBuilder(item).onInteract(event -> event.setCancelled(true)).build())
But when i interact with this item, it's doesn't cancel the event
Can anyone help me why my event is not getting triggered? Someone else tested the same code and compiled it himself and that worked.
https://paste.md-5.net/oguremarap.xml
how old is your Ess version and what did you test it with?
tested with spigot 1.18.2
ess is v2.19.4
In this one I tried 2.19.0
Someone told me its more stable for the api
?stash
Either it is an EssX bug or the event rightfully does not fire
Test the event with /pay
I did test it like that
it gives no errors, nothing
all the events are not triggering
(all the essx)
I'd guess you have two ess jars on yoru test server
wdym?
Your code looks fine and your dependencies look fine too. So I'm going to guess you are listening to the wrong event class
is there any way to cancel sand and gravel from falling. I've tried canceling EntityChangeBlockEvent and also with BlockPhysicsEvent and they don't work. I know that there's a way with NMS but I will prefer to do it in a simplier way
If no ess events are triggering for you and ess IS running then you have the wrong references
i thought of that too, I copy pasta's this from the essentials documentation
bottom of the page
can someone help me?
@limpid bronze You never call build()
You have to call .build() at the end
This also isn't something I would use
It's going to create a memory leak/performance issues on servers with long uptime
It registers a new listener for each item that has a listener, but never unregisters them
Meaning that every time you construct one, another register is permanently added
So every time the click event is fired it will be slower and slower and take up more and more memory based on how many times you've registered these items
It likely won't cause issues until you have a lot of them but it's definitely not going to be insignificant either, at least for a server with a good number of players
running into trouble using applyPatches.sh in craftbukkit on mac
anyone else have this issue?
oops i forgot that i've already that in my code
but even with build() event.setCancelled(true) is not working
is there a way of unregister when the inventory is closed?
does PlayerConnection contain a method for handling every packet?
every packetplayin... packet ^
it seems to, but im not sure
Think it does
is FileConfiguration#options#copyDefaults(true) setting defaults for when some path doesnt have a value?
yes
thank β€οΈ
im lookin for a good way to make a lang file thing
i had an enum before which stored paths to where in the config file the entries were saved but that went brr
brr
maybe java.util.ResourceBundle is something
My more insane way of dealing with it is
private static final Map<String, Map<String, String>> TRANSLATIONS = new HashMap<>();
private static final Map<String, String> EN = new HashMap<>();
private static final Map<String, String> DE = new HashMap<>();
private static final Map<String, String> DEFAULT = EN;
@NotNull
public static final String WRONG_ARGUMENT_COUNT_CORRECTED_SYNTAX = "wrong-arg-count";
// [...]
@NotNull
public static String translate(@NotNull String key, @NotNull Locale locale) {
Map<String, String> translationTable = TRANSLATIONS.getOrDefault(locale.getISO3Language(), DEFAULT);
String value = translationTable.get(key);
if (value == null) {
PlayerCurrency.getInstance().getSLF4JLogger().warn("Unable to find value for translation key \"{}\" in language table \"{}\".", key, locale.getISO3Language());
String s = DEFAULT.getOrDefault(key, key);
if (s == null) {
return "";
}
return s;
}
return value;
}
static {
TRANSLATIONS.put(Locale.ENGLISH.getISO3Language(), EN);
TRANSLATIONS.put(Locale.GERMAN.getISO3Language(), DE);
EN.put(WRONG_ARGUMENT_COUNT_CORRECTED_SYNTAX, "Syntax error: Wrong argument count. Correct command syntax: ");
DE.put(WRONG_ARGUMENT_COUNT_CORRECTED_SYNTAX, "Falsche Anzahl von Befehlsparametern. Richtige syntax: ");
// [...]
}
is there a way to disable initial world creation or override it in a plugin?
how do i register a channel that is marked as reserved / access it
aah lol
I personally think that something like https://github.com/Geolykt/Presence/tree/main/src/main/java/de/geolykt/presence/i18n is more suited to something like this. The idea is still the same as the one I mentioned above just with enum keys - only issue is that there are no default values heh
ah i just took a look at the essentials way
https://github.com/EssentialsX/Essentials/blob/8b23c2c4cd140afc0ed697ec4f691a3d7295682e/Essentials/src/main/java/com/earth2me/essentials/I18n.java
resourcepacks maybe?
The client always sends the locale of the user
I personally do that (sending messages based on the client locale) in Presence
It won't work on older versions of mc however as those do not always send the locale
the client's language locale
Nothing with geolocation (which would legally be a grey area without consent)
That may be illegal
Until they consent that is.
But ask a more qualified lawyer about this, I am not qualified at all about this. I'd recommend to keep your hands off from geolocation for such non-vital usecases unless you are absolutely sure that data protection laws aren't going to kill you either way however
if (p.getInventory().getItemInMainHand().getType() == Material.INK_SACK) {
How do i check if this is GRAY_DYE?
If you are using MC 1.12 or below I am going to rip your head off (metaphorically that is)
Im using 1.12.2 because i have no choice cause my friends server is 1.12.2 xD
But yeah, if you are above that, it is as simple as using GRAY_DYE
Good luck on figuring it out yourself.
Just a small tip: Use the damage value
Alright thanks! I will try that
They are all magic values however and I have no idea how noone came to the conclusion that this system is a bit dum at that time.
Lemme see how canarymod handled those cases
check forum post about old stuff
Oh yeah, much better of an idea https://github.com/CanaryModTeam/CanaryLib/blob/master/src/main/java/net/canarymod/api/inventory/ItemType.java#L472.
Far better than whatever we have these days too
that is a rewrite of a fork of hmod, quite different from the bukkit we see these days
who thought it was a good idea to use durability to store magic values
i thought this should print "null"
idk config was weird af last time i did editing it from the code
sorry
im too tired to understand jokes rn
how could i check if a player is in the nether dimension?
yes but how do i know if its a nether world?
if it equals (or just the name) Bukkit.getWorlds().get(1)
0 is overworld, 1 nether 2 ender stuff and the rest is custom
?jd-s this does not seem right
I was looking at the spec for an area effect cloud and found that this link doesnt lead to anywhere. Anyone know anything?https://wiki.vg/Entity_metadata#Particle
Well, it's the WorldInfo object actually
But since World extends WorldInfo, noone will care
π
uhm ye
Yes
Has anyone ever encountered something like
22:08:08.254 INFO: ClassWriter: Position UNKNOWN in type annotation: @org.jetbrains.annotations.NotNull
22:08:08.254 INFO: ClassWriter: Position UNKNOWN in type annotation: @org.jetbrains.annotations.NotNull
22:08:09.458 INFO: ClassWriter: Position UNKNOWN in type annotation: @org.jetbrains.annotations.NotNull
22:08:09.459 INFO: ClassWriter: Position UNKNOWN in type annotation: @org.jetbrains.annotations.NotNull
22:08:09.459 INFO: ClassWriter: Position UNKNOWN in type annotation: @org.jetbrains.annotations.NotNull
22:08:09.459 INFO: ClassWriter: Position UNKNOWN in type annotation: @org.jetbrains.annotations.NotNull
when compiling? If so, does one know how to get rid of those warnings?
does instance = this works in a constructor?
set <scope> to provided
annotations do not need to be shaded
I am pretty sure that it is not related to shading given that I would do it "manually" (and even then I do not). It is probably something inside the java compiler API
You see, I am using a mostly custom toolchain
sure, why not
but why would you ever need that?
sounds like a design failure if you need to do that
public class Test {
private static Test instance;
public Test() {
if(instance == this) {
System.out.println("Why am I doing this check?");
}
}
works fine
ah
= this, not == this
Code such as
int valueslen = super.values == null ? 0 : super.values.length;
@NotNull StateActorFactory<?>[] temp = new @NotNull StateActorFactory<?>[valueslen + 1];
if (valueslen != 0) {
System.arraycopy(super.values, 0, temp, 0, valueslen);
}
seems to cause the warn to appear 4 times extra if not uncommented
but yes to both cases lol
it looks like all the things im trying are leading to the same thing
oh. sure, that obviously also works
I don't see any reason why someone would think that either of them wouldn't work
I made some changes to NMS adding a method, and a class, but when I run it on a server, it tells me that the new method and class don't exist. When I run my plugin through luyten, the class and method are there, which signifies its something to do with the server jar (possibly?), does anyone know how to fix it?
changes to NMS in your plugin .jar? what?
nono, I made changes to my spigot jar that you maven import into plugins
i.e
forked spigot
and did you also use that custom spigot version to run the server?
I did not, is that what I need to do lol
yes ofc
you cannot just change a .jar and then expect it to be included in the official spigot
big brain
when you use spigot as dependency in your plugin, it only tells the compiler what methods and classes etc are available at runtime. of course the regular spigot doesn't include the changes you made to your custom spigot version so it cannot work like this
whut
they made changes to spigot's NMS code. it makes no sense to shade spigot into the plugin because spigot wouldn't use those shaded classes anyway
plugins use their own classloader
the only proper way to make the spigot server use your custom NMS classes is to actually run the custom spigot version
use object... placeholders instead i think
it uses that ye
in the method parameter i mean
there are two methods:
formatted(String) and formatted(String...)
ah right
it doesn't know which one you are calling
if both are the same anyway you can simply ignore it
try casting to String[], should work fine
or be on the safe side and cast it to (Object)
as parameter for your "get" method?
pls show your full class, otherwise it makes little sense to guess
i meant this but it doesnt work
no of course not
you have to do it like this:
String[] arr = new String[] { "sus" };
ye so String... converts it to a string array implecitely?
dunno how to type that word lol
no, varargs works like this:
if you define something like this:
public void sth(String... asd);
then it's the same as this:
public void sth(String[] asd);
there is ONE big difference though
ye ik
using the "..." notation allows you to use both syntaxes:
sth(someArray);
// OR
sth(firstString, secondString, thirdString);
in the method, you will however always receive a String[]
cuz you can cast varags to a string array does it mean the compiler casts arguments passed to a string array implicitly?
no wait
you never have to cast the String... to a String[]
so it compiles to sth(String[] str)
it automatically is a String[]
yes, but it also sets a flag in the class file that "str" is a varargs
so it allows other classes to also use sth(string1, string2, string3)
the only difference between String[] and String... is that the latter also allows you to pass normal strings "comma separated"
however, imagine you have this:
public void sth(String asd);
public void sth(String... asd);
and now you do this somewhere:
String asd = "asd";
sth(asd);
now java doesn't know if you want to use the String... thing with only one element, or if you want to use the method that only takes exactly one string
that's why you cast your asd string to either Object or Object[]
if you have an array, you won't get this problem, then it's obvious you call the varargs method
you only get this problem if you have a sth(String) and sth(String...) method
my tip is to simply get rid of the sth(String) method
you will never need it
makes sense ye
Hey, is it possible to run a mcfunction on a spigot server?
good
what is an mcfunction?
wondering the same lol
minecraftfunction
what is a minecraftfunction?
probably yeah
you can use Bukkit.dispatchCommand to force players to run a command
however they need to have permission to use the command
I created a random maze and its being stored in a .mcfunction file. However I dont know how to implement this into a spigot server
as said you can do sth like this
Bukkit.dispatchCommand(somePlayer, "function yourfunctionname");
but that requires players to have the minecraft.command.function permission or however its called
you could simply give them this permission, dispatch the command, then remove the permission again
a bit dirty but I don't see another way to use the function command without allowing players to run ALL functions
does Bukkit.getConsoleSender().sendMessage("/function blablabla") also needs permission?
the consolesender is OP. I am not sure if they have all permissions though
but wait
sendMessage only sends them a message
