#help-development

1 messages · Page 1184 of 1

timid berry
#

or else existing items wont work

#

:(

sly topaz
#

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

ivory sleet
#

sounds like an opportune moment for DFU :DD

timid berry
#

looking at this

#

uh

sly topaz
#

is there some third party library to use DFU I wonder

timid berry
#

and using the api

sly topaz
#

you can't use API for custom nbt

timid berry
sly topaz
#

you got to use that library

timid berry
#

look at that

sly topaz
#

I mean, it is pretty straightforward

#

read the thing, it explains how to access item nbt there, in the working with items section

timber eagle
#

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

sly topaz
#

what is that API

timber eagle
#

its not an api

sly topaz
#

well whatever it is, PitInventoryButton and TaskScheduler isn't Spigot's API

timber eagle
#

no kidding...

#

i made it

timid berry
sly topaz
timid berry
#

in the code of the orginal plugin that set that
its written like
JSONEnchantList enchantList = nbtItem.getObject("customEnchantList", JSONEnchantList.class);

timber eagle
#

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????????

timid berry
#

oh its just json

#

i can just modify it

timber eagle
#

seriously????

ivory sleet
#

its goofy

timid berry
#

write as json

#

set to string

timber eagle
#

i lost about an hour

#

and another 30 mins to reels

#

because of that

sly topaz
# timid berry write as json

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

timid berry
#

it looks like json

sly topaz
#

the API has some methods to just treat it like json through gson if you prefer it that way

timid berry
#

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

remote swallow
#

it cannot find that class

#

so first you havent shaded it or added the plugin, second

#

?whereami

timid berry
#

in my target folder

eternal oxide
#

@young knoll ^

#

nm

timid berry
#

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

remote swallow
river oracle
#

Imagine all your item stack code breaking

timid berry
#

probably

#

man I just want to access customEnchantList

#

😭

remote swallow
#

so read

timid berry
#

im trying man

#

(The nbt already on the item wasn't written by this api)

remote swallow
#

to me it looks like thats inside of minecraft:custom_data

timid berry
#

i managed to get it

#

somehow???

remote swallow
#

probably by scrolling further down

timid berry
#

guys

drowsy helm
#

Zahin451

timid berry
#

how can i turn this into a json string that is valid

#

I know i need to place \ behind the generated " but

remote swallow
#

if you paste that in a string intellij will add them for you

timid berry
#

but im getting the string

#

from nbt

#

I need to parse it

#

but idk how

remote swallow
#

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

timid berry
#

im gonna pretend I know what that means

remote swallow
#

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

proper radish
#

Which is more efficient and performant for running Async tasks in a plugin development:

  1. CompletableFuture
  2. BukkitScheduler
worldly ingot
#

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

proper radish
#

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 ?

buoyant viper
#

probably yeah

proper radish
# worldly ingot The scheduler runs on ticks, completable futures have their own thread pool (by ...

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 ?

river oracle
proper radish
#

so just use the second method

#

i didn't mean immediate but

river oracle
#

I use bukkit async task if I'm ticking a timer of something that can't or shouldn't be in the main thread

proper radish
#

so for db queries do you use completable futures or bukkit async tasks ?

river oracle
#

The former

#

With an executor service

worthy yarrow
#

@river oracle are you aware of any internals that use the PerlinOctaveGenerator?

worthy yarrow
#

Boo

remote swallow
#

Just figure it out

worthy yarrow
#

You figure it out

#

then tell me :p

blazing ocean
wide cipher
#

Is there any way to set a player's PlayerProfile? from what i can see there isn't an option for that

eternal night
#

no

wide cipher
#

then is there a work around to set a player's skin?

eternal night
#

packet magic

wide cipher
#

nooo, i was trying to avoid learning magic

rough drift
wide cipher
rough drift
smoky anchor
#

I think you may be able to use SkinRestorers API

wide cipher
smoky anchor
#

In that case, enjoy Hoggwarts!

upper hazel
frigid falcon
#

What arguments do I need to use with modifyItemStack or do you have an example for achieving this with NMS?

frigid falcon
#

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 :)

proud badge
#

The itemframe object is a superclass of entity

frigid falcon
#

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

proud badge
#

HangingPlaceEvent

#

check if the item in players hand has some metadata

#

use PDC

sly topaz
#

it is a bukkit utility, not an internally used class

sly topaz
#
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
frigid falcon
hushed spindle
#

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

sly topaz
#

because there's a different packet for whatever the player is holding in their hand

hushed spindle
#

yeah im just talking inventory for now

sly topaz
#

but why do you want to modify how an item is displayed client-side

hushed spindle
#

because i want to change how the item looks without modifying its meta

sly topaz
#

it should work, but you may find some desync issues

hushed spindle
#

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

sly topaz
#

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

hushed spindle
#

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

sly topaz
#

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

hushed spindle
#

cool cool

sly topaz
hushed spindle
#

how does this work again

#

also tried itemStack with the same result

blazing ocean
#

guessing you're using paper

hushed spindle
#

nope this is spigot

#

tried both

#

otherwise the error message would be red

blazing ocean
#

odd

#

try getDeclaredField ig

worldly ingot
#

Yeah, you need to use getDeclaredField

#

getField only accesses public fields

hushed spindle
#

ahhh i see

#

no error 👍

young knoll
#

Imagine a world where we never needed reflection

#

Or NMS

#

Or mixins

blazing ocean
remote swallow
#

Just add the aw to spigot

blazing ocean
#

yea

remote swallow
#

Wait about 9 months and answer 5000 questions about why it needs adding

remote swallow
#

Is it paper safe

young knoll
#

Idk

#

Probably

remote swallow
#

Wheres the nms reflection

#

To load nms

young knoll
#

AdapterInstance in core

worldly ingot
#

and non-final

#

Encapsulation be damned

young knoll
#

Yeah @Mojang

orchid trout
remote swallow
#

You can't be calling mojank versions semantic bc they aren't

young knoll
#

Don’t care + didn’t ask

young knoll
remote swallow
#

Dam

remote swallow
shadow night
remote swallow
hushed spindle
#

what does mixins actually do, what does it allow?

shadow night
#

It lets you inject code into the app, allowing you to modify behaviour

hushed spindle
#

would that be similar to patching

shadow night
#

Yes, but a lot more dynamic

hushed spindle
#

its at runtime?

#

or does it allow modifying app behaviour conditionally before the app itself starts

shadow night
#

Well Idrk the details

#

I just know it uses asm and it works

chrome beacon
#

at runtime

rough drift
#

oh wait no olivo is right

#

I'm dumb

#

was thinking of the wrong thing

chrome beacon
#

It injects during the first time a class is loaded

#

So it doesn't let you swap and inject after that

floral drum
#

I meannn..

chrome beacon
#

but if you really wanted to you could probably setup a hotswap agent and do that part yourself

floral drum
#

:D

#

bytebuddy!

shadow night
#

My favourite part about mixins is that you can mixin conditionally

young knoll
#

It’s just a fancy wrapper around asm

chrome beacon
#

and ASM is a pain to use

#

Visitor pattern for code modification 🔫

shadow night
hushed spindle
shadow night
#

If you ever develop a fabric mod, there is 70% chance you'll need it

hushed spindle
#

im sticking with spigot for the time being

chrome beacon
#

Mixins give a lot of freedom

#

There's Ignite if you ever feel limited with API and NMS

blazing ocean
pure dagger
#

[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

chrome beacon
#

Just let it regenerate

#

Why would you want it to stay missing

sly topaz
#

just don't have a default config

pure dagger
errant crest
#

Excellent crates crate openning doesn't make sound now, is it only me?

errant crest
#

oh ok

#

thanks

pure dagger
slender elbow
#

I'm 99% sure saveDefaultConfig doesn't load it as default, only saves the file if needed

pure dagger
#

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?

sly topaz
#

basically

slender elbow
#

you'd need to load the defaults as defaults for that

sly topaz
#

well no, users could input invalid data I guess

pure dagger
slender elbow
#

you just said you don't want to load the default config as default values, no?

pure dagger
#

yes

slender elbow
#
public void saveDefaultConfig() {
    if (!configFile.exists()) {
        saveResource("config.yml", false);
    }
}
#

it indeed does not load as default values

pure dagger
#

thats the implementation

#

?

slender elbow
#

yes

#

in JavaPlugin

#

which your plugin class extends

pure dagger
#

okay ill test it

#

i mean again

slender elbow
#

if it's loading the values as default then it's something else in your code that's doing that

pure dagger
#

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

sly topaz
#

what the

#

ksnip you'll be damned

pure dagger
#

i remove it or set it to null and it reads form the values i typed in before compiling

#

WHY

remote swallow
#

?paste anything that you interact with the config with, the default config in your resources and the config on the server

undone axleBOT
slender elbow
#

getConfig() loads the defaults when loading the file from disk as well

#

that's funny

pure dagger
#

what

slender elbow
#

getConfig() loads the defaults when loading the file from disk

pure dagger
#

what should i do

blazing ocean
slender elbow
#

¯_(ツ)_/¯

pure dagger
#

because everyone says it doesnt happen and it does happen, do they use different method or what

slender elbow
#

not using bukkit's config api sounds very appealing

pure dagger
#

: (

chrome beacon
#

?configs

undone axleBOT
blazing ocean
#

configurate >>

pure dagger
chrome beacon
#

It shows how to make your own config

#

Without relying on getConfig

#

which loads defaults

pure dagger
#

can i also make any other file?

chrome beacon
#

other configs, sure

#

or well yaml files ig

pure dagger
#

im asking if i can place there any other files like txt or png

#

or load it

remote swallow
#

you can put whatever you want in /resources and save it to the data folder with saveResource

pure dagger
#

can i generate it while running

remote swallow
#

generate what

pure dagger
#

file

#

not from /resources

remote swallow
#

sure

pure dagger
#

just in code

#

oki doki

#

thanks

#

ill just stay with the default values

#

i gues

#

for now

sly topaz
#

what was the property one had to use to avoid the 20 seconds delay on startup

blazing ocean
sly topaz
#

thanks

#

you're not pink anymore

#

what has become of the world

blazing ocean
#

😔

river oracle
#

Gonna be me soon tho fr

pure dagger
blazing ocean
#

what ??

sly topaz
floral drum
#

you’re outdated!

#

sorry had to

blazing ocean
#

update!!

pure dagger
#

i dont get what flag but okkk

sly topaz
#

it's just a funny haha

hushed spindle
#

is it still possible in java 21 to make a final field not final

#

with reflection

blazing ocean
#

why would you do that

hushed spindle
#

because i need to edit a packet that has a final property

slender elbow
#

setAccessible(true)?

#

unless it's a record class

hushed spindle
#

im not sure why but it works with most packets, just not a specific one

blazing ocean
#

maybe it's a record

slender elbow
#

that just sounds like it's a record

hushed spindle
#

oh it is yeah

#

anything that can be done about that

blazing ocean
#

no

hushed spindle
#

darn

slender elbow
#

recreate the packet with the same values except the one you want and send the new one down the pipeline

hushed spindle
#

im considering it yea

slender elbow
#

I mean you don't really have a choice lol

hushed spindle
#

i mean the other choice is to just ditch a use case of the plugin lol

slender elbow
#

giving up is a choice, true

hushed spindle
#

i do enjoy giving up

#

taking after my father

young knoll
#

Is there anything I can do to make that first chunk loaded not nuke the server for 5 seconds

rough drift
#

no

#

or maybe yes

#

idk

eternal oxide
#

Run it on a super computer

young knoll
#

Why is it only the first one

eternal oxide
#

it probably ques up 9 chunks when you ask for that one

young knoll
#

I mean, even that should't take 5 seconds

eternal oxide
#

If its the first world chunk it may que up even more, possibly view range

young knoll
#

Ree

eternal oxide
#

you shoudl be able to test it

#

do yoru first chunk load, then try loading a chunk WAY away from spawn

young knoll
blazing ocean
#

reloading!?!?

quaint mantle
#

Why are you loading 49 chunks?

young knoll
glossy laurel
#

how can you register commands without including them in plugin.yml

blazing ocean
#

command map

pure dagger
#
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

sly topaz
#

if you are trying to do a repeating task, use BukkitScheduler#runTaskTimer

pure dagger
#

umm okay but would it be safe?

sly topaz
#

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

pure dagger
#

im asking if there wont be stack overflow

sly topaz
#

what are you trying to do

pure dagger
#

i just want to make it happen every day

sly topaz
#

did this not work?

pure dagger
#

no because i have to execute command and its different thread

sly topaz
#

just do runTask inside of it

chrome beacon
#

^^

remote swallow
#

does anyone know if it was 1.17 or 1.17.1 that introduced mojmaps to spigot

sly topaz
remote swallow
#

the build data info introduces mappingsUrl in 1.17

remote swallow
#

cool, ty

pure dagger
# sly topaz just do runTask inside of it

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));
    }
