#help-development
1 messages · Page 795 of 1
really that's weird I thought they only supported latest
No like different uuid versions have different purposes sort of
cant you read the version of the uuid in the actual id itself?
Yes
That’s what I asked if y2k could do
one sec I juts have to run UUID#Version or sth right
Like there is one version that tells u the uuid is randomly generated, one that is time based, etc etc
Yea
power them
server settings
theres a setting for how often hopper items get transfered
so its not possible through code?
u can edit the server settings through code.
but you have to restart server, no?
guess so yh
@ivory sleet its version 4
Version-4 UUIDs are randomly generated
seems like this type is almost exclusively used by microsoft*
Ah rip
Gg go next
alr use a UUID as key type for the outer map
And then inner map either array or record
does it matter whether an array or record is used really
No, I mean using an array is more data oriented design of an approach while using record is more of a data oriented programming approach
lol I'ma stick with the array as its an internal temporary object anyways
its just going to get GC'd
Yeah alr
Functional programming approach when
java could never
Skill issue
And then y2k u prob just want to use the map as a read through, right through one right?
if you can make a function, you can make a functional approach
How do you define a function steaf?
There is the mathematical definition which is based of sets
idk just like a method or something
And there is imperative programming one
idk im just trying to get distracted from work
I'm using the map as a cache basically
While the chunks with the generators are loaded it reads them from PDC and writes them into this map.
Once the chunk unloads it takes the data from the Map and loads it back into PDC
Ah alr
and if it happens to be the case that a chunk is unloaded for a specific coordinate, how do you serve the cache end user then?
wdym by this
Let’s say the chunk (-10,4) is not loaded by the api
But somehow a call is invoked to the cache for a coordinate (x,y) in that chunk
explode
🔥🔥
I mean, it is somewhat valid to say "this cache is only usable for loaded chunks"
depends on the premise of the cache
Indeed, absolutely
Worst case, read PDC from region file manually 
since the objects are only really defined with the world calling it in an unloaded chunk is the same as trying to do things with a block entity or entity in a unloaded chunk

