#help-development
1 messages · Page 1114 of 1
fuck it
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous usernames, global display names, and server...
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
well no custom commands shown here ig lol
?uptime
I have been up for: 18 days, 9 hours, 50 minutes, 12 seconds (since <t:1723067352:f>)
damn bro should get some sleep, up for 18 days
almost as much as me
damn illusion 😔 think about ur health
the guide sets the location for the npc in the first code block. i can't really find any method in the ServerPlayer class for that, wtf
?cc list in #bot-commands
thanks rad
u got the names for the packets and stuff u used somewhere bc just trial and error is a bit depressing and i feel like not very efficient lmao
@hybrid turret about your menus
I suggest you this video https://www.youtube.com/watch?v=e80NO9Pgz7s kody simpson makes very good videos and it seems to me that his menu system is very similar to yours
oh aight imma give it a watch
could i keep a chunk loaded by placing an npc in it?
Probably not, but you can use plugin chunk tickets
oh interesting
so when would this ticket have to be added? once and it's loaded forever?
(until the ticket is removed)
That is how I assume it works, never used them.
Not sure how they persist over restarts btw.
yeah that's not gonna be a problem
it's jut for a small private server so i'll just create a hashmap and either gson it or just store it via yaml
probably with coordinates or something
for getting the chunk
(just theory, no idea if that's how it works)
tryina remember... does spigot have some inbuilt database manipulation?
no, just java
why is yaw -180 to 180 and not just 0 to 360
mafs
probably because of https://en.wikipedia.org/wiki/Atan2
intimidating
hi, does anyone know?
@worldly ingot You could check FishHook#getHookedEntity()
like check this every second and if its not anymle then cancel the effect? or how
declaration: package: org.bukkit.event.player, class: PlayerFishEvent
Pretty clear here tbf
If that works for it
i mean, when the Player ffor exsmple goes far the hook breaks and no thing gets called i testex it
sorry im typing from my Phone
Well you can always just have a task follow it after the caught event
u mean this?
i mean i tested it that every time the event would be called it would msg me the state
it didnt in many cases
hi
How do I add the Check for Updates feature in my plugin?
How To Remove Death Animation & Particles ?
Have entity damage event, check if it would die from said damage, cancel the event and remove the entity instead if killing it.
Might break other plugins that depend on the entity death event
I assume the answer is no but is there ANY hacky way to achieve the
void setCooldown(@NotNull
Material material,
int ticks)
On different items but use the same material under the hood.
no
if you have a resource pack
I do.
Then yeah custom model data
Not yet, wait for the next version, cooldown groups will exist.
Hopefully we get an API with that :)
Right, would calling the death event with proper cancel logic in the damage event work ? :D
Probably would have other side effects.
You shouldn't call bukkit events manually
That's not supported and might break other plugins even more since the player isn't in the right state
cooldown groups 🙏
Is it possible to remove the upgrade text, when the trim still put on
I ran remapped buildtools for latest but i maven won't let me input the correct version in the dependency in the pom.xml
could there be any other reason?
Did you reload your pom
yes
I take it you forgot to reload the pom
i mean i clicked the reload button IJ showed me every time
now i manually clicked the reload button in the maven tab and it worked
are they different?
no
weird
how can I collaborate with someone on spigot to work on the formatting of a resource page?
any ideas?
please help me with this error
#help-server in the future, but this seems like an issue you should be sending to ItemsAdder as it's a bug in their plugin
u wanna fite me bruv?
I'll shank ye
I'll hammer ye
I'll give you the good ol' 1-2

