#help-development
1 messages · Page 1182 of 1
well it works fine on 1.21.3
or just check if the jar needs extraction
i wanna PR to the java stdlib
ZipFile has close but doesn't implement Closeable smh
wait it does
what
gzip is pretty cool
@blazing ocean figure out how i can add all the libraries and spigot to my run config classpath
thanks
wait i just realised whats happening
what is
well what ur seeing with no stdout
okay
would need an application run config
so yeah it has to be something here
yea
im gonna say, we dont have spigots log4j2 config
idk what mojanks is
left is mc, rfight is spigot
okay so log4j2 isnt causing it
it has to be the dedicated server stuff
hold on i need to take my plate down and illt ake a better look
Hi guys, with the new 1.20+ attribute on items "item_name", how can i access this attribute via the api?
... biome instance
what is a biome instance
new stuff?
is there finally an api way to check for custom biomes?
and actually tell them apart?
ItemMeta#getItemName
I'm confused, looked on my IDEA didn't finded but is indeed on ItemMeta on spigot javadocs. in what version this was added?
in 1.20.5 it seems
Biome are registry backed as of 1.21.3 so yeah
Registry.BIOME
Arent value based hash implementations bad because once the objects values change, a hashmap doesnt point to its value anymore?
no but I mean
can I check what name a custom biome has according to a plugin author
like if I make a biome and call it skibidi can another plugin detect the skibidi biome in the world via api?
they are not enums
Oh wait no they are an interface now
getKey()
Then yeah maybe
so the key can be arbitrary?
Yes
finally I can make the skibidi biome we've all been waiting for
that's great news then
yeah it got most of my plugins to error so it was hard for me to miss
How did they error
Should still work unless you're doing something with reflection or something
I was in fact doing exactly that
in a truly convoluted way too
it's called cursemaxxing
just trying to maximize weird bugs due to weird setups and trying to 100% every maven bug known to man
Yes
Idk whatever their key is
for the namespace
Minecraft
what should the hash implementation be based on if not its value
ok so that's annoying
hmmmmmm
damn it
I need a custom format don't i
like minecraft:taiga
and coolplugin:skibidi
What about it?
are custom ones like from datapack or plugins also in the minecraft namespace or their own?
Their own
well if I want it to be able to detect the biome correctly I still need to provide the right key in the namespace
and I can only do that if it is provided
memory adress
the opposite, a hash value should never be based on the memory address if one can help it lol
the default one does because that's the only way to ensure different instances have different hashes, but you don't want that for the most part
ok
a hash code should be a representation of the object in question, that is the sum of its field + some arbitrary prime numbers for uniqueness sake
This is why mutable objects don’t make the best map keys
Is there a way to remove achievement messages from the chat for a specific player? For example, if I'm in vanish, I don't want my achievements to show up in the chat, like when I grab some armor from creative mode or similar scenarios
And it's impossible remove vanilla recipes without nms?
Correct
Well you would be forced to use reflection anyways because those lists are private with no getters
Isn't it easier do with event?
Hello, I have a small problem that I have had for days and I have not been able to, I have created a plugin that records your characteristics such as deaths, murders, your uuid, among other things, and everything is fine, when you enter it creates the row for each player, the problem is when updating the statistics, when you die it has to increase the deaths variable, but it does not, in the database it will always be 0
?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.
who comes up with these commands, they're actually quite useful
public static void savePlayer(Connection con, PlayerModel model) {
try {
PreparedStatement statement = con.prepareStatement("INSERT INTO player (uuid,name,deaths) VALUE (?,?,?)");
statement.setString(1, model.getUuid().toString());
statement.setString(2, model.getName());
statement.setInt(3, model.getDeaths());
statement.executeUpdate();
} catch (Exception e) {
// TODO: handle exception
}
}```
public static PlayerModel getPlayerData(Connection con, UUID uuid){
try {
String query = "SELECT * FROM player WHERE uuid = ?";
PreparedStatement statement = con.prepareStatement(query);
statement.setString(1, uuid.toString());
ResultSet resultSet = statement.executeQuery();
if (resultSet.next()) {
String name = resultSet.getString("name");
// int deaths = resultSet.getInt("deaths");
// int asesinatos = resultSet.getInt("asesinatos");
return new PlayerModel(uuid, name);
}
} catch (SQLException e) {
e.printStackTrace();
}
return null; // Si no encuentra los datos, retorna null
} ```
I have a model class which is where the variable increases
public class PlayerModel {
private UUID uuid;
private String name;
private int deaths;
public PlayerModel(UUID uuid, String name) {
this.uuid = uuid;
this.name = name;
this.deaths = 0;
}
public void incremeant() {
this.deaths++;
}
}```
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
PlayerModel playerData = SQLData.getPlayerData(plugin.getConnection(), player.getUniqueId());
if(playerData == null) {
playerData = new PlayerModel(player.getUniqueId(), player.getName());
SQLData.savePlayer(plugin.getConnection(), playerData);
} ```
When the player enters, his attributes are saved.
and when he dies the variable of deaths increases, but in one way it doesn't
Player player = event.getEntity();
PlayerModel playerData = SQLData.getPlayerData(plugin.getConnection(), player.getUniqueId());
if(playerData != null) {
playerData.incremeant();
player.sendMessage("las muertes han subido");
SQLData.savePlayer(plugin.getConnection(), playerData); ```
?codeblock
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Oof ow my main thread database interaction
I'm sorry I didn't know that
I was about to comment, yeah
Does anyone have any idea why my deaths variable isn't increasing?
You’re using an insert statement to save the data
Which is probably creating a new row or throwing an exception because of a duplicate key
Use an update statement or the ON DUPLICATE KEY function
Also do your database interactions async
- DON'T do sql queries in the main thread as Coll said
- Use a try-with-resources for those prepared statements
You also may want to close the connection after using it
I don’t remember the standard for MySQL since I normally use HikariCP
that'd depend on the database in question, you'd do ON CONFLICT for postres
OR REPLACE INTO for sqlite
or if you want a "SQL-standard" there's merge into apparently, not sure how is the support for that tho
if it can support enough connections, then odds that left open connections cause issues is pretty low. But the standard is to close connections you are done with otherwise they are left open for like 30 seconds (TCP default timeout)
SQL is always everything but standard
What do you mean by that queries should not be made in the main thread? sorry for my ignorance
It’ll cause the thread to stall until it’s conplete
Normally you’d use something like a completablefuture
and you don't want to stall the main thread, since it handles all the server logic, inclduing loading chunks and among other things
Could you give me an example of how a query would be made?
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitRunnable;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class DatabaseTask extends BukkitRunnable {
private MySQLConnection mysqlConnection;
public DatabaseTask(MySQLConnection mysqlConnection) {
this.mysqlConnection = mysqlConnection;
}
@Override
public void run() {
Connection connection = null;
PreparedStatement statement = null;
ResultSet resultSet = null;
try {
// Obtener la conexión
connection = mysqlConnection.getConnection();
// Crear y ejecutar una consulta
String query = "SELECT * FROM tabla_ejemplo WHERE columna = ?";
statement = connection.prepareStatement(query);
statement.setString(1, "valor"); // Reemplaza con el valor que necesites
resultSet = statement.executeQuery();
while (resultSet.next()) {
// Procesar los resultados de la consulta
String dato = resultSet.getString("columna");
Bukkit.getLogger().info("Dato: " + dato);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (resultSet != null) resultSet.close();
if (statement != null) statement.close();
if (connection != null && !connection.isClosed()) connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public void start() {
// Ejecuta la tarea en el hilo principal de Spigot
this.runTaskAsynchronously(YourPlugin.getInstance());
}
}```
would it be something like this, in a task?
private CompletableFuture<Void> savePlayerAsync(PlayerModel model) {
return CompletableFuture.runAsync(() -> {
try (PreparedStatement statement = databaseConnection.prepareStatement(
"INSERT INTO player (uuid, name, deaths) VALUES (?, ?, ?) " +
"ON DUPLICATE KEY UPDATE name = ?, deaths = ?")) {
statement.setString(1, model.getUuid().toString());
statement.setString(2, model.getName());
statement.setInt(3, model.getDeaths());
statement.setString(4, model.getName());
statement.setInt(5, model.getDeaths());
statement.executeUpdate();
} catch (SQLException e) {
throw new CompletionException(e);
}
});
}
this is how your savePlayer method would look if done off the main thread
aaa, so it is not necessary to create a separate class?
not necessarily, no
The same method is executed in another thread
thanks bro for taking the time thanks
I just made claude generate an example so no worries lol
for anything that returns something, you'd use supplyAsync instead of runAsync btw
Claude deciding to concat 2 strings for the query is kinda weird
But at least it didn’t make up new methods
text blocks 
i'll block your texts
PreparedStatement statement = connection.prepareStatement("""
INSERT INTO player (uuid, name, deaths) VALUES (?, ?, ?)
ON DUPLICATE KEY UPDATE
name = ?,
deaths = ?
""");
My beloved 
and then to actually use the result, you'd use:
// put this somewhere in your plugin
public static final Executor MAIN_THREAD_EXECUTOR = task ->
Bukkit.getScheduler().runTask(YourPlugin.instance(), task);
savePlayerAsync(playerModel)
whenCompleteAsync((result, exception) -> { // the result is Void in this case so we don't really use it
if (exception != null) {
getLogger().severe("Failed to save player: " + exception.getMessage());
} else {
getLogger().info("Player data saved successfully: " + playerModel.getName());
}
}, MAIN_THREAD_EXECUTOR);
this is how you'd use the result of whatever query you may use
in java 23 with previews I could just use _ for that result 😔
no preview since 22
But those aren’t LTS :(
and?
that doesn't mean anything until a new version comes out
whats next lts
and the same case applies to LTS, just, a larger time scale
java 1000000
LTS = larger time scale 📖✍️ Noted
I mean, basically
I mean, that's on spigot not java lol
I mean idk how much space ItemStacks take up
I guess it depends on how complex they are
What makes an itemstack complex?
their degree in philosophy
and the fact that item stacks are notorious wine connoisseurs
I think the max amount for an item was like 8mb or something
The torn relationship between them and their father
or was it 32 uncompressed? I don't remember
Oh god
but that's the max, for like a shulker box full of written book stacks with a bunch of shit on them
I don’t expect to have any chests full of chests full of chests full of chests
I calculated it once, but it is on the paper discord and I am not there anymore lmao
It’s for dungeon loot, so I expect some fancy weapons at most
the average item stack is no more than 32kb so don't worry too much about it
32kb is already huge for a single item stack
i love book banning people
Alternatively I could just load them as needed
But then I need to deal with a database :(
I'd just dump them in memory honestly
Need to decide the same for mobs
Not gonna load all the room schematics into memory, I’ll grab those as needed
depends on how big the schems are
they can't be more than a few mb
well, ig uncompressed they do take a bit of mem
u guys dont use ORMs?
ORMs are annoying with plugin dev, you got to do the set classloader thingy and if you don't know SQL, it is better to use it raw to actually learn what goes behind
It isn't that hard to setup
it is just annoying, and for something as simple as this, I'd just go for raw sql queries anyway
for something mildly complex I'd consider it more
quick question
for enchanted books, are their enchantments not stored like item enchantments (EX: sword)? if not how are they stored
EnchantmentStorageMeta
ok thanks
It's a different component because people figured out you could use them as items enchanted with that enchantment lol
e.g. a Sharpness V book would have Sharpness V
No more free grass :(
ok that makes sense
is there an easy way to check if an enchant type goes on an
item?
EX: if its a pickaxe then Efficiency would return true and unbreaking would return true but Sharpness would return false.
Enchantment#canEnchantItem(ItemStack)
ty
onProjectileLaunch event when you throw an egg, how can you get the item since it could be thrown from the offhand or mainhand
that's the cool part, you don't, unless you add a manual check, but that isn't really guaranteed to yield proper results
so its just not possible?
since you can only launch projectile from offhand if there is not a projectile in mainhand could you possibly use that to check?
is there a way of checking if an item is a projectile?
pretty sure there's an edge case where if you're using the last projectile the used hand will be empty in the event
i might be wrong
yeah I thought so too. and it seems to be working that way
let me check
on my totally unmodified spigot source, not spigot fork, i would never
bc I can throw last projectile and it still says item in hand
Ah yes only spoon
ok so is there a way to check if an item is a projectile just from itemstack?
this code is a mess
I think you can just hardcode some materials
Not ideal but I don’t think there’s a tag for it or anything
alright that sucks. thanks guys
charge, arrow
okay so it seems that the item is not yet consumed in that event
or, i guess it depends on the item
for eggs at least
eggs seem to work so its working for me
eggs, snowballs and ender pearls seem to bne available
i cba to check every item zzz
What about exp bottles?
do fishing rods count
There’s a separate event for that too
yeah but won't it trigger both events?
wait new idea: can I just replace the projectilelaunchevent with a playerinteractevent?
i guess it would fire at the start of the launch even if you cancelled it for things like tridents & bows. but for eggs it should work right?
yeah I just thought of that\
😦
petition for spigot to add a .getItem() to projectilelaunchevent
I wonder if that could even be done
couldn't you just check for the interact event instead
ah you already thought of that
you'd have to save the item in interact within a map or something and check for it in launch event
kinda annoying but it is what it is
Ideally we could expose the shooter, item, and hand to the event
But I’m not familiar with what the internal code looks like in this case
I am looking at it currently and it does not look like you would expect it to.
CraftEventFactory is quite the class
can't you just cast it to ThrowableProjectile and getItem on it
We love CraftEventFactory
I don’t think that stores any data about the thrown item
But I could be wrong
it stores the item
not sure if it is linked to the item in the inventory at all or it is a clone, but it does give you an ItemStack instance
Exactly
Problem with exposing item in the launch event if we are not going to add or change code is that most of the time it would be null since the item would be gone
wouldn't it be air in that case
I guess giving you the hand is good enough
in the few cases I checked the event is fired before the item is consumed
EntityShootProjectileEvent or something
EntityShootBowEvent, yeah
does that expose the arrow item used?
Yes iirc
yeah it has getConsumable
Right but unless you cancel the event it cause issues if you tried to do something with the item which is unexpected behavior as far as the event goes
i mean, it will spawn the entity after the event is called
so if you alter the itemstack it'll use the altered one
(which sounds stinky)
or
err
no
the entity is already spawned
the whole thing stinks
Lol
Could just expose a read only copy of the item
That could be a solution
How does the bow event handle things
Afaik it exposes the arrow item even though the arrow entity is already spawned
if it is a read only copy then there's no difference between that and ThrowableProjectile#getItem no?
Depends if that actually contains the data of the held item
Could we just check ProjectileLaunchEvent get the shooter get item in main hand?
This because the game handles bows differently
Or if it’s just a basic copy of the held item
Offhand
Or that
To get the data you know and then apply pdc to the projectile
Okay then main hand first
Do you only throw one if both hands are holding a throwable item
Yes I think
Reason the bow returns an itemstack is because the arrow is in the inventory when you fire a bow.
Main hand first
Well then assuming the event is always called before the item is removed that should be reliable
A little awkward but it works
Yeah the removal of the arrow happens after the event or when the projectile is spawned.
So you fire the bow, projectile is spawned then arrow removed
This is about directly throwable items
dawg
But it appears they also function that way, so exposing the item should behave the same as the bow event
wait
I know, just explaining how its different for bows lol.
With throwables the code is swapped for when item is removed and entity spawned. If i recall
Is there some sort of bow.getCharge() that returns a vector object perhaps?
I could be wrong been a while since i have looked at it in depth
I'm probably just wishful thinking here
getForce()
But it gives a float
I can work with that
0-1 I believe is the range for that float
how did I never think of the bow charge mechanic for ndg throwing mechanics
I must be dumb 😦
If it turns out it does then yeah we should expose it
It seems to
getItem returns a copy with count 1, shame
projetile launch is an entity spawn event so I don't know how you would pass down the actual item all the way down from ItemEgg#use and the like tbh
Do skyblock servers generate a world for every players island? Or are they in the same world but separated by distance? Like hypixel skyblock
Usually same world but separated by distance
Hypixel might be different server for each island
They have a few worlds per server usually
makes sense honestly, it'd be too much of a waste to run a single server per island
ig you could containerize the hell out of an instance, but then you run into noisy neighbor issues and it is eh
They are not using an entire vm instance for each island lmao. That is way too much resources then necessary. If they did per world per island and ensured the world border is only like a single region size then you could easily put like 100 or so worlds on each vm instance since each world would consume just a few hundred mega in ram and basically nothing in terms of cpu
And given its just a single region file the most amount of space that world could in theory take up is no more then a few hundred megs as well
Well the theoretical maximum is like 1tb but i doubt any player will manage to occupy 1024 chunks and fill it completely
I am aware, that's what I was hinting at as well
Hold up, does that mean languages are like APIs and compilers are implementations?
not quite
language are human readable tokens
while a compiler converts it into machine readable code
a human has trouble understanding that 010 000 means i want to move to the position in the next 3 bits
and that is position 0
but a computer just knows this
a human has an easier time with goto first; to see what it means
Is there a way to check if a player has Allow Server Listings enabled?
F me. I somwhow only looked for all posisble way this could be named in the docs. then figured out the settings name and did not try searching that. my bad
all good
one could make that statement as a form of analogy, and it'd be correct however technically speaking, the concept of an API doesn't extend in such a way that one could define these that way
Alr thx
thats the PDC
well "gcore" seems to use it
GCore is my "Library" plugin
stores Kotlin and some extra stuff
doesn't do anything at all, it doesn't even have an onEnable
I mean, something is setting that PDC value
I guess check the Gcore too then?
this is GCore
this is GGPS
hm
should i search packetevents too?
I'd be surprised if packet events randomly uses your plugins namespace to set a pdc value
Maybe some dependency does some sus stuff ?
lemme check
on every item? why
identification prob
oh my hunch was correct, it is IF :D
i'm gonna ask on their support channel
Kinda weird it needs to use it at all
Yea sounds a bit weird that all items get that
can you do a funny lil /data get entity @p SelectedItem
while holding the compass you're saving
or when you get it back
yup, weird
seems excessive
anyway, apparently BlockDispenseLootEvent doesn't actually know about the loot table the block is spitting out. is there a way to get the loot table actively dispensed from a vault block?
vaults dispense multiple drops which can variate in loot table, but there doesnt seem to be an event that actually associates each drop with their respective loot table
The loot table is stored in the block. Can you not get the block and then the loot table ?
I might be misunderstanding you.
its not stored in the block because vaults/trial spawners can spawn from several loot tables
they spawn a couple drops from the "common" loot table and then maybe some extra drops from "rare" and "unique"
so theres not 1 loot table
Is it stored in the vault
the vault block data does not have a loot table
or was that changed in 1.21.3 specifically
its not in the tilestate either
declaration: package: org.bukkit.block, interface: Vault
no its my own
it is some sort of library
containing Kotlin, JetBrains Exposed, IF and ...
no wonder it is 15mb
lol
nms is confusing as hell
nah
so everything i need can be gotten from VaultConfiguration, makes sense
how to get it? no clue
there's a similar thing for TrialSpawnerConfiguration, makes sense because both blocks have similar functionality
trialspawnerconfiguration can be accessed through the TrialSpawner class, makes sense
theres no Vault class
how'd i miss that i literally looked at it 5 minutes ago
Cool you got VaultConfig.DEFAULT and some other stuff on VaultBlockEntity
and you can get the block entity from craftbukkit's Vault
it's a tile entity basically
can i suggest a color theme?
depends on how you define cool
for example lately I work a lot with bedrock at work and most networks just use custom player skins with geometry for custom mobs
I made a system that through packet manipulation + a lot of fuckery I can have true custom entities for geyser players
With properties, custom width and height etc
Without forking geyser
That's one of the things I'm proud of
nice
the entity component system at work is also clever
yea that's what i meant
We can make entities hold data and stuff
Attach "templates" to entities that apply components in case we want persistent components
there's a whole ecosystem around entities and it's pretty much all I made for the past 6 months
cool
Someone here have ever used moshi to parse http requests? I'm having some issues to parse the data
don't know what "moshi" but i use Javalin
I use this https://github.com/square/moshi
ktor
If u wanna check it out
ow
i'm using jackson's one
lemme find it
Module that adds support for serialization/deserialization of Kotlin (http://kotlinlang.org) classes and data classes. - FasterXML/jackson-module-kotlin
I'm gonna throw fire here and https://github.com/Mojang/DataFixerUpper
I use Mojanks Codecs for JSON
I mean, i'm not using kotlin but I guess I have to be doing something wrong
I NEED HELP
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous usernames, global display names, and server...
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
There
I NEED MONEY
Guys how do I use gson or whatever it was called
To do what exactly
Man, what a terrible class and a great justification for variadic templates
Save stuff
Like integers
And string
And doubles
And byte arrays
cool, how many more data types can you name out...
Itemstacks
Longs
Floats
Uuids
Thats about it
Products.P16 moment
This is why people hate DFU
I mean, I don't care how it's written, it does its job well
Fairly easy to write the codecs
When Java doesn't have variadic templates, this is what you have to resort to lol
yeah
I love DFU too
i hate code
Hey!
hi
I'm trying to serialize an itemstack into base64 but i'm getting some errors
Let me send them
public static String itemStackToBase64(ItemStack item) throws IllegalStateException {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
dataOutput.writeInt(1);
dataOutput.writeObject(item);
dataOutput.close();
return Base64Coder.encodeLines(outputStream.toByteArray());
} catch (IOException e) {
throw new IllegalStateException("Unablwe to save item stack.", e);
}
}
public static ItemStack itemStackFromBase64(String data) throws IOException {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
ItemStack item = (ItemStack) dataInput.readObject();
dataInput.close();
return item;
} catch (ClassNotFoundException e) {
throw new IllegalStateException("Unable to decode class type.", e);
}
}```
why
When trying to use itemStackFromBase64 i'm getting an error while reading the object
What am I doing wrong?
idk what any of that is, but you're writing a 1
which I don't think the read code likes
?whereami paper even has methods for that btw...
Does it?
hi @blazing ocean
and I mean, this is from bukkit, I don't think that the software i'm using matters here 🤔
declaration: package: org.bukkit.inventory, class: ItemStack
thanks
wow you're not even gonna say hi back?
declaration: package: org.bukkit.inventory, class: ItemStack
I was gonna!
I was waiting for so long
I have implemented guns, but when doing a quick rotation the tracers get spawned at an offset previous rotation. Does spigot smooth out the player rotation?
I was doing the hard work of searching up something in the javadocs for them
thanks
Do you have an example of what does this return? I would like to save this in PDC so to know how to serialize it
why do you wanna store an item inside of an items pdc
or any other pdc for that matter
you can just encode those bytes with b64 btw
Also that's true
Because it is a head item that when placed generates an armorstand with armor, so i'm saving that armor
Would it be better to save those bytes as b64 or just PersistentDataType.BYTE_ARRAY ?
me when he writes an int but doesn't read it
💀
I have implemented guns, but when doing a quick rotation the tracers get spawned at an offset previous rotation. Does spigot smooth out the player rotation?
Perhaps playerMoveEvent takes into account rotations in this way?
byte array
base64 is expanding the byte array to a smaller subset of possible values so it'll be larger
^
i don't really like base64 anymore, there's very few reasons i can think of where it would be useful
uh could you tell me more? Does it somehow get smoothed with a linear or sth? I don't quite get what you're saying
It doesn’t work lol
I was thinking perhaps it had some getRotation() method or something, probably just wishful thinking I dont use that event much, anywho perhaps you could use the playerInteractEvent for when they are firing the gun and get their facing at the moment of firing the gun? Unless this is what you're already doing
Hey nice pfp mate
ohh thanks!
how do you apply fall damage to a player that has canFly
you need to handle it yourself
with ground distance
I made it so that it disables flight when falling higher as some float and then re enables flight
// Perform ray tracing to check distance to the ground
RayTraceResult rayTraceResult = player.getWorld().rayTraceBlocks(
player.getLocation(),
new Vector(0, -1, 0), // Straight down direction
10, // Maximum distance to check
FluidCollisionMode.NEVER,
true // Ignore passable blocks like grass
);
// If ray trace hits the ground, check the distance
if (rayTraceResult != null && rayTraceResult.getHitBlock() != null) {
double distanceToGround = rayTraceResult.getHitPosition().distance(player.getLocation().toVector());
// Check if fall speed and distance indicate fall damage
if (fallSpeed > 0.15f && distanceToGround <= 5 && distanceToGround >= 3.25f) {```
You can remove the fall speed tho and it would work with distanceToGround depending on your needs.
i mean this is probably just lag isn't it?
nah, locally tested with self coded auto aim (One player auto aimed at the other player while the other player walked and flew around)
the smoothing is real
I'm not sure if this is the smoothing you refer to, but yaw/pitch changes are definitely rate-limited on the event
you need to use the packet directly if you want to avoid it
ahh
I get what you just said. My tests makes now sense
Because of the rate-limiting the server indeed uses smoothing. Good to know
Do you know what the rate limit is tho?
I'm currently making a "medkit" which the player can use to spawn a predict redstone block, a marker where to shoot (Similar to a GTA V mission where you need to shoot a jet down). I'm currently using the Velocity and latency to measure this out. Tho it's just multiplied by a factor which is very inaccurate.
To make it accurate i need to understand more of it tho
omfg, tysm that's exactly what I wanted
Hi, does NBT data change from one version to another?
Like does it vary from version
sometimes, but rarely
Trying to include NBT in resources for a plugin, but I get this in result
Malformed NBT file:
Unexpected tag id found: 31.
in IntelliJ
1.15 I think, and trying to get it working on 1.19
What is the file storing?
do you have it working in any version?
They had it working in 1.15
I don’t think the NBT format has changed in a long time
The contents inside it might no longer be valid, but the file format should still be fine
It could be encoded wrong, or maybe Maven doesn't know what to do with it
No format change in Structures that I can remember
Yeah compression breaks in resources if shaded with filtering
I'll try that now, thank you
Nah it's doing the exact same thing now sadly
It's a 1.15 plugin with NBT resources, made with Apache Ant
I've got it running and compiling in 1.21 with Maven (in IntelliJ), works mostly alright
?paste your pom
how can I do stuff with events if the file is not the main file?
src.dir is also not needed
and shade plugin is outdated (3.6.0 is latest)
making changes as you type
also you should relocate the dependencies you shade to prevent conflicts with other plugins
I know I know, just trying to nurse an old plugin back to life at the moment
then we'll clean it up if it does work
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
i know how to work with events
thanks for all your help by the way, making the changes and then I'll report back
...
Make a separate class for your listeners
What is it you're trying to do?
I want it to
listen on the block break event
and do something
on event
in the autosmelt java
You didn’t read the page did you
no
I copied and pasted
make a new class MyListener.class or whatever you'd like to call it
public class MyListener implements Listener {
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
// code here
}
}
then in your main class, onEnable, run getServer().getPluginManager().registerEvents(new MyListener(), this);
Why not just have one file listen to the block break and run conditional code there
(also no luck in this department, but thank you for your help)
(it's something about the way NBT is being included)
like how
its like an enchanting plugin
each enchant has a file
and each file checks on block break
like in an enchant called autosmelt
on block break event, smelt item broken
etc
Are you trying to run different code depending on the enchantment?
so like if I have a specific enchantment on a tool, and break a block, something will happen?
unrelated to your issue but use UpperCamelCase for class names please
oh yeah please do that too
java naming conventions, Let's learn what is naming convention and what are its benefits.
theres legit no point
unless someone
decompiles
and decides to code review forwhatever reason
no performance nor effiency effect
except there is
it doesn't affect performance, but it just makes your life harder for no reason
how
you'll have methods with the same names as classes at some point, and when you go back to that code to make a fix later you'll think to yourself, what the heck was I smoking when I wrote this
and it's literally unreadable
especailly for people trying to help you
there's no point being a contrarian about this kind of thing
all lowercase
and not even what that method does
that method is an event handler
and should not do that itself
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
ItemStack itemInUse = player.getItemInUse();
if (itemInUse != null) {
// here you can use itemInUse.getItemMeta().hasEnchant()
}
}
Is this what you mean by the way
and especially if you wanna be working with other people in the future
welp, I'm telling you in the nicest way possible since I know it isn't easy forming those habits in the beginning
you cannot be doing that
okay
do conditional code there based on the enchantment
I'm no good with how enchantments work with Spigot, but you can figure it out
Everyone has their own way of doing things but when it comes to Java, you must follow the rules in ways things are written and constructed. This makes it much easier for developers to read your code.
You won’t get hired if you do not know how to follow coding conventions, that’s for sure lol
but in the end you'll find people that will bully you into oblivion for having bad naming practices or unorthodox formatting overall. It just gets in the way of people actually trying to help you if you go against these practices that are well in-grained in programming for no specific reason
hell, even md_5 gets made fun of due to his formatting preferences lol
it's similar to saying that I'll now say dates in md/my/dyyy format
We are not saying this to put you down btw, we really want you to improve and be the best programmer you can be 🙌
That's because they're bad 
they are
some companies use really weird formatting though, like Valve
I think Valve do something weird like also including the type in the actual name
What programming language do they use?
That's a common practice in cpp
No way it’s C
think I saw a screenshot at some point
not when I write cpp 😰
Roff lnfao
hungarian notation? It isn't that weird, more useful in loosely typed languges if anything
And even more common in C where namespaces don't exist

I like LSP's C++ formating ngl
honestly it would probably help me out a lot, but IDEs do a good job at keeping me sane
Less common now when intellisense is being used
I've only ever done one major C/C++ project and it was/is a nightmare
but many older projects still use it
I remember coding windows api in c, you would have to use a very heavily nested switch statement to change windows 😳
Windows API is disgusting
how can i get the information of the person who broke the block?
I used the PlayStation 4 api to code in c++
you are using he wrong event
people give it more shit than it deserves
event.getPlayer()
my t key is not keying
they're good at not breaking user-space part, if anything
Microsoft have put a bad taste in my mouth haha I'm an Apple user at heart
it just looks disgusting since they preserve backwards compat to extreme points
the worst microsoft programming is the custom events for PowerPoint and stuff
VisualBasic
I think both apple and windows are good in their own ways.
https://github.com/lsp-plugins/lsp-plugins-mb-gate/blob/master/src/main/plug/mb_gate.cpp like this is still pretty acceptable
And bad in their own ways.
which one should i use?
I use my Windows computer for writing my plugins, but my Mac for server and webapp stuff
BlockBreakEvent or BlockPlaceEvent
BlockBreakEvent
depending on what you want
man I showed you it's BlockBreakEvent
BlockEvent is the superclass for all block events
oh okay
sidenote, LSP plugins are fucking amazing
I've never had the pleasure of working with them but hopefully an opportunity will present itself soon
need to use the Linux ecosystem more
like you won't get this for free and open source anywhere else
that looks disgusting
that UI
all VST UIs will make your head hurt
who thought putting a thousand knobs together was a good idea
I'd have an easier time navigating an airplane
I'm an Ableton x Logic kind of guy but only because they're the simplest
I have Cubase Elements lmfao
I use REAPER and Ardour sometimes when I'm on Linux
and Carla as my VST host
My dad likes Reaper
Idk Cubase for much but some insane vocaloid producers use it for crazy tracks
that's all I know
how can I run the code in my autosmelt file?
?learnjava! at this point
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.
https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
"can they please stop doing that" LMFAO
I see that there's people who understand me
Like dude I NEED a lot of those knobs
Hahaha
use a damn slider
I have physical knobs and sliders hooked up to my PC :3
well that's more understandable but still
@timid berry Why are you using Customenchantattempt2 31 times in the project
wdym
How are you using it?
actually don't worry I misinterpreted what counts toward usages sorry
not as crazy
still though, I wouldn't have your JavaPlugin implement the Listener
separate it into a new file
it is vital that you have 3 keyboards at minimum
I've got one very embarrassing AKAI LPK25
and probably getting a midi controller soon™
which does the trick
probably a good idea
every popular techno or related songs, they all have had 3 keyboards
so I have concluded its vital to have 3 of them 
what if I use one and change instruments 🤔
idk, just saying if you want to produce a hit song and become famous that is one of the requirements it seems
how can i acess e.getblock()
in my autosmelt file?
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! 🎉
by using the correct object type
Event is way too generic, you're to be using BlockBreakEvent
you are using Event not blockevent or which ever event object you are looking for
I'd maybe follow a YouTube tutorial on how to do a simple plugin to get started
Java you can pick up on the way
you need to know java basics to make a plugin
Yeah the fundamentals, but everything else can be learnt as he works
is this a good way to do it
It's better than before but what's the value in sending across the entire event?
maybe just extract what you need and then send that across
then i might as well handel everything in one file
It'll become a nightmare of files with thousands of lines if you keep doing it that way
It's good to separate things out
Think it's decomposition or some computer science principle like that
why do you still not know how to name classes and methods
because they are refusing to actually learn java
but something as simple as naming shit is not even that hard
its like this guy is going out of his way to not name things properly
Ignoring the capitalization, what the fuck is "doit"? Do what?
obviously it
Can we automatically ban people after they get 5 ?learnjavas
?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! 🎉
@young knoll ^
We’ll just force people to add the name to the command and then track it
So if I did ?learnjava @lynxplay 5 times he would automatically be permanently banned with no appeal
And uhh, his computer would explode
surely this could not be abused in any way whatsoever
Do you really think that would happen
yeah, by me
People on the internet abusing something solely to be negative towards an individual?
I'd be a bit depressed if I was banned on here coll 😦
Impossible!
public void playerchangeworld(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
World lobby = player.getWorld();
if (lobby.getName().equalsIgnoreCase("world")){
player.sendMessage("world");
for(PotionEffect effect:player.getActivePotionEffects()){
player.removePotionEffect(effect.getType());
}
if (lobby.getName().equalsIgnoreCase("lobby")){
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 10, false, false, false));
}
}``` Hello why when I use /mv tp lobby or use my lobby command. The PlayerChangedWorldEvent don't detect this. For the world "world" with /(essentials)spawn. I don't have problem?
try printing before the if statement
if that still doesn't work try using PlayerTeleportEvent
ok
No print with /lobby but /spawn yes. I will add my effect during the teleport in command /lobby for fix that
Do u know why this problem exist?
are the words always the same?
@chrome beacon @young knoll @eternal oxide You guys helped me earlier with NBT data not working when trying to get a 1.15 plugin working on 1.21 (it was https://github.com/garet90/simple-skyblock).
I've got it working miraculously. Updated https://github.com/Querz/NBT and it works seamlessly(~)
Thank you!
Is it possible to reset the players unlocked recipes, priority? Basically I removed custom recipes but for players they have an error on join. Is it possible to clear all the recipes before the server sees it?
Complex story but I’ve put 10k+ player data files onto a new world and they need to start fresh with no unlocked recipes. Unless of course yes there’s a tool that could loop over 10k files to reset it
there is no such tool but it shouldn't be hard to make one
You can also just do it when they first join
I’m ok with doing it on first join, I just wanted to ask if I should put it on prelogin event or will on join be sufficient in resetting it before a error occurs
well, they wouldn't first join since the player data files already exist
I have another way to check for it
Join -> clear recipes -> set PDC tag so you don’t do it again
Will give it a try. Thnx.
can you send me a single player data file, I want to see the format
It’s just NBT
If you have minecaft, just join and then exit, in your world player data folder it has your uuid
yeah but I want to look at it with ImHex to see if it'd be hard to parse
I have JNBT posted on my repository
I've looked at them before but they all seem to be lacking some support for the new chunk format among other things
But i wouldn’t bother looping over 10k files when i can reset it on first join
Yeah mine doesn’t support the new chunk format either
Because it has compressed NBT data inside compressed NBT data
Oh my
NBT seems pretty straightforward. But yea, you could just update stuff onjoin
Each chunk is compressed and then the entire region is compressed
wonder if they do that on purpose
I doubt just layering compression algos like that has much benefit lol
My question tho was to prevent the error from coming up, assuming recipes are read on join, how would you reset that before it’s read 🤷♀️
It’s not really an error
The game just complains about an unrecognized recipe and then removes it
Tried to load unrecognized recipe: ResourceKey[minecraft:recipe
i know i can ignore it but i minus well be able to reset them before the error shows because i need ppl to start fresh anyways
Then just remove the player data files?
I want to sync inventory,enderchest,armor without a database. (looping through on join to remove enchants or cheatable stuff) this way ppl can keep their collectibles
Why do unlocked recipes matter
fresh server reset and so id want the stats to be new
Yeah but unlocked recipes don’t actually do anything
Unless you are using doLimitedCrafting
They show up in the recipe book. :3
^
bugged with hundreds of custom recipes from a old plugin, some ppl have stats like 1000levels, score, health.
easy to reset on first join.
Also fun fact
Advancements are used to unlock recipes
Which means the game has 100s of invisible advancements
They unlock recipies??
Mhm
I thought they just give rewards
its a new world i didnt transfer advancements
They can do a lot of things
I keep forgetting the official game has a Bukkit reference
Besides making a loop to undiscover them all, is there a more performant method?
Probably not. You'd have to iterate over your entries anyways considering it's a list.
ok np
undiscoverRecipes(getDiscoveredRecipes)
Set<NamespacedKey> knownRecipes = player.getDiscoveredRecipes();
player.undiscoverRecipes(knownRecipes);
```yea i did similar like this