worthy yarrow
sly topaz
pure dagger
#

oh sorry

#

/ 50

chrome beacon
#

and during larger timespans you might drop a couple ticks

#

So it could be off by more than you'd want

pure dagger
#

so i should go back to

#

this thing

#

before

#

with new thread

chrome beacon
#

yes

#

but use runTask to jump back to the main thread

sly topaz
#

optimally yes, since it doesn't depend on the server's performacne

lilac dagger
pure dagger
#

i didnt know you can jump back to main thread

lilac dagger
#

it adds up quickly

chrome beacon
lilac dagger
#

you can expect +- 30 mins to 1 hour

chrome beacon
#

dispatch command will be run on the main thread

pure dagger
#

you repeated bukkit,getScheduler

#

why

chrome beacon
#

oops I copied to much

#

xd

sly topaz
chrome beacon
#

Fixed

pure dagger
#

so bukkit like has built in method to jump back into the thread?

sly topaz
#

but yeah probably a few minutes off

lilac dagger
#

but you can't expect it to be lag free

pure dagger
chrome beacon
#

yes

pure dagger
#

thankss

chrome beacon
#

it will schedule it to be run on the main thread

sly topaz
#

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

pure dagger
#

what do i set

#

scheduler = Executors.newScheduledThreadPool(100);