uh oh dev fight
1-2 hugs*
lemme get my camera
🔪
I like lynx better
🎥 yup go now
WORLDSTAAAR 👊
can i somehow get the playtime of a player on the server?
declaration: package: org.bukkit, enum: Statistic
would anybody here be aible to help me with nms custom entity registration(spigot 1.12.2) . I am not familiar with this and I tried just copying some code from people but It ended up not really working. What I want to do is make a custom nms armorstand entity that will stay even after the server restarts
You will need to remove the entity on chunk unload
and the spawn it again on load
Do not try to inject your entity to a registry
(but it's fun to do)
until the client can't join
I think that is the way I tried doing it before, but what are the downsides of this?
the easiest way to remove it is just to set persistent to false
It's a lot more complex and you risk breaking the client
since it doesn't know what your entity is
Edit the packet to change the entity id /j
I don't really understand to be honest. If I use your method will I need to manually resummon all the entities in my plugin somewhere?
If I want to disable the default behaviour of an event until the user does something and then enable it back, how can i reach that?
Anyone know how to give yourself a random effect?
./effect @s <how do I make this random?>
Sounds like a question for #help-server
yes
you save and resummon the entities on your own
use an if statement
that checks if your event is enabled for your player
???
You store somewhere (like a Set) if the player has it enabled or not and then only cancel the event if it isn't
Ok, thanks bro
I love injecting my own classes into private final registries
Hello dear people, can someone help me please? This code is supposed to update a sign at a specific location. I made sure that there was a sign at the given location but it's not updating fsr. Does anyone have an idea? It's on 1.12.2
Bukkit.broadcastMessage("ERROR");
Block block = loc.getBlock();
if(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) {
Sign sign = (Sign) block.getState();
sign.setLine(0, "§4§l[ERROR]");
sign.update(true);
Bukkit.broadcastMessage("debug1.");
} else {
Bukkit.broadcastMessage("debug2");
}
}``` The message "debug1" was broadcasted but the sign didn't update
I tried using this resource
https://www.spigotmc.org/threads/1-11-2-1-12-class-for-easily-registering-custom-nms-entities-items.235431/
but it didnt work maybe because it was 1.12.2 but idk
I kept getting like skipped entity or something when enabling the server
i'm trying to display the player's playtime on the sidebar scoreboard but it doesn't even show up. am i missing something?
private void registerScoreboardPlaytime() {
ScoreboardManager manager = Bukkit.getScoreboardManager();
assert manager != null : "Scoreboard manager is null";
Scoreboard scoreboard = manager.getNewScoreboard();
Objective objective = scoreboard.registerNewObjective("playtime", Criteria.statistic(Statistic.PLAY_ONE_MINUTE), "Playtime");
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName("Playtime");
Bukkit.getScheduler().runTaskTimer(this, task -> {
List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers());
players.forEach(player -> {
Score score = objective.getScore(player);
score.setScore(player.getStatistic(Statistic.PLAY_ONE_MINUTE));
player.sendMessage("Your Statistic has been updated.");
});
}, 0, 60 * 20);
}
No errors
I don't see any player.setscoreboard method being called?
Im a but rusty on spigot but don’t you have to set the block state after modifying
hope that fixed it lol otherwise Idk im not that experienced
someone?
😿
Have you tried adding item flags
oh i just set trim show_in_tooltip:false
Apparently I can't change the content of a cartography table that was opened with code?
for instance, the following code is not working:
Inventory gui = Bukkit.createInventory(player, InventoryType.CARTOGRAPHY); // Setting the owner as null doesn't have any effect.
player.openInventory(gui);
gui.setItem(0, new ItemStack(Material.STONE)); // This is the line that is not working
However, it does work with other types of inventories such as BREWING and it also works when the player opens the cartography menu manually. Am I doing something wrong?
Make sure Spigot is up to date
I used the latest stable version from the buildtools: 1.21.1-R0.1-SNAPSHOT (Exact same version as in the pom dependency)
it needs to be the base64 encoded texture property
Hey guys.! Im working on a sustem but i need some help.
System Description:
This system tracks the damage taken and the remaining hearts of players in Minecraft. It records each player's starting heart count (defaulting to 10 hearts) and monitors the damage they receive. When a player takes damage, their remaining hearts are updated, and the total damage taken is tracked. Upon a player's death, the system calculates the difference between their starting hearts and their remaining hearts to determine how many hearts were lost. This amount is then reported to the killer, indicating how many hearts they effectively took. Additionally, the system can also show the remaining hearts of the deceased player.
https://pastes.dev/23x2Eut85m
There is more than one build for 1.21.1
so make sure it's up to date
run /version
oh wait, no-
I was wrong
The problem is, when one player kills another player,
Shows the remaining hearts of the player who killed the deceased. This is correct.
However, I cannot determine how many hearts the killer took from the player he killed. For example, more than one player can attack a player. The last person to kill will send a message to the person who dealt the final blow, and I want this person to keep track of how many total heart rates the dead person took and report it to the killer.
Could you help me with this?
[19:01:17 INFO]: This server is running CraftBukkit version 4300-Spigot-a759b62-7070de8 (MC: 1.21.1) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
[19:01:17 INFO]: You are running the latest version
Now if you want to get the texture from a players uuid you can simply use the following methods:
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Bukkit.html#createPlayerProfile(java.util.UUID)
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/profile/PlayerProfile.html#update()
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/meta/SkullMeta.html#setOwnerProfile(org.bukkit.profile.PlayerProfile)
I guess you can report it as a bug
?jira
will do. Thank you
uh
mfnalex
help
isbroken
got this from you
however, when a guy custom made a head and sent it's base64 to me, this happened
the url provided here is valid
wait why are you using reflection to access those methods
At least use a MethodHandle
static final Methods are just as fast
Which ItemFlag hides this text?
I just do ItemFlag.values()
hide attributes
anyway, does anybody know how I can change the title of a gui?
declaration: package: org.bukkit.inventory, interface: InventoryView
I assume you mean after it's been created
wait, there's a method for that?
yes
I just closed and reopened the gui
from which version is this a thing?
I don't remember
like 1.8+?
it still shows
spigot also does that
but doesn't close the gui
just reopens it
nice
I put all the flags and a log that showed they are added to the item :/
you need to add attribute modifiers to use the hide attribute modifiers flag
Attribute modifiers like?
like attribute modifiers
just add a random one?
like the ones shown in your screenshot, but the flag doesn't work if the ItemMeta doesn't have any directly set
depends
do you want to keep the default ones or is it just for a gui item?
it works for hiding the armor trim, just not the attributes
its a gui item
thats enchanted and stuff
then if you don't care about the attribute and its values you can just add any random modified
.addAttributeModifier(Attribute.GENERIC_ARMOR, null); can use this even if its not a armor?
hi
How do I make the plugin file inside the server update automatically after updating the plugin .jar file?
and yes you can add for any attribute kind
If you’re using maven for your Spigot plugins (which you should do), it’s easy to make maven automatically save your plugin’s .jar in your plugins folder. There’s two ways of doing this: 1. The lazy way (not recommended) If you only work alone on one computer, you can just directly declare the output location in...
thanks
Thanks it worked 🙂
Can I somehow create custom items, food, weapons, armor with spigot?
Both
Looks just with customModelData right?
Alright uhm could u give me an example on what i can do? Like would a CustomFood Item or Armor work?
I see alright
Okay i will do that
Can i modify the strenght or protection of an item directly? And the data of how much saturation will be restored?
I see alright
How do i use the food component?
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous usernames, global display names, and server...
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
I'll try that, ty
there is no #setState() and shouldn't it be updated with block.getState().update() ?
Does anyone else has an idea on that one?
no
every call to getState fetches a NEW state
you keep the state, modify it, then call state.update()
Ho do I do that? This was my code:
Bukkit.broadcastMessage("ERROR");
Block block = loc.getBlock();
if(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) {
Sign sign = (Sign) block.getState();
sign.setLine(0, "§4§l[ERROR]");
sign.update(true);
Bukkit.broadcastMessage("debug1.");
} else {
Bukkit.broadcastMessage("debug2");
}
}```
instead of sign I just put block.getState() ?
why isn't it working then?
Do you have something else overriding the sign
code is correct, but clearly you are on old version as signs have a side now
That too ^^
the server I'm coding this for is on 1.12
1.12.2
no
1.12.2 😿😿😿
yess
Does noone have an idea? There must be a way! Is it allowed to @ the helpers?
the code you posted is correct. you are doing somethign wrong elsewhere
Is it some kind of event? have you registered the Event/Command?
Decrease the count by 1, if the count is 0 then remove
umm wait.. inventory click event only returns main hand
If the count is 0 set main hand to null
To remove the stack
You have to give us some more context
Are you decompiling a plugin JAR?
And trying to edit the source code?
Are you allowed to decompile it
And edit the code
you mean when count is 1
does null means just AIR?
bruh
i forgot that soups are unstackable LOOOL
can i just do this to check if either left or right hand is the item ? its InventoryClickEvent
ItemStack item = event.getCurrentItem();
ItemStack item2 = player.getInventory().getItemInOffHand();```
Hiring Builder
yo, im kinda new at java, I want to access a variable from a class that is different than the class where the variable is specified, how do I do that?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
yes it does, thats its whole purpose
di for a beginner?
really?
you dont even know what this variable does
or is
doesn't seem like actual help
If you are unable to understand it their Java knowledge is lacking and needs further study.
just a referal at beast
could have explained it to them
its a complete tutorial about dependency injection
why? the link does everything. We have that link because everyone has explained it a million times already
No assumptions, you want me to copy paste the contents of that link everytime someone asks?
what is the variable doing?
if its just suppose to be const use static.
if you want to use it like for operations or whatever, you can make a static method for that class and call that method in your class with the variable
to be clear you shouldn't do this alot, and should use a singleton/di/whatever to access that class and get the variable from it
God no, don;t start throwing static at new devs
how will they learn?
just give them all the info and dont let them make mistakes?
i've told them what they should do instead, but for their case use static
let them experience learning
by learning di. Static has a very specific purpose with many downsides.
no kidding
but if you throw everythign that is bad and good at them they can't learn
okay
static also isn't bad
its just the uses of public static
that are bad
teach best practices and they will leanr static when its actually needed
why dont you just ask the person instead of assuming how they want to learn
should have gave them a video sorry bananarobot
i should just like refer them to somewhere else
and not actually help them
or... you know use the resources that are provided in this channel. like ?di
it was literally what he asked for
you went off on a crazy rant about not helpign and he shoudl just use static
stop arguing already this man already solved it 😭
but then he said he wasn't really
for a beginner learn di
di is one of the MOST basic java principles a beginner needs to learn
not the best of choices
like fr 😭🙏
I can;t argue with an idiot. not possible to win
this isn't even true
lmao
the most basic is literally a singleton
ask any seasoned dev in here
You start with di and go over to singleton patterns when you understood the drawbacks of this pattern.
Di forces you to write more robust code. Singletons can quickly crash your applications when they get more complex
and things like circular dependencies become an issue.
I would agree if we would be talking about spring's di. But the tutorial he gave is basically only about passing objects within constructors and avoiding static, which is one of the most trivial things in java. Although the wiki page indeed can be overwhelming for newcomers
What are u on about lmao
Di is one of the first things you learn about oop
You listen to them just the same as you do for any Bukkit event. Just ensure any code you call from the Listener is thread safe
Add the word Async to your events name as a hint
hiring builder
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
If you're making your own event use the constructor that takes a boolean and pass true to indicate an async event
how do i get a nullable integer from config?
what is wrong with this code? I cant make it work
btw the minecraft version is 1.19 and the plugin is conditional events
MinigamePickup is missing a space
also ask in #help-server
why argue with the answers you get?
ALL events in raised by Bukkit are sync or async. internal and custom. you listen to them all exactly the same. The ONLY difference is you have to be aware aof thread safety when async.
It is an Event registered with Bukkit and listened to in teh EXACT same manner
sanity check, better to have a task manager that checks 100k entities than 100k standalone tasks right
yes
you cna even distribute teh load, but still one task is better
though in my defense it is using a shockingly small amount of power
Show your pom
got something to run 81 million times in 1 hour
big pog
on an empty server no less
dont modify an immutable collection
not really
immutable = can not make changes
elgar's advice is better
No this is a basic issue of trying to mutate an immutable collection
Without reading your code in detail, the List returned by LiteBans is probably immutable. you need to use their API to add a ban
use recaf
although, you can't create new classes on there last time I checked.
Uh, in that case you would need a proper decompiler and the proper tooling around it
I need to shadow my plugin with gradle, there is any guide or something?
how do i parse &#rrggbb chatcolor
its part of the bungeecord chat api
net.md_5.bungee.api.ChatColor#of(java.lang.String)
public static String hex(String message) {
Pattern pattern = Pattern.compile("(#[a-fA-F0-9]{6})");
Matcher matcher = pattern.matcher(message);
while (matcher.find()) {
String hexCode = message.substring(matcher.start(), matcher.end());
String replaceSharp = hexCode.replace('#', 'x');
char[] ch = replaceSharp.toCharArray();
StringBuilder builder = new StringBuilder("");
for (char c : ch) {
builder.append("&" + c);
}
message = message.replace(hexCode, builder.toString());
matcher = pattern.matcher(message);
}
return ChatColor.translateAlternateColorCodes('&', message).replace('&', '§');
}
```Usage: hex("&#rrggbb Text");
does Inventory#getHolder return a clone of the holder?
people go to crazy lengths to not use components damn
Rewrite it then
Component.text("hi", TextColor.fromHexString("#ffffff"))
Sure that would work but no it’s not compatible with most things, usually only text
w/static imports, its even better. text("hi", color(0xffffff))
me when adventure-bukkit:
everything else is a spigot issue
Nothing a little NMS can’t fix
I was recently working on a GUI, you had me think for a bit about the line you gave but I think while that might be awesome for basic return messages I use the function I sent for very universal use. I do not want to add NMS, it is best to avoid that so when updating the server you don’t need to make edits
I definitely would never use the paper api. As for the server, I don’t find it to be much different except a few minor settings I do need
ok
what, did u make this claim up lmao
adventure also isnt paper api
its a separate text framework that paper does incorporate but can be also used on other bvukkit software too
I don’t believe there’s an issue here, you guys especially rad just want to start an argument. No one responded to the user, I gave a legitimate working method. Maybe it’s not perfect, but it will work anywhere which is important.
gui's suck
shut the up and its "guis suck"
GUIs as its an acronym
components are just bloat icl
unless you're using them in chat
genuinely can't be bothered to use them
Mfw translation components
cba too
if you can't understand English in 2024
it's your problem
unless you mean keybind stuff
Both
Yeah fonts are huge
actually they're quite small
Not if you mess with the character size
I should get to work on that library to host a resource pack through the server port
How should I organize my test configurations? This is what I currently have: https://imgur.com/t5KTLLz
mfw bedrock supports translatable components but not rgb
also scoreboards truncate after 16 chars
Bedrock moment
Bedrock is getting all the cool features
But... Just worse then java
Imagine dying from lag on your single player world
json ui kinda goated tho