I'm on my mission to make a plugin that for some reason most authors tick and do it completely lazily
😎
I'm lazy so my code is lazy too
ticking is for plebs
why nothing happens when i click on the bread, its a inventoryclickevent?
this is all right, it worked before i dont used a async database
Hello, if I did it right: I set the size of the world map using worldborder to 15000x and 15000z world. It works.
And I want the world to be 15000x15000. Then I set the chunky radius to 15000? And I want the world to be 15000x15000 Is that right?
is there a list of slots to slot numbers somewhere?
what slot number is a player helmet?
thanks bb
If you just want to set amor you can use entity equipment
im using player.getInventory().setHelmet(item) but i want to make sure your clicking on the helmet slot
What about le crafting inventory 👀👀👀
its fake
also when i use player.getInventory().setHelmet(item) the item just disapears
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.
Why u not pink anymore
@storm crystal Didn’t feel like paying this month
every time someone says "I see" it reminds me of this https://youtu.be/BaqfM6e9LNc?si=LT_E00dSd8TL_wff
@EventHandler(priority = EventPriority.HIGH)
public static void PlayerInteractEvent(PlayerInteractEvent event) {
ItemStack item = event.getItem();
Player player = event.getPlayer();
if (item != null && item.hasItemMeta()) {
if (item.getType().equals(Material.KNOWLEDGE_BOOK)) {
if (player.getInventory().getHelmet().getType() != Material.AIR) {
player.getInventory().setHelmet(item);
}
event.setUseItemInHand(Event.Result.DENY);
event.setCancelled(true);
}
}
}```
trying to equipt an item as a helmet, anyone know why this isnt working?
im getting java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because the return value of "org.bukkit.inventory.PlayerInventory.getHelmet()" is null
and [10:02:49 ERROR]: Tag not valid: {AttributeModifiers:[{Amount:3.0d,AttributeName:"minecraft:generic.armor",Name:"armor",Operation:0,Slot:"head",UUID:[I;-738681445,809191117,-1596173948,-1024297573]}],CustomModelData:1,HideFlags:2,display:{Name:'{"extra":[{"text":"this is a hat name "}],"text":""}'}}
🥲 should probably check for both, spigot uses a mixutre of null and air or atleast item != null && item.hasItemMeta as he did above
ok its fixed now but it still wont equip it
nvm
oh yeah I can feel that
its sometimes me with rent
this duplicated the book, should i delete 'item' after?
if (item.getType() == Material.KNOWLEDGE_BOOK && item.getItemMeta().hasCustomModelData()) {
if (event.getSlot() == 39 && player.getInventory().getHelmet() == null) {
player.getInventory().setHelmet(item);
item.setAmount(0);
}
}```
trying to make it so you can manually put this item on your head but it doesnt seem to work
also using ItemStack item = event.getCurrentItem();
you need to cancel the click event after this i think
you set the amount to zero? Couldn't that be the issue
hes trying to swap the head and item in hand
iirc you shouldnt set the item to 0 but set the item in main hand to air btw
event.setCancelled()?
ye
He's passing the same instance as the helmet of which he set the amount to zero right afterwards, but that alone wouldn't explain why there's no helmet (there should still be an item stack with amount of zero at least it was in legacy versions)
In newer versions
In legacy versions you were able to have items with zero amount of them (it's weird yh)
So I assume the underlying implementation was changed so a zero amount equals out a removal of that item
@EventHandler
public static void inventoryInteract(InventoryClickEvent event) {
ItemStack item = event.getCurrentItem();
HumanEntity player = event.getWhoClicked();
if (item != null) {
if(item.hasItemMeta()) {
if (item.getType() == Material.DIAMOND_HELMET && item.getItemMeta().hasCustomModelData()) {
item.setType(Material.KNOWLEDGE_BOOK);
}
if (item.getType() == Material.KNOWLEDGE_BOOK && item.getItemMeta().hasCustomModelData()) {
if (event.getSlot() == 39 && player.getInventory().getHelmet() == null) {
player.getInventory().setHelmet(item);
event.setCancelled(true);
}
}
}
}
}```
ok i have this but it still dosnt work
This looks awful on phone
It does indeed
it looks awful normally lol
Yeah we all love 5 nested control blocks
hm this is weird i dont see something immediately wrong with this
have you checked if it reaches that if clause?
so i click to pick up the knowledge book, and i click my helmet slot and it doesnt leave my cursor
Did u register ur handler 👀
I mean first things you should do when you encounter such issues start debugging, so I assume you've done that and the deepest if clause is reached?
uhh
I'm looking at some fairly easy ways to improve your code
ok so when trying to place it on the slot it doesnt pass if(item.hasItemMeta())
Most are covered here
ok
I'd probably rework it as such
ok
well right now i want to fix this
so when placing it item.hasItemMeta() returns false
well that's what programming is about, finding solutions to problems or workarounds. What do you need of the meta data exactly? I mean you only test if it has custom model data right
?jd-s
declaration: package: org.bukkit.event.inventory, class: InventoryClickEvent
@EventHandler
public void inventoryInteract(InventoryClickEvent event) {
ItemStack item = event.getCurrentItem();
HumanEntity player = event.getWhoClicked();
PlayerInventory playerInventory = player.getInventory();
if (item == null || !item.hasItemMeta()) {
return;
}
Material type = item.getType();
ItemMeta meta = item.getItemMeta();
boolean hasModel = meta.hasCustomModelData();
if(!hasModel) {
return;
}
switch(type) {
case DIAMOND_HELMET:
item.setType(Material.KNOWLEDGE_BOOK);
// fall-through
case KNOWLEDGE_BOOK:
...
break;
default:
// no-op
return;
}
}
type deal
bit cleaner
declaration: package: org.bukkit.event.inventory, class: InventoryClickEvent
He wants to click his cursor onto the helmet slot
I'm not fixing code just making it acceptable
just use a switch for that item type
Nah you don't need to honestly, not for two cases imo
I haven't used switch in years
could just go with an or too lol
That is just over engineering to make it look more organic but it isn't
remove that extra if
that's the syntax right?
that?
forgot the default
fuck
Ah you edited it
there
yeah I won'd use switches a lot either
there is updated switch stuff too now
which I forget the usage for
I know nobody asked for my opinion but a switch case for this instance just makes it look awful if I'm completely honest xD
which is why I don't use switches
Well you write an entire default block without any usage or gain out of it
I can read code if it contains 100 if statments just the same if its some other thing that condenses it
With 2 cases and one fallthrough
you could do 1 case and fallthrough instead if I remember right
don't think it actually has to have a 2 cases specifically outlined, just 1 case and a default as that counts as 2
So idk it just doesn't click for me why you should prefer a switch case over the more simplistic approach of if else clauses
never said you should prefer it
you would*
however if I was doing it, I would have used an || on that item type comparison
since it can only be one or the other
well
and I would have done a reverse check on it
you can just do an || and set the type regardless
I'm worried about side effects regarding item meta
This is similar on how I would've done it, going after google's approach
@EventHandler
public void inventoryInteract(InventoryClickEvent event) {
ItemStack item = event.getCurrentItem();
HumanEntity player = event.getWhoClicked();
PlayerInventory playerInventory = player.getInventory();
if (item == null || !item.hasItemMeta())
return;
// just overseen a possible nullpointer lmfao
ItemMeta meta = item.getItemMeta();
if (!item.hasCustomModelData()) return;
Material type = item.getType();
if (type == Material.DIAMOND_HELMET)
item.setType(Material.KNOWLEDGE_BOOK);
if (type == Material.KNOWLEDGE_BOOK) {
// ...
}
}
i think this is much more expressive and fitting than a switch clause and unnecessarily using locals when only used once
well its only local to the method so it doesn't really matter since that method is going to be invoked regardless
wonky code flow
you shouldn't use a switch with materials anyways
it's more about the code asthetics not about the callstack or whatever (if that's what you are aiming at)
future changes yada yada
have you lentlemen seen a working implementation of custom block hardness using mining fatigue in 1.20? All of the resources I could find are outdated
switch is inferior because it provides incompatibilities with the new registry stuff
asthetics are not important in programming and generally will lead you at some point to problems
its been forewarned for a while now
so if people decide not to head and have a lot of maitenance
on them
I disagree, when you work in enterprise or teams you have to fulfill guidelines and aesthetics to be approved in code reviews. Consistency and core principles is key in good vs. bad software
but functionality wise aesthetics have no impact (if we define aesthetics the same)
frosty has been throwing some wild takes lately
enterprise doesn't care how it looks, just whether it works or not and meets the requirements needed
that is just wrong tho
idk what teams you are working on that cares about looks
Enterprise cares about future-proofing and consistency on top of just functionality
some teams care how it looks, I mean tbh as long as it follows some styling guidelines I don't see the big deal
google, netflix have entire guidelines on how their code should look and is done
but i get your point, if you're the only programmer on a project then it doesn't really matter yh
At work I'm fairly strict on maintainability and stuff
mining straight down is safe above y 12
but it will matter when you come back
Some yes, and if it doesn't affect the performance, but in Java this isn't always the case and it does matter where you are or not declaring variables
and other stuff
If you're working by yourself no one cares, if you're working with others you want to make sure you are not hated by your peers
If you're the only one that understands how the code works you become a liability
tbh (even tho I just brought up that argument myself), this argument isn't really true. Imagine you come back after a while to your source, a good style guideline is key to finding issues more quickly and more efficiently
yea i try to avoid writing code like that but i cant even understand my own code half of the time
but on small projects it really doesnt matter
It leads into 3 scenarios:
- You get fired and your entire project is recoded from scratch
- You lead a team that recodes it
- You have to document and teach someone / a team on how to maintain your project
I think you mean how it should be formatted?
format is not the same as defining other aspects of the language
that is to say, the format doesn't go on to say switches can't be used
not just the formatting, but general guidelines on when to use what in what scenario, also naming conventions (which may fall under formatting tho)
erm well some guidelines define exactly that
code architecture matters
You can't just throw everything in a class, slap static everywhere and expect to not get fired
"but it works bro"
exactly 🤣
There is no enterprises that forbid usages of stuff in a language
Hi! Im new to Java, so please be patient.
Im struggling with this, and i dont really know what the problem is?
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
public final class Discord extends JavaPlugin {
}```
The end( } ) has a red line under it and it's a error..?
This isn't my 'main class'(or whatever - Its not the first class, that was made when i created this project)
They forbid the misuse of features
hover over it
Your IDE tells you the problem
It says that it is expecting a Interface or a Class, but i dont really know what it is ;p
extends
whaats that :8?
youre only supposed to extend javaplugin on ur main class
@EventHandler
public static void onEntitySpawn(org.bukkit.event.entity.EntitySpawnEvent event) {
if (event.getEntityType() == EntityType.WANDERING_TRADER) {
Entity trader = event.getEntity();
}
}```
how do i add trades to this entity
well yes, the java plugin is where you tell the server 'look here for startup'
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
public final class Discord extends JavaPlugin {
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return true;
}
}```
I mean, this is all of my code. Shall i remove the red thing bracket?
believe the trades are created when the window opens 🤔
Ohhh.
oh
also commands need to implement commandexecutor, not extend java plugin
Oh, yea. What shall i edit in this file? What shall i remove?
Do i use "shall" correctly? xD
(technically you can do both but then its just a mess)
also you need to do 2 things here
remove the first } because thats not supposed to be there
and change 'extends JavaPlugin' to 'implements CommandExecutor'
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
public final class Discord implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return true;
}
}```
So this?
yea
what event should i use for adding a trade to a wandering trader
Thanks!!
then you just do your command stuff in that
i looked at some events but im not too sure what to use
the best one is probs to replace it on spawn
which packets sets an enitity to mount another entity?
As in adding merchant offers?
use the inventory events
or generated its trade
declaration: package: org.bukkit.inventory, interface: Merchant
Well there is your event
EntitySpawnEvent and then add a recipe to him
Uhm, hi again! I have trouble with defining the player... The last "player." you see, is the red one.
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
// /discord - Sending you a discord link
if (command.getName().equalsIgnoreCase("discord")){
Player p = (Player) sender;
player.sendMessage("Discord link:");
}
return true;
}
}```
It tries to make me define a player, but it doesn't really work.
...
names the variable p
Point out where you define your player variable
is confused as to why there is no variable called player
Oh, genius. Thanks :D
You stole my player!
I didn't know that the "p" was the actual name. I thought you just could use "player".. My bad :-}]
i cannot find the entity mount packet on the protocol wiki, what is it called?
When i write /discord(the command is valid, yes!), nothing gets send to me :-[?
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
// /discord - Sender dig et discord link
if (command.getName().equalsIgnoreCase("discord")){
Player p = (Player) sender;
p.sendMessage(ChatColor.BLUE + "Discord link:" + ChatColor.WHITE + "-");
}
return true;
}
}```
Whoops, send discord link - Sorry!
well did you register it?
Show us how you register this command
version: '${project.version}'
main: dk.mcbjerget.meteoren.plugin5.Plugin5
api-version: '1.18'
commands:
discord:
description: Få tilsendt et link til vores discord```
Din JavaPlugin class
Hold up, du dansk? a hah
Hvad er JavaPlugin class for noget?
Er det den første class, som bliver lavet?
Adding this to your plugin.yml is not enough. You need to register an executor for this comman,.
Din Main ja
Ohh, okay. How do i do that?
xD
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Thanks ;-]
this.getCommand("discord").setExecutor(new CommandDiscord());
I've added this under my main class, in the startup thing - Just like in the docs. But the "CommandDiscord" is red, and it doesn't help, when i hover over it.
import it
How, what?
Ur class is called Discord
turn on auto imports
Oh, i have imported. It isn't that.
Nope, my main class is "Plugin5", but all the command stuff(Alll that i send above my newest), is in a class called "Discord"
If your class is named Discord then you shouldnt expect to find anything if you create an instance of a class called CommandDiscord