#

here

sly topaz
#

just 1 lol

pure dagger
#

but now im gonna need more

sly topaz
#

I doubt you have 100 threads in your cpu

sly topaz
pure dagger
#

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

sly topaz
#

it'll only really be an issue if you want to run two tasks at the exact same time

pure dagger
#

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?

worthy yarrow
#

?paste

undone axleBOT
worthy yarrow
#

Or do you mean for a review?

sly topaz
pure dagger
worthy yarrow
pure dagger
#

okay thx

sly topaz
#

btw use Executors#newSingleThreadScheduledExecutor for the executor

pure dagger
#

now im using lambda in lambda 😵‍💫

worthy yarrow
# sly topaz yeah, milisecond difference probably

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

pure dagger
worthy yarrow
#

I'm certainly taking the difficult route on this one

sly topaz
#

it's all a learning experience

sly topaz
#

I would help you but I haven't done terrain generation in ages lol

worthy yarrow
#

No that's ok

sly topaz
pure dagger
#

okay

worthy yarrow
#

I'm getting there just slowly

#

I'm just one of those people who always needs others validation kek

pure dagger
#

me toooo

worthy yarrow
#

It seems you're getting a bit into concurrency though which is a total headache so good luck with that lol

pure dagger
#

🤷‍♂️

worthy yarrow
#