not really it's just too bothersome to use them
in most cases
Well if choco gets that PR merged
I've been busy :(
make sure it's written in Go because hypixel loves writing solutions in janky languages
What percentage of the codebase is in kotlin 🤔
0% that I'm aware of at least
I remember the public SWM test plugin was made in kotlin
Was it like official official though or was it just a MK project? lol
I believe it just encoded and decoded regions
somewhat official
can you tell them to actually look at my applications :3 I know I fucked up but like it's been 3 years or wtv
fork the server and reimpl it yourself
ezpz
create new world with same seed
copy chunk
300iq
create the world on a dedicated world-creation server to not lag
send the files over UDP
for less latency
make sure to do it async because async = performance
I should start charging my hourly rate async so I get more work done at the same time
mess with NMS and recreate the old logic
what does automated even mean
brother you're in #help-development
this is genuinely a decent solution tho
it's what worldedit does for //regen
I was gonna make that joke
Well the reason is that it doesn't work anymore because the world-gen code has changed so much over the years
Surely the doggy could be made to do that
You asked the same thing in the paper discord yesterday, and got the same answer
Sure, the behaviour probably worked relatively well enough. But with 1.14 (the version where that exception started being thrown), the change was significant enough to where the effort wasn't really warranted
Create a copy of the world and copy chunks over
^ it's not a bad alternative solution
All possible with the API
In fact, you may get better results this way
You will get 100% accurate results
I concur
Assuming there’s no bugs with the deterministic generation based on seeds
Or a plugin doing something stupid in world gen
Both of which would also impact any regenChunk method
server I work with, we have a backup of the world and use that to make worldedit //regen work off of that backup when there are chunk corruptions
Anyone here use a live server with intelij? looks neat
I have never had issues with //regen it just sounds like your seeds are messed up
I told you the reason 😅
By all means, if you can figure out a way to reimplement it in 1.21 with modern world generation internals, we welcome a PR to reimplement that method
How should I organize my test configurations? This is what I currently have: https://imgur.com/t5KTLLz
The configuration is properties.properties, which won't be shared in the remote repository
properties_template.properties is as the name explains, the template
tbh I just use them to make messages easily configurable
ChatColor.stripColor maybe ?
serialize with the legacy component serializer and then strip
ezpz
use legacyAmpersand
(maybe?)
Just print stuff out
What kind of itemmeta is this? The docs don't have ItemMeta#displayName but ItemMeta#getDisplayName
we cannot provide you some help with this :/
?paperdev
Make sure to ask in the appropriate server concerning development towards different JAR types such as PaperMC. (Tip: Google them!)
What do you need the unformatted component for? There is almost no use case for this.
is it possible to interact with npcs without using ProtocolLib?
well ig it probably is, but how... much more work would that be?
Add the name as metadata via the PDC of the ItemStack instead.
Or even better: Write a proper GUI implementation that doesnt need any data from the clicked ItemStack.
Reading from a clicked ItemStack in the InventoryClickEvent is a dirty fragile hack.
But a quick fix: Add a PDC tag with the Players UUID or Name.
it is?
what's wrong with storing the player's uuid in pdc?
You are relying on UI data. You should strictly separate the clean data used for logic and the user interface representation.
When writing a website, you wouldnt do checks like if(button.text == "Next"), but rather properly attach an action
to the button object in memory.
The logic needs to be completely separated from the visual representation.
ic, how would that look tho? like... how would you know which player to choose with the logic not bound to the UI?
i'm using ur gui tutorial... am i doing something wrong then?
lol
i mean obviously, but i don't see how that tutorial teaches that
(or i missed it)
Ill write you an example based on the tutorial
that would be mint thank you
i'm on the road to get my code as clean as possible and stuff like this helps a ton (idk why but i learn a lot from more-or-less-spoonfeeding lol)
public void decorate(Player player) {
Bukkit.getOnlinePlayer().forEach(online -> {
InventoryButton selectionButton = createSelection(online.getUniqueId());
addButton(selectionButton));
});
}
public InventoryButton createSelection(UUID targetPlayerId) {
return new InventoryButton()
.creator(player -> createPlayerHead(targetPlayerId))
.consumer(event -> {
Player clicker = (Player) event.getWhoClicked();
Player selected = Bukkit.getPlayer(targetPlayerId);
if(selected == null) {
clicker.sendMessage("This player is no longer online.")
return;
}
// Do your selection logic here
selected.sendMessage("You have been clicked by " + clicker.getName());
});
}
private ItemStack createPlayerHead(UUID playerId) {
...
}
ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
omg i'm stupid apparently
thank you sm
oh right also this ^
👍 .
In Spigot its not. The server discards interaction packets for unkown Entities. Paper has an PlayerUseUnknownEntityEvent.
In general you would have to either use NMS or ProtocolLib to listen for incoming packets.
What about packetevents
Thats possible, but quite complicated. You basically have to inject a packet handler into the netty pipeline.
Its probably best to reuse someone elses code for this. Im still trying to refine my packet handler and its only almost there.
Im doing some fked up shenanigans with a queue for multithreaded packet handling
This allows me to have multithreaded, per-player instanced entities
woah
uhm
welp
ig either NOT add npcs to my plugin or give in to protocollib lmao
Hmm. I have a gist for a trivial implementation. Let me check if it still exists.
have y'all heard about packetevents
i thought packetevents were a protocollib thing
That's its own library
Packetevents is a plugin which listens for pretty much all packets and fires bukkit events for them
Well, just read up. Not exactly spigot events, but something similar.
Is this for a public plugin?
eventually
In that case ProtocolLib is probably the way to go.
For a server impl i would have given out the packet listener. But ProtocolLib is basically on every
server using public plugins.
i see okay, guess i'll take a look at that then.
ProtocolLib also makes spawning npcs and such a lot easier i suppose?
or in other words
can NMS be fully replaced by ProtocolLib?
Yes, ProtocolLib just lets you build the same packets as NMS.
With different methods that can be quite cumbersome sometimes.
Stuff like this for example
This is from my hologram tutorial. It has an NMS and ProtocolLib implementation.
You can take a look at it. Wont cover NPCs but this shows how to generally spawn entities.
https://github.com/Flo0/HologramTutorial/blob/master/src/main/java/com/gestankbratwurst/hologramtutorial/implementations/protocollib/PlibHologramLine.java
Contribute to Flo0/HologramTutorial development by creating an account on GitHub.
When a player kills someone, how can I keep track of how many hearts they took and how many HP they took when they killed someone?
For example, a player has 10 hearts. 10 hearts and 20hp
Now let's say a player falls from a height, 2 hearts are lost and 8 are left. If someone kills this player at that moment, they will kill him with 8 hearts.
You killed (player) with 8.0 hearts ❤️ remaining
A message in style
I tried to do it but I couldn't do it
Yeah PlayerDamageEvent and then gather the data you need and store it in a Map or something like that.
why a map? isnt all the data provided by the event? and when the hit entity's hp goes below 0, send the message?
He wants to check who did the most damage on a target so they can reward the kill to the player with the most damage done.
I did it but it says 10.0 hearts every time. For example, the player was damaged by someone else, and someone else killed him. I think it counts all the damage as being done to the person who killed him
ahhhhhhhhhhhh
now i get it
Do you create one DamageTracker instance for every player that joins?
Then this class logically makes no sense
Do not store Player, use UUID instead.
You need to track who did the most damage to who.
So more like a
Map<UUID, Map<UUID, Double>>
Is it like taking each player's uuid and tracking how much HP each player took to the dead person, then finding the person who killed them and calculating it that way?
Keeping track of who does more damage, but if two players hit each other at once and the player who does more damage doesn't hit at one point and kills the one who does less damage, what will be the result?
The result will be me getting a stroke trying to understand what this is supposed to mean...
I'm not sure they even understood what they want sadly
😂.
I think they want to register the whole record of who damaged how much on a given player, and then find out the one who dealed the most
Idk what you're saying but I was talking only about storing UUID instead of Player instance.
There are various reasons why and I know about none of them.
Nope
What are you trying to do?
Multiple players can attack a player. A player has Max 20hp, it doesn't matter which one does the most damage.
What matters is how much HP the killer used to kill.
You can not get the HP of the victim in the death event ?
You dont need to track that. The EntityDamageByEntityEvent already covers that for you.
No need for any Maps
how much damage the killer did or how much hp the killer has left?
Exactly
I think I got it
He wants to know how many HP in total the killer dealed to the player
Here. This will track how much damage the last (killing) blow was
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onDamage(EntityDamageByEntityEvent event) {
Entity defender = event.getEntity();
Entity attacker = event.getDamager();
if (!(defender instanceof Player) || !(attacker instanceof Player)) {
return;
}
Player defenderPlayer = (Player) defender;
Player attackerPlayer = (Player) attacker;
double damageDone = event.getFinalDamage();
double healthLeft = defenderPlayer.getHealth();
boolean isKillingBlow = healthLeft <= damageDone;
if (isKillingBlow) {
UUID attackerId = attackerPlayer.getUniqueId();
UUID defenderId = defenderPlayer.getUniqueId();
System.out.println(attackerId + " killed " + defenderId + " with " + damageDone + " damage.");
}
}
No need for Maps here
You still gotta store something if they want to change the death message.
Sure, was that something he wanted?
Oh no sorry, I mistead the code
Ah i should have read the entire code lol
Hmm, does SinHa just want to write a plugin which lets you steal max health from other players?
Or one that just halves your max health on every death?
Ciao cerco qualcuno italiano
English is the official language on this discord 🙂
alternative answer: i understood not a single word there, sorry :/
Something something hello, is there someone italian
Or similar. idk what "qualcuno" means
ask gpt4 lol
I could also just not care enough. Thtat what i decided to do initially.
fair
'Hi I am looking for someone Italian' (said google)
so google said you are looking for an italian?
not me, i just translated it
static public void cloneWorld(String originalWorldName, String newWorldName) throws IOException {
Path path = Paths.get(System.getProperty("user.dir") + File.separator + "worlds" + File.separator + originalWorldName);
Path newPath = Paths.get(System.getProperty("user.dir") + File.separator + "worlds" + File.separator + newWorldName);
Files.copy(path, newPath, StandardCopyOption.REPLACE_EXISTING);
}
```I'm trying to clone worlds but the resulting folder is empty?
you might not be able to copy any currently open files. do you get any error?
why hardcode path into your home folder
Wait you got a point
Files.copy doesnt recursivley copy directories. You need to walk the file tree for that.
cuz it only copies the folder ;D
Oh 😭
Help pls
look into Files.walk
can anyone help me out with my snipset here:
https://mclo.gs/WEwI5t0
i am trying to cancel itemadder drops from block even they are set in itemadder config with this code if canceliadrops is set to true in my config
but its not working for some reason
i litterally been trying eveything
maybe @wise rock can help out ? as there is not api help channel in itemadder
public static void cloneWorld(String originalWorldName, String newWorldName) throws IOException {
Path sourcePath = Paths.get(System.getProperty("user.dir"), "worlds", originalWorldName);
Path targetPath = Paths.get(System.getProperty("user.dir"), "worlds", newWorldName);
if (!Files.exists(targetPath)) {
Files.createDirectories(targetPath);
}
try (Stream<Path> paths = Files.walk(sourcePath)) {
paths.forEach(source -> {
try {
Path target = targetPath.resolve(sourcePath.relativize(source));
if (Files.isDirectory(source)) {
if (!Files.exists(target)) {
Files.createDirectories(target);
}
} else {
Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
}
} catch (IOException e) {
e.printStackTrace(System.out);
}
});
}
}
Also, wtheck is Paths.get(System.getProperty("user.dir"), "worlds", originalWorldName); this supposed to be?
Just pass it through as a method parameter.
I got it
hey gamers.
so ive generated an empty void world, but upon reloading it seems like the emptychunkgenerator i made doesn't exist anymore and it reverts back to generating the remainder of the world normally. any idea how to fix this?
Step 1) Read the warning on /reload
Step 2) Never touch the /reload command again
oh i meant restart
my bad
xD
How are you attaching the chunk generator to your world?
if(worldExists(world) == null) {
WorldCreator wc = new WorldCreator(world);
wc.generator(new EmptyChunkGenerator());
World w = wc.createWorld();
w.save();
return w;
} else {
return null;
}
}```
mfw I created like 12 different damage and kill tracking systems at work
is PacketType.Play.Server.SPAWN_ENTITY the correct ProtocolLib-PacketType for spawning a player npc? (What connection.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, npc)); with connection.send(new ClientboundAddPlayerPacket(npc));
did in NMS)
I can decide that the "killer" is the skeleton that shot the first arrow within the last 15 seconds
Also, is an Angle type just a float that has to be mathematically converted? https://wiki.vg/Protocol#Spawn_Entity
Why does worldExists(world) not return a boolean?
idk just how i coded it 🤣 i wanted it to return a boolean then changed my mind
🤣
Explain what this code is supposed to do. The method names seem to claim something else than the logic
(This is btw the best way to confuse other devs)
lol
all good. the thing im asking about is the emptychunkgenerator swapping out for a regular chunk generator after restart
It doesnt if you load the world with your emptychunkgenerator.
i guess im just confused cause it gens the empty void world, but then later it glitches and generates normal chunks. could it be cause im using paper?
No, this just means that you are not loading the world with your emptychunkgenerator anymore
oh makes sense
so how do i load a world with the emptychunkgen?
Are you trying to use the chunk generator on your default world?
actually i think it is yeah
I would start by removing your condition here:
public World createEmptyWorld(String world) {
if(worldExists(world) == null) {
WorldCreator wc = new WorldCreator(world);
wc.generator(new EmptyChunkGenerator());
World w = wc.createWorld();
w.save();
return w;
} else {
return null;
}
}
public World createEmptyWorld(String world) {
WorldCreator wc = new WorldCreator(world);
wc.generator(new EmptyChunkGenerator());
return wc.createWorld();
}
The condition makes no sense. And the save() call is weird as well.
And then you need to tell me if you are trying to use this on your default world (the one defined in server.properties)
i think it is yeah

