#help-development
1 messages · Page 1184 of 1
ideally it'd use custom enchantments but there's no API for those yet kek
I do remember you trying to do it with that guide and failing miserably lol
still, you could just migrate existing items
sounds like an opportune moment for DFU :DD
is there some third party library to use DFU I wonder
and using the api
you can't use API for custom nbt
you got to use that library
look at that
I mean, it is pretty straightforward
read the thing, it explains how to access item nbt there, in the working with items section
can someone help me
im so lost
protected final void addButton(int slot, PitInventoryButton inventoryButton) {
TaskScheduler.scheduleTask(() -> this.inventory.setItem(slot, inventoryButton.getItemStack()), 3, false);
this.inventory.setItem(slot, inventoryButton.getItemStack()); // valid slot
TaskScheduler.scheduleTaskTimer(() -> {
this.inventory.setItem(0, new ItemStack(Material.WOOD_AXE));
}, 1, 10000, false);
}
The wood axe is present but not the itemstack from the pit inventory buttom?
i've check if its exists; it does
what is that API
its not an api
well whatever it is, PitInventoryButton and TaskScheduler isn't Spigot's API
yes but is each enchant its own thing like
nbt.setString("demonicrage", "5");
or is it just customenchantlist and then some map that gets modified?
you'd do nbt.getCompoundList("customEnchantList").get(index)
how would i write to it
in the code of the orginal plugin that set that
its written like
JSONEnchantList enchantList = nbtItem.getObject("customEnchantList", JSONEnchantList.class);
hey guys
uh
why the hell
when you try and set a slot in the inventory to any item that is a material of a door it doesn't work...?
omg.
bro.
what is the difference between dark_oak_door and dark_oak_door_item????????
seriously????
dw the api is a bit old
its goofy
😭
i lost about an hour
and another 30 mins to reels
because of that
you can just modify the list like:
var list = nbtItem.getCompoundList("customEnchantList");
var entry = list.get(0);
entry.setInteger("level", entry.getInteger("level") + 1);
list.set(0, entry);
nbtItem.setCompoundList("customEnchantList", list);
it is just a list, you can write to it, iterate it, whatever you want
it looks like json
the API has some methods to just treat it like json through gson if you prefer it that way
Oh okay
ReadWriteNBT nbt = NBT.createNBTObject();
everytime i do this
does it erase existing nbt?
package org.zarif.zarifenchant.cmds;
import de.tr7zw.nbtapi.NBT;
import de.tr7zw.nbtapi.iface.ReadWriteNBT;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class test implements CommandExecutor {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
ReadWriteNBT nbt = NBT.createNBTObject();
System.out.println(nbt.getCompoundList("customEnchantList"));
return true;
}
}
idk what the problem is
Caused by: java.lang.NoClassDefFoundError: de/tr7zw/nbtapi/NBT
what does this mean
it cannot find that class
so first you havent shaded it or added the plugin, second
?whereami
if the does this mean i use the shaded jar?
in my target folder
oh okay i got the api working
how can i access this
with this ?
how can i get an existing object?
Im not sure how to edit existing nbt
This must be ass in modern versions
Imagine all your item stack code breaking
so read
im trying man
(The nbt already on the item wasn't written by this api)
to me it looks like thats inside of minecraft:custom_data
probably by scrolling further down
guys
Zahin451
how can i turn this into a json string that is valid
I know i need to place \ behind the generated " but
if you paste that in a string intellij will add them for you
im telling you how to make your string valid
if you want to parse your list to json you need it to be valid json to start with
oh wow it is actually json
parse the array to an object
im gonna pretend I know what that means
your enchants is an array, marked by the [] surrounding it, its an array of objects, they are "name" to string and "level" to int
parse the array to the object
Which is more efficient and performant for running Async tasks in a plugin development:
- CompletableFuture
- BukkitScheduler
I mean, depends what you need lol
The scheduler runs on ticks, completable futures have their own thread pool (by default). But CompletableFutures are best used for when you intend on introducing callbacks
also, what is the difference between:
player.sendMessage(MSG);
Bukkit.getBukkitScheduler().runTask(PLUGIN, () -> { player.sendMessage(MSG); });
does the second one execute at the start of the next tick ?
probably yeah
Yes exactly
like If I need to fetch a player's data from the database, I would use the first method because I need the data to be returned immediately (Async) . However, if I want to update the player's statistics, such as inserting a new kill into their stats, the second method would be better because it's an Async operation that doesn't need to immediately return data and can be scheduled for execution without blocking the main thread ?
Nothing async is immediate. I'd usually use completable futures unless I've got some ticking task in the background
I use bukkit async task if I'm ticking a timer of something that can't or shouldn't be in the main thread
so for db queries do you use completable futures or bukkit async tasks ?
@river oracle are you aware of any internals that use the PerlinOctaveGenerator?
I don't touch world gen
So no
Boo
Just figure it out
clone spigot -> apply patches -> go to that class -> find usages
Is there any way to set a player's PlayerProfile? from what i can see there isn't an option for that
no
then is there a work around to set a player's skin?
packet magic
nooo, i was trying to avoid learning magic
YOU'RE A WIZARD! HARRY!
yooo, i was hoping someone would make that joke
it's mandatory
I think you may be able to use SkinRestorers API
i wanna avoid that so that people don't have to download skinrestorers as well
In that case, enjoy Hoggwarts!
Ryan Gosling and his journey as a programmer
What arguments do I need to use with modifyItemStack or do you have an example for achieving this with NMS?
Hey, does someone have an Idea how I could implement invisible item frames, because I've tried many ways and I can't get it to work. My problem is to give an itemframe which is invisible when placed I would need to translate the following command /minecraft:give @s item_frame[entity_data={id:"minecraft:item_frame",Invisible:1b}] to some spigot api call. The problem is I wasn't able to find a way to edit the nbt data. Is there some way to do this?
My other idea was to give some item frame identified by custom metadata and set it invisible when spawned, but the problem is there is no listener which gives me both the entity and the itemstack
Thanks in advance :)
ItemFrame.setVisible
The itemframe object is a superclass of entity
Yeah, but thats not my issue, i need to be able to identify if the itemframe which has been placed had the custom metadata. I want a crafting recipe which gives the player an invisible item frame
I told you, internals don't use that class
it is a bukkit utility, not an internally used class
you don't have to use NMS for it, Unsafe#modifyItemStack essentially lets you modify the item's nbt directly
var item = new ItemStack(Material.ITEM_FRAME);
Bukkit.getUnsafe().modifyItemStack(item, "{\"components\":{\"minecraft:entity_data\":{id:\"minecraft:item_frame\",Invisible:1b}}}")
// now that item has that component tag
Thank you very much that works perfectly
just to make sure, you can read and modify NMS packets just fine right?
as in if i read a ClientboundContainerSetSlotPacket and modify the itemstack property it has it'll change how the item is displayed
you mean in the inventory or outside of it
because there's a different packet for whatever the player is holding in their hand
yeah im just talking inventory for now
but why do you want to modify how an item is displayed client-side
because i want to change how the item looks without modifying its meta
it should work, but you may find some desync issues
it doesnt have to work perfectly
im making a lore api type of deal that allows me to dynamically change an items lore depending on stats and environment
I mean, you can do that without packets, since an item is only ever held by a single player
oh I guess not in shared inventories but eh
modifying the items meta a lot seems both inefficient and over the top and id like the items to revert back if the plugin is removed or disabled
and id like a placeholder for the actual lore of the item, that way i can inject what lore the item had within the fake lore
it should work fine, you'll just have to figure out the desync issues but other than that I don't really see much of a problem with it
cool cool
apparently you have to use the same format as when inputting it to a command, so it'd be minecraft:item_frame[entity_data={id:"minecraft:item_frame",Invisible:1b}] instead, just tested it
guessing you're using paper
accesswideners fr
Just add the aw to spigot
yea
Wait about 9 months and answer 5000 questions about why it needs adding
Is it paper safe
AdapterInstance in core
Make everything public
and non-final
Encapsulation be damned
Yeah @Mojang
you can use mixins in spigot?
You can't be calling mojank versions semantic bc they aren't
Don’t care + didn’t ask
Well, with ignite you can
Dam
I'll ignite jishlib
Or just fabric load spigot
Gonna mixing ur plugins
what does mixins actually do, what does it allow?
It lets you inject code into the app, allowing you to modify behaviour
would that be similar to patching
Yes, but a lot more dynamic
its at runtime?
or does it allow modifying app behaviour conditionally before the app itself starts
yes, usually what happens is the latter and then the code is ran iirc
oh wait no olivo is right
I'm dumb
was thinking of the wrong thing
It injects during the first time a class is loaded
So it doesn't let you swap and inject after that
I meannn..
but if you really wanted to you could probably setup a hotswap agent and do that part yourself
My favourite part about mixins is that you can mixin conditionally
It’s just a fancy wrapper around asm
And it's fucking amazing
ooooo that is sick
probably wont use it myself but its great that it exists
If you ever develop a fabric mod, there is 70% chance you'll need it
im sticking with spigot for the time being
Mixins give a lot of freedom
There's Ignite if you ever feel limited with API and NMS
asm-tree be like
[i asked it before but didnt really get the answer]
i want to save config from jar to folder if its not there, so i do saveDefaultConfig() but then if the config in folder is cleared by user for example, then if i try to read a value from it, it takes the value from the default config in jar, can i just save the config to folder, but when the value is not there then dont readd it from the jar file config? how does that workded
just don't have a default config
what if i just want to generate it at the begginng with some default values and comments so user can see, and if they remove they remove
Excellent crates crate openning doesn't make sound now, is it only me?
use saveResource instead
Sounds like a question for #help-server
wont it take default value anyway?
I'm 99% sure saveDefaultConfig doesn't load it as default, only saves the file if needed
i also was sure but i teested it and it worked like i said, but i dont trust myself imma test it again..
ok but if i have the default config then i dont have to check if the values are null etc because i have default values right?
basically
you'd need to load the defaults as defaults for that
well no, users could input invalid data I guess
oh
i dont understand
you just said you don't want to load the default config as default values, no?
yes
public void saveDefaultConfig() {
if (!configFile.exists()) {
saveResource("config.yml", false);
}
}
it indeed does not load as default values
if it's loading the values as default then it's something else in your code that's doing that
okay thats my config (right side) and these are the values printed, ill send the code
@Override
public void onEnable() {
saveDefaultConfig();
new BukkitRunnable() {
@Override
public void run() {
System.out.println(getConfig().get("a"));
System.out.println(getConfig().get("b"));
System.out.println(getConfig().get("c"));
}
}.runTaskTimer(this, 100, 100);
}
thats the code
what am i doing wrong that it reads it like that
you were right
what the
ksnip you'll be damned
i remove it or set it to null and it reads form the values i typed in before compiling
WHY
?paste anything that you interact with the config with, the default config in your resources and the config on the server
getConfig() loads the defaults when loading the file from disk as well
that's funny
what
getConfig() loads the defaults when loading the file from disk
what should i do
flameshot my beloved
¯_(ツ)_/¯
because everyone says it doesnt happen and it does happen, do they use different method or what
not using bukkit's config api sounds very appealing
: (
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
configurate >>
i think it doesnt say anything about what im asking
It shows how to make your own config
Without relying on getConfig
which loads defaults
can i also make any other file?
you can put whatever you want in /resources and save it to the data folder with saveResource
can i generate it while running
generate what
sure
just in code
oki doki
thanks
ill just stay with the default values
i gues
for now
what was the property one had to use to avoid the 20 seconds delay on startup
-DIReallyKnowWhatIAmDoingISwear
😔
Gonna be me soon tho fr
??
what ??
that flag avoids the 20 second delay when you're outdated
update!!
i dont get what flag but okkk
it's just a funny haha
why would you do that
because i need to edit a packet that has a final property
im not sure why but it works with most packets, just not a specific one
maybe it's a record
that just sounds like it's a record
no
darn
recreate the packet with the same values except the one you want and send the new one down the pipeline
im considering it yea
I mean you don't really have a choice lol
i mean the other choice is to just ditch a use case of the plugin lol
giving up is a choice, true
Is there anything I can do to make that first chunk loaded not nuke the server for 5 seconds
uhhhhhh
delete it
Run it on a super computer
Why is it only the first one
it probably ques up 9 chunks when you ask for that one
I mean, even that should't take 5 seconds
If its the first world chunk it may que up even more, possibly view range
Ree
you shoudl be able to test it
do yoru first chunk load, then try loading a chunk WAY away from spawn
hmm
reloading!?!?
Why are you loading 49 chunks?
The dungeon is 7x7 chunks
how can you register commands without including them in plugin.yml
command map
public void scheduleCommand(String command, String timeZone, int hour, int minute, int second) {
//some code
new BukkitRunnable() {
@Override
public void run() {
Bukkit.getScheduler().runTask(plugin, () -> {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
});
scheduleCommand(command, timeZone, hour, minute, second);
}
}.runTaskLater(plugin, initialDelay / 50);
}
is this safe? because the Bukkitrunnable calls the method, which makes another bukkitrunnable, and its recursion, but i think its safe because every thread ends after it creates another thread
I'm struggling to understand what you're trying to do here
if you are trying to do a repeating task, use BukkitScheduler#runTaskTimer
umm okay but would it be safe?
it isn't a matter of it being safe or not, everything there is being executed in the main thread but what you are doing doesn't make sense
im asking if there wont be stack overflow
what are you trying to do
i just want to make it happen every day
did this not work?
no because i have to execute command and its different thread
just do runTask inside of it
^^
does anyone know if it was 1.17 or 1.17.1 that introduced mojmaps to spigot
my memory tells me 1.17.1 but let me check
the build data info introduces mappingsUrl in 1.17
1.17.0
cool, ty
can i do this?
public void scheduleCommand(String command, String timeZone, int hour, int minute, int second) {
ZonedDateTime now = ZonedDateTime.now(ZoneId.of(timeZone));
ZonedDateTime nextRun = now.withHour(hour).withMinute(minute).withSecond(second);
if (nextRun.isBefore(now)) {
nextRun = nextRun.plusDays(1);
}
long initialDelay = Duration.between(now, nextRun).toMillis();
new BukkitRunnable() {
@Override
public void run() {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
}
}.runTaskTimer(plugin, initialDelay, TimeUnit.DAYS.toMillis(1));
}
I’ve done it myself kek
Time is in ticks not ms
well not quite since the bukkit scheduler uses ticks as base unit, you'd have to convert the miliseconds to ticks
and during larger timespans you might drop a couple ticks
So it could be off by more than you'd want
optimally yes, since it doesn't depend on the server's performacne
bukkit task will slow it down
i didnt know you can jump back to main thread
it adds up quickly
Bukkit.getScheduler().runTask(plugin, () -> {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
};
you can expect +- 30 mins to 1 hour
dispatch command will be run on the main thread
eh, if the server doesnt' lag I doubt it'd be that bad
Fixed
so bukkit like has built in method to jump back into the thread?
but yeah probably a few minutes off
but you can't expect it to be lag free
so just this instead of only dispatchCommand
yes
thankss
it will schedule it to be run on the main thread
I mean, it has methods to schedule tasks on the server thread, since BukkitScheduler works with the server thread
there's also libraries which facilitate the context-switching like TaskChain, if you're going to do it a lot
usually just using runTask is enough
just 1 lol
but now im gonna need more
I doubt you have 100 threads in your cpu
you don't need multiple threads to run multiple tasks at once
i mean , i dont really know how this works, but ineed more commands to run every day at certain time
i mean every command can have different time
just schedule more tasks to the same thread pool then, it doesn't matter if it only uses 1 thread
it'll only really be an issue if you want to run two tasks at the exact same time
okay thankssss
so they will like run
if both are set to the same time they will just run a little bit one after another?
is there a place to post entire code?
?paste
Or do you mean for a review?
yeah, milisecond difference probably
yes
okay thx
btw use Executors#newSingleThreadScheduledExecutor for the executor
now im using lambda in lambda 😵💫
So I ended up building my own perlin system of sorts, based on this mc terrain gen video I found, it's quite basic but I'm using spline points as mentioned in that video to give the randomness feel, however I gotta spruce it up because I'm not taking into account neighboring tile heights so it looks uh... awful right now kek
ok, idk what that is, ill learn later
I'm certainly taking the difficult route on this one
it's all a learning experience
no argument?
I would help you but I haven't done terrain generation in ages lol
No that's ok
no arguments
okay
I'm getting there just slowly
I'm just one of those people who always needs others validation kek
me toooo
It seems you're getting a bit into concurrency though which is a total headache so good luck with that lol
🤷♂️
You'll probably get more attention tbf, especially if you post in the review thread
is it that one complex thing
:concern:
average command class length
what? i dont understand
this is why you need to use a command framework.
I tried and gave up after 3 mins
As in if you want more advice on your implementation, post it in the review thread
imagine I learnt to use that
your life would be so much better
Now keep imagining
I bet it would
laughing so hard at his own demise
but why tf would I sacrifice 30 minutes of my life learning a command map to save countless hours later on? Seems like a waste of time
😭
💀
this is what's gonna happen to you ^
lemme find where I said this is good code
yeah ik
i don't understand why people are like this
nested code, my beloved
.
ignorance it is
man fucking
rad asking for frosty to sponsor another month of pink kek
tu tu tu tu tu- tu tuuu tu tu tu.
ok back to dirt rally
you at work?
Noone:
That last braincell: https://www.youtube.com/watch?v=poa_QBvtIBA
No thanksgiving today
dirt rally the racing game kek
oh
sameee
rad did you literally think I was gonna rally some dirt at work
idk??
I love how you're just not talking to me like I'm insane or smth
you do all kind of weird shit at work
including
playing with chemicals
spraying plastic
Psh that's not weird that's maintenances job
same thing
I love being background noise in a conversation
keep ignoring him rad
keep ignoring who
Who?
Gotta make a move to a town that's right for me 💃
Idk
no?
tf I got pinged
discord moment I swear
fuckin discord mate
@worthy yarrow I did an assignment in kotlin today
and completely overcomplicated it
You said that already but without the pic kek
now I have the pic
what the rpg game is that
I don't see why it's overcomplicated
I think the rest of my classmates just did like
@worthy yarrow Don't respond to this message if you're geh
Based on the naming it just looks like regular oop more than anything
python :(
what is i18n?? 😭
abstraction my beloved
I don't think it's overcomplicated, you might just be a bit ahead of the classmates
a bit
||I know you read this 💀 ||
I wonder if you could make it actually comlex
but not in a good way
improper abstractions and putting shit in random places
TALK TO MEEE
I bet I could do that
You probably already do but thats ok
💀
real
nah I dont do abstraction
😎
welp
using abstraction is not sigma 🙅♂️
@blazing ocean pop muzik
what
dam you dont know pop muzik?
no
Now in HD!!! Official remastered HD video for M - Pop Muzik. Pop Muzik was one of the first new wave singles to top the charts including in the US, Australia and West Germany. The single's popularity was bolstered by this catchy video - the first from renowned video and film director Brian Grant - that featured Robin Scott (AKA M) as a DJ singin...
wait this is lowkey good
Found good Minecraft hash (59353fb40c36d304f2035d51e7d6e6baa98dc05c)
**** Warning, Minecraft jar hash of c301de10f575027d13eac18c7f34409d60648cf56a35d566aa1f530ff617840a does not match stored hash of 9450361863f1d3e9d3cb9dedddd15d328df84461d55cf26d0b787102a076d2db
Exception in thread "main" java.nio.file.FileSystemException: work\server-1.21.1.jar: The process cannot access the file because it is being used by another process
at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92)```
it creates a java process, which uses the files it needs, then tells me it cant use it because something else is using the files?
this has been happening with my gradle too, had to downgrade to 8.5
you have some other process using that file
I assume that's from BuildTools
^^ Make sure you're not running it twice
if it still persists, check task manager
or just restart the pc
or you shaded spigot
?
man I love shading the entire spigot server
I am 100% sure i'm not running it twice, computer restart, all java tasks closed(even intelliJ), just command prompt, still the same
what if you just delete that file
the explorer usually tells you what app uses it iirc
smh
it only tells you if it's being used. also I can delete it
one sec
yeah, but I use windows because theres more compatibility, also theres like -2 antiviruses for linux
clam av is no longer maintained and doesnt detect unknown malware
You don't really need an AV for Linux
you can still get malware on linux
Setup your perms properly and you're good
Exception in thread "main" java.nio.file.FileSystemException: work\server-1.21.3.jar: The process cannot access the file because it is being used by another process
at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)``` 😐
Block all ads and don't download for dodgy sites = no malware
Are you running BT UI or BT command line?
if you have an AV, exclude the BT folder from scanning
I was coding normally but then all the sudden gradle hates me now. I've tried almost everything I can think of. even disabling my AV
That's BuildTools not gradle though
gradle has the same issue, the files are denied access because it's being used
the only thing that worked was downgrading gradle
Have ya tried restarting your machine?
^^
yes, and reinstalling the IDE multiple times
Sounds like Windows is broken if that happens to multiple things
I'm going to blame gremlins in the machine, or you have a virus
^^
it started when I tried implementing Paperdev(NMS) but everything broke after that, even when I tried reinstalling almost any IDE related files I could find like .gradle, Gradle, env vars. nothing
is that error occuring in command line while running buildtools or when reloading gradle
It happened to both. But downgrading grade seemed to work. Now it’s just BT
I just want to use NMS 🥲
ebic you know what i'm thinking
like i should be working on spigot builder
exactly
sounds crazy
How can i work with tags? Bcs hasTag is deleted in CompoundTag, for my ItemTagHandler
Where can I harass the Bukkit devs about not letting me set nbt tags that aren’t messy namespace keys?
Fr
For what reason are you trying to access NMS NBT ?
If it's to store your custom data, you should use PDC. If you're below 1.14 there is NBTAPI
For my ItemTagHandler for my InventorySystem.
That's not answering my question
I don't know what your ItemTagHandler is nor what it does
He does set tags, remove tags, get tags, getStrings for my items.
Why do you not use PDC
How works PDC?
?pdc
it stores in NBT under a bukkitvalues key
?nms
That works ig
Does anyone have experience working with native code in plugins?
?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!
Works fine
I take it you're speaking from experience writing a plugin with native code involved
(that you also wrote)
I did not write the native code
yeah I would like to hear from someone who's written their own native code for a plugin
sorry
Why would you do that though
because I have code that is doing a fair amount of math and C++ is considerably faster at it
What are you raycasting?
because moving data from native and java isn't exactly free
It's probably not gonna be faster
arbitrary geometry
And certainly not worth it
i'm a c++ developer, so i really don't know how much optimization the Java compiler does
like I assume Java's not slow
but I've never worked with it in a performance-critical context
It's java, not python, it's being jitted into optimised native code already
People write high frequency trading programs in java
alright, I'll stick to pure Java then
if performance ends up an issue I'll look into it further, Java's Vector API seems decent enough
As with everything performance test don't speculate
i'm mostly going off my experience using spigot raycasts a few years ago, they were pretty slow when you did them repeatedly
you can speculate to a reasonable extent when you know something is slow or inefficient
just don't be like..."hmm, this string parsing sounds slow, better SIMD it"
SIMD is rarely a solution to a fast algorithm, it just limits the usability for no particular reason
tell that to my work, we use it all the time
it works very well for specific applications, you don't write general-form SIMD libraries usually :p
I mean for anything that'll be used at scale, if it is a solution for a specific company then it is probably fine
yeah no this is all internal
if it is in the JVM, you'd rather just rely on auto-vectorization if it can be helped
Java does have a vector API
that's incubating still, but yeah you can use it
anyhow, performance will not be an issue with java even without the vector api
Yeah I should probably clarify it's more Minecraft/Spigot I don't trust lmao
Java's been around for decades and gotten much better over time
I mean, I'd like to assume you are writing your own raycasting algorithm rather than depending on minecraft's
yeah that's why I asked about native code
if you are more comfortable with doing it in native, you can do that, nowadays it isn't that ugly with the foreign function and memory API
Yeah it's in incubator waiting for Valhalla
but it hasn't changed in a while
it is true that i'm more comfortable doing it native - and C++ is better about templates than Java, Java generics are all object based
it won't change until valhalla arrives, but we are definitely not there yet
probably going to be out by java 27 or so
I mean, I don't know what templates would achieve in a raycast algorithm but well, you do you. If it were me, I'd definitely do it in rust or c for the funny
ah mb that was more of an aside
like doing an n-dimensional vector type
java doesn't do primitives in templates (generics)
not yet™️
we're so close, just 2 years apart
I can smell it
don't know how much the java architects are going to bikeshed it but I doubt they're gonna wait much longer, been 10 years already since valhalla is been in the works
for some context on what I'm doing in the first place, I dug up an old RPG core I wrote and part of that is: every weapon swing (not tools, mind you) from both players and NPCs has a raycast (for dynamic weapon range/effects like piercing, explosive, weapons that don't melee attack at all but instead fire a projectile), targeting for ability casts uses a raycast, i need the option to do raycasts within the ability for hitreg or whatever
and this could theoretically be happening on a pretty substantial scale, so i didn't want it to cause performance hits during large fights
but ofc since I wrote this shit during uni the code is a bit ass here and there, and I know for a fact it did not run those raycasts very cleanly last time I used it
I have no idea if MC itself has added anything that could replace any of those things in the last few years though
Hello guys, does anyone know how does player motion works in spigot? I mean in vanilla you can't give player motion but with spigot you can
It just adds a movement vector to the player
for some of those you can probably just edit the reach attribute nowadays
if this is what you wanted use native code for that would be a bad idea
No making part of the logic native in java app doesn't make it faster. You only use jni to access low level stuff
that isn't necessarily the case
if you are better at the native language than you are in java, or there is a library that does it better in the native language, then it is probably better to just call native
people don't use to do that because it's annoying to deal with jni
then again, there's FFM API nowadays which makes it less annoying, so you could ultimately go for that
FFM is a lot better
I honestly never realized you couldn't give motion to players in vanilla
you can't do it even with the /data command?
Can't modify player data directly with commands in vanilla
I'm surprised since it isn't like spigot does anything special, mojang's code allows for it just fine
they just don't expose it with commands, for whatever reason that might be
Why am i getting again and again this error? java.lang.RuntimeException: java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
What am i doing wrong?
hikari = new HikariDataSource();
hikari.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
hikari.addDataSourceProperty("serverName", host);
hikari.addDataSourceProperty("user", user);
hikari.addDataSourceProperty("password", password);
hikari.addDataSourceProperty("databaseName", databaseName);
hikari.addDataSourceProperty("port", port);
hikari.addDataSourceProperty("autoReconnect", true);
hikari.addDataSourceProperty("cachePrepStmts", true);
hikari.addDataSourceProperty("prepStmtCacheSize", 250);
hikari.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
hikari.addDataSourceProperty("useServerPrepStmts", true);
hikari.addDataSourceProperty("cacheResultSetMetadata", true);
have you shaded the mysql driver
yeah, mysql driver must be wrong
How do i shade the mysql driver? Can't remember. Just 1 day ago again starting with coding.
CraftBukkit already shades a MySQL driver. It shades ConnectorJ
The class probably just hasn't been loaded
isn't that what setDataSource does, load the class
what version of the connector does craftbukkit shade
Yeah?
that is the latest version
Idk, he sets it, does this mean it loads also?
That's not the correct driver name though
seems like it is the wrong package
com.mysql.cj.jdbc.Driver is
I will try.
com.mysql.cj.jdbc.MysqlDataSource if what Choco said doesn't work
Wich one now? Haha
MysqlDataSource doesn't seem to be a driver 
try choco's one first
This one ^
Okay
it is a JNDI interface
Yeah which, notably, isn't a driver lol
the Driver implements it so I assume you're supposed to use the driver yeah
guys
If it doesn't work, you'll need to do this to load the class and register the driver
try {
Class.forName("foo.bah.Driver");
} catch (Exception e) {
// it failed here
}
if I had a items that had custom nbt, and wanted to convert it to pdc, what would be the most efficient way?
almost every player has a sword with a custom enchant
i know how to convert it into pdc
but
Im not sure when to do it?
do i just take the whole world and scan every item?
Loading class
com.mysql.jdbc.Driver. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Maybe it's the SQLite driver that still needs it
?
can you tell us what you want to do, i dont really understand
okay
lets say I had a enchant plugins
that did custom enchants
each item has a nbt like this
{enchant name, level}
but now I want to make it use pdc instead of nbt
I know
how to make it into pdc
but I want to convert everythingwith a custom enchant into pdc
but I dont know if i should do it on join or what?
you could do it on join, yeah however that isn't gonna cover items stored in inventories
okay that easy, do it when a player joins, closes their inv (opening their inv doesnt call an event), and when closing a chestinv (they could get a item) + when picking up items
you'd also have to do it on inventory open
doesnt call an event
only close does
Now im getting this error:
java.lang.RuntimeException: java.lang.ClassCastException: Cannot cast com.mysql.cj.jdbc.Driver to javax.sql.DataSource
try what I said then
and also for ones that are intheir hotbar right?
you'd do it on join for player's inventory, inventory open for anything else
yes, thats part of their inventory
com.mysql.cj.jdbc.MysqlDataSource
this one?
yes
just check their inv when it might change
yes
just on join and inventory open is fine
if i havent missed anything you should be good
no, if a player gets an item from a chest it wouldnt recognize
i mean
if you do it on inventory open then all items would be converted already so there's no need
ill always have to have it scanning forever right?
insane someone opens a chest months later
that has the old items
*incase
you can probably add a pdc to the container so that you can mark it as converted
open doesnt call on the player inv, and for chests they can just put it directly in the hot bar and cause errors
same for the player
yes
again, you'd do on join for player's inventory
???
you'd scan player's inventory on join, any other inventory in the inventory open event
so, all items would be converted by the time the players clicks on one
open is bad, cause it changes when player takes something and then closes, they dont take items out of a chest on open
that's fine, you want to convert all the items anyway
why would you only convert when they take the items
best way would be to store your items in a database, changing the data model is easier there
cuz thats when their inv change, why would you convert if nothing changed
wont this also change other plugins who use chest guis?
Now it stays on this Survival Pool - Starting... line of text, i dont get any errors, or starting the server..
no do it when the player closes
because you'd save time trying to track all items that haven't changed
i mean yah close
just convert everything
how?
if they don't have the component it wouldn't change anything, so no
i hope you have an identifier for your custom items
I mean the identifier is the custom nbt tag
the items in the gui will have it
now if the player closes the auction gui
will it change that item?
depends on ur impl
you can just check if the inventory has a block inventory holder attached to it
im guessing you dont save your auction gui if its changes due to something
if it doesn't, then it is a custom inventory and you shouldn't convert
okay
then again, there are some custom inventories you may wanna convert from, like backpack plugins or the like, but if you don't have any of those then it should be fine
you could also just check the player inv, checking the gui they are in is useless as if they dont have the item in their inv, they cant break anything with it
so its not important to scan throguh the gui
just scan player inv
either option is a pain in the ass, and the worse option is scanning the nbt of statically 😛
@worldly ingot @sly topaz
Now it stays on this Survival Pool - Starting... line of text, i dont get any errors, or starting the server..
what is the code looking like right now
Yeah. Could be a variety of reasons. Could be you're just trying to open a connection synchronously and you're blocking the server thread from doing anything
hikari = new HikariDataSource();
hikari.setDataSourceClassName("com.mysql.cj.jdbc.MysqlDataSource");
hikari.addDataSourceProperty("serverName", host);
hikari.addDataSourceProperty("user", user);
hikari.addDataSourceProperty("password", password);
hikari.addDataSourceProperty("databaseName", databaseName);
hikari.addDataSourceProperty("port", port);
hikari.addDataSourceProperty("autoReconnect", true);
hikari.addDataSourceProperty("cachePrepStmts", true);
hikari.addDataSourceProperty("prepStmtCacheSize", 250);
hikari.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
hikari.addDataSourceProperty("useServerPrepStmts", true);
hikari.addDataSourceProperty("cacheResultSetMetadata", true);
Actually, I'm realizing you're doing setDataSourceClassName(). You don't need to do that.
you do need to do that for most databases, just not mysql apparently
What must i do instead?
use the jdbc url
HikariConfig config = new HikariConfig();
config.setDriverClassName("com.mysql.cj.jdbc.Driver");
config.setJdbcUrl("jdbc:mysql://" host + ":" + port + "/" + databaseName);
config.setUsername(username);
config.setPassword(password);
config.addDataSourceProperty("autoReconnect", true);
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
config.addDataSourceProperty("useServerPrepStmts", true);
config.addDataSourceProperty("cacheResultSetMetadata", true);
HikariDataSource hikari = new HikariDataSource(config);
// Now you can work with hikari
This is how I would configure it
That would work?
The HikariConfig stuff is mostly preference because HikariDataSource is a config, if I'm remembering correctly. But the important parts to note are the setDriverClassName(), setJdbcUrl(), setUsername(), and setPassword()
It should, yeah
is setDriverClassName necessary since spigot doesn't automatically load the class?
Im trying it.
Yeah CraftBukkit doesn't load it, it just shades it
the DataSource is better if you use JNDI dependent software like tomcat, otherwise it doesn't really matter
hi emily 
well tomcat has a driver-based configuration now that I'm looking at it, so I am not so sure where it does matter lol
choco jumpscare
Man I had a stupid thought at work today and was like "I probably would have done it this way", then one of our QA members sends me a Spigot thread related to that topic and I fucking answered it 😭
Me: I'm like 90% certain you can do it on entities themselves to just not drop items, but worst case, you can definitely clear them on death
QA: :lul: https://www.spigotmc.org/threads/removing-drops-for-entity.526433/#post-4267324
Me: I swear to God, before I open this link
Did I respond to it?
QA: mayhaps
Me: Son of a bitch
Why am I EVERYWHERE?
Where do you work? Haha
Hypixel
LMFAO
Oeeh, nicee!
I've had players on the server, while playing a random game with me, tell me "Hey! I've seen you on the Spigot forums before"
fml
😂
Yeah, lets do that!
com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
I've never seen a hypixel staff in-game
It's like in Portal, one psycho killed them all and there's no-one around and it's just you and the mindless turrets
is your mysql instance/container online
That's because you don't play while I'm playing

timezones be ruining the fun
what is choco standard time
Earth should be flat fr
Yeah, the mysql from my server is online.
idk like any time between 5pm - 11pm EST
tbh there's a high likelihood you've played with a staff member before, you just don't know it lol
No, we're just sneaky 

I like to play unnicked most of the time though because it's more fun that way
Right!
don't you get targeted lol
or are you so confident in your skills you just don't even care
skywars or bedwars lobby 1 usually has staff pretty regularly i feel
or at least it used to
Sometimes
But not often enough for it to bother me
reminds me of a server I used to play skywars on
whenever I won against the co-founder in skywars, they'd teleport me to a prison or turn on creative and kill me with eggs
LOL🤣
Most of the time I just get this 
choco will you be my friend on hipxel
okay anyway, does anyone know why i cant clone src/main/java/net
call cloneRepo here
only modification i do is this, but its the same as normal buildtools
String string = NBT.get(player.getInventory().getItemInMainHand(), nbt -> (String) nbt.getString("customEnchantList"));
this works fine and gets the nbt
but how can i delete the nbt?
i think i got that
how could i modify the items in a players inventory if im looping through them?
for (ItemStack item : player.getInventory().getContents()) {
ArrayList lores = new ArrayList<>();
lores.add("line one lore?");
item.getItemMeta().setLore(lores);
}
Its fixed btw with my MySQL. But why is he saying No operations allowed after connection closed.
But 1 table is created, but the rest of my tables isn't?
Table 1 code:
private static void createPlayersTable() {
try (Connection connection = getConnection()) {
Statement statement = connection.createStatement();
statement.executeUpdate(CREATE_TABLE);
} catch (SQLException e) {
Logger.DATABASE.log("Database:createPlayersTable", e);
}
Logger.DATABASE.log("The 'survival_players' table has been created!");
}
Table 2 code:
private static void createAchievementsTable() {
try (Connection connection = getConnection()) {
Statement statement = connection.createStatement();
statement.executeUpdate(CREATE_TABLE_ACHIEVEMENTS);
} catch (SQLException e) {
Logger.DATABASE.log("Database:createAchievementsTable", e);
}
Logger.DATABASE.log("The 'survival_achievements' table has been created!");
}
its just the same code 
does getConnection return the same connection every time
yeah, my DriverManager connection.
You're closing it :kekw:
Then tell me where?
I don't see closing.
It closes when it exists the scope of the try
That's kind of the whole point with try with resources
How tf am i fixing this then?
Just don't use try with resources and you're good
So, why is 1 table working then?
Are you running it more than once
If the answer is no then that's why
The code you sent will work exactly once
and then your connection is closed on scope exit
I have used this code so much in history, and don't even where getting this error🤣
im guessing you used to return a different connection before
if you return a different connection you can use twr
different connection? How?
No, that was with hikari datasource. Now i'm using JDBC
hikari didn't work anymore.
thats an xy, you should fix the issues rather than not using it
for mysql hikari is a lot easier and allows you to have connection pools
Iknow, but nothing helped with the error fix for java.lang.RuntimeException: java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
I have again hikari in my code, and again that error @remote swallow
okay so read the exception and figure out what line is causing that error
He dont find this class
hikari.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
Error:
[00:08:11] [Server thread/ERROR]: Error occurred while enabling Survival v1.0.0-SNAPSHOT (Is it up to date?)
java.lang.RuntimeException: java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
at com.zaxxer.hikari.util.UtilityElf.createInstance(UtilityElf.java:106) ~[?:?]
at com.zaxxer.hikari.pool.PoolBase.initializeDataSource(PoolBase.java:323) ~[?:?]
at com.zaxxer.hikari.pool.PoolBase.<init>(PoolBase.java:113) ~[?:?]
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:91) ~[?:?]
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:111) ~[?:?]
at com.github.tacticaldev.survival.database.Database.getConnection(Database.java:146) ~[?:?]
at com.github.tacticaldev.survival.database.Database.createPlayersTable(Database.java:89) ~[?:?]
at com.github.tacticaldev.survival.database.Database.open(Database.java:60) ~[?:?]
at com.github.tacticaldev.survival.Survival.onEnable(Survival.java:36) ~[?:?]
that isnt the data source anymore
What then?
com.mysql.cj.jdbc.MysqlDataSource afaik
Thanks, it works! But earlier this didn't work haha
lol
that's funny
I'm pretty sure earlier was some error with your jdbc url or something
I just forgot to mention it since I was playing bedwars while answering lol
Haha, dont mather! It works now haha
bump
you have to get the meta and set it again