You'll probably get more attention tbf, especially if you post in the review thread

glossy laurel
blazing ocean
#

that what

#

also just use a command framework I beg you

glossy laurel
#

No >:)

#

I like my switch statements

blazing ocean
#

:concern:

glossy laurel
#

average command class length

blazing ocean
glossy laurel
blazing ocean
#

or cloud

worthy yarrow
glossy laurel
blazing ocean
#

your life would be so much better

glossy laurel
#

Now keep imagining

glossy laurel
worthy yarrow
glossy laurel
#

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

glossy laurel
#

👌

blazing ocean
#

😭

tall dragon
#

💀

blazing ocean
#

this is what's gonna happen to you ^

glossy laurel
blazing ocean
blazing ocean
#

ignorance it is

worthy yarrow
#

Rad

#

funky town

blazing ocean
#

kat

#

funky town

#

:duckdance:

worthy yarrow
blazing ocean
#

man fucking

glossy laurel
#

My tab completer is 50 lines long

#

send help

blazing ocean
#

@wet breach my nitro went out and I can'T use duckdance anymore

#

wtf

worthy yarrow
#

rad asking for frosty to sponsor another month of pink kek

glossy laurel
worthy yarrow
#

ok back to dirt rally

blazing ocean
#

you at work?

worthy yarrow
blazing ocean
#

oh right

#

we don't celebrate that here

worthy yarrow
#

dirt rally the racing game kek

blazing ocean
#

oh

glossy laurel
worthy yarrow
#

rad did you literally think I was gonna rally some dirt at work

blazing ocean
#

idk??

glossy laurel
#

I love how you're just not talking to me like I'm insane or smth

blazing ocean
#

you do all kind of weird shit at work

#

