#help-development
1 messages · Page 1087 of 1
because you skipped the learning Java part
huh why
Why do you want it to try and store an invalid address
i'm making /ipban, and i want it so if the address is invalid it ipbans the player
if that makes sense
so /ipban bob would ipban someone named bob, /ipban 127.0.0.1 would ipban 127.0.0.1
ok
can you "join" a bukkit task? like a thread
nvm
is it possible to get all the ips a player joined with
or the last ip the player joined with
String zeroTo255 = "(\\d{1,2}|(0|1)\\" + "d{2}|2[0-4]\\d|25[0-5])";
String regex = zeroTo255 + "\\." + zeroTo255 + "\\." + zeroTo255 + "\\." + zeroTo255;
technically there is no standard format for a textual IPv4 representation, so if you are expecting it to be in a certain format, just parse it yourself so you don't get any surprises
how to decompile jar in intellij
I mean you can
Intellij ships with a decompiler
Though I recommend just using Recaf
how do i check if an offline player has a permission (without vault)
offline players have no permissions
they get added on join
they technically do, they're stored somewhere
just like how you can get their statistics
iirc vault, pex, lp, etc store them in their own database
and add it on join
ah
doesnt lp use vault?
ok
yes it does
Wrong channel
ok thx
What problem?
Armor stand, I set it so that right click does not work if there is no head on the head.
And I said this should only apply to armor stands with names starting with "enderchest"
that is a quick and surefire way to let people abuse your plugin
But all these armor stands prevent me from right clicking and I cannot equip a head.
that isn't a kotlin issue though
Ok I know there is something wrong with the code
so why haven't you sent the code
here
Check numbers 98 to 115
1 minute, since the explanations are in Turkish, it is difficult to understand, let me explain it in English for you
And have you done some debugging?
There is no way for us to know if that config field exists
I think there is a problem between 98 and 115, what I want to do is, if the armorstand starting with the name "enderchest" does not have a helmet on its head, right click should be blocked.
But this applied to all armor stands, and when I right click on other armor stands it blocks it.
I use the command to attach heads to armor stands starting with the name Enderchest.
/applyhead (name) I'm obsessed with writing, but I can't wear it because normal armor stands don't have names.
To briefly summarize, right-clicking is only valid on armor stands that start with "enderchest"
I couldn't find the problem
And then what problem are you having??
// Interaction blocking check
val interactionBlocked = config.getBoolean("armorstands.$worldName.$armorStandName.interaction_blocked", false)
if (interactionBlocked) {
event.isCancelled = true
}
I did this
Event.isCancelled = true
But it didn't work very well
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
... Sir, I have been explaining the problem for two hours already.
Wait 1m
setCancelled exist
You've been explaining what you want it to do, not what isn't working
...
Kotlin allows you to use property access syntax for getters and setters
Syntax sugar
I call kotlin the diabetic language
Yea but it's pretty fun to use
Well, yeah, ig
How can i use my plugin in github release in other gradle plugin like dependency?
What?
I'll send a video 1m
You want to use your plugin as a dependency?
how to publish into maven repo
Look video
?google should help
Google your question before asking it:
https://www.google.com/
Normally, if there is a head in the armor stand named enderchest, the command works.
But otherwise the command will not work
I blocked right click so that the command does not work when I am not wearing a helmet.
This prevents this when I right click on the normal armor stand with any armor or head.
depends
Thats the problem
@EventHandler
public void onClick(PlayerInteractEvent event){
Action action = event.getAction();
Player player = event.getPlayer();
if ((action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK) && NeoWorldPlugin.playerIsInListInConfig(player, "cpsTest.players")){
FileConfiguration config = NeoWorldPlugin.getConfig();
int playerClicks = config.getInt("leftClicks." + player.getUniqueId().toString());
playerClicks++;
config.set("leftClicks." + player.getUniqueId().toString(), playerClicks);
NeoWorldPlugin.saveConfig();
} else if ((action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) && NeoWorldPlugin.playerIsInListInConfig(player, "cpsTest.players")) {
System.out.println("Clic droit détecté pour " + player.getName());
FileConfiguration config = NeoWorldPlugin.getConfig();
int playerClicks = config.getInt("rightClicks." + player.getUniqueId().toString(), 0);
playerClicks++;
config.set("rightClicks." + player.getUniqueId().toString(), playerClicks);
NeoWorldPlugin.saveConfig();
}
}
``` Why the right click is not detected 🤔 ?
where u clicking the air with nothing in hand
That doesn't fire the event
Well yeah, that fires with an item in hand
And left clicking is attacking
if u right click while looking at nothing and holding nothing
it doesnt send a packet
Yeah it doesn't trigger for right clicking with an empty slot
because mojang loves us
Blame mojank
mojank
Lol but there is not event for this type 😭 ?
it kinda is
😦
but u need a hacky way
😭
Not without an item
that would need a tp
tp?
texture pack
No, a resource pack. It's not the same thing
Problem solved.
fr?
i've been lied to my whole life
what's the difference
Resource packs do much more than just textures
A texture pack was a collection of files that were used to change the in-game textures of blocks, items, mobs and the GUI. They were .zip files that had various PNG images in them and a text document named pack.txt. The native resolution of Minecraft's textures were 16×16 (measured pixels in block height and width). 32×32, 64×64, 128×128, 256×25...
"was a collection of files"
https://minecraft.wiki/w/Texture_pack_(disambiguation) But yea, this
A texture pack is the mechanism used to customize textures in Java Edition prior to 1.6.1 and in Xbox 360 Edition prior to TU13.
Texture pack may also refer to:
Resource pack, the current mechanism used to customize textures and other assets in Java Edition
Texture pack/DLC, downloadable replacement textures in Bedrock and Legacy Console editio...
You could use that new entity
Interaction entities are a technical entity, useful for map or data pack creators to see who the last player to click on a certain spot is. They can only be created with the /summon or /execute summon commands.
Interaction entities are invisible, invincible and of a custom size. Their boundary box can be viewed via the F3 + B debug shortcut.
But yea you would have to do the same thing with it following where the player is looking
Probably
Typically when people say texture packs nowadays they’re referring to resource packs so I feel like it’s not that unreasonable
You can just assume at that point
Well the term sucks since resource packs do a LOT more than just textures
Not basic
You can do a lot of cool fuckery with them
Spheya made coloured lighting with just a resource pack.
I don’t think you can replace every shader in the game like you can with optifine/iris
That’s dope
Well most
Not just spheya tho
So ehm I made this cool thing with this other cool girl @spheya_ COLORED LIGHTS! 100% Vanilla, no fabulous graphics 💜
Like do you just write shader programs
They get some custom info from the server
Yea
Or does it use some kind of weird json format
Wow that’s pretty cool
Resource packs really are something nowadays
Especially combined with data packs
Mojang has done a really good job moving things out of code and into data
Yea for definitions but you write GLSL for Vertex and Frag shaders
That’s so interesting
I mean it makes sense but
I just never would’ve expected mojang to add that
https://github.com/PuckiSilver/NoShadow e.g. this
Shaders themselves are kind of simple but making cool shit with them is harder
For sure
I tried to make my way through that online shader book at one point but never finished
A Player is also an Entity, meaning this should def result in a Player being returned.
If they are online
i can raytrace entities to check for block displays, right?
the raytrace thing doesnt go based off of hitboxes, righttt?
:Clueless:
is that a question or a statement
it certainly didn't sound like one lol
checking for entity "collisions" does not mean it needs a hitbox to work?
well, you can only collide with entities that have a hitbox
how do i check for display entities then
nevermind
found it
sorry
forgot the raysize
hm, looking at it, it doesn't really need to have a hitbox
Note: Due to display entities having a zero size hitbox, this method will not detect them. To detect display entities use rayTraceEntities(Location, Vector, double, double) with a positive raySize
i wasnt using the raysize param
i guess ray trace works in mysterious ways
Yes
it literally just does a getNearbyEntities by max distance, expands their bounding boxes by the ray size, and checks if the ray intersects the bounding box
is bounding box not hitbox?
yeah
oh but it expands from a dot to ray size
yeah
that kinda makes sense I guess
oh and it has to check the distance to every entity that intersects the "ray" so it gets the nearest one
it's less of ray tracing and more of, uh, that
wouldn't it make more sense to just uh
create a bounding box at each point with a diameter of raySize and see if any of the corners intersect any though
instead of expanding entity boxes
i mean it works either way, but also, what does "at each point" mean? what is your atom here?
urgh
I've written the exact code illusion is talking about here
still part of my legacy code suite
you need a resolution
it's not great
yeah i mean ray-tracing and step-based is bound to not work with 100% accuracy
"each point" would be the position where it grows from anyways
the problem is the distance between each step
there's two ways to do it either resolution or if you want to get fancy with it raymarching, never did the second one for this purpose but with some math I can imagine it could be a funky way to do it
pretty sure if you did a raymarch with a simple validation you'd have 100% accuracy
but also probably expensive to run, idk it's overkill for this application anyway
raymarching is great though, it can do a lot of interesting things
great for faking fluids too
if anyone wants to get megasweaty they could try to implement entity chunking and raymarching for a really accurate and efficient ray
I think you forgot we're spigoteers, not magmachads
yeah in here we ask basic java questions and refuse to learn any math beyond addition
I actually am a pro, I learned subtraction too
No vc today D:
Ah goofy retrooper
Hey do you guys have any tips for designing data structures?
like what?
Anything generally applicable?
Unit tests are more handy than what you think
Talk to ur rubber duck, logic can get confusing
sounds good
well also
Don’t copy pasta from jdk source
Much of its code is not really up-to-date
Fair enough
I mean its fair to read it, but yk, doing a goofy copy pasta 
I tend to write things out and play around with them myself so
yea that’s nice
Unit test
I wrote that!
FAFO driven dev >>>>

Don't look at any sources unless it's sources to learn about the idea behind the structure itself
You won't learn copy pasting
Also avoid geeks for geeks
Their data structure implementations are god awful
dont they just provide pseudo code anyway?
They are god awful
ftfy
No they do actual impls in a few languages
oh right
But their code is horrid
ftfy, again
I remember talking to one of the devs of one of those guide sites, and he just wrote code, didnt even try it before publishing an article or something 
ftfy?
fixed that for you
@worthy yarrow tho I'd reccomend finding a reputable data structures course at a local tech college or university from a processor with good ratings
Oh god
You actually stand to gain a lot from a datastructures course
Google generally has good and well implemented data structures on their repos iirc
@tardy delta yes im a snitch conclube
erm
🤓
i was implored by staff
Meh I'd discourage looking at actual impls unless you're checking your work
Yea, of course, I mean it depends on what your end goal is
retro irl:
Often times u don’t have the exact data structure u need so u cant find it anywhere regardless
I thought he just wanted to learn about them tbh
yea idk tbh
Well yes
If you need to make your own I'd reccomend looking at the theory and take a crack yourself
It'll be hard if it's a complex structure but you stand to gain a lot
^ this is exactly what I am doing right now actually
Is it normal that using adventure api in spigot (having it relocated) sending a message uses 0.04% server thread? Or is it too much
just only send a message if the user is looking at their screen
and not sleeping
best optimization
i mean it might be
I mean, this command is consuming 0.08% server thread
I think that's too much right?
oh no!
wha
Stop micro optimizing
This is giving x y problem energy
its probably a bit much, but like, there’s so many layers of abstraction there adri so like, it’s presumably not surprising
you bought the whole cpu, youre gonna use the whole cpu
i /command you to send me your plugin source rn
If you're concerned about performance use a proper profiler and use JMH
uh
Shameless
jk, they provide a free license to open source projects
if you regard that as a sponsor
then its a sponsor
they sponsor me a free license
Is that command dispatched often?
if not, then not an issue by any stretch of the imagination
Not really, but it can get much laggier
Because I'm looping through the config which can be expanded
cached i think
👀 doing IO in the main thread be like
well if its io, then there’s a worthy optimization to care about
Io as in u reading the contents of that file from the disk
As opposed to read it from memory ^
Alr well I wouldn’t worry too much then
I mean you can ask yourself if you really need the adventure api in that specific case, lets say you’re just sending a simple message
I do need it, for colors xd
yea

Lynx lurking
per usual
The thing is I don't know if I can handle the message consum
0.03 is because of adventure code
I mean maybe u could load up the message on start up or something ?
if you’re not doing that rn
Well I havent seen ur entire spark so idk
spark a fire
Use this better @ivory sleet
i think im just stupid but how do i pathfind an nms entity to a location in 1.20?
I know it is micro optimising but just confused why is it consuming that much
ah okay its because it calls gson, and has to serialize and everything
doing like AAA SHIT bunch of method calls under the hood
many layers of abstraction I suppose?
PathNavigation iirc is the name of the class
xd
every cool entity has a navigation object u can invoke
Then is it not my problem?
I mean, it using gson to round trip to bungee component is kinda needed given you are using platform?
🥲
ive tried this:
this.mob.getNavigation().moveTo((double)((float)blockPos.getX()) + 0.5, (double)blockPos.getY(), (double)((float)blockPos.getZ()) + 0.5, this.speedModifier);
U need to make sure that no goals/brain activities are interfering w it
yes its a pain, but doable
ive cleared all the goals
yea not rly ur problem
Could use this other fork if that satisfies u more, think adventure is better implemented there
ye
ah yea like LuckPerms
idk hard to tell w/o any code
but I mean in theory its just some method calls on the navigation
i treid using the movetoblock goal
public class PathfindGOTOBLOCK extends MoveToBlockGoal {
private final BlockPos targetBlockPos;
public PathfindGOTOBLOCK(PathfinderMob pathfinderMob, double speedModifier, Location location) {
super(pathfinderMob, speedModifier, 0);
// Convert Bukkit Location to Minecraft BlockPos
this.targetBlockPos = new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
@Override
protected boolean findNearestBlock() {
// Set the block position to the target
blockPos = targetBlockPos;
return true;
}
@Override
public void tick() {
blockPos = targetBlockPos;
this.mob.getNavigation().moveTo((double)((float)blockPos.getX()) + 0.5, (double)blockPos.getY(), (double)((float)blockPos.getZ()) + 0.5, this.speedModifier);
super.tick();
}
@Override
protected boolean isValidTarget(LevelReader levelReader, BlockPos blockPos) {
// Check if the target block is valid (implement your logic here)
// For demonstration purposes, we'll assume all blocks are valid.
return true;
}
}
to make a custom goal
https://github.com/Mojang/brigadier/
can someone explain me, if I want to execute the command whether there are arguments or not and retrieve them all how I can do?
the args List
if u need it to be a number u can parse the string with args[n], with n being the argument
You can have a greedy argument string
or u have to set the executes() for all arguments
that is both for the literals and arguments on the tree
So doesnt MoveToBlockGoal already implement the move logic?
if i give args server say that it dont know the command
LiteralCommandNode<CommandSource> helloNode = BrigadierCommand.literalArgumentBuilder("test")
.executes(context -> {
System.out.println("a");
})
.build();```
Your only job is to filter out valid blocks
yea but i cant implement that
how do i do so
i noticed the entity moves back to where it was spawned
u do something like:
var lit = literal("lit")
var arg = arg(…, “arg”)
lit.executes(…)
lit.then(arg)
arg.executes(…)
and u pass same execution logic to both executes() invocations
just derive the class and implement isValidTarget I think?
Any ideas on how to make these numbers and wheel rotate?
there is not way to just get all args without having to do that?
(idk how spigot implement commands but it probably use brigadier)
what are the numbers
is the entire thing an image or are the numbers sperate displays
well spigot u just read the arguments array in the CommandExecutor?
but like
wheel - item display
transform them
thought u were on about brigadier
spigot command system doesnt use brigadier
Without breaking SpigotMC's rules, where do I find developers that would work for money?
?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/
Thank you
how exactly?
math
yes, when you create the command you dont give a required args amount, spigot put all args in an array
because spigot doesnt care what args there are, it just hands you them all
you just check argument n + an extra m arguments w spigots command executor api
and how is LeftRotation applied? does it rotate relative to the center? or just the visual itself?
you can?
And that should be fine just
lemme try it tysm
Similarly to how u did
I think I missunderstood, its just not the objectif and philosophy of brigader (its impossible to work with unknowed args amounts?)
no its not
but if u want a variable argument u probably need to use greedy argument type
w a string
I guess it could be possible to have a custom argument type
with brigaddier you mean?
yup
are you sure its possible? for brigaddier every space marke a new arg I think
StringArgumentType.greedy()
just to be sure, if I want to accept 2 args, what should I do?
.executes(context -> {
System.out.println("a");
CommandSource source = context.getSource();
Component message = Component.text("Hello World", NamedTextColor.AQUA);
source.sendMessage(message);
// Returning Command.SINGLE_SUCCESS means that the execution was successful
// Returning BrigadierCommand.FORWARD will send the command to the server
return Command.SINGLE_SUCCESS;
})
@sleek island anyway if u wna implement it urself, implement canUse() and canContinueToUse() properly, run moveTo() in start(), (u may wanna run it in tick() to recalculate path), dont forget to set goal flags
I mean if you KNOW you wanna accept two args, just arg1.then(arg2)
and arg2.executes(…)
else assuming u use a greedy string argument type u can get a string of multiple args (separated by spaces)
I find this example, where do you add you arg2 implmentation (I am note sure to understand that you said)?
public static BrigadierCommand createBrigadierCommand(final ProxyServer proxy) {
LiteralCommandNode<CommandSource> helloNode = BrigadierCommand.literalArgumentBuilder("test")
.requires(source -> source.hasPermission("test.permission"))
.executes(context -> {
CommandSource source = context.getSource();
Component message = Component.text("Hello World", NamedTextColor.AQUA);
source.sendMessage(message);
return Command.SINGLE_SUCCESS;
})
.then(BrigadierCommand.requiredArgumentBuilder("argument", StringArgumentType.word())
.suggests((ctx, builder) -> {
proxy.getAllPlayers().forEach(player -> builder.suggest(
player.getUsername(),
VelocityBrigadierMessage.tooltip(
MiniMessage.miniMessage().deserialize("<rainbow>" + player.getUsername())
)
));
builder.suggest("all");
return builder.buildFuture();
})
.executes(context -> {
String argumentProvided = context.getArgument("argument", String.class);
proxy.getPlayer(argumentProvided).ifPresent(player ->
player.sendMessage(Component.text("Hello!"))
);
return Command.SINGLE_SUCCESS;
})
)
.build();
return new BrigadierCommand(helloNode);
}
I dont make command Im just trying to understand but lets imagine a command who need two or one args
with pleasure
I don't remember doing this
how? sorry
so kind
Hey guys, how do I increase the number of enemies/mobs in total that should be spawnable on the server and also a specific mob e.g., iron golem?
Via the config files
I've been looking, which settings exactly?
I have made a plugin that spawns a lot of monsters but it seems like I run in some max cap for certain enemies e.g., iron golem
something something spawn-limits
@lost matrix can't seem to find it
Probably looking in the wrong config file
I have already looked around and I can't find the config, hence why I am asking here.
In which config find would I find this?
I am asking in #help-development because I don't believe it exists.
So I am asking for an alternative way.
If you know please help me figure out how to change it.
What's the name of the config file?
bukkit.yml
Ok so that groups all monsters under one bucket, how do I do it specifically for e.g., iron golem?
Programatically?
Sure
What platform are you running?
Spigot latest (1.21) windows
In that case there is no more granular way to increase the spawn limits
Seems to run pretty smoothly with 2500
I'm increasing the number of enemies with the number of people online
Atm I'm just hooking into natural zombie spawns but it would be awesome to spread the spawns further to not make it all as grouped
Not sure how to achieve that though
What are you trying to do in the first place?
Btw you can set the spawn limit per World using
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/World.html#setSpawnLimit(org.bukkit.entity.SpawnCategory,int)
declaration: package: org.bukkit, interface: World
Ah sweet
@EventHandler
fun BlockPlaceEvent.onBlockPlace() {
val blockItem = CraftItemStack.asNMSCopy(ItemStack(blockPlaced.type))
val tagsList = ListTag()
tagsList.add(StringTag.valueOf("#dmcc:all"))
val tag = blockItem.orCreateTag
tag!!.put("CanPlaceOn", tagsList)
blockItem.tag = tag
val modifiedBlock = CraftItemStack.asBukkitCopy(blockItem)
val itemMeta = modifiedBlock.itemMeta
itemMeta.addItemFlags(ItemFlag.HIDE_PLACED_ON)
modifiedBlock.itemMeta = itemMeta
player.inventory.addItem(modifiedBlock)
}
am i missing something, this doesnt seem to work for me, no errors, i just dont get an item
Not a kotlin expert but I'm not too sure that's how you define listeners
nah that part's fine, its a nice extension function feature
That is the dumbest way I've ever seen a listener defined
Please don't
I use kotlin too blood but that isn't it
i enjoy it 🤷
You're actively abusing extension functions for no purpose
I always see rad do it like:
fun onPlayerJoin(event: PlayerJoinEvent) {```
yeah you can absolutely do it like that
but it just saves me from having to write event all the time and im lazy
That's how listeners should be defined you should also register them normally
man i was not looking for kotlin advice, im perfectly fine using it like that 😭
Extension functions compile down to static util methods
Not guaranteed to play nice with the current event system
Come back with a properly registered and formatted event handler and I'll be haply to help
@EventHandler
fun onBlockPlace(event: BlockPlaceEvent) {
val blockItem = CraftItemStack.asNMSCopy(ItemStack(event.blockPlaced.type))
val tagsList = ListTag()
tagsList.add(StringTag.valueOf("#dmcc:all"))
val tag = blockItem.orCreateTag
tag!!.put("CanPlaceOn", tagsList)
blockItem.tag = tag
val modifiedBlock = CraftItemStack.asBukkitCopy(blockItem)
val itemMeta = modifiedBlock.itemMeta
itemMeta.addItemFlags(ItemFlag.HIDE_PLACED_ON)
modifiedBlock.itemMeta = itemMeta
event.player.inventory.addItem(modifiedBlock)
}
``` there you go
yes and yes
Are you sure
and what if you give yourself just a normal item?
well when the debug statements i added inside the function print, i'd say im slightly confident that it run
Did ya do what steaf said uet
trying that now
Ik the issue prob
Don't convert back to a Normal Bukkit stack stay using a CraftItemStack
Bukkit can't represent some of the data you're adding
It's probably lost in translation
Try using a mirror
asCraftMirror
This is prob old nms I'm guessing
using 1.20.4 remapped moj
Try using a mirror instead of a bukkit copy
will do
So like what do we use nms for nowadays
I feel like a lot has been implemented in spigot hasn't it? At least since 20.5
I use it for components, others registries, an actually good itemstack api is another good one
? I don’t think a ton has changed in spigot since 1.20.5
prior to 20.5 I meant
Ig that's why I'm shading adventure for component support kek
There is kinda it goes through ItemMeta still but it's far less powerful than actual components
What is missing
Well yeah that's the ItemMeta limitation
You have to do it to specific items that should have that type
Technically that’s how the game is meant to be
But yea you can add the component to anything technically
Not really if that was the case mojang would limit it hard
They have hard cap on values already
I think the argument for ItemMeta is fairly week. Doesn't mean it's horrid API it can be done better tho
Right but most components don’t work on other items so there’s no point
I mean sure but what happens if let's say items go data driven
I think components are much more ready to handle such a transition
Well let’s cross that bridge when we come to it
Idk I don't think there is a downside for future proofing and improving an API
Not to mention having to clone ItemMeta to read is annoying
Well then you should get to work
I would love to but I hate to have to manage so many prs at once
I'll do so when my current inventory crusade comes to an end
I'm not just sitting here complaining I'm actually trying to do stuff to make improvements. It's easy to complain but I genuinely also want to change things
I honestly usually see that as a you won't comment but I will :P may not be soon I can only do so much at once
It's a clone automatically
It's a copy your editing
Why do you think you have to set it again
Feel free to contribute you have to sign a CLA but all contributions are welcome
It's always nice to have more people working on things
?contribute
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
@blissful crow I'm always open to questions if you need help contributing
I'm #1 spigot shill
Wanna know how to understand nms :3
Contribute
Or spend a few weeks fucking around with specific things
I did the latter
Blegh that's just packets
all the cool kids use PacketEvents
@ retrooper plug
Makes me wonder… can I send a raw byte[] to the client
If so you could make a very lightweight yet pretty advanced packet system
I can't see why not if Netty allows you to you probably could
I'm not really familiar with netty so I can't really answer that fully
I haven’t actually looked deep enough
The thing is with nms handling, it pre-processes your packet before it's sent, which essentially encodes it's id, the length, and all the data, as it seems to only take the Packet<?> class. But, there might be a way around it.
can I destroy an Item using the Damagaeble interface?
@young knoll what happened to ItemType changes
? What changes
ditching material
Forge and Fabric are much less simple
lots of writing JSON files and such to add stuff
imho the APIs are much less user friendly to beginners. Fabric you are kinda expected to mostly be using mixins though you can also use their API though in scale its much smaller than spigot
If you think about it, the Plugin Message packet is essentially a custom data packet. Basically what you're "trying to do"
I have minimal experience with both but those are simply my observations
The json stuff is just how minecraft works
Fabric has some sort of datagen system you can use
yeah ik
not a downside just an observation
Right so you'd just simply have to use the PacketDataSerializer, or write directly to the "ByteBuf"
I’ll have to look into PacketDataSerializer
yeah luckily it's quite simple to understand
I use it sometimes to construct packets that don't have the necessary constructor
Thankfully netty isn’t obfuscated so you can just depend on it and its ByteBuf directly
or just for custom data like chunks
I’m curious why they encode the packet length
Can’t they just read until the end of the data
I'm pretty sure they do, and I'm pretty sure it's to ensure you receive the correct length of data.
Fair enough
Yeah they do
tcp networking 101: framing
there is no "end of data", it's just a continuous byte stream with no inherent framing, so you need to come up with your own
it will wait, yeah
the most basic and just reliable kind of framing is bytes length followed by bytes
you could do, like, a delimiter, like a null terminator, but 💀
Essentially it takes the current readable bytes of the Netty ByteBuf, and adds it to the PacketDataSerializer.a(readableBytes) (Not sure what this method does). To ensure the packet is writable for that length.
It then writes the length of the packet using - PacketDataSerializer#d (Writes a VarInt).
And then lastly it writes all the bytes from the ByteBuf to the PacketDataSerializer.
(This is what I get from the Prepender class)
spigot mappings 💀
So it’s just packet id, data length, data
Length - Id - data
Ah okay PacketDataSerializer#a is getVarIntSize
Is that not just the length of the byte array
as a varint
it's just a way to encode a compressed int, instead of always sending an int as 4 bytes
So step by step to construct a ByteBuf/PacketDataSerializer to send to the client
- Write the (to be sent) bytebuf's length as a varInt (PacketDataSerializer#d)
- Write the (to be sent) bytebuf's current data using writeBytes
- Write the Packet ID as a varInt (PacketDataSerializer#d)
- Write the Packet Data
How can I know if the player has an anti kb, I saw talk of the velocity but what value indicates that it is possible that the player has it or that he necessarily has it.
that moment when the fix for SPIGOT-6833 causes SPIGOT-7856
Is the bytebufs data not the packet data
is there an event for potions that place blocks
@young knoll
So yeah it essentially -
Packet encoding
- Write the id of the packet as a varInt (into data)
- Write the packet data (into data)
After, into the outbound ByteBuf
- Writes the packet length as a varInt (data.length)
- Then writes all the bytes for the whole of the packet (data)
I would like to nominate Damageable as a strong contender for the worst part of the spigot api
lolll
public static void when(AtomicBoolean b, Runnable runnable) {
Thread thread = new Thread(() -> {
while (!b.get());
runnable.run();
});
thread.start();
}```
is there a better way to do this
what are you doing
I'm going to need more context this seems possibly very scary
when "b" becomes true, is runs runnable
why
why not
why do you need to run a task when a certain random AtomicBoolean turns true
sounds very suspicious of bad design
my friend told me "why isn't there a when keyword like while and if" so i did that
for fun
and was wondering if u can do it better
I think the best you can do is strive to never use this
ok
Whatchu mean which one
Damagable is an ItemMeta concept and an entity concept
I'm so stupid I was so overcomplicating this plugin loading system never even thought of using a graph 😭
item
CompletableFuture ✨
erm no thanks I'll be using this totally legit system!!
if it works for you
it works 100!!! ExecutorServices are overrated anyways
I just go raw on threads with AtomicBooleans
hello, does anyone know how i would cancel the crafting event for the autocrafters
anyone had this problem where intellij can't recognise bukkit classes and ends up looking like this
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
Does anyone know if there is a way to get the number of lines in TextDisplay?
thanks
anyone had this problem where intellij can't recognise bukkit classes and ends up looking like this
the plugin builds just fine
If I had to guess, update intelliJ
ok I fixed it, went to File -> Repair IDE and kept going until it was fixed (took like 8 steps)
I'm pretty sure getText is the only related method
hah always happens to me
whats the best way to move the player? my end goal is a parkour plugin that generates parkour that has an option to move the player automatically through it
i saw that you can apply velocity to the player but id rather not have to completely mimic the vanilla movement
you could use a pathfinder or whatever and make a tracking shot to show the parkour
wait spigot just has a pathfinder??
this is my first self project after doing youtube tutorials
no
well then you should search for something more easy
nah ive made it before in python i know the coding concepts
but my python one only worked outside of the game
and just generated
to let the player jump the parkour automatically will be the hard part
yeah
i was thinking i would have to recreate the player movement with the vector methods
how to get black stained glass pane in 1.8 itemstack?
yeah but you would need a path or whatever which you can push along
luckily there is pathetic https://github.com/patheloper/pathetic
wasnt it something with setting the byte data
i thought it was just a number
idk its my first time working on 1.8 i learned 1.20 spigot
then screw it lol
ohh
i dont think that would work for parkour
you can make it work for parkour, you just have to create your own strategy
thats where the hard part begins
i would probably just look at how they implement player movement, and use only that then just hardcode jump paths for specific jumps given an end and start point, that way i dont have to do any complicated on the fly reasoning since all of whats upcoming is known behind the scenes in code
no need to overcomplicate with on the fly reasoning when im using disscrete known chunks
wait cant i just do a thing where when registering a new jump, i make a thing that is called every tick that gets the velocity and saves it to a list, then that list can be used to individually set the velocity
then i literally do not need to simulate anythin
then again, the jump of a minecraft player is a parabola of a specific max distance for a given velocity, and you can only gain a specific amount of momentum with a given number of space, and the parabola could be simulated, the vectors would be generated from the slope on that graph.
🤔
simulated seems very possible and kind of fun ngl
Hi Rob, good question. If you want to do this optimally, I recommend storing the usernames in-memory in a radix-tree. Feel free to take my implementation if you want (do bear in mind the LGPL license). The test show guide you on how to use it (basically you call .traverse with the prefix of the username): https://github.com/Jannyboy11/InvSee-plus-plus/blob/master/Utils/src/test/java/com/janboerman/invsee/utils/UsernameTrieTest.java#L47
bit more complex than a trie but does a fairly ok job
The reason this makes tabcompletion efficient for non-empty prefix strings, is you only have to search the descendents of the node that is found when traversing through the prefix.
It's also space-optimised; you won't have to store all the full username strings: common prefixes will be shared in memory.
Hey guys, I'm pretty new to Java and I have a background of C++, I have this snippet of code and not really sure how memory management really works on java, so I was wondering if I had to set the variables to null (I couldn't find a destructor)
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
if (event.getEntity() == null)
return;
PlayerAccount victimAccount = AccountLoader.getPlayerAccount(event.getEntity());
if (victimAccount != null)
victimAccount.setDeaths(victimAccount.getDeaths() + 1);
// else: add 2 queue
if (event.getEntity().getKiller() == null)
return;
PlayerAccount killerAccount = AccountLoader.getPlayerAccount(event.getEntity());
if (killerAccount != null)
killerAccount.setKills(killerAccount.getKills() + 1);
// else: add 2 queue
victimAccount = null;
killerAccount = null;
}
No, you don't have to
Gc will handle that for you
Ah okay I was just worrying because PlayerAccount is a pretty big class and I didn't want to have a bunch of instances just chilling, thanks!
Dont use deprecated methods
(IF there is a replacement)
Which method is deprecated?
Did you use gorilla glue on your hair
none in your code
He was probably scrolled up and commenting on a previous post.
what should I set the default: to for a permission node in my plugin if I want nobody (not even OP players) to have it unless they explicitly have that permission node?
I want to use permissions as a type of per-player settings thing for my plugin, so I have a plugin.ignoreme permission that makes the plugin just not interact with the player
But I dont want anybody (OP or not) to have the permission by default
false
what is the smallest unit of vanilla minecraft hitboxes in units of block pixels?
found a list
In short everything acts as a "pointer" and when there are no references to it the GC will take care of it
it appears to be a lily pad
does anyone know of any block with a finer precisionn than that from newer versions?
hi,i am trynna give a custom nbt tag to an item so it dont stack, i cant import those classes tho
to get a player name from uuid if it never played on the server, I have to use mojang api?
?bt
You might be able to use the PlayerProfile API
is a spigot thing?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Server.html#createPlayerProfile(java.util.UUID)
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/profile/PlayerProfile.html#update()
declaration: package: org.bukkit.profile, interface: PlayerProfile
declaration: package: org.bukkit, interface: Server
yes
It should call the Mojang API for you
how do i make it so the get Cofnig and config woprks?
in the main file i got this
this.saveDefaultConfig();
this.getConfig().set("useWorldguard", true);```
We've told you how multiple times now
how was it
you shoudl saveDefault before you touch the config
There is no getConfig method in your commands class. You need to access it from your plugin instance
doing so with the help of di
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
this again
IM TOO DUMB FOR THIS
Read through it
?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! 🎉
is this riught for the main file?
That's not valid Java
Thats pretty much not even Java, yeah
i dont quite get it how is this supposed to help me
SimpleCore plugin
i already have my server built
its like ehre
and not pvp
which external jar should i import in eclipse
?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 do recommend using maven
?
You need to run BuildTools for your version at least once, otherwise you wont have Craftbukkit and/or NMS on your machine.
and hopefully not the Spigot jar
What version are you writing for?
1.20.4
i already setup my server, arent build tools for building ur spigot server?
In that case you dont need craftbukkit or nms. Since 1.14, Spigot has an API for NBT tags.
?pdc
oh alr
what did i do wrong? bc i did it like in tut
private final pvp plugin;
public pvp(SimpleCore) {
this.plugin = plugin;
}
}```
thnx but is there a way to work with NBT tags without using an api?
And if you are willing to update to 1.20.5:
Minecraft now supports setting the stack size of any ItemStack directly.
plugin variable is of the wrong type
these are not teh same
yoru field is wrong
and yoru constructor is broken
private final pvp plugin;
public pvp(SimpleCore plugin) {
this.plugin = plugin;
}
}```
You cant write Spigot plugins without using Spigot. Not sure what you mean by that.
Its not an external API. Its simply a part of Spigot.
Hello guys, is it possible to register a new DataComponentType in nms?
ohh i just reread it and now i understand, thnx im still confused on why this isnt there by default if its part of spigot
?
what do i do then
Try it and see
Its there by default. If you use Spigot 1.14 or higher, it just exists. Nothing else you need to do.
i tried but when i create a new item with the custom component it crashes the client (disconnecting), it looks like the client doesn't recognize the component but is there a way to prevent sending the component data to client?
You can detect outgoing item packets and clean them up. What is the benefit you hope to achieve with custom components?
Sounds like you're registering custom components?
No
At least not without that happening
Just use the custom_data component
some custom data that i don't want to read from nbt every time i need it, even if i try to sync the de-serialized data with the nbt it's hard to cache it
Making an Item unstackable:
1.20.5 and higher:
ItemStack itemStack = new ItemStack(Material.DIAMOND);
ItemMeta meta = itemStack.getItemMeta();
meta.setMaxStackSize(1);
itemStack.setItemMeta(meta);
1.20.4 back to 1.14:
JavaPlugin plugin = ...;
ItemStack itemStack = new ItemStack(Material.DIAMOND);
ItemMeta meta = itemStack.getItemMeta();
PersistentDataContainer dataContainer = meta.getPersistentDataContainer();
NamespacedKey key = new NamespacedKey(plugin, "__random_id__");
dataContainer.set(key, PersistentDataType.STRING, UUID.randomUUID().toString());
itemStack.setItemMeta(meta);
how can i do that? could you help me with that?
Why can you not use the custom_data component?
i just said why
.
That would require reading the data each time
it's not easy cause item stacks are not like entities to have like metadata or something
What?
ohh, i will already be using the nbt tag sso i will just give it a unique id, thnx tho
how do you expect me to cache the data? if it was entity it would be easy cause i could cache it using it's metadata, but for itemstacks there are no metadata for them
It is incredibly hard to detect when an item is equipped/unequipped.
Detecting changes in the players Inventory and caching the deserialized nbt data on each one is really hard.
guys is there a easy alternative to the config.yml?
config.yml isn't hard
The config.yml is as easy as it gets
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
yeah that's what im saying. if i could create a custom component data type myself it would be way better and way more performance friendly
item meta is not metadata
I personally cache the data in memory data structures and do all the detections via events
with metadata you can store any objects, item meta is like bukkit version of components
?pdc
Metadata is absolute rubbish tho.
I mean, the performance killer isn't the PDC de/ser to your type.
it is ItemMeta cloning
alr i guess i have to figure it out myself, thanks for your time
pdc is the bukkit version of nbt bruh, it's the same with custom_data component
Myeah, depends on how complex your data is and how good your deserialization works. If you have huge data objects in your PDC as json Strings and
deserialize them on something like the PlayerInteractEvent, it can be noticable.
DFU 😉
Yea, true
I dont even know what that means
not that DFU has anything to do with it 
You can just use it to (de)serialise NBT tags ig
but having plugins insert their own class instances into nms is not smart so, you are kinda stuck with de/ser
(or you cache them, which is what I do for most of my shit)
Some 5 min evicting cache that you first try to hit with a single uuid parsed from the data, otherwise do the full read
writing becomes a bit more annoying but is fine usually
I currently use small identifiers in my PDC (just storing integers) and then using a registry to get the respective in-memory Objects.
Getting an int from the pdc is neglible in any event.
On fabric I just create my own Components and throw a CompoundTag into them using DFU, cache it and there ya go
?whereami 😡

Hey
If I call PlayerList#initializeConnectionToPlayer() method, which calls PlayerList#onPlayerJoin(), it calls an event which uses the server thread a lot
And as far as I can see onPlayerJoin() calls PlayerJoinEvent
I am suspecting that another plugin might be listening to PlayerJoinEvent and do resource-extensive operations, but on other plugins the server thread usage is pretty low
Spark should catch invocations from other plugins. How many connections do you have to handle on average?
I am not sure on that since this report was taken from my client. But I can say that this method has been called at least 200 times, aka 200 players joined.
Oh, I just saw another plugin lol
It had 18-19% usage
Its 100% some garbage plugin which loads data from a File/Database and not using the AsyncPlayerPreLoginEvent but the PlayerJoinEvent for that.
You guessed it right haha
Not sure if it's a garbage plugin tho, but for data loading it is
do blocks have PDCs?
?blockpdc
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
nice
What is persistent data container
It is a container which can store persistent data.
persistent means it wont vanish on restarts.
?pdc
You can store data on things like ItemStacks, Entities, Players, Chunks, Worlds, certain Blocks and some more.
All of them have a PersistentDataContainer.
That's cool
Yes its one of the coolest api features and i use it a lot
inventory click event not detect item move with 1-9 numbers
what the event i need use?
InventoryClickEvent
bro
.
It is the event you need
oh wait
I didn't translate it correctly. When I move an item through the keyboard buttons (1-9) from inventory to my inventory, inventoryClick does not work.
Show your code
That is a missconception. The InventoryClickEvent is fired when you move items into your hotbar from another Inventory using the number keys.
btw
how'd I copy the direction of my character
to use in code
nvm, im kinda stupid, i can just print it out

I mean you can also just press F3 and look at the debug screen
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
Ah its in the video
so uh, how do i get a vector from this again..
player.<getVectorMethod>
no um
dont remeber
I want to use my player's vector
but
not on it
like, I want to shoot a snowball from a block
but with this exact direction..etc
player location.getDirection() gives the vector
just spawn teh snowball at the location you want, applying teh vector and velocity you want
*getEyeLocation()
thank you guys
also uh
how do I change the vector so that the starting point is the dispenser block's face?
no
a vector has no origin
a Location is a point defining a position
a Vector is just an indication of a direction
A vector always goes from 0|0 towards its direction.
But you can find out a Location from which to start by using the Directional interface. You can cast the BlockData to it, and then calculate the middle.
i mean tracking back to this problem, u just summon the snowball and apply the given velocity needed? not sure how much you need to overthink concerning vectors
why there's no splash potion in 1.8.8 spigot?
there is?
There is bro
I'll try that
If you are using a Dispenser, then cast to Dispenser, getBlockProjectileSource and call launchProjectile
oh
right
ty
using launchProjectile you can provide the projectile and a vector
What. I thought he wanted to fire a custom virtual projectile via particles...
But he just wants to fire a vanilla Projectile. oof. Good thing Elgarl got thatz
idr exactly but could very much be the case that splash potions just had a custom data value
yeah ill just use resource packs to make it look fancy
What is a good place to get support/guide on how to use protocol lib? I can't find a good place to ask questions
I think the general deal is to use packet events instead, but there should be plenty resources online, like on forums etc
else just ask away here
Today is finishing my plugin loader day
I realized far to late I could use a graph to detect circular dependencies
Perfect for constructing a load order
well i wanted to update the sign from he client side in an an area: here is what I came up with after searching a bit
PacketContainer packet = pm.createPacket(PacketType.Play.Server.TILE_ENTITY_DATA);
BlockPosition blockPosition = new BlockPosition(block.getX(), block.getY(), block.getZ());
packet.getBlockPositionModifier().write(0, blockPosition);
packet.getIntegers().write(1, 9); //read that 9 is to update sign (no way to check if it is true or not)
WrappedChatComponent[] chatComponents = new WrappedChatComponent[4];
for (int i = 0; i < 4; i++) {
chatComponents[i] = WrappedChatComponent.fromText(entry.getKey()[i]);
}
packet.getChatComponentArrays().write(0, chatComponents);
for (var living : location.toBukkit(world).getNearbyLivingEntities(60)) {
if (living instanceof Player player)
pm.sendServerPacket(player, packet);
}
yea, think that is the agreed upon way of doing it, gradle uses a graph and so does spigot/paper iirc
Now I gotta build it then optimize it
good luck :}
is there a way in protocol lib to specify the entity type? like TileEntityType.SIGN or smth
cuz writing 9 i am not sure if it is correct
Before I was thinking about some tree but then I realized that's way to exact I'd need to go higher up and last night I finally realized oh shit graphs
I always forget about them
is there a best libs to make http requests from a spigot plugin?
java have a default http lib?
public static final PotionEffectType HEAL = new PotionEffectTypeWrapper(6);
which effect this resembles?
Yes you can make http requests without a library
ah good

speed