Ej, føler mig lidt dum. Det jeg faktisk ked af :(
Hey, if you are just starting with Java and you don't have experience coding, it's not always the best idea to start with plugins. You are going to run into a lot of very trivial problems just because you don't understand the basics and the syntax of the language. You can take any approach you want, but imo you'd be better off first getting familiar with the language. There are a lot of good resources online for that
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Thaaanks :D!
welp im having this issue again, is the only way around this a builder method?
I'm trying to avoid a massive method call a la
this(center, new Location(start.getWorld(), start.getX(), center.getY(), start.getZ()), new Location(start.getWorld(), start.getZ(), center.getY(), start.getX()... distance);
just make more constructor overloads till you pop
A builder would be infinitely cleaner lol
looks like you are going the wrong way around
Why insist on constructors anyway
I dont understand how you could create a circle with a center and a start...
this is for a flat circle, which will be like 99% of uses
what is start
so i only need center, point on circ, distance
Then you only need a center and a radius
yeah what is distance xD
radial distance betwen points, im generating location lists to represent geometric shapes
if distance is radius then start needs to be on the circle?
yea, im generating my shapes from sets of points that define them
or is radius just the distance between center and start
Ok so you create a vector, going from your center to your point, and then extending until you reach the length "distance"?
But you can literally create an infinite amount of circles through that...
well no
Is your circle always parallel to the ground?
also no, hence me calling the super method, id like to avoid duplicating code
im using the distance to calculate the angle, and the vectors from the center to the circle surface to generate the plane the circle is in. Then i just rotate a vector around the center location with that angle and plane and mark the locations it hits until it completed one rotation
So your "distance" is your step size in radians (Or degrees).
its part of the blocks data i think
its the distance on the surface, the boolean of the super method is the mode (radians / distance)
cuz i cant have two constructors with the same signature
What do you mean by "distance on the surface"? A distance is a measurement for length.
but yeah you should probably use a builder
like the length of the circle segment
So the radius of the circle?
so you can make parts of a circle
probably. whats the proper exception to throw if the builder's used wrong? IllegalArgumentException
so a distance can be the whole circle on a small radius but only part of it on a bigger radius
hence why it also accepts radians
again depends on the mode, sometimes you dont know both
for flat circles it assumes you know the distance
the reason im assuming that is that depending on the particle you know usually how far apart they can be before they appear disjunct
Alright, now if you have two points, A and B, then you can literally create an infinite amount of circles through those two points.
How do you know where to rotate towards?
cuz this constructor assumes the circle is flat
Please explain to me what a non-flat circle would look like...
a circle rotated in 3d space
Which is still flat
with 'Flat' i mean that the circle's y values are the same
i want equal with note value in json file blockState
but note this class (
Ok so when i asked if the circle is always parallel to the ground, and you answered 'no' you lied.
and note has 3 int value
are both points a and b on the circle?
You dont need two locations for that. Just one location, a radius, and a step size
I think he projects the second point onto the XY-plane of the center
For 'some' reason
oh
Yes in minecraft coordinates its xz
(im now realizing theres a mistake in my math tho)
Then why do you have a second Location?
right, like a top down kinda view
because i once again assume you dont have the radius
or you wouldnt in the use case im making this for
Here. Just wrote that (For radians)
public List<Location> getCircleLocations(Location center, double radius, double angleDeltaRadians) {
List<Location> circlePoints = new ArrayList<>();
for (double angle = 0; angle < 2 * Math.PI; angle += angleDeltaRadians) {
double x = center.getX() + radius * Math.cos(angleDeltaRadians);
double z = center.getZ() + radius * Math.sin(angleDeltaRadians);
circlePoints.add(new Location(center.getWorld(), x, center.getY(), z));
}
return circlePoints;
}
Well but if you have two locations, then you have a radius for the XZ projection
public double getProjectedDistance(Location loc1, Location loc2) {
return Math.sqrt(Math.pow(loc1.getX() - loc2.getX(), 2) + Math.pow(loc1.getZ() - loc2.getZ(), 2));
}
Here. Thats your radius on the XZ plane for two vectors in 3D projected on the XZ plane of the first loc
thats true, but im creating the circle based on locations anyhow
tho isnt the code there not assuming your deltaRadians can be multiplied by a natural number to get 360?
for larger values of deltaRadians it may produce problematic results, like if u tell it delta = radius
Then just truncate
angleDeltaRadians %= 2 * Math.PI;
for (double angle = 0; angle < 2 * Math.PI; angle += angleDeltaRadians) {
double x = center.getX() + radius * Math.cos(angleDeltaRadians);
double z = center.getZ() + radius * Math.sin(angleDeltaRadians);
circlePoints.add(new Location(center.getWorld(), x, center.getY(), z));
}
or instead of specifying the angle between each location, just have an amount of locations
and then every point can have the same distance to the other points
yea that'd be the ideal case
the delta radians given >= delta radians required then
but whats the math to get that
Sure, amount of points on the circle works too.
Then you just pass an int and define double angleDeltaRadians = (2 * Math.PI) / pointCount;
im aware, it's just that if radians are given they might need to be 'smoothed out'
so that that up there doesnt happen
int points = Math.round(0.5 + (2 * Math.PI) / radians);
this sound about right?
Hi , does anyone know why InventoryClickEvent doesn't called while shift clicking?
@EventHandler
void InventoryClickEvent(InventoryClickEvent event){
Inventory inventory = event.getInventory();
HumanEntity player = event.getWhoClicked();
if (!(inventory instanceof AnvilInventory)){
return;
}
if (!event.getSlotType().equals(InventoryType.SlotType.RESULT)){
return;
}
// for (int i=0;i<inventory.getSize();i++){
// System.out.println(inventory.getItem(i).getType());
// }
// event.getWhoClicked().setItemOnCursor(event.getCurrentItem());
// System.out.println(event.);
// inventory.clear();
if (!inventory.getItem(1).equals(MoneyMendingBook.item())){
return;
}
System.out.println(event.getClick());
if (event.isShiftClick()){
return;
}
player.setItemOnCursor(event.getCurrentItem());
inventory.clear();
}```
You can just cast this to int instead of using Math.round
and add 1?
Which part doesnt get called
Add 0.5 and cast to int
whole function doesn't get called
k
Did you register your event?
If you registered the listener and added your EventHandler annotation then the method gets called or you get an exception.
Which one is it?
it didn't throw any exception , and it doesn't get called(i see it using debugger)
it is ignoring shift click now
hm
and the slot got clicking is result slot of anvil
im making a builder rn. Should i just have one 'build' method, or two separate methods for the flat and 3d circle?
what would be the best way to see NMS changes
But normal clicks work? Are you in creative mode? Which spigot versiona are you using?
I think using https://mappings.cephx.dev is pretty decent, Go to the class oyu want to check and press the clock button
normal click work , i tried it both creative and survival
spigot 1.20.2
THANKS BIG MAN 💯
Alright. Ill try to reproduce the problem
where can i formally complain to mojang for changing nms too often
I believe you can make a reccomendation to stop improving their codebase on the suggetions website
oh right that aside, if i do make a builder, should i throw an IllegalArgumentException or fail silently if wrong values are passed?
illegal arugment exception!!!
failing silenty lacks context!!!!
thank you
and on the build, if theres wrong data? IAE or RTE?
IAE
specific
IAE is more specific
ah
alright now i have a question about obfuscation
public final class SpigotSandbox extends JavaPlugin implements Listener {
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onClick(InventoryClickEvent event) {
getLogger().info("Clicked: [" + event.getClick() + "]" + event.getSlot());
}
}
Clicking into an anvil result and getting an item from there, fires the event. Doesnt matter if its a shift click or not.
🤔
why does 🅱️lud use the obfuscated field name in one place and deobfuscated in the other
can I use either obfuscated or mojang when working with NMS?
or should i stick to one of them
Add debug messages to your code
mojang
its way easier to update and maintain
most of the time you just copy paste code xD
so the guy had no actual reason to use obfuscated and mojang mixed?
nope
oh
if you do multiple modules you can use the mappings
Got a NPE getting a command, code: https://paste.md-5.net/opitahiqov.cpp
InfiniteKits line 34
why not use just multiple modules?
im only planning on supporting 1 version lol
oh then just use mojmaps and no refleciton
unless you need to specifically use reflection to change field values or something that you usually can't access
getCommand("getkit").setExecutor(new GKitCommand())
should i still use IAE for if the chunk isnt loaded or something else?
Show plugin.yml
OH
add getkit to your plugin.yml
i spent like 3 hours trying to get nms to work and now you tell me i need to use something else 😭
?nms is the best way unless you absolutely need reflection no point in using it
its just a hastle
i mean idk, the tutorial i was following uses this
what are you trying to get
i guess im trying to overwrite the sound for block breaking
it work correctly when other items , but when i getting result after prepareAnvilEvent , the inventoryClickEvent will not be called.
no clue how tf you'd do that without mixing in, unless its a field you can change
Sry but this sentence makes no sense to me
if the field is private static final pretty sure you'll need unsafe
Why so complicated
hold on , i'm adding debug code on prepareAnvilEvent
the resource had like half broken code so im trying to update the gh version instead
im still tilted we cant just register a handler to Event
did you ever end up solving this btw lol
?
you cant register a handler to Event. It would make certain things SO much easier to test
just Event
Why would you need that
oh you want an example?
You can jsut register all events easily
it is possible for left clicking to neither trigger entityDamage nor PlayerInteract
took me a few hours to find the only event that still fires if you do
that being ArmAnimationEvent
like seriously wtf
val reflections = Reflections(nameSpace)
reflections
.getSubTypesOf(Cancellable::class.java)
.filter {
it.declaredFields.any { field -> field.type.name.endsWith("HandlerList") }
&& !ignored.contains(it.name)
}
.forEach {
EventRemapper.remapAndSubscribe(it as Class<out Event>, isCancelledMethod)
}
👌🏻
wallah ever heard of jesus?
Ur lukas not jesus
ever seen him irl?
that's what u think
i honestly forgot that channel exists
should rename it to shitposting
eh fair
dont think i got an answer for this earlier btw
do i throw an IAE for data mismatch in the build method?
or smth else?
@EventHandler
public static void onEntitySpawn(EntitySpawnEvent event) {
if (event.getEntityType() == EntityType.WANDERING_TRADER) {
WanderingTrader trader = (WanderingTrader) event.getEntity();
trader.setRecipe(trader.getRecipeCount() + 1, new MerchantRecipe(CreateHat.createHat(), 1));
}
}```
so how do i add a trade to this guy? this didnt seem to work and i didnt find anything on the javadocs
If argument is wrong, yes
think i have smth for this
1sec
@EventHandler
public void onVillagerPrepare(VillagerAcquireTradeEvent event){
MerchantRecipe recipe = event.getRecipe();
ItemStack result = recipe.getResult();
//Item manip in progress...
recipe.adjust(result);
}
the setRecipe might only work if you do it on an already existing recipe
is there an addRecipe method?
hmm , i find that it is because ViaBackward
hm theres not
hmm
you might get somewhere adding something to getRecipes and setRecipes
i am testing on a server on 1.20.2 but i am testing on 1.19.2 client
so it didn't got the shift click correctly
but when i run on 1.20.2 client
it got called
maybe viabackwards parses the event wrong
Via things are always a little broken
cough negative y values cough
I mean via everything is scuffed asf
btw am i even getting the wandering trader right?
casting the entity?
i mean if it does run and doesnt throw yes
does EntitySpawnEvent work with spawn eggs
does anyone know if its possible to send NMS Packets via protocollib
specifically im trying to send a ClientboundBlockDestructionPacket but since the sendPacketNearby method got removed im wondering if protocollib supports sending it
forgot to register the handler
-.-
hey! anyone know how i can override the default bukkit ban msg? right now i have this code:
@EventHandler
public void onPlayerLogin(PlayerLoginEvent event) {
if (event.getResult() == PlayerLoginEvent.Result.KICK_BANNED) {
event.setKickMessage("You are banned from this server.");``` but it just does the default bukkit ban message, how do i make it custom?
the issue of saving a large number of blocks to the database. Do I check that they are still in the world or trust completely on events?
Why are you saving blocks to a database
What's wrong with PDC here
It seems like the logical choice when dealing with the world
to save in the chunk?
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
it's just that databases are faster
yes
Where the fuck did you get that from
So you think saving to a file is faster than saving to a database?
Your saving to PDC which then the server saves to a file. When working with the world PDC is your best option as far as storage goes
Also yes it will be faster depending where the db is hosted
You deal with latency when working with databases
Because databses scale much better than a file system
It also allows the data to be replicated and avaliable across many nodes
But the thing here is your dealing with a mc world store the data where it belongs
oh i was read post, file save really faster
I'm not saying database suck just know when to use then
please does anyone know?
the server takes care of loading the chunk PDC
the chunk PDC is a full in-memory structure
now, PDC has its downsides
its data is bound to the Chunk which is great if you have the chunk. It is not great if you don't
wdym
when a chunk is loaded, the chunks PDC is loaded by the server from file
the PDC and all its values hence exist in memory when its chunk is loaded
memory access is multitudes faster than a database connection, simply due to the fact that no IO is involved
now, PDC might not be the best solution anyway tho. It depends entirely on your usecase
hm
if you need that data when the chunk isn't loaded, PDC is terrible
as well, it only exists when the chunk does
at which point, do a DB
but if you have extremely block specific data (idk, custom items stored in the thing or something)
pdc is great
I just heard that the database is 1000 times faster
almost everyone has said that to me.
i have no idea who in their right mind said that a database is faster than PDC
it may be faster than files on disk
for some usecases
or is it a moot point and it's hard to say which is faster.
PDC is literally just a Map<NamespacedKey, Value> internally
like
you are just using a fancy map really
the server loads that map for you
you use persistent data types to ensure the data you store in that map can be written to the server specific format
but beyond that, it is just a Map
you are probably misconstrueing in what was actually said
I doubt anyone said DB was faster then PDC and I doubt you even asked the question in regards to this as well
PDC uses files as far as I know, that's why I compared
just like how any game uses files
Even databases use files
I think online games use databases to store data
Chop Suey by System of a Down?
yes but online games also use files to store information too
but I think it's optimized
its optimized for a lot of data
the question is how much big data
more than you need for your plugin
hey guys i have a dumb problem if i use player.getInventory.setItem(Equipment Slot, Itemstack) and i insert the Options it always changes to player.getInventory.setItem(int, Itemstack). idk if its a problem of my IDE or im just to stupid.
well then files always win in speed and the database in quantity
This means I was in vain connecting the database to my plugin....
and I only kept the id there
i always find the bug when i try to complain about it here so ill try again lmao
note that the manager.getService(qualifiedSourceKey) eventually calls the create method, and qualifyServiceKey sets the remote channel name.
now tell me how the value changes bruh
this is prob vague as shit
then are there cases when a database is needed for a plugin (not cross-server plugins)
well in a way yes, but it depends how you are saving to file really
flat file storage is one of the slowest ways to store and read from
flat file storage is human readable format, IE yaml for example is flat file storage
it is one of the slowest ways to store data and read from
yml slow for save data? this what you mean?
i just store stuff in PDC bc i usually only need a boolean array
i cannot find the entity mount packet in the protocol wiki, does somebody know what it is called?
if you don't even know about the variety of storage formats and the sorts why are you even asking which way to store stuff
as this point you are better off just using which ever is easiest and works for you
have you tried teleporting entity a ontop of entity b and setting entity a's passengers to b?
no like literally
tell the entity 'your location is this now' and the other entity 'your passenger is this entity'
I know about the variety of formats, but when you said that the file system for storing a database is faster than a database, you didn't mention the yml format.
do you absoluletly need to mess with packets?
flat file format is any format that stores data in human readable form
which is why I was surprised
so yaml is one of them because you can open it and read it without using anything else to do so
ini files same thing
yaml might be the worst option i cant imagine the syntax being very efficient/parsing being very fast
however, while it is one of the most convenient for your end users it is the slowest way to write/read from
i cannot find the entity mount packet in the protocol wiki, does somebody know what it is called?
preferably use a database
or at the very least a binary format
tho thats prob more difficult to set up
json isn't really a storage format, its a data format. You can save this format to a file if you want, but it will still be flat file unless you are saving it as binary
u should check out sqlite or hikari
what format does minecraft use to store chunks of blocks, etc.
mysql/mongo/any other if u need cross-server support
nbt is like binary json almost
the actual block data is encoded as a byte/short array im pretty sure
should I use this guide: https://www.spigotmc.org/threads/how-to-sqlite.56847/
or this one: https://www.spigotmc.org/resources/sqlitelib.46801/
for setting up SQLite
uh outdated
both?
and if I store data in files in the form of bytes, will it be faster than databases, provided that huge data is stored?
can someone help me on how to use the enitity mount packet?
No? Maybe?
Some databases depending on location are just as fast as some files
Yes it seems to be a really controversial topic I just want to identify the criteria when to use regular files and when to use a database.
Whenever you feel like it 👌🏻
If you want smth crossserver etc etc. Go for databases
logically...
If you got something extremely huge
Go for databases if it’s singular but a lot of data
you misinterpreted my entire first point and turned this into a database vs file storage topic. If you're storing data to blocks in a world it just makes sense to use PDC and NBT
Yes
this isn't what is better in general, this is what is better and makes more sense in your case
Though. Don’t overdo it
you provided not a lot of information so I responded with the best response with the information you provided
you said you were storing something to do with blocks so PDC makes much more sense than a Database here
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
Yes, but I was thinking about other situations when storing user data, for example.
Depending on the usecase for the data
or action
Depending on the usecase for the data
you have to beable to make an informed decision on what data storage you will use depending on what data you have
hash, save, upload
this all
for example, an auction needs to store data about the item
time, player, price etc
if this not cross-server plugin file system better?
Auctions can be both just fine
unless you want it to work cross server you could go either way
I just thought that if I stored them in files, it would take a long time to load the items when opening the inventory.
than the database
you need to load files on server start
player.isInvulnerable() doesn't exits in 1.8?
put them in memory
Probably not
probably not legacy versions don't get new API
all loading must take place during runtime
when player add, delete item
not in start
files aren't databases
or stop ver
You load previous auctions on start
When a player opens you display them
When a player adds you add to them
When a player deletes you remove from them
hashing store?
how come multipe accounts can connect to a server but only one debug hook can be applied?
Hashing is a one way function which turns some object or data into a number
any1 got up to date guide for SQLite?
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
PacketContainer packet = manager.createPacket(PacketType.Play.Server.MOUNT);
packet.getIntegers().write(0, entityID);
int[] passengerIDList = new int[passengerID];
packet.getIntegerArrays().write(0, passengerIDList);
manager.sendServerPacket(player, packet);
}```
why does this code doesnt work, it doesnt set the entities ass a passenge :(
You are sending an empty list
You a creating an int array of size ID
i need to say new int in .write ?
jantuck
Yes
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
PacketContainer packet = manager.createPacket(PacketType.Play.Server.MOUNT);
packet.getIntegers().write(0, entityID);
packet.getIntegerArrays().write(0, new int[passengerID]);
manager.sendServerPacket(player, packet);
}```
this doesnt work too
Still sending an empty array
for real?
ok
right click the SENTRY logo in the top left
On phone?
jan how do i add stuff into it now?
oh
sorry that ur lame like that
when ur on computer try it out
its actually really cool
Just int[] stuff = { passengerID }
ok thanks
https://fxtwitter.com/MichelleBakels/status/1724828291528319030 @rotund ravine is what I was trying to get u to do xd
wowow @getsentry this is so nice!! 🤩
Ah k
thank you bro
@EventHandler
public static void onEntitySpawn(EntitySpawnEvent event) {
if (event.getEntityType() == EntityType.WANDERING_TRADER) {
System.out.println("trader spawn");
WanderingTrader trader = (WanderingTrader) event.getEntity();
//trader.setRecipe(trader.getRecipeCount() - 1, new MerchantRecipe(CreateHat.createHat(), 1));
List<MerchantRecipe> recipeList = trader.getRecipes();
ArrayList<MerchantRecipe> recipes = new ArrayList<>(recipeList);
MerchantRecipe recipe = new MerchantRecipe(CreateHat.createHat(), 1);
recipe.addIngredient(new ItemStack(Material.DIAMOND_HELMET));
switch ((int) (Math.random() * 10)) {
case 1: recipe.addIngredient(new ItemStack(Material.DIAMOND, 6));
case 2: recipe.addIngredient(new ItemStack(Material.GOLD_INGOT, 12));
case 3: recipe.addIngredient(new ItemStack(Material.IRON_INGOT, 32));
case 4: recipe.addIngredient(new ItemStack(Material.NETHERITE_INGOT, 1));
case 5: recipe.addIngredient(new ItemStack(Material.DIAMOND, 16));
case 6: recipe.addIngredient(new ItemStack(Material.REDSTONE, 64));
case 7: recipe.addIngredient(new ItemStack(Material.ANVIL, 1));
case 8: recipe.addIngredient(new ItemStack(Material.DIAMOND, 12));
case 9: recipe.addIngredient(new ItemStack(Material.EMERALD, 16));
default: recipe.addIngredient(new ItemStack(Material.EMERALD, 12));
}
recipes.add(recipe);
trader.setRecipes(recipes);
}
}```
why does this keep saying that im using more than 2 recipes, the only ingrediant that doesnt say that is when it chooses the default one
Because when you work with switch statements there's a concept called fall-through
If you don't have a break statement it's going to fall through to the second case, then the third, then the fourth, etc.
ohhhhh
You need an explicit break if you don't want it to fall-through to the next case
yeah thats right i completely forgot
What you could do to resolve that without needing a break is to use a switch expression which doesn't have fall-through
Basically just replace the : with a -> instead
Java 16+ though
Do you think it's more reasonable to use a single skript plugin instead of many small plugins and write these features as a skript?
Script?
Sorry i mean skript
I would always choose a plugin over a skript
But you can make a plugin that runs kotlin scripts and write lots of those
Okay but why? Does it negatively impact server performance?
Yes it does
The amount of times i have seen skript in spark logs are insane
People do dumb ass shit with it
Oh thanks a lot
ByteSkript time
Is it better?
It compiles to bytecode
So in theory it should be about as fast as a plugin if your script isn't a mess
and if the compiler is any good :^)
does anyone know where i can find documentation for sendPacketNearby
in intelij is there a way to make it so theres predefined code inside a java file when i make a new one
idk why i struggled so hard to find this but its just been renamed to broadcast
can someone explain why typing 'sha' then hitting enter for auto complete results in this
like whats that
its nowhere else in my code either
okay so uh
i have the nms stuff i wanted to do ready but
now my issue is actually getting it to work on the server lmao
the plugin cant find the NMS classes
did i miss a step-
hm
Looks like it's a comment used when you want to avoid pushing known bugs to prod
you want to use the obfuscated names
uh but then my ide wont find the imports
im on maven tho
you should probably have some build logic in charge of reobfuscation
oh fr
That shortcut is probably just builtin to IJ just like fix me
hm true, seems weird tho
cant believe i randomly found something like this again
i managed to crash myself in 4dminer the other day by finding just the right wrong orientation
i guess i need something like alex's remap-obf for gradle
paperweight-userdev lol
alternatively https://github.com/patrick-choe/mojang-spigot-remapper
^
is it possible to write an algorithm to detect if a given player is underground? I was thinking about first checking the x & z coordinates of the player's location for any large amounts of air above a given block, and if that fails due to a tower or smth then analysing the entire chunk that a player is in, find the average surface y level by checking for large amounts of air above any given block, and then check if the user is below that?
oh right thats what the plugin did
i added the plugin but i never understood what it did 💀
possible yes, difficult also yes
depending on your definition of 'underground'
discord:
description: Få tilsendt et link til vores discord
info:
aliases: information
description: Få tilsendt info om serveren```
Is this done right? /Discord and /info is 2 different commands.
An easy underground check is just to check the heightmap
heightmap?
But that’ll also count if they are just under a random block
Are you writing to me?
heightmap is just highest non air block isnt it?
Yes
i dont think thats meant for underground checks lol
I believe there is also one that ignores leaves, but yeah
cough
Looks fine
You might need quotes around the description because of the special characters
Im trying. Its only the "Info" command, that doesn't work.
shouldnt aliases be an array
do you guys think its ok to make your own preconditions framework
isn't guava even exposed by the spigot-api 😅
yeah
reinventing the wheel is usually not the smartest idea
Preconditions works pretty well
not even reinventing something fun to make
preconditions libraries are boring and repetative
legit they just evaluate boolean statements and throw exceptions if they're false it doesn't get much more boring than that
isnt it also like one class though
yeah, but like why its shaded is spigot
legit just a ton of boring administrative work for what
maybe you dont have access to spigot everywhere in ur project
fair, but I doubt that is the case here
true
also wait its 5 miliseconds in a tick right
public long ticksBetween(long now) {
long between = now - current;
return between / 5;
}``` pretty sure this would get ticks between 2 milisecond time stamps right?
50
1000 / 20 = 50 :p
shhhh I thought there were only 100 miliseconds in a second
Imperial System baby 
Sorry I prefer my units in random arbitrary increments
is there any specific event to select random player to be the target?
Just.. Get random number from 0 to currently online players
And use it as index for Bukkit.getOnlinePlayers
is there any event fired when a player stops digging a block
is there any builtin methods to check if something is the best tool for breaking a block
is there a way to only generate entityids that arent currently in use?
Use nms.Entity.ENTITY_COUNTER
nms?
well entity ids are not a concept in the API really
you generate an "unused" entity id by incrementAndGet the AtomicInt
so you'll need internals
and this would be bulletproof, so it wouldnt return numbers even though an entity just spawned with the exact number?
what do you need an entity id for then ?? o.O
im using protcollib maybe i jsut dont understand the term nms correctly
hmm maybe PL has a helper for this ?
net.minecraft.server
pretty much just "server internals"
so follow any run of the mill tutorial for those
I can’t believe Mojang just leaves radioactive variables hanging around in their code, this is a kids game!
?
I need to learn how to properly make use of atomic variables
Mostly because they have like 10 get and set methods and idk which one to use
how do i create a entityid that isnt currently in use then?
Use NMS or reflection
random.nextInt() 
Hi all,
i'm looking at create a head hunting plugin for my server, can anyone suggest the best way to supply mob heads? for those that aren't items for example Pig heads?
is this multiplier additive?
like
if someone has a diamond sword is it 1.5 + 8 or is it just 1.5
Expose nms as api 
Sorry could you explain a bit more! sorry to be a pain
Minecraft heads has a ton of heads you can browse
And grab the link of for use with the api
Yeah nothing wrong with that
Okay, so essentially, we get all the mob/animal head IDs from Minecraft Heads, store them hardcoded, and call them when needed through the API? It feels wrong for some reason
You can have them in a config if you want them to be customizable
Ok, i guess if they never change its fine
ok thanks
Yes
thankz
alright ima be honest
i dont feel like recoding the whole vanilla breaking speed calculation system
is there any resource or library for it 😭
Doesn’t look too bad
i wanna die
I have this issue: when I start the plugin for the first time and it creates the config files, it creates a fake value - let's say 'b', but it should be 'a' (b is used as well and it's stated in the next line), but next time I run it with the config created already, it works normally.
I assume it's some loading issue but the all config stuff is called before creating the thing that causes the issue.
Show the code
Maybe weirdness with defaults
creating config and loading config are two different things. Just because it creates the configs doesn't mean it loads it, therefore you can have a situation where in memory values are not synced with saved values, more so the case if you start changing the in memory values. Restarting the server would cause the in memory values to go away and instead pull values from the config since the config exists.
well it's actually an item that has attack damage and attack speed - you insert them in the config (first one is 6.5 and second is 1.6, therefore in code the speed is calculated -4.0 + value from config - player default attack speed is 40) but on the first start it shows 1.6 on both
and it's weird bcs the 1.6 is actually on the next line so it's loaded afterwards
or it might be some weird overwriting
ik ik
just fyi
so 1 + null = 1
because null defaults to 0
because primitives can't be null is one of the reasons, if however you were to be using the object form you get an NPE instead
I'll send the code in the morning
How do you make a persistent data container? I need to make a PersistentDataContainer because I need to put a tag within a tag
nvm
I'ma just make a custom type
container.getAdapterContext.newPersistantblahblah
?morepdc
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
:p
I have to store a bunch of animations. One animation contains one implementation of a shape class. An animation also contains stages which can be static, rotation, etc.
I'm using json (for the ability to edit data) and storing each animation in a json array. To get the specific implementation of shape used i could add "type": "star" . But then what...i dont want to make a giant switch structure. same thing goes for animation stages.
Use a lookup map then
ill look that up
i have to instantiate the shape class when retrieving data. also the data varies based on the shape type, so I could have a method in each shape which retrieves its own data from a jsonObject and returns a new class. Idk how to get from "star" to a variable of star.class without using reflection.
ShapeFactory
is there an event fired for the fishing line breaking
Have it be a Map<String, Consumer<JsonWhatever>>
what event triggers for a fishing rod to break