including

#

playing with chemicals

#

spraying plastic

worthy yarrow
#

Psh that's not weird that's maintenances job

blazing ocean
#

same thing

worthy yarrow
#

however, maintenance does not do their job

#

so i do

glossy laurel
#

I love being background noise in a conversation

worthy yarrow
#

keep ignoring him rad

blazing ocean
#

keep ignoring who

worthy yarrow
#

Who?

glossy laurel
worthy yarrow
#

Idk

glossy laurel
#

I can't see anyone

worthy yarrow
#

Yo rad

#

did you just ping me?

blazing ocean
#

no?

glossy laurel
#

must've been the wind

#

I swear

worthy yarrow
#

tf I got pinged

blazing ocean
#

discord moment I swear

worthy yarrow
#

fuckin discord mate

glossy laurel
#

watch me do magic

#

@blazing ocean

#

they just dipped

#

omg

#

💀

blazing ocean
#

@worthy yarrow I did an assignment in kotlin today

#

and completely overcomplicated it

worthy yarrow
#

You said that already but without the pic kek

blazing ocean
#

now I have the pic

glossy laurel
#

what the rpg game is that

worthy yarrow
#

I don't see why it's overcomplicated

blazing ocean
#

I think the rest of my classmates just did like

glossy laurel
#

@worthy yarrow Don't respond to this message if you're geh

blazing ocean
#

prompt("helo what is your name?") and shit

#

in python

worthy yarrow
#

Based on the naming it just looks like regular oop more than anything

glossy laurel
blazing ocean
#

meanwhile I did that shit

#

imagine not having i18n fr

glossy laurel
#

what is i18n?? 😭

blazing ocean
glossy laurel
#

this is not funny guys 😭

#

I exist

worthy yarrow
blazing ocean
#

a bit

glossy laurel
#

||I know you read this 💀 ||

worthy yarrow
#

I wonder if you could make it actually comlex

#

but not in a good way

#

improper abstractions and putting shit in random places

glossy laurel
#

TALK TO MEEE

glossy laurel
worthy yarrow
glossy laurel
#

real

#

nah I dont do abstraction

#

😎

worthy yarrow
#

welp

glossy laurel
#

using abstraction is not sigma 🙅‍♂️

remote swallow
#

@blazing ocean pop muzik

blazing ocean
#

what

remote swallow
#

dam you dont know pop muzik?

blazing ocean
#

no

remote swallow
glossy laurel
elfin socket
#
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

blazing ocean
chrome beacon
blazing ocean
#

close all BT instances

#

and terminals in that directory just to be sure

chrome beacon
#

^^ Make sure you're not running it twice

blazing ocean
#

if it still persists, check task manager

chrome beacon
#

or just restart the pc

eternal oxide
#

or you shaded spigot

chrome beacon
#

?

blazing ocean
#

man I love shading the entire spigot server

elfin socket
#

I am 100% sure i'm not running it twice, computer restart, all java tasks closed(even intelliJ), just command prompt, still the same

blazing ocean
#

what if you just delete that file

#

the explorer usually tells you what app uses it iirc

chrome beacon
#

It doesn't

#

It just says it's being used by something

blazing ocean
#

smh

elfin socket
#

it only tells you if it's being used. also I can delete it

blazing ocean
#

this is why linux is better

#

then try deleting it

chrome beacon
#

Rerun BuildTools in an empty folder

#

see if it still happens

elfin socket
#

one sec

elfin socket
#

clam av is no longer maintained and doesnt detect unknown malware

chrome beacon
#

You don't really need an AV for Linux

elfin socket
#

you can still get malware on linux

chrome beacon
#

Setup your perms properly and you're good

