#help-development
1 messages · Page 1092 of 1
what is MessageFormat?
public interface MessageFormat {
String format(String message);
<T> String formatObject(T object);
}
google!
oh
lol
that it was gonna be a bukkit thing
@river oracle why is this bad? i dont understand
goofy type paramter
@pine crest people dont like kotlin it looks weird xD
i mean i hate kotlins superfluous semantics
u can do things a googol different ways
w/o a style guide or something; inconsistency is prone
but i dont think it looks weird
if u say that its prob cuz u a basic dev who r only used to C langs
fun main(args: Array<String>) {
println(args.contentToString())
}```
f is for friends?
xD
you can't do String[] in kotlin?
its Array<String>
}```
WAR
no
if you stab him ill stab you
threat :0
i mean i said throw out the window
but I can stab this fellow as well
Just add an infix extension function to array and call it heheXd which prints your array.
Then you can write
arr heheXd ","
And your array will be printed.
Because Kotlin loves standardization and there is no problem in everyone throwing their
arbitrary extern functions on objects. If you say thats an anti-pattern you are lying.
mind you there's a difference between can and should
but yes u can meme kotlin for it
ThrowsThreatException()
I liked writing it. I liked how they handled nullability on compile time, but i would not write a bigger project with multiple devs on that language.
eh I mean would be cool if u could config what features u want
cuz kotlin just fkn dumps everything on u fair and square
cant we all agree gradle is garbage tho?
its the best of the worst
Its... complicated. All build tools are garbage honestly.
anyway its hard impossible to design good build tools
u just have to make sure they're not bad
Lets just go back to using Ant. Or Makefile. If i have to use Makefile to compile javac stuff again, ill simply look for anothe profession. Farmer or sth.
lol