i created it initially using createEmptyWorld, but then since then i set that world to my default world
in server.properties
so it didnt used to be the default world, but now it is
Ok, for that you need to define your custom chunk generator in the spigot.yml
oh dang makes sense. so it overrides for the default world?
Let me check if this information is still correct
its the bukkit.yml
oh interesting i founmd a method in java plugin (getDeafaultWorldGenerator) - could it be that?
oh okay
How would I know a block is spawned using a cobble stone gen
You should override this
And then configure
worlds:
world:
generator: yourPluginName
In your bukkit.yml
You mean after it was spawned or do you want to hook into the spawning process and change the block type?
Hook into
Listen to the BlockFormEvent
That's 1.21.1 right?
Has been there for years
Ohh
a decade even
And how would I know the cause of how it formed
Or is it specifically for when lava and water touch
b- uhm bump?
do i need to configure this for new worlds i make btw? or just the default world?
ADD_PLAYER just sends the information and needs to be sent before spawning the player entity.
Since 1.20.5 (or 6) the spawn packet changed from using a specific player spawn packet to the general entity spawn packet.
well if the new state is cobblestone. that event is only ever fired for cobblestone if it was lava and water touching.
Just the default world.
If you want to create or load void worlds, simply use a WorldCreator and pass your chunk generator to it.
unless theres other stuff that can form cobble i dont know about
bet! so if im loading an existing void world i need to make sure i also parse in the empty chunk gen when loading it?
True
Yes. Just do this to load or generate a void world. Doesnt matter if it exists or not:
public World createEmptyWorld(String world) {
WorldCreator wc = new WorldCreator(world);
wc.generator(new EmptyChunkGenerator());
return wc.createWorld();
}
thanks mate!
in this project i'm in 1.19.4
i wanna know the ProtocolLib equivalent type for spawning a "Player"
It says lava when I try to get the material
Then first send the ADD_PLAYER packet followed by the SPAWN_PLAYER i believe its called
did you get the new state?
BlockFormEvent#getNewState
new state says water or lava
wait what
public class BlockForm implements Listener {
@EventHandler
public void onPlayerQuit(BlockFormEvent event) {
Block formedBlock = event.getNewState().getBlock();
Bukkit.getServer().broadcastMessage(formedBlock.getBlockData().getMaterial().toString());
}
}
Ignore the name
-.-
-,-
I forgot to change it
i thought i wouldnt need NMS anymore if i used protocollib
I don't get it
Block is a Position. If you get the Position at that events time, and check the type on this Position, then you will get the BlockState before the event happened.
You need to check the type on the new BlockState.
getNewState is is the old one?
I'm here nowww
and ADD_PLAYER is NMS
yes and then u do getBlock
@lost matrix I'm going home now sir, I'll test the code you wrote
Nope, but getBlock() gets the position, which is the same for the old and new state.
which is going to be the current or "old" block
u can just call getType directly on the new state
instead of getBlock
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(new Listener() {
@EventHandler
public void onForm(BlockFormEvent event) {
event.getBlock().getWorld().createExplosion(event.getBlock().getLocation(), 5F);
}
}, this);
}