elfin socket
#
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)``` 😐
eternal oxide
#

Block all ads and don't download for dodgy sites = no malware

#

Are you running BT UI or BT command line?

elfin socket
#

command

#

ui gets the same error

eternal oxide
#

if you have an AV, exclude the BT folder from scanning

elfin socket
#

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

chrome beacon
#

That's BuildTools not gradle though

elfin socket
#

gradle has the same issue, the files are denied access because it's being used

#

the only thing that worked was downgrading gradle

river oracle
#

Have ya tried restarting your machine?

chrome beacon
#

^^

elfin socket
#

yes, and reinstalling the IDE multiple times

chrome beacon
#

Sounds like Windows is broken if that happens to multiple things

eternal oxide
#

I'm going to blame gremlins in the machine, or you have a virus

chrome beacon
#

^^

elfin socket
#

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

remote swallow
#

is that error occuring in command line while running buildtools or when reloading gradle

elfin socket
#

It happened to both. But downgrading grade seemed to work. Now it’s just BT

#

I just want to use NMS 🥲

blazing ocean
#

ebic you know what i'm thinking

remote swallow
#

like i should be working on spigot builder

blazing ocean
#

exactly

remote swallow
#

sounds crazy

grand timber
#

How can i work with tags? Bcs hasTag is deleted in CompoundTag, for my ItemTagHandler

elfin socket
#

Where can I harass the Bukkit devs about not letting me set nbt tags that aren’t messy namespace keys?

eternal oxide
#

There are no Bukkit devs.

#

Spigot includes Bukkit

elfin socket
#

Fr

smoky anchor
grand timber
#

For my ItemTagHandler for my InventorySystem.

smoky anchor
#

That's not answering my question

#

I don't know what your ItemTagHandler is nor what it does

grand timber
#

He does set tags, remove tags, get tags, getStrings for my items.

smoky anchor
#

Why do you not use PDC

grand timber
#

How works PDC?

smoky anchor
#

?pdc

eternal oxide
#

it stores in NBT under a bukkitvalues key

elfin socket
#

?nms

elfin socket
#

That works ig

prime reef
#

Does anyone have experience working with native code in plugins?

chrome beacon
#

?ask

undone axleBOT
#

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!

prime reef
#

my question's pretty general

#

"How is it"

#

"does the plugin shit itself"

#

etc.

chrome beacon
#

Works fine

prime reef
#

I take it you're speaking from experience writing a plugin with native code involved

#

(that you also wrote)

chrome beacon
#

I did not write the native code

prime reef
#

yeah I would like to hear from someone who's written their own native code for a plugin

#

sorry

chrome beacon
#

Why would you do that though

prime reef
#

because I have code that is doing a fair amount of math and C++ is considerably faster at it

chrome beacon
#

What are you doing that's going to benefit from it

#

AI?

prime reef
#

mostly raycasting

#

might also be constructing a BVH for collision

chrome beacon
#

What are you raycasting?

#

because moving data from native and java isn't exactly free

sullen marlin
#

It's probably not gonna be faster

prime reef
#

arbitrary geometry

sullen marlin
#

And certainly not worth it

prime reef
#

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

sullen marlin
#

It's java, not python, it's being jitted into optimised native code already

#

People write high frequency trading programs in java

prime reef
#

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

chrome beacon
#

As with everything performance test don't speculate

prime reef
#

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"

sly topaz
#

SIMD is rarely a solution to a fast algorithm, it just limits the usability for no particular reason

prime reef
#

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

sly topaz
#

I mean for anything that'll be used at scale, if it is a solution for a specific company then it is probably fine

prime reef
#

yeah no this is all internal

sly topaz
#

if it is in the JVM, you'd rather just rely on auto-vectorization if it can be helped

chrome beacon
#

Java does have a vector API

prime reef
#

it does, yeah

#

i just looked it up

#

seems like it has SIMD support so that's cool

sly topaz
#

that's incubating still, but yeah you can use it

#

anyhow, performance will not be an issue with java even without the vector api

prime reef
#

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

sly topaz
#

I mean, I'd like to assume you are writing your own raycasting algorithm rather than depending on minecraft's

prime reef
sly topaz
#

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

chrome beacon
#

but it hasn't changed in a while

prime reef
#

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

sly topaz
#

it won't change until valhalla arrives, but we are definitely not there yet

#

probably going to be out by java 27 or so

sly topaz
prime reef
#

ah mb that was more of an aside

#

like doing an n-dimensional vector type

#

java doesn't do primitives in templates (generics)

sly topaz
#

not yet™️

prime reef
#

ah, the ol' Soon™️ lmao

#

honestly I'd love if it could

sly topaz
#

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

prime reef
#

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

uneven marlin
#

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

chrome beacon
#

It just adds a movement vector to the player

sly topaz
chrome beacon
quaint mantle
#

No making part of the logic native in java app doesn't make it faster. You only use jni to access low level stuff

sly topaz
#

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

chrome beacon
#

FFM is a lot better

sly topaz
#

you can't do it even with the /data command?

chrome beacon
#

Can't modify player data directly with commands in vanilla

sly topaz
#

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

grand timber
#

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);
lilac dagger
#

this is pretty cool

#

looks fine i think?

sly topaz
lilac dagger
#

yeah, mysql driver must be wrong

grand timber
#

How do i shade the mysql driver? Can't remember. Just 1 day ago again starting with coding.

worldly ingot
#

CraftBukkit already shades a MySQL driver. It shades ConnectorJ

#

The class probably just hasn't been loaded

sly topaz
#

isn't that what setDataSource does, load the class

#

what version of the connector does craftbukkit shade

grand timber
#

Yeah?

worldly ingot
#

I don't think it actually loads it, does it?

#

It shades 9.1.0

sly topaz
#

that is the latest version

grand timber
worldly ingot
#

That's not the correct driver name though

sly topaz
#

seems like it is the wrong package

worldly ingot
#

com.mysql.cj.jdbc.Driver is

grand timber
#

com.mysql.jdbc.jdbc2.optional.MysqlDataSource

#

Changing thath to that?

worldly ingot
#

Yeah iddk what that's from

#

Change to the one I mentioned, should work

grand timber
#

I will try.

sly topaz
#

com.mysql.cj.jdbc.MysqlDataSource if what Choco said doesn't work

grand timber
#

Wich one now? Haha

worldly ingot
#

MysqlDataSource doesn't seem to be a driver aPES_Think

sly topaz
#

try choco's one first

worldly ingot
grand timber
#

Okay

worldly ingot
#

Yeah which, notably, isn't a driver lol

sly topaz
#

the Driver implements it so I assume you're supposed to use the driver yeah

timid berry
#

guys

worldly ingot
#

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
}
timid berry
#

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?

sly topaz
#

Loading class com.mysql.jdbc.Driver. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

worldly ingot
#

Maybe it's the SQLite driver that still needs it

inner mulch
#

can you tell us what you want to do, i dont really understand

timid berry
#

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?

sly topaz
#

you could do it on join, yeah however that isn't gonna cover items stored in inventories

inner mulch
#

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

sly topaz
#

you'd also have to do it on inventory open

inner mulch
#

only close does

grand timber
#

Now im getting this error:

java.lang.RuntimeException: java.lang.ClassCastException: Cannot cast com.mysql.cj.jdbc.Driver to javax.sql.DataSource

timid berry
sly topaz
inner mulch
grand timber
#

com.mysql.cj.jdbc.MysqlDataSource
this one?

sly topaz
#

yes

inner mulch
#

just check their inv when it might change

timid berry
#

cant i do something with player.getinventory

#

?

#

on join

inner mulch
#

yes

timid berry
#

scan through player get inv

#

aight

inner mulch
#

yes

#

just create your scan method and call it in every event i mentioned

sly topaz
#

just on join and inventory open is fine

inner mulch
#

if i havent missed anything you should be good

inner mulch
timid berry
#

i mean

sly topaz
timid berry
#

ill always have to have it scanning forever right?

#

insane someone opens a chest months later

#

that has the old items

#

*incase

sly topaz
#

you can probably add a pdc to the container so that you can mark it as converted

inner mulch
sly topaz
#

same for the player

sly topaz
inner mulch
#

???

sly topaz
#

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

inner mulch
#

open is bad, cause it changes when player takes something and then closes, they dont take items out of a chest on open

sly topaz
#

that's fine, you want to convert all the items anyway

#

why would you only convert when they take the items

inner mulch
timid berry
#

also

#

if im scanning everytime a player opens a chest

inner mulch
timid berry
#

wont this also change other plugins who use chest guis?

grand timber
#

Now it stays on this Survival Pool - Starting... line of text, i dont get any errors, or starting the server..

inner mulch
sly topaz
timid berry
#

i mean yah close

sly topaz
#

just convert everything

timid berry
#

but if a plugin uses

#

chest guis

#

would it mess with the gui items?

inner mulch
#

how?

sly topaz
#

if they don't have the component it wouldn't change anything, so no

inner mulch
#

i hope you have an identifier for your custom items

timid berry
#

yah i do

#

but imagine an auction house item

sly topaz
#

I mean the identifier is the custom nbt tag

timid berry
#

the items in the gui will have it

#

now if the player closes the auction gui

#

will it change that item?

inner mulch
#

depends on ur impl

timid berry
#

not my auction house

#

plugin

sly topaz
#

you can just check if the inventory has a block inventory holder attached to it

inner mulch
#

im guessing you dont save your auction gui if its changes due to something

sly topaz
#

if it doesn't, then it is a custom inventory and you shouldn't convert

sly topaz
#

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

inner mulch
# timid berry okay

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

sly topaz
#

either option is a pain in the ass, and the worse option is scanning the nbt of statically 😛

grand timber
#

@worldly ingot @sly topaz

Now it stays on this Survival Pool - Starting... line of text, i dont get any errors, or starting the server..

sly topaz
#

what is the code looking like right now

worldly ingot
#

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

grand timber
#
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);
sly topaz
#

apparently

worldly ingot
#

Actually, I'm realizing you're doing setDataSourceClassName(). You don't need to do that.

sly topaz
#

you do need to do that for most databases, just not mysql apparently

grand timber
#

What must i do instead?

sly topaz
#

use the jdbc url

worldly ingot
#
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

grand timber
#

That would work?

worldly ingot
#

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

sly topaz
#

is setDriverClassName necessary since spigot doesn't automatically load the class?

grand timber
#

Im trying it.

worldly ingot
#

Yeah CraftBukkit doesn't load it, it just shades it

sly topaz
#

the DataSource is better if you use JNDI dependent software like tomcat, otherwise it doesn't really matter

worldly ingot
#

hi emily PES3_Wave

sly topaz
#

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

slender elbow
#

choco jumpscare

worldly ingot
#

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 😭

sly topaz
#

lmao

#

chocoception

worldly ingot
#
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?
worldly ingot
#

Hypixel

grand timber
sly topaz
#

it is nice indeed

#

whenever I experience lag in HP I can just blame Choco for it

worldly ingot
#

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"

#

stitchFrustrated fml

grand timber
#

😂

grand timber
#
com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
slender elbow
#

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

sly topaz
#

is your mysql instance/container online

worldly ingot
sly topaz
#

timezones be ruining the fun

slender elbow
#

what is choco standard time

quaint mantle
grand timber
worldly ingot
#

tbh there's a high likelihood you've played with a staff member before, you just don't know it lol

slender elbow
#

are you calling me STUPID

#

no

#

you wouldn't do that

worldly ingot
#

No, we're just sneaky hypixel_ninja

grand timber
worldly ingot
#

I like to play unnicked most of the time though because it's more fun that way

grand timber
#

Right!

river oracle
#

don't you get targeted lol

#

or are you so confident in your skills you just don't even care

buoyant viper
#

or at least it used to

worldly ingot
#

But not often enough for it to bother me

sly topaz
#

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

grand timber
#

LOL🤣

worldly ingot
#

Most of the time I just get this KEKW

remote swallow
#

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

timid berry
#

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);

}

grand timber
#

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 md_5

remote swallow
#

does getConnection return the same connection every time

grand timber
#

yeah, my DriverManager connection.

chrome beacon
#

You're closing it :kekw:

grand timber
chrome beacon
#

Try with resources closes the resources on exit

#

hence the name

grand timber
#

I don't see closing.

chrome beacon
#

It closes when it exists the scope of the try

#

That's kind of the whole point with try with resources

grand timber
#

How tf am i fixing this then?

chrome beacon
#

Just don't use try with resources and you're good

grand timber
#

So, why is 1 table working then?

chrome beacon
#

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

grand timber
#

I have used this code so much in history, and don't even where getting this error🤣

remote swallow
#

im guessing you used to return a different connection before

grand timber
#

I have checked it, and yeah 😅

#

I cant use it without try with resources

remote swallow
#

if you return a different connection you can use twr

grand timber
#

different connection? How?

remote swallow
#

you said you did it before

#

so do it again

grand timber
#

No, that was with hikari datasource. Now i'm using JDBC

#

hikari didn't work anymore.

remote swallow
#

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

grand timber
#

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

remote swallow
#

okay so read the exception and figure out what line is causing that error

grand timber
#

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) ~[?:?]
remote swallow
#

that isnt the data source anymore

grand timber
#

What then?

remote swallow
#

com.mysql.cj.jdbc.MysqlDataSource afaik

grand timber
#

Thanks, it works! But earlier this didn't work haha

sly topaz
#

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

grand timber
remote swallow
#

you have to get the meta and set it again

summer scroll
#

Guys, how come Sugar Cane is part of Ageable?