Did someone say defenestration
Im pretty sure you guys talking about shiving someone
Wait, is shanking not a euphemism for having sex?
Whats the difference between shiving and shanking then?
No it isn't
Lol
yes
Shank afaik usually means stab someone
yea blud
Ah, i was thinking about shag not shank...
Fair
@river oracle never answered the question 😦
he knows i will whopp his ass
It's personal preference it should be a string util method imho
Unless you're doing some advanced parsing and replacement p.sendMessage(color(message)) is much more preferable to me
Plus legacy chat sucks :P
i love legacy chat
I hate legacy chat because I have to shade all of adventure for my spigot plugins
yep thats also not very runtime performant
but legacy chat is as concise and tight as my pants
making it quite nice
Legacy serializer with the useUnusualXRepeatedCharacterHexFormat
Fourteen was having a go with this method name kek
Welp spent the whole day with the girl and now it's time to work
it should be the other way around
Hey man she needs attention too
I was about to write "Thats a weird nickname for your hand", but then "the girl" could as well be a pet...
I've tried but she is completely uninterested
Oh boy
Or even worse... someone related
Don't give me that label smile D:
double it and give it to the next person
I got my last gf to study CS, and she is struggling hard rn
Hm?
how many gfs does smile have?
Last implies a previous relationship
Hence why she is struggling because she is no longer with you
none of these words are in the bible
bless you
Unironically he has the same pfp as my boss
Ah, yeah. She started studying and couldnt handle all the attention she got from all the guys there, so she did an oopsie, resulting in me making her a "last" gf.
i downloaded a default one
Her loss, very clear
I bet FeetDevourer is in there
She wants to be an immigration lawyer or a sonographer
alright well I was here to mention how nice the object instantiation in c# is with new() but I guess I'll be back when the feet people are done talking about making gfs or whatever the hell is going on here
She got some financial backing from fafsa or wtv it is, and I'm quite sure she's going with sonography
Those are some very specific job descriptions with fundamentally different profession requirements. What?
Sonographer as in medical sonography?
yes
Immigration lawer has some rather personal reasons behind it, I think sonography is really what she wants to do though
you brought up the bible
i dont exist there
That is so specific
i think 7smile7 needs to coach you guys
Youll find out what you want in the middle of your studies. I originally wanted to specialize in quantum computing and cryptography, but now i went the machine learning route.
neither does c# but at least one of these two are related to the topic of this room
i am turing complete, the bible is not
Did you just type a programming language in my political discussion and philosophy channel? How dare you.
guess we'll just have to talk about TempleOS again then
Weird problem here, config.yml is in resources but not generating in plugins
and HolyC
Did you saveConfig in a place that would actually create the config? Ie: startup or something
saveDefaultConfig()
it doesnt get any simpler
I've never had to do that before?
The config.yml doesnt get automatically exported unless you tell your plugin to
strange, thank you.
now i gotta look back in old plugins to see xD
wasn't using maven before
tortural
Hey, I've been running into a gradle problem where I'm trying to install this dependency, but keep getting .class files instead of .java files (Getting XMaterial.class instead of XMaterial.java).
Yahh
oh then its not normal
Should be able to access XMaterial for utility
Weird thing is some files are in .java form (like XBlock.java) but others are not
My full build.gradle is here https://github.com/CryptoMorin/XSeries but I would guess this is the important part?
repositories {
mavenCentral()
}
dependencies {
implementation fileTree(rootProject.archiveFolder.getAbsolutePath())
implementation project(":API")
implementation 'com.bgsoftware.common.config:CommentedConfiguration:b1'
implementation 'com.bgsoftware.common.updater:Updater:b1'
implementation 'com.bgsoftware.common.reflection:ReflectionUtils:b6'
implementation 'com.bgsoftware.common.executors:Executors:b3'
implementation 'com.bgsoftware.common.shopsbridge:ShopsBridge:b11:all@jar'
implementation 'com.bgsoftware.common.dependencies:DependenciesManager:b2'
implementation 'com.bgsoftware.common.nmsloader:NMSLoader:b5'
implementation 'com.zaxxer:HikariCP:4.0.3'
implementation 'org.slf4j:slf4j-api:2.0.5'
implementation 'org.bstats:bstats-bukkit:3.0.0'
implementation 'com.github.cryptomorin:XSeries:11.2.0'
// Spigot jars
compileOnly "org.spigotmc:v1_8_R3-Taco:latest"
compileOnly 'org.spigotmc:v1_16_R3-Tuinity:latest'
}
hey guys is there any way to detect item place in inventory?
InventoryClickEvent and InventoryDragEvent
thank you
but when I tried this :
protected void onClick(InventoryClickEvent event) {
System.out.println(event.getAction());
System.out.println(event.getClick());
it just returned
[13:26:29 INFO]: PICKUP_ALL
[13:26:29 INFO]: LEFT
Check getCursor for a item
It'll be null or air forgot which one If the cursor is empty
Otherwise it'll contain an item
[13:32:13 INFO]: [ShibaCustomEnchant] ItemStack{STONE_PICKAXE x 1} current Item
[13:32:13 INFO]: [ShibaCustomEnchant] ItemStack{AIR x 0} cursor
Yeah the cursor item return AIR
switch (action) {
case PLACE_ALL, PLACE_ONE, PLACE_SOME -> System.out.println("hello there ");
case PICKUP_ALL, PICKUP_SOME, PICKUP_HALF, PICKUP_ONE -> {
if (slots.contains(slot)) {
event.setCancelled(true);
}
}
}
All place actions just not worked
?jd-s
drawing a blank here bc im stupid
is there an api method i could use to check if a block is like a /normal/ block?
like 1x1x1 bounding box type block
not something without a full block boundingbox like slabs, fences, doors, etc
Unless you check the size of the BoundingBox your best bet is https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/BlockType.html#isOccluding()
yeaahhh i was thinking boundingbox was gonna be the way i had to go
How do I check if the opened GUI is "this one" and no another without checking title? 🤔
How :>?
Great question, hadn't messed with inventories too deeply so I'm not sure, I just know that's what you're supposed to do 😂
🥺
does PlayerInteractEvent not fire if the player is holding nothing in 1.21?
need to be holding an item for right click air
rip
kinda defeated what i wanted to do for a plugin
im guessing the client just doesnt send a packet, rather than spigot not calling the event
ehh ill just pick a random item to be the activator
youtube not work(
And do you know for items in 1.8?
Hi! my plugin runs a block break event, but when another plugin cancels the event my plugin still runs the event. how can I prevent my function from running if another plugin cancels the event?
and way to return if its cancelled. or a tag like ignoreCancelled = false?
Run your event late and just check the cancelled state at the start of your event.
event.isCancelled()
and run it at a priority such as HIGHEST
if a plugin cancels after yrou plugin has run it will never know
and if you do not need to edit things, you can use MONITOR
ignoreCancelled true should also have that behavior? or am I missunderstanding smth
so if (e.isCancelled()) { return } ? will prevent it from running the code if another plugin cancelled the event (GriefPrevention)
BUT do NOT make any changes on MONITOR
if the plugin's event was ran before yours, yes
ignoreCancelled = false
but the main issue here is priority
HIGHEST means it runs later
^^^^
you want ignoreCancelled to true and have a higher priority than gp
^
im seeing some other plugins code using ignoreCancelled = true, which didnt make sense because if we read those words it means yes you should ignore cancelled events... therefor still running my code?
ignoreCancelled = false means that your event will run even if it was cancelled
its a confusing label
yep
lol
find and replace it is
🤣 exactly
So BiggerBukkit
Basically, yes
it just looks at Spigot's API
looks at various pitfalls
improves them
repeat
i.e. for example
for(var res : Helix.scheduler().asyncTimer(SomeGenerator, 5, TimeUnit.SECONDS)) {
// you will get a new "res" every 5 seconds, blocking, useful if you're doing something async, don't suggest doing it on the main thread
}
Helix.scheduler().syncLater(Bukkit::shutdown, 30, TimeUnit.SECONDS);
I'll stop with the examples
do you have adventure support 🙏
I like the scheduler
Oh fuck no kill me before that
at least components?
Yeah obv it's all component based
good
what how come i just know this lmao
Yeah the default is true so most never come across it
It's really not done though
i thought the default is false?
no the default is true
i swear i've read it somewhere
well, not having that being = true cased a dupe bug for me XD. so you guys go check your plugins! claim plugins cancelling the event isnt enough!
okay so, ignoreCancelled = false it means the event will not run if it's cancelled?
false = ignore teh cancelled state and run this code anyway
very
For the record: @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) solves the issue so that your plugin will not run the code if another plugin such as a claim plugin cancels the event.
yep
claim plugins run early (or should) so highest is good
High would also do
For me I do Permissions (LOWEST), Eco/Protection (LOW), Most Plugins (NORMAL)
@EventHandler
PlayerMoveEvent event {
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
PlayerMoveEvent event {
System.out.println("This code will not run")
}
@EventHandler(priority = EventPriority.HIGH)
PlayerMoveEvent event {
System.out.println("This code will run")
}
correct
the fuck kinda syntax is that
xml by the looks
too lazy to write the whole thing lmao
You're not actually cancelling player move event are you?
no lmao, just an example
kek
ah I thought he was talking about the highlighting
I didn't even notice it was pseudo code
whats weong with cancelling player move 😳
Unless it's a /freeze command, everything
wdym
yk like those admin utils
isnt the point of cancelling to freeze the player in place?
one of them being freeze
what else can you do with it
Not anything that's like recommended
such as
preventing a player moving into or outof a specific area
why do you always argue
for
valid
but I still allow looking around and falling down
like y movement is not restricted
only x-z
besides jump boost potion... what would be the easiest way to increase a players jump velocity?
not to say its an XY prob bc... well i havent even written any code to test, i more so just want to consider my options to try
jump_strenght attribute
wouldn't be xy anyway would it? you had an idea and asked a question for it
not sure, im not too keen on what classifies as XY or not
no jump strenght should be usable on players
idk wiki says its horse attribute, can try later ig
hmm I thought that may have been something changed in 1.20.5
Gravity
Heyo,
I'm currently fixing a cloud system and came across a method for class reflection with CraftBukkit. Here's an example of the method I'm using:
private Class<?> reflectCraftClazz(String suffix) {
try {
String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
return Class.forName("org.bukkit.craftbukkit." + version + suffix);
} catch (Exception ex) {
ex.printStackTrace();
try {
return Class.forName("org.bukkit.craftbukkit" + suffix);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
return null;
}```
It seems like this method was working correctly to get the version, and I found a similar approach in this thread (https://www.spigotmc.org/threads/reflection-nms.407785/). However, it appears that with Minecraft 1.21, getPackage().getName() now returns org.bukkit.craftbukkit without the version part.
Has anyone encountered this issue or found a fix for it? Any suggestions on how to properly extract the version in the newer Minecraft versions?
Ah sorry, it isn't 
?jd-s
Gravity attribute could maybe work
declaration: package: org.bukkit, interface: Server
Yep, just found this thread https://forums.papermc.io/threads/important-dev-psa-future-removal-of-cb-package-relocation.1106/
just add/multiply velocity in the jump event?
no
i forgot to specify im trying to just increase the players jump, not a horse
fam did not read the convo
oh there is a generic jump
mc fandom page has like 10 attributes mc wiki has like all of them lol
pog thats literally what im working in rn
All the new attributes in 1.20.5 and 1.21 are great
how certain are you with that coll
weird that player movement speed attr is 0.1 by default
i thought it was 0.2 for some reason
and jump being 0.4199999999*
hmm
is it not just 0.42⁉️
guess I missed its consumption
Gravity one is 0.05 default
Yeah idk game is weird
You can check with /attribute @s <attribute> base get
Assuming you haven’t messed with the base
indeed coll is correct lol, I was confused while looking through client code because the auto jump feature still makes use of the specific JUMP_BOOST mob effect
for whatever reason
Mojank
I like how Mojang did the equivalent of pushing a major update on a Friday with 1.21
And now they are pushing 1.21.1 with “critical exploit fixes”… several weeks later
tbf that exploit simply wasn't found
Hey they said plural fixes!
Tbf idk what exploits there were
I remember seeing some weird dupe glitch in creative… but that’s creative so who cares
remember kids, never push updates on a friday
kek
what
they rather named it glitch fixes. when ctrl dropping from your inv some items simply got lost 💀
thats one mindset
Rip items
be like nintendo, push the final product
Oh yeah .8 not .5
waiting for mojang to add this

tried implementing the wesdj anvil gui api, I have pasted in the repo & dependency into my pom.xml, I can problemfree reload mvn, but whenever I try to compile my plugin it gives me this error?
You need a higher java version in your project
60 - 44 means you need java 16+
The java version is defined in your pom
In top you defined a property java.version
I cant get excited over 21
The leap from 17 ist just random stuff it feels like
.
did you run a clean first?
nah it so long since I've been doing plugins
I forgot where the mvn clean install is located
latest compiler plugin version is 3.13.0
idk if that is related, not a maven expert, but yea
Should def go on 3.10+ for java 21
I ran this
and after I ran the normal install
and I still seem to get the error
Update your maven compile plugin to 3.13.0
Update the maven shade plugin
and where do I do that?
You set it to 3.6.0
the guy just said I should put it in 3.13.0?
That's the compiler plugin
That was the compiler plugin
maven-shade-plugin
Hey, i'm trying to use nms to change or set blocks because if I use Bukkit API this happens:
maybe show code
1s, i'm developing the question xd
I've tried setting the block with nms but I get stuck with BlockState
thats not a lot of code buddy
it is not
doubt that those four lines are causing a 4% tick usage
Oh you mean the non nms code?
yea 1s
private boolean isFullyGrownCrop(Block block) {
if (block.getBlockData() instanceof Ageable ageable) {
return ageable.getAge() == ageable.getMaximumAge();
}
return false;
}
private void replenishCrop(Block block) {
long timeToReplenish = plugin.getConfig().getLong("tools.hoe.time-to-replenish") * 20;
Material cropType = block.getType();
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
block.setType(cropType);
Ageable ageable = (Ageable) block.getBlockData();
ageable.setAge(0);
block.setBlockData(ageable, false);
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
ageable.setAge(ageable.getMaximumAge());
block.setBlockData(ageable, false);
}
}, timeToReplenish);
}
}, 1L);
}```
CraftBlock.setType looks scary
it is ServerLevel.setType
wheres the event handler
How many tasks are you scheduling
those two tasks just seem scary
Every time a crop is broken
🙃
cant you yield the thread for timeToReplenish in the spawned task
Have a single task
And use a priority queue
holy shit thats a lot of code
Or just a normal queue if the respawn time is the same for all crops
blocking queue maybe?
Normal queue should be fine
yea, that's why i didn't send all xd
but doubt you can yield the thread in a task and continue execution afterwards
Peek first -> check if it’s time to replenish -> poll and replenish -> repeat
As soon as you find one that isn’t ready to replenish you break out of the loop
I didn't understand it
I get this error now
Isn't that the same?
Can I use packets instead?
You could
Send the packet that the crop is age 0 and when the replenish time is off send again the packet where is fully grown
Big gens server have packet based crops
Is there any way I could see packets or something else to have an idea on what to use for this? xd
wondering what server arch wynncraft usess
I mean, the methods
ProtocolLib/PacketEvents
I've heard ProtocolLib is bad optimized, should I use PacketEvents instead or is it the same?
Well, thanks i'll check that
.onClick() maybe?
I've just read about player.sendBlockChange(), Can i use that instead of setType and setBlockData?
Something like this:
private void replenishCrop(Block block) {
long timeToReplenish = plugin.getConfig().getLong("tools.hoe.time-to-replenish") * 20;
Material cropType = block.getType();
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
//block.setType(cropType, false);
Ageable ageable = (Ageable) block.getBlockData();
ageable.setAge(0);
//block.setBlockData(ageable, false);
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendBlockChange(block.getLocation(), ageable);
}
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
ageable.setAge(ageable.getMaximumAge());
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendBlockChange(block.getLocation(), ageable);
}
//block.setBlockData(ageable, false);
}
}, timeToReplenish);
}
}, 1L);
}```
would probably have one dedicated task that polls from a "task" queue
but tasks arent preemptive so that goes meh
priority queue
how would i send a message that doesnt get shown in console? like if i use Bukkit#broadcastMessage sometimes i dont want the output to be displayed in console
would i just have to get onlineplayers and send messages individually instead..?
the case i have here is that im trying to make auto announcements, however using bukkit#broadcastMessage just clogs console.
for each Bukkit.getOnlinePlayers .sendMessage
still logs to console
it does not
does someone know how to add custom nbt into an item in new 1.21
..?
pdc as per usual for custom data on items?
I mean, in what context are you doing that
broadcast will indeed print to console
but sendMessage on each online player will not
No it shouldn't
so you are failing somewhere else
for (String line : announcement) {
for(Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(ChatUtils.processMessage(line));
}
}
What's ChatUtils
my own class to translate hex color codes, gradients, and centering messages
Ah okay, what is it printing to the console
the announcement in config.yml
however i just fixed it by fully restarting the server and not just plugman reloading lul
common plugman L
Ah okay true lol
can somebody help me please🥹
idk why people are still using that
i swear
^
Wait is there actually issues with plugman?
because restarting the server every minor fix is a pain...
interestingly enough, never had issues reloading
I use it so I don't have to /reload during development
I mean, reloading plugins itself is braindead
still braindead
No lmfao what
you are praying it doesn't break
Ok and if it does the off chance, restart
or you just hot reload
I've never had something break with reloading :3
and live a happy life
how do i do it
yes it is logical to wait a minute for the server to load for 5 seconds of testing just to do it again 3 seconds later
?pdc
idk man, hot reloading exists for a reason
Isn't that exactly what plugman does anyways
and does not suffer the same downsides a full classloader destruction has
no
hot reloading is completely different from plugman
like in the ide?
Yea
only used it once, then i just made sure my reload impl didnt break lol
with JBR and some fun flags you can get pretty damn far for what you can hot reload
Oh okay. True. Still though during dev it doesn't hurt to do that. Worst case scenario you haev to restart once every 20 reloads
yeah
but shit just broke because reloading is flawed
its java shit regularly breaks with no obvious errors
True, I've never had that happen to me in my entire life so I can't relate
just make your reload impl works and you dont need hot reloading 

How can I disable collision between players on Spigot 1.18.2? I need to write such a plugin
I looked into it, it does look more convenient
can you send a link over for that?
if you use JBR, you can also pass -XX:+AllowEnhancedClassRedefinition -XX:+AllowRedefinitionToAddDeleteMethods for some extra fun
damn
You learn something new every day I guess
Call that "absolute hotswapping"
You can do that with code changes?
Oh, well yeah. I thought you meant a ./mycommand reload
or a whole server reload
i mean, you can detect a server reload, but you can't detect a plugman reload; and even then, case in point, the reload shown above literally didn't work at all and the whole broadcast thing was still from the old plugin xD
hot reloading is far safer than scuffed plugman or server reload solutions
Making me restart my server now making sure everything is working fine lol
"In 1.21, when I added the code 'Objects.requireNonNull(this.getCommand("status")).setExecutor(new command());', I got a NullPointerException error. Is there a workaround for this?
register your command in plugin.yml
I have already added this.
- You do not need to write a plugin for this I believe
- Teams have option to disable collisions
the jar on your server you are testing is not the same as your current code
mvn clean package
and do not replace teh jar on a running server
does player metadata get purged by default if the plugin that assigned it reloads..?
or on a /reload
depends what you mean by metadata
Metadatable?
ah yes the builtin memory leaks api
I just set up that hot reload stuff. So useful wtf, especially using the debugger
metadata is garbage
what should i use instead then? all im doing is this
for(Player player : Bukkit.getOnlinePlayers()) {
player.setMetadata(FLY_METADATA_KEY, new FixedMetadataValue(this, false));
}
with a check to see if the player can fly or doublejumps
is there a better alternative to using metadata?
?pdc
A literal Map or even Set you can throw players in. PDC would also be fine, but that one persists over restarts and can be a hustle to manage.
persistent over restarts is what im looking for actually
what are the downsides of using pdc for something as easy as this
then i just switch to that, i didnt realise you could use that on players
all entities, worlds, chunks and any block with a TileEntity
Does anyone know a hashtable-based implementation of List<T>?
The ordering semantics are irrelevant (though the iterator is still required).
like a set but with duplicates?
No duplicate entries are allowed
huh
So you're trying to iterate the hashmap? I'm confused
ABI compatibility.
Some moron decided it's a good idea to use a List as a Set - even though calling List#remove(Object) on a list of 400k+ elements is obviously an extremely bad idea
🍴 time
I'm too lazy to write the ASM transformers for that - especially since I need to ensure compatibility and stuff
add(int, Object), remove(int), get(int) and all other index-based methods are not called.
The iterator however is being used.
You could use a LinkedHashMap if you want to iterate over it
If I'm understanding what you're asking
ABI compatibility doesn't allow me to just alter the type of a field though
If I had my way I'd use ConcurrentHashMap#newKeySet(I)
Oh true. I'm not sure then
Well I shall implement it myself then
j.l.r.Proxy :copium:
when working with 7's inventory guide, should an inventory be unregistered upon closing it? or when should it be unregistered?
i fsr realized i never used the unregisterInventory-method lol
?gui
yes
oh oops
not removing it when closing will only give memory leaks
remove it when you know you are not going to use it anymore
well
since it's a clickgui it should be unregistered the moment it is closed, no?
public void handleClose(InventoryCloseEvent event) {
InventoryHandler handler = this.activeInventories.get(event.getInventory());
if (handler == null) return;
handler.onClose(event);
this.unregisterInventory(event.getInventory());
}
what would be the difference there instead of registering it again?
a choice between memory use and performance
Constantly (un)registering listeners on runtime rebakes the handlerlist, which is not exactly cheap when a lot of listeners are registered.
Register a single listener for all your GUIs and never unregister it. Just delegate the events to your GUIs.
^
wait what? i was never talking about a Listener o.O
i just felt the urge to type ^
also the man himself, flogestankbratwurst 🇩🇪
i'm a bit confused
it's about the GUIManager#unregisterInventory method
to remove the inventory/handler mapping from the map
Ah i see
i can't see that it makes much of a difference, does it?
and if it did, i can't really comprehend how another player would get the same instance instead of just registering it again since in openGUI it just registers a new one
This tutorial is not exhaustive. The openGUI method is really just a helper method. But when used, you should 100% unregister the inventory when its being closed.
You can make a distinction for static and dynamic GUIs. A GUI that always looks the same, can be registered once, and then opened for multiple players.
But most GUIs have usages specifically tailored to the viewer. Which means you need to create a new instance, every time someone opens this GUI. And in that case, you should unregister it when its being closed, as its completely unique and wont be reused again.
yes, a use and yeet kinda deal
lol
you know you sound like a bot right?
anyways yes I am working on my plugin
but im actually moving to paper so yeah...
im just here when I have spigot related questions
(which is probably like a lot of other people ig)
wait is vanilla 1.21.1 out?
no
md just time travelled
that was rc1
i know
what did they do? rework item meta again?
Is spitgot a launcher
spitgot ain't a launcher
yes, you must download fabric api along with it
its a server
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
something they way you say stuff like that pisses me off
I have fabric installed with feather client

hey @young knoll probably a selfbot
mods can someone ban this bot?
not you
Someone needs to kick that bot
Hey im wondering if this is the place where i can ask for help? about minecraft servers
?kick @rigid siren bot
Done. That felt good.
if you are a developer yes, otherwise #help-server is for help with server administration
Hey, I'm trying to make players swim x% faster using the PlayerMoveEvent, but somehow I'm swimming extremely slow. Can someone please help me understand where my issue is?
@EventHandler
public void onMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
if (!player.isSwimming()) return;
Vector velocity = player.getVelocity();
player.setVelocity(velocity.multiply(1.05)); // supposed to be a 5% increase
}
probably because the vel gets applied after the event
there's also a lot of client-sided prediction going on with that
hmm, do you have any idea on how I can make this work?
but even then, I don't see how a positive change in the velocity would make me slower
Something about the new velocity only being applied next tick too 🤔
it really shouldn't matter that the velocity is only applied in the next tick
The velocity is greater than what it was without modifications, so I should be moving faster, not slower, no?
?learnjava
For Beginners:
Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/
For Intermediate to Advanced Learners:
Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/
Practice and Hands-on Learning:
Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/
Free Resources and Documentation:
Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/
Community and Support:
Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/
Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉
I'm already learning java, thank you
I’m creating a Minecraft server and I’m having trouble with making the scoreboard balance format look good. Currently, I’m using the vault_eco_balance_format but I’m not really satisfied with it. I’m looking for a placeholder that shows values like “1.25m” instead of “1m.” If anyone knows how to fix this, please help me.
Still the Wrong channel
what
?kick @blazing ocean
??
oh mb
i didnt mean it for you
my friend is learning java
#bot-commands
so i wanted to send him these resources
Oops lmao
same lol
Is it possible to send the server a broken block packet?
send the server?
from the client? yes
but this is spigotmc, a server software...
I'm sending packets to show the player the crop has been broken
what the bug!
but when the crop is not grown
looks to me you are sending block updates/age of teh crop. and yoru code sucks
The code still says it is grown
The server sends a packet right away after and tells the client that it has not been broken
@Override
public void replenishCrop(org.bukkit.block.Block block, HarvesterTools plugin) {
long timeToReplenish = plugin.getConfig().getLong("tools.hoe.time-to-replenish") * 20;
World world = block.getWorld();
ServerLevel nmsWorld = ((CraftWorld) world).getHandle();
BlockPos blockPos = new BlockPos(block.getX(), block.getY(), block.getZ());
ServerLevel serverLevel = nmsWorld.getLevel();
final LevelChunk levelChunk = serverLevel.getChunkIfLoaded(block.getX() >> 4, block.getZ() >> 4);
final BlockState blockState = levelChunk.getSection(levelChunk.getSectionIndex(block.getY())).getBlockState(block.getX() & 15, block.getY() & 15, block.getZ() & 15);
//BlockState blockState = levelChunk.getBlockState(blockPos);
BlockState newState = blockState.setValue(BlockStateProperties.AGE_7, 0);
//nmsWorld.setBlock(blockPos, blockState, 0);
ClientboundBlockUpdatePacket packet = new ClientboundBlockUpdatePacket(blockPos, newState);
for (Player player : Bukkit.getOnlinePlayers()) {
CraftPlayer craftPlayer = (CraftPlayer) player;
ServerPlayer serverPlayer = craftPlayer.getHandle();
serverPlayer.connection.send(packet);
}
Bukkit.getScheduler().runTaskLater(plugin, () -> {
//nmsWorld.setBlock(blockPos, grownState, 2);
blockState.setValue(BlockStateProperties.AGE_7, 7);
ClientboundBlockUpdatePacket grownPacket = new ClientboundBlockUpdatePacket(blockPos, blockState);
for (Player player : Bukkit.getOnlinePlayers()) {
CraftPlayer craftPlayer = (CraftPlayer) player;
ServerPlayer serverPlayer = craftPlayer.getHandle();
serverPlayer.connection.send(grownPacket);
}
}, timeToReplenish);
}```
also, i think blocks breaking isn't a C2S packet
private boolean isFullyGrownCrop(Block block) {
if (block.getBlockData() instanceof Ageable ageable) {
return ageable.getAge() == ageable.getMaximumAge();
}
return false;
}
I am comparing two ItemStacks using isSimilar(), and I want it to return true, but it is returning false. These are the two ItemStacks being printed. The second on is the base item from my ItemManager class, and the first is a stack of it from the player's inventory.
ItemStack{POTION x 26, POTION_META:{meta-type=POTION, display-name={"text":"","extra":[{"text":"New Make Scotch","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"red","bold":false}]}, enchants={minecraft:luck_of_the_sea=1}, ItemFlags=[HIDE_ENCHANTS, HIDE_ADDITIONAL_TOOLTIP], max-stack-size=64, custom-color=Color:[argb0xFFC0C0C0], custom-effects=[]}}
ItemStack{POTION x 1, POTION_META:{meta-type=POTION, display-name={"text":"","extra":[{"text":"New Make Scotch","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"red","bold":false}]}, enchants={minecraft:luck_of_the_sea=1}, ItemFlags=[HIDE_ENCHANTS, HIDE_ADDITIONAL_TOOLTIP], max-stack-size=64, custom-color=Color:[argb0xFFC0C0C0]}}
The only differences are the stack size, and that the one in the player's inventory has custom-effects=[] at the end. How can I fix this?
im pretty sure all the client does is send block breaking progress
adnd the server does the rest
dont do that
?pdc
compare ids
use pdc to recognize your custom items
ok
why does it sucks
#brokies
gawk gawk gawk
otherways the bukkit api is just so laggy
cuz it doesnt work properly
can you use the same NamespacedKey for all your custom items?
bukkit is a bad api
That's why i'm askinglol
"help-development"
because its not working
i just like complaining
first off, why are you using packets to age a crop?
only sigmas would understand
Bukkit api is too laggy
its not
It is
what..
yes
bro.
like 'id'
spark consume was about 7% in 5seconds
how is an api laggy
It does unnecessary checks
#relatable
It consumes a lot
okay bro
theyre definitely unnecessary.
Your code may show in spark that its laggy, but its yoru code not the API
and it's not your misunderstanding of what they do
🤑🤑🤑
in any case, you should use the **Ageable **interface to set a crop's age
I was doing the code with setType and setBlockState then tried with sendBlockChange
Consumed double or triple what is consuming now with packets
I've done that already
But the consume was really high
you are changing the state of a single block. the API is not laggy for that
unless you're doing it for thousands of blocks
Unless you do that 30 times a second
setBlockState was consuming a lot for that
why do you need to do that..
don;t do it 30 times a second then
a crop replenish system
...
you're probably doing something wrong if you need to do allat
^
which is why yoru packets are also bugged
how are you doing something more than there are ticks
That's why i came asking
I mean, if two players are farming?
Or 4
what do you want to do?
its still 20tps
a crop replenish system
that gave me a lot of information, thanks!
so making the crops grow faster after being harvested?
You can see that in the video right?
The crop basically grows again
I don't see how can that lag a server
you can create a scheduler for each crop block
When changing the blockdata via packets, you have to make absolutely sure the server doesnt screw around and resend the data with a different state.
Because this will happen a lot.
and -n seconds each time is harvested
when you are using setChangeState many times it uses a lot of server thread
declaration: package: org.bukkit, class: GameRule
it will grow faster
Yeah, that's what I came asking, however they've came with this
The proper way would be to have one single task for all your crops and a PriorityQueue to poll from
why is this chat so cursed
I'm not making a crop grow faster...
I'm replanting a crop and making it fully grown after 3 secs
it looks like thats exactly what you are doing
Why use packets for that?
that's exactly what "making it grow faster" means
but not whith a gamerule?
why not?
randomTickSpeed?
So don;t use packets, use the API and actually update teh block
Because i've tried using setBlockState Ageable sendBlockChange etc
you send nothing to the client. just let spigot do it all
However all this used a lot of server thread
Have you seen the video?
sendBlockChange is fake
Mhm
I just want the age to come from 0 to 7
Ik
just make the randomTickSpeed really fast then
Just like i'm doing rn packets.
I just asked for a way to let the server know the age is 0 but using packets or tghat doesnn't use that much serverThread
I cant imagine that this would even come up in the timings. Maybe at 0.01% of the game tick.
A single player would never be able to create lag, even if you where to constantly break plants with 10 players on parallel.
Actually there are many lobbies maps etc that if you don't have the randomTickSpeed in 0 they break
Let me send you a spark profile 1s
I just achieved what you want to do
in 2 seconds
with a minecraft command
i dont see why this necessitates a plugin, unless other plugins change vanilla behaviour
Man, look at this
Maybe he wants to have control over this behavior in a custom way.
thats not lagging
its spending most of the time waiting
the server is under performing that it spends most of the tick waiting
Looks like it does literally nothing. The most expensive call here is to Economy.add()
.67%
low quality but still
That was bugged
in 37 seconds
in a few years spark will be .. deprecated.. and then someone will think of spark Plus or some crap and then users will be warned that spark is no longer supported BLAHBLAH XD
The crop was planted again automatically
Well, it doesn't look like he does from the video he sent
and cannot use the gamerule you said because many custom maps break when you don't have randomTickSpeed 0
so just not
I'll try to figure it out myself
listen to block break event, then
Block block = ...;
if (!(block.getBlockData() instanceof Ageable ageableBlock)) return;
age.setAge(age.getMaximumAge();
block.setBlockData(age);
probably persistent
no reason for it to be changed
I believe you haven't read any of my messages
pretty sure chunks save entities
?
you don't want it to run instantly, yes?
use a bukkit scheduler?
Here is my proposal if you want to actually restore blocks on your server:
record RestoreData(Block block, BlockData data, long time) implements Comparable<RestoreData> {
@Override
public int compareTo(RestoreData o) {
return Long.compare(time, o.time);
}
public void restore() {
block.setBlockData(data);
}
}
public class BlockRestoreTask implements Runnable {
private final Queue<RestoreData> restoreQueue = new PriorityQueue<>();
@Override
public void run() {
long currentTime = System.currentTimeMillis();
while (!restoreQueue.isEmpty() && restoreQueue.peek().time() <= currentTime) {
restoreQueue.poll().restore();
}
}
}
You create one restore task and simply throw blocks you want to restore in there
if I'm storing it as a string in a config file and getting it when the server starts to check for an entity and it is returning null, is the problem that it isnt persistent?
but you are still setBlockData
using*
I'm not sure, but entities are persistent. Maybe entity hasn't been loaded? Entities are stored in chunks from what I know
which is more consuming that using packets
why do you care about performance so much lmao
you're using java dude. java.
(real)
what?
because if you fire that event many times can become laggy
Sure, this is the approach for actually changing the blocks that need to be restored.
You can use packets, but be prepared for hundreds of lines of code to ensure consistency for your state.
the api uses packets too though
Man, 2Hex just stop
okay bro sure ☠️
so you basically want to do exactly what the api does?
also you sending packets will seriouly mess up if there is any interaction with the block while you are sending update packets
that was my first question 😭
I came asking a way to solve that
don't do it
save the state yourself then
use teh API
What happens if you leave the chunk and come back? The server will send the entire chunk data. You need to be prepared for that.
If a player right clicks a broken crop, it will also be sent by the server again.
You will have to write a lot of code if you want to handle this with packets.
you can not get around interacting with the block during you sending packets
just update the block via the API and leave Spigot to update the client. There is no better way
When 5 people will start farming the server will notice that
That's my concern
no they won;t
why?
With proper code it shouldnt
water flowing will be a heavier load than that
5 people is crazy
I was just setting BlockStage 2 times and consumed all that
depending on teh server, 25 players all breaking multiple blocks at once MAY be noticable... slightly
My problem is I'm doing a lot in that event
then don't
Math, retrieving from PDC etc
And how should I do my goal if I need the event?
so far all you have shown is growing crops faster
troll
Because that is what i'm doing rn
Hey can someone tell me why not all classes are contained in the remapped-mojang jar which are present in the acual server jar
Show your code and we can give you some hints on how to improve it
?bootstrap
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
I'll send full code of what I have rn (It may not be optimized or pretty as i'm working on it)
if you look at CraftBlock.java
then the checks aren't for nothing (obviously)
what here could cause any issues?
tile entity cleanup?
there's no way IBlockData#hasBlockEntity makes that much of a difference
white theme
default theme*
is causing issues
it doesn't use any server thread
Its hard to read this code as you have created an uber class. The maps shouldnt be in there, and most of this code shouldnt be in your listener.
Yeah, as I said it was because I'm working on it, had in mind to change the code to make it more readable, sorry
sorry i dont want to annoy
But one thing that can be improved right away:
e.setCancelled(true);
if (!ToolUtils.isTool(itemStack)) {
if (plugin.getConfig().getStringList("farming-worlds").contains(world)) {
e.setCancelled(true);
MessageManager.miniMessageSender(player, plugin.messages.getConfig().getString("wrong-tool"));
}
return;
}
Dont double cancel the event and dont read from configs on rumtime.
Also calling contains on a List is not optimal.
?bootstrap
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
should I run a for loop in the list then?
sorry what is meant with bootstrap jar
also, probably use Map#putIfAbsent(key, value)
And i'll change the config
instead of this
In short: Dont rely on the server jar. Use maven and setup your project using it as a dependency manager.
true, will look that
Reduce your nesting. I usually dont go deeper than 2 nests.
yeah i am doing it but why does the dependency remapped-mojang dont contain all classes present in the acual server jar?
I tried actually, but because of the checks it was difficult, I think if i divide the code in different classes that will be solved
and you probably shouldn't be directly accessing your config
Probably
An example would be PlayerConnection in package net.minecraft.server.network
Yeah, however as it didn't show in spark I didn't give much importance
Thanks
Are you not remapping?
i remapp before every compile with the maven plugin md5 provided
and use this dependency <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<scope>provided</scope>
<version>${remapped.version}</version>
<classifier>remapped-mojang</classifier>
?nms
Maybe let us know your actual root problem
Does your IDE not resolve the classes? Do you get runtime exceptions?
so my main Problem is this exeption Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.server.network.PlayerConnection.k()" because "var0.c" is null
Are you making NPCs
yes
That isn't a mapping problem
That's a your code problem ^^
but i dont know how to fix it and wanted to go about trubble shutting
oh
Next time just tell us your actual problem 😅
i think that can only be done by using reflection right?
The issue is that the server can't send packets to a player that doesn't exist
hahahah
makes sense
Nope, if you use nms then you can just set it
Well it doesnt send any packets to the fake player anyways. The main problems are the properties embedded in this connection, like the players ping
What version are you on?
i am on 1.20.4