💀
Did you figure it out?
imma come back later, bit much going on here rn lmao
this would be important for me to know tho
and what the entityId should be filled with, since i can't really know which ids are already in use(?)

oh god
For ProtocolLib you should look at the NMS packets instead of the protocol itself. PLib doesnt construct packets on a byte level. It just uses reflections to add values to the NMS packet objects.
man do I really want to do all of this for 20 bucks
why do modern decompilers still suck at figuring imports 
If its done in an hours or two
sooo they're bytes
bc in NMS they're bytes
even within an hour it still sucks
but hey one more premium plugin fully rebuilt
Ctrl + Shift + O
all of this because the mf was doing calls to bukkit.getUnsafe that crash on 1.21
Yes, 256 values for 360° rotation.
thanks :)
that turned on my gpu's metrics
Shoulda have used eclipse
I mean, if it is just that, Recaf would probably be the better play here
mfw Ctrl+Alt+L doesn't fix my finances
both recaf and jd-gui suck
but together
- winrar into intellij for some reason
can rebuild like 99% of projects
Who in their right mind would use jd-gui in 2024 if Recaf 4X exists
recaf takes like 19 years to load
Even the EOL Recaf 3X is great
also feels more lcunky imo
I still use that one jd-gui instance ive downloaded 3 years ago...
same
I've redownloaded it like 5 times
familiarity is key imo
I'd still be using intellij 2016 if it weren't for copilot
Well, as long as you don't use ghidra I guess
and now that my student license ran out I no longer have a need to update 
ain't paying for that
^
you can get it from nms
or my personal go-to approach
start from like 1 trillion and count up
fair enough lmao
prob not
I know plib reflection class has it
I always feel hella guilty looking up entities by their entityid tho
It does https://jd.papermc.io/paper/1.21.1/org/bukkit/UnsafeValues.html#nextEntityId()
||If you use paper||
ThreadLocalRandom.getCurrent().nextInt() 🙂
Should be fine
what does that do? 🤔
guess
Or to not clash with illusion: Start at minus one trillion and count down
(let's completely ignore that those are out of range for the ints, so a modulo won't work)
and if that happens you prob deserve to restart your server ngl
I mean trillion already overflows integers by a ton
nerd
its like 2.17 bil iirc
uhm
Yes im talkin about good old 32bit signed java integers
doesn't help that intellij is a fucking nerd
Well my approach would be to use nextEntityId via MethodHandles which is configured with a fallback of ThreadLocalRandom#nextInt
what's the problem, can't you convert hex to dec in ur head? weak
need to bribe em rq
Real programmers only use HEX.
I dont even know what 1200 is. Do you mean 0x00422F ?
oh you know hex?
fr
name every torx size
once went to the chick at the juice bar and told her to name every vegetable
Sounds like a recipe for success
mfw she named me
0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF
i wont keep going dw
ok I'm actually going insane just finished doing imports for what felt like 30 of the same exact class and now I gotta import every hologram plugin known to man
wait a minute.. when i'm trying to spawn an npc with protocollib... how do i set a skin and stuff like that?
pov, you dont need to do that because you create everything in-house
ain't my plugin
god bless compileOnly(fileTree(dir: 'libs', includes: ['*.jar']))
yeet
But i feel your pain. Before i came here they used HolographicDisplays. And that stopped working in 1.20.2

what time is it for u illusion?
11am
Sleeping schedule of the gods, as always
💀
💪
i'm at work 💀
it's the world renowned "don't bother me" schedule
got a meeting at 1pm
and then imma honk shoo
i hope so
prob gotta pass by a print shop later today
Ayy, my denoising Autoencoder trained properly 😄
Time for my next step: VAEs.
(Slowly walking towards a diffusion model for minecraft structures)
Imagine Flux or StableDiffusion, just for buildings in minecraft.
or do i just combine nms and plib?
oh ffs
If you use Plib just for listening then i would say its fine to mix them.
nah i generally want to use plib for all
Then do just that
Let me leak some stuff for you
uh oh
watch him say "hypixel" and my soul leave my body
hi everyone
Ok nvm, that code is useless to you. Too much peripherals.
You basically get the GameProfile wrapper of ProtocolLib and set it to the data packet
oh so the data packet IS sent for the player entity
not sure if I have code for that either
i was confused bc it was nowhere listed https://wiki.vg/Object_Data
Mine is only nms based
I recall making a system where you could overlay skin parts into a player's skin and it'd upload to mineskin and set the player's skin back
same
and have fancy hashes so that duplicate skins wouldn't reupload
no clue where that code is
prob rewrote it in minestom ngl
Ive used this for custom armors before shaders where a thing.
gameprofile wrapper?
WrappedGameProfile profile = new WrappedGameProfile(UUID.randomUUID(), "Bob");
Multimap<String, WrappedSignedProperty> propertyMap = profile.getProperties();
i use this for npcs but that's nms
String skinValue = "";
String signature = "";
WrappedGameProfile profile = new WrappedGameProfile(UUID.randomUUID(), "Bob");
Multimap<String, WrappedSignedProperty> propertyMap = profile.getProperties();
WrappedSignedProperty property = new WrappedSignedProperty("textures", skinValue, signature);
propertyMap.put("textures", property);
Something in this direction. But i would have to tinker with it.
Hm. Maybe its time for a proper NPCs with ProtocolLib tutorial.
Hi guys i'm trying to shade my plugin but the shadowJar is not working. Here is the build.gradle.kts
plugins {
id("com.gradleup.shadow") version "8.3.0"
}
apply(plugin = "com.gradleup.shadow")
version = "1.0.0-SNAPSHOT"
repositories {
mavenCentral()
maven {
url = uri("https://libraries.minecraft.net")
}
maven {
url = uri("https://repo.papermc.io/repository/maven-public/")
}
}
dependencies {
implementation(project(":lib"))
compileOnly("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT")
}
shadowJar {
// this dont work
}
you need to make your assemble task depend on shadowing
tasks.assemble {
dependsOn(tasks.shadowJar)
}
ohh okay
how would I get an NMS class via reflection in an annotation?
Either that or call it manually. Depending on it is preferred in most cases.
Attribute value must be constant
Values in an annotation are resolved at compile time.
You cant use any functionality in them. Especially not reflections.
how about this?
Yeah
isn't it possible to get the version with maven?
then somehow do what this man is talking about
You need to write an annotation processor for this
that would be very appreciated. bc until that point, i'm getting fine. now i have to set this to the entity spawn packet but the data wants and int so uhm yeah
maybe i misunderstood tho
the fuck
ffs why would you not just use boolean logic for that
what in the fuck is that
decompiled code go brr
what are you even doing with this plugin illusion? like what's the task here?
ahh
oh
it's decompiled
so there's this one plugin that goes fucky shit with bukkit.getUnsafe
I'd use recaf for something like this but paper is fucking up and I'd rather deal with it this way than to figure out how to import paper without recaf shitting the bed
The GameProfile is sent in the ADD_PLAYER packet
😭
what packettype is that?
i love and hate learning new stuff bc i feel stupid but i learn new stuff
fr why couldn't they setDurability('翿')
RIGHT
Works like that in Vistual Studio Code when you program in .JS atleast
oh
PacketType.Play.Server.PLAYER_INFO
i suppose
yes but they shouldn't be
why shouldn't they??
you can add custom ones with resourcepacks
cool it took me 2 hours to finally compile
this is totally worth the 20$ (like 13€ after all the fees)
tf are you even doing
rebuilding project source
cool now that that's done I got another hour to kill
any ideas on how to not pass out?
public class BlockForm implements Listener {
@EventHandler
public void onBlockForm(BlockFormEvent event) {
BlockData formedBlock = event.getNewState().getBlockData();
Location location = event.getBlock().getLocation();
Material material = formedBlock.getMaterial();
if (material == Material.COBBLESTONE) {
BlockData blockData = Bukkit.createBlockData(Material.DIAMOND_ORE);
World world = location.getWorld();
world.setBlockData(location, blockData);
}
}
}
```Why doesn't it place the diamond ore
time for the world famous "try waiting a tick"
Best solution
Cancel the event
Tyty
eh ffs
https://wiki.vg/Protocol#Player_Info_Update how would i set the gp here now? ._.
Dont look at the protocol. Look at the NMS packet.
funny decompiler artifact
I too like setting durability to 翿
yeah
yeah the nms packet sets a ServerPlayer
but idk how that's supposed to help me
._.
the gp?
gameprofile
bc i want to set the skin
or WrappedGameProfile ig in case of ProtocolLib
mm yeah idk about protocollib
does anyone have any idea to work around this?
@Mixin(value = version + "...")
public abstract class MixinCraftServer {
@Shadow public abstract Logger getLogger();
private static String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
this isn't possible, and uh
if i move it to another class and make it static
it tells me that annotation values must be constant
are there any alternatives?
Arent mixins for mods
ignite
sponge
ah
sadge
not really
like it talks about the framing and stuff but it just talks about the protocol as if it were written in any language with any networking tool
not really, annotation values must be compile-time evaluable constants as they exist in the classfile
Mmm, do you know of anywhere that does cover it
At the very least the order of handlers
jree fava lessons
I love fava
can i force intellij to let me open 2 popup windows at the same time?
aka dont remove a window if i click outside
i just wrote the funniest code ever
but i need 2 popups for context
probably not
literally just put my hand on my forehead rn