#help-development

1 messages · Page 1218 of 1

remote swallow
#

what the fook is that @SneakyThrows doing in there

grim hound
grim hound
#

wasn't the translation first?

worldly ingot
#

Right rotation is applied first, then scale, then left rotation, then translation

grim hound
#

will post testing results tomorrow

worldly ingot
#

The "right"ness is to do with the matrix iirc

grim hound
#

(technically today but uh

#

we don't talk about that)

worldly ingot
#

I have no promises that that works btw lol

worthy yarrow
#

And you asked what more physics I would need smh

dawn flower
#

i have a weird bug, so uh basically i have a list of things which does other things in order for example {"broadcast t", "broadcast tt", "wait 20", "broadcast waited"}, the problem is having "wait x" breaks the whole code and makes it so even the first 2 which is broadcast t and broadcast tt not work (i never even come near the wait x until broadcast t and broadcast tt finish working)

if that's not weird enough if i run the debugger and breakpoint the line that executes the code then click "Resume code", it just magically works

not to mention that if i try to print stuff before execution code it prints it but it refuses to execute

remote swallow
#

how do they get handled internally, then what provides wait 20. and if you have a breakpoint on the wait code its going to pause untill you resume?

dawn flower
remote swallow
#

show code

#

thats the thing we need

dawn flower
#

1 sec

#
    @Override
    public void execute(Queue<ScriptStep> body, ExecutionContext context) {
        context.setNextAction(TurboAPI.getScriptParserStatic().getNextAction(body));

        while (context.getNextAction() != null && !body.isEmpty()) {
            ScriptStep step = body.poll();
            context.setNextAction(TurboAPI.getScriptParserStatic().getNextAction(body));
            if (step instanceof ExecutableSection executableSection) {
                context.setCurrentSection(executableSection);

                if (executableSection.getSection().getSyntaxElement() instanceof TurboSection turboSection) {
                    turboSection.executeSection(executableSection.getSection(), context, executableSection);
                }

                continue;
            }

            ParsedElement action = (ParsedElement) step;
            if (!(action.getSyntaxElement() instanceof TurboAction turboAction)) {
                return;
            }

            action.executeArguments(context);
            turboAction.execute(action, context);
            context.setNextAction(turboAction.next(action, context));
        }
    }```
#

then what provides wait 20. and if you have a breakpoint on the wait code its going to pause untill you resume

a file provides the list, if i put a breakpoint on the code that calls the execute method then resume the code it works like there isn't a bug

remote swallow
#

that code means absolutely nothing without any info about it, how does the wait code actually work to wait

dawn flower
#
public class ActWait extends TurboAction {
    public ActWait() {
    }

    public void execute(ParsedElement parsedElement, ExecutionContext executionContext) {
    }

    public ParsedElement next(ParsedElement parsedElement, ExecutionContext context) {
        long ticks = (long)parsedElement.getNumberArgument(1, 0).intValue();
        if (ticks < 1L) {
            return super.next(parsedElement, context);
        } else {
            Queue<ScriptStep> body = context.getCurrentSection().getBody();
            Bukkit.getScheduler().scheduleSyncDelayedTask(TurboLanguage.getPlugin(), () -> {
                body.poll();
                TurboAPI.getScriptEvaluatorStatic().execute(body, context);
            }, ticks);
            return null;
        }
    }

    public boolean init(ParsedElement parsedElement) {
        return (parsedElement.compareName("wait") || parsedElement.compareName("sleep")) && parsedElement.hasArg(1);
    }
}
remote swallow
#

without asking for almost every single class, best i can say is just start adding debug statements and figure out whats running and when

#

use runTaskLater not scheduleSyncDelayTask too

dawn flower
#

tried both

#

but ok

#

what in the

#

it just started working, i didnt change any code

dawn flower
remote swallow
barren peak
#

Is it possible to spawn either a falling block or a block display and attach a bunch of leads to it that are all tied to individual chickens that float down above it?

dawn flower
#

u cant attach a lead to them

barren peak
#

you cant attach to a block display or a falling block?

#

wb armor stand?

dawn flower
#

u can with them

barren peak
#

can I attach to a marker armor stand>

#

or does it have to have hitbox

#

& whats the code to attach leads

dawn flower
#

not sure abt the marker

#

entity.setLeashHolder(holder);

barren peak
#

ok thanks I will try that

dawn flower
#

nvm according to this i dont think armor stands can also be attached to a lead

barren peak
#

hmmm

#

can you attach multiple leads to a single entity?

#

besides a player bc I dont want to deal with that

dawn flower
#

but u can do the opposite

barren peak
#

?

#

wdym

dawn flower
#

u can attach multiple entities to one lead

barren peak
#

it doesnt appear you can lead armor stands unfortunately

barren peak
#

spawn a supply drop ( either a falling block chest or a block display chest) and lead it to a bunch of chickens that float down with it

#

is the only way to spawn a bunch of invisible living entities and lead the chickens to that?

dawn flower
#

hold on

barren peak
#

cuz that would suck

dawn flower
#

r u trying to make it seem like it's attached to it or do u want it to actually fall

barren peak
#

wdym?

dawn flower
#

like r u attaching it to chickens because u want the display block to move with the chickens or for decoration

barren peak
#

the supply drop will fall down from sky if thats what you are asking. yes the chickens will fall down to decorate as a parachute

dawn flower
#

just put another ai-less invisible chicken in the middle of the supply drop and move it with the supply drop and attach the lead to that chicken

barren peak
#

yeah but I would need a bunch of them

#

which isn't ideal

dawn flower
#

idk other ways around it

#

srry

barren peak
#

the question is there any entity I can summon that will let me attach multiple leads to it so I only need one

barren peak
#

hmm it seems spawning a player the normal way leads to an illegalargumentexception

ebon pier
#

hello could anyone help me with nantibot plugin ?

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!

ebon pier
robust helm
#

so to download it you need to complete a captcha?

mortal vortex
#

@ebon pier @robust helm.

Little confused here, are we talking about nAntiBot or are you mispelling, and referring to a generic AntiBot plugin?

Why I'm confused is, nAntiBot is a plugin that is not on SpigotMC, as it's generally considered a premium plugin

#

And also, this isn't a development question so I dont know why you're here.

ebon pier
mortal vortex
#

Okay. so see this? They have a support server.

worldly cradle
mortal vortex
# ebon pier Its Dead

Not my problem, and not related to this channel, move along so this guy can ask his question which actually belongs here

robust helm
#

i dont get how i should run redis in a distributed server network. it says i shouldnt expose it to the internet but thatd mean all my servers using the instance would have to be in the same network?

worldly cradle
#

they should definetly make this channel a thread 😇

robust helm
#

well it says you should use threads if channel is in use

#

but yea ig dc forum would be simpler

buoyant viper
#

back in my day

#

we used THE spigotmc forum for code help...

robust helm
#

and then wait for hours for an answer (i never tried the spigotmc forum)

buoyant viper
worldly cradle
#

yeah tbh I've had the most success asking on the minehut disc server

robust helm
#

lol i used to spent hours passing my plugin instance to a bukkit schedula cuz i didnt know how to use java and didnt want to use the forum 🥲

#

and then someone on the forum told me to use static 🤠

amber fjord
#

?paste

undone axleBOT
amber fjord
#

welp

amber fjord
#

any other pastebins?

mortal vortex
#

wym?

amber fjord
#

?paste is down

undone axleBOT
mortal vortex
#

Good point.

#

Just google it?

#

pastes.dev is what a lot of giganerd here use

#

and I've never seen it go down

amber fjord
mortal vortex
#

Cant you use a switch statement btw?

#

I mean that wont really improve speed

mortal vortex
#

why are you making the function call Objects.requireNonNull() everytime?

amber fjord
mortal vortex
#

store it is a AttributeInstance

amber fjord
#

._.

mortal vortex
#

?

#

Why every tick? Like why?

amber fjord
#

i see that now

#

once every 2 seconds should do

#

i forgot about that 😭

mortal vortex
#
new BukkitRunnable() {
        public void run() {
            for (Player player : Bukkit.getOnlinePlayers()) {
                // Store the return of the function calls HERE so you arent calling it each time
                AttributeInstance attackDamage = player.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE);
                AttributeInstance maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
                // Make this if block sexier.
                if (attackDamage == null || maxHealth == null) continue;
                
                boolean shouldHaveBoosts = player.getInventory().contains(droughtItem) && isAridBiome(player);
                boolean hasAttackBoost = attackDamage.getModifiers().contains(damageBoostModifier);
                boolean hasHealthBoost = maxHealth.getModifiers().contains(healthBoostModifier);
                
                // then the rest of your logic doesnt look like a clusterfuck you can do this.
                if (shouldHaveBoosts && !hasAttackBoost) {
                    attackDamage.addModifier(damageBoostModifier);
                } else if (!shouldHaveBoosts && hasAttackBoost) {
                    attackDamage.removeModifier(damageBoostModifier);
                }
                
                // Apply or remove health boost if needed
                if (shouldHaveBoosts && !hasHealthBoost) {
                    maxHealth.addModifier(healthBoostModifier);
                } else if (!shouldHaveBoosts && hasHealthBoost) {
                    maxHealth.removeModifier(healthBoostModifier);
                }
            }
        }
    }.runTaskTimer(this.plugin, 0L, 40L);
amber fjord
#

that is pretty sexy

mortal vortex
#

And when I hear isAridBiome my brain jumps to, chunk loading or world checks, which can also be just as expensive as the dozens of inventory checks you're doing.

amber fjord
#

theres no other easier way tho

mortal vortex
#

correct.

#

or maybe?

amber fjord
#

uh oh

mortal vortex
#

You could make a hashmap, like playerBoostStates and begin by checking if any states have changed, so you can skip over some results.

#

that would use an event though

#

eh that would be more hassle than what its worth

mortal vortex
#

ywkim?

amber fjord
#

thats probably more work than necessary

#

i see it but i dont want it

mortal vortex
#

Gotcha

#

go with what i sent

amber fjord
#

yeah

obtuse meadow
#

hey guys does any one how to use FoodComponent, EquippableComponent, UseCooldownComponent ? Thanks 😛

obtuse meadow
# amber fjord much better

i know it but its a interface and a i need to create a new UseCooldownComponent but just implementing it at the class dosnt work because cant cast as CraftUseCooldownComponent

amber fjord
#

i think more context is needed to help you

obtuse meadow
#

    private NamespacedKey group;
    private float seconds;
    
    public GenericCooldown(NamespacedKey group, float seconds) {
        this.group = group;
        this.seconds = seconds;
    }
    
    @Override
    public Map<String, Object> serialize() {
        return Map.of("seconds", seconds, "cooldown_group", group);
    }

    @Override
    public float getCooldownSeconds() {
        return seconds;
    }

    @Override
    public void setCooldownSeconds(float cooldown) {
        seconds = cooldown;
    }

    @Override
    public NamespacedKey getCooldownGroup() {
        return group;
    }

    @Override
    public void setCooldownGroup(NamespacedKey group) {
        this.group = group;
    }

amber fjord
#

i dont understand what you want to make happen though

obtuse meadow
#
    
    @EventHandler
    private void customPotions(InventoryClickEvent ev) {
        if(ev.getClickedInventory()==null) return;
        ItemStack item = ev.getClickedInventory().getItem(ev.getSlot());
        if(item==null || item.getType().equals(Material.AIR)) return;
        if(!(item.getItemMeta() instanceof PotionMeta potion)) return;
        if(potion.hasMaxStackSize()) return;
        potion.setMaxStackSize(16);

        NamespacedKey spk = new NamespacedKey(SpecificServerPlugin.getPlugin(), "potion");
        GenericCooldown cooldown = new GenericCooldown(spk, 0);

        potion.setUseCooldown(cooldown);
        
        item.setItemMeta(potion);
        
    }
#

change the cooldown for a specific potion, than i will use FoodComponet to change the consume_seconds but probaly i will be stucked in the same point

amber fjord
#

so what doesnt work again?

#

so you shouldnt have the cooldown be 0 just make it 0.1

obtuse meadow
#

sorry wrong error

amber fjord
#

ah

obtuse meadow
#
[04:09:20 ERROR]: Could not pass event InventoryClickEvent to SpecificServer v1.0
java.lang.ClassCastException: class me.RaulH22.SpecificServer.cooldowns.GenericCooldown cannot be cast to class org.bukkit.craftbukkit.inventory.components.CraftUseCooldownComponent (me.RaulH22.SpecificServer.cooldowns.GenericCooldown is in unnamed module of loader 'SpecificServer-1738393755688.jar' @15dd0197; org.bukkit.craftbukkit.inventory.components.CraftUseCooldownComponent is in unnamed module of loader java.net.URLClassLoader @4e515669)
amber fjord
#

im not sure

#

maybe wait for someone more experienced than I am

worldly ice
#

i believe the API way to do it is to optain a component using the get method, modifying it, then setting it back

#

similar to item meta

obtuse meadow
#

forget its, was simpliest than i was thinking hahahah

#

thanks btw

#

Working...

@EventHandler
    private void customPotions(InventoryClickEvent ev) {
        if(ev.getClickedInventory()==null) return;
        ItemStack item = ev.getClickedInventory().getItem(ev.getSlot());
        if(item==null || item.getType().equals(Material.AIR)) return;
        if(!(item.getItemMeta() instanceof PotionMeta potion)) return;
        if(potion.hasMaxStackSize()) return;
        potion.setMaxStackSize(16);

        UseCooldownComponent cooldown = potion.getUseCooldown();
        cooldown.setCooldownSeconds(500);
        
        potion.setUseCooldown(cooldown);
        
        item.setItemMeta(potion);
        
    }
amber fjord
#

mmy amateur java brain doesnt know how that works

mortal vortex
#

you dont know basic english?

#

im pretty sure the word "continue" is self explanatory

amber fjord
#

yeah

#

i thought so too

#

but it didnt do what it was supposed to do

mortal vortex
#

oh

amber fjord
#

it wanted to continue but it never really did

#

idk why

#

because when i switched it to just a regular if block it worked 😭

mortal vortex
#

damn i guess i wrote wrong

#

but also probabyl becuase i couldnt properly read ur code

amber fjord
#

Reference my middle school scratch projects

mortal vortex
#

jesus dude

wooden frost
#

In protocolLib, how does one send a fake laying on ground animation?

wooden frost
robust helm
#

is there some way to cancel server start if plugin failed to load or should i js try catch the whole onenable?

sullen marlin
#

Not really, a plugin shouldn't stop the whole server

robust helm
#

alr thx

split gull
blazing ocean
#

lying on the ground does not exist, it is exclusive to beds

#

there is swimming tho

#

which is just a pose

wooden frost
eternal oxide
#

google, there are plenty of examples

#

you will need nms whatever you choose to do

wooden frost
#

and yes

#

?whereami

eternal oxide
#

then use a corpse plugin

wooden frost
#

Oh

#

nono

eternal oxide
#

a plugin that creates a player corpse

wooden frost
#

why would i do that

robust helm
wooden frost
#

should'nt protocollib have that already

eternal oxide
#

you can set teh player to observe the corpse

#

no

eternal oxide
#

PL will let you set teh pose but it will constantly change

eternal oxide
#

it will keep getting reset to the player standing anytime the player meta gets re-sent

wooden frost
#

any other way to do it then?

eternal oxide
#

even if you constantly send a fake meta packet it will still flicker with the player standing

#

a player corpse plugin

robust helm
#

the player corpse plugin has a way to do it too

wooden frost
#

exactly

robust helm
#

cant u just use npcs?

wooden frost
#

i can, but i also dont know how would that be done

robust helm
#

me neither

wooden frost
#

bro😭

eternal oxide
#

that requires nms

wooden frost
#

YOU CANT SPAWN

#

NPCS

#

THROUGH PROTOCOLLIB

#

??

eternal oxide
#

well you can, but its not simple

wooden frost
#

I am finna kill myself in this shit, hell no

robust helm
#

just copy source code from corpse plugin :>

wooden frost
#

bro why did paper have to do me dirty like that, u cant just import it, and im banned on there if i want to ask questions😭😭

eternal oxide
#

start coding against Spigot then

robust helm
#

im banned there too lol

wooden frost
#

HOLY SHIT

eternal oxide
#

this IS spigot

wooden frost
#

WE BE FORMING A CLUB

robust helm
#

xd

wooden frost
#

?whereami myself again

wooden frost
robust helm
#

alt account

wooden frost
eternal oxide
#

in before teh ban for evasion

robust helm
#

dont think so

robust helm
eternal oxide
robust helm
#

but paper?

eternal oxide
#

I don;t use Paper so no clue

robust helm
#

and they cant rlly detect it

blazing ocean
#

and this server is spigot so you are expected to be working with spigot here.

split gull
wooden frost
#

how on earth

blazing ocean
eternal oxide
#

Some servers ban at teh drop of a hat

split gull
mortal vortex
#

I got banned from a Sikhism Discord server, before i even hit verify.

wooden frost
wooden frost
mortal vortex
#

I'm not even a religious troll, I didnt even type, I opened a verification ticket and got insta banned

split gull
mortal vortex
wooden frost
#

i personaly dont

mortal vortex
#

What are you talking about?

mortal vortex
wooden frost
wooden frost
mortal vortex
#

understand how what's offensive?

wooden frost
#

me being a religious troll or whatever

wooden frost
mortal vortex
#

when did i say you were a religious troll????

mortal vortex
#

NO. I was talking about ME.

wooden frost
mortal vortex
#

No?

#

I got banned from a religious server, before speaking, despite not being a troll (which is what people normally get banned for)

#

anyways not the channel, and probably not place for this

split gull
#

Y'all this ain't the channel for that

eternal oxide
wooden frost
#

true

#

#general

dawn flower
#

if one of the actions gets the ExecutableSection object that it's in and does getBody, it returns the contents of persistentBody like none were removed

#

I assume it's a concurrency thing but that could be bs

blazing ocean
#

?paste please

undone axleBOT
dawn flower
blazing ocean
blazing ocean
dawn flower
blazing ocean
#

are you making a scripting lang

dawn flower
#

sortof

blazing ocean
#

I don‘t really understand your issue tho

dawn flower
#

ok so uh

#

turboAction.execute(action, context); you see this part?

blazing ocean
#

Yea?

dawn flower
#

if that turbo action gets the currently being ran executablesection then does getBody, it's supposed to getu the Queue<ScriptStep> of steps until that turbo action, but it just gets the full Queue<ScriptStep>

#

as if the poll part never existed

#

if that makes sense

#

omg

#

nvm i'm dumb, the code being executed is a clone of the executablesection and the context contains the original executablesection

grim hound
#

~60 blocks away

#

the transformations seem correct

#

it's just that it's somehow in the incorrect position

echo basalt
grim hound
#

also, this

#

with different params

echo basalt
grim hound
#

yeah, isn't it?

orchid furnace
#

Does anayone know a good IDE as I didn't realise that Jetbrains idea is only a subscription or should I just pay for it

blazing ocean
#

Intellij Ultimate is paid

#

community is free

orchid furnace
#

Oh really?

#

whats the difference?

blazing ocean
#

Some extra features

#

Most of which aren‘t neccessarily needed for plugin dev

#

So just stick to intellij

orchid furnace
#

Oh wow I didn't know that thank you! :D

quaint mantle
blazing ocean
#

please no

wet breach
#

its the official ide of spigot 🙂

grim hound
#

a what now

blazing ocean
#

wouldn‘t call it official

wet breach
blazing ocean
#

I know

#

95% of other people use intellij tho

#

especially plugin devs

#

and for a good reason

wet breach
#

and what reason is that?

#

because netbeans does everything intellij does minus maybe a feature or two lol

blazing ocean
#

it‘s simply the best IDE for java out there

wet breach
#

if its good enough for the owner of spigot to make spigot with it all these years, then obviously it must not be horrible

blazing ocean
#

right I never said it was horrible

wet breach
#

but I doubt everyone even uses all the features intellij even provides as well, therefore they would have no issues using netbeans and other then locations of some menu/options they probably wouldn't notice a difference

blazing ocean
#

I use a pretty good amount of IJ‘s features

wet breach
#

maybe you do, wouldn't say that is the majority

#

just like I make use of most of what netbeans offers

blazing ocean
#

yet it barely has kotlin support

wet breach
#

anyways as I said, most of it is preference base though in which one should choose. However netbeans in comparison to IJ isn't really lacking. There might be one or two features IJ has that maybe netbeans doesn't? not entirely sure

wet breach
#

however, Jetbrains are the ones that created kotlin to begin with, therefore it makes sense their IDE natively supports it

#

its like saying IJ barely supports C or CPP in comparison to Visual Studio

blazing ocean
blazing ocean
wet breach
#

ok but everyone is not using kotlin

#

as I said, there may be a feature or two that IJ might be better for if you really need it. Aside from that though both are optimal and efficient. Both can refactor code, format and all the other frills

#

both can compile with gradle or maven which ever is your fancy or both if you want them both

#

both can decompile and debug and allow remote debugging

robust helm
#

is netbeans foss?

wet breach
#

its owned and ran by Apache Foundation

robust helm
#

ooh maybe ill try it

wet breach
#

Oracle gave it to Apache some few years ago

shadow night
#

Netbeans is kinda ass ngl

placid sun
robust helm
#

For a PerkRegistry that tracks selected perks of all players i have an implementation using mongodb, which requires some init stuff, now should i
a) add an init() method to the PerkRegistry interface
b) just make an init method in the implementation (could get kinda annoying cuz i first need to make a variable of the implementation type, then init it, then assign it to the actual perkRegistry variable)
c) just call init in my constructor

grim hound
#

wait no

#

it's the only option for the client channel

grim hound
#

so still, no

#

see ServerConnectionListener or ServerConnection class

grim hound
#

how are you even supposed to account for yaw & pitch?

uncut wedge
#

How do i generate a single biome world using the 1.17.1 logic for generation but with 1.21.3 version?

chrome beacon
chrome beacon
#

as for the question it depends on what the init method does

robust helm
robust helm
#

SelectedPerkTracker

worldly ingot
#

Or at the very least, inversed

grim hound
#

chcooo

white anchor
#

is there an alternative to block#setBlockData since it lags on large scale

grim hound
#

but do you know how to account for the block's yaw & pitch?

chrome beacon
#

?nms

grim hound
#

...the bukkit yaw is broken

grim hound
white anchor
#

is there an alternative to block#setBlockData since it lags on large scale

eternal oxide
#

no, do less each tick

chrome beacon
#

?workdistro

white anchor
#

?blockchanger

echo basalt
#

there technically is but you're entering nms territory

sullen canyon
#

w

white anchor
echo basalt
#

Because spigot acts as an abstraction layer for NMS

#

It doesn't necessarily implement new features by itself

#

other than maybe virtual inventories

white anchor
#

Yea but it won't hurt if they added improved ways to do stuff for example set blocks

echo basalt
#

it's like asking spigot to impl modelengine

white anchor
#

since nms isn't the best for multi version

echo basalt
#

you're passing the responsibility to them

white anchor
echo basalt
#

Bukkit's the API, CraftBukkit is the implementation

#

Spigot is the whole package

echo basalt
white anchor
#

okay xd

echo basalt
#

A lot of these hacky multi-block pasting techniques end up causing issues

#

Writing directly to the palette will cause ghost blocks on the client unless you update the client

white anchor
#

Method 3 from the spigot post works fine with no issues

#

but I understand your point

blazing ocean
#

Doesn‘t work on latest directly last time I tried

quaint mantle
#

It gets faster if we rewrite minecraft in rust

white anchor
blazing ocean
urban cloak
#

well there is no arguing with that

white anchor
echo basalt
#

I can do massive amounts of block changes if I just develop an ASIC for it

quaint mantle
#

Massive?

white anchor
#

yeah not possible any other way

#

since i needed a way a massive amount of blocks fast

blazing ocean
#

I mean you could just not use reflection there

white anchor
#

what else should i use?

blazing ocean
#

nms directly?

white anchor
#

I needed it to be MultiVersion and all in 1 class so i can just copy and paste right away and use it

#

something easy to implement

eternal oxide
#

thats not how nms works

mortal vortex
white anchor
eternal oxide
#

nms changes version to version (but not all)

mortal vortex
#

LOWW TAPERERR FADEEEEE

white anchor
eternal oxide
#

you asked for multiversion and all in one class.

white anchor
#

yeah?

mortal vortex
#

how’s that possible wut

white anchor
#

reflection

mortal vortex
#

You just learnt that word, hush up kid

white anchor
#

what?

eternal oxide
#

Its probably better to tell us what you are actually trying to do

white anchor
#

i made that lib xd

mortal vortex
#

I’m bullshitting

winter sandal
#

Good morning,
I created a plugin in 1.21.1 that I'm trying to update, but I come across a problem that I can't solve... In my plugin I make a craft recipe or I use a custom item in it but in game the custum item appears as if it were a vanilla item (paper) whereas in 1.21.1 everything works fine.
goldenCarrotRecipe.setIngredient('P', Material.POTATO);
goldenCarrotRecipe.setIngredient('C', new RecipeChoice.ExactChoice(carton));

Can you help me please?
Thank you, Have a nice day.

white anchor
eternal oxide
#

whithout nms, no

mortal vortex
soft hound
#

Maven Publish build.gradle, I need some help.

winter sandal
#

manually everything works fine but via the quick recipe book no

kindred quest
#

Hello, I am building a GUI. Is there a way to prevent moving items from the GUI to my inventory and from my inventory to the GUI? I also want to prevent dropping items from the GUI

robust helm
#

?gui

valid burrow
white anchor
#

sorry boss

kindred quest
kindred quest
valid burrow
#

its like telling someone asking how to write emails to use chatgpt

#

sure it works

#

but it wont help you understand

valid burrow
undone axleBOT
#

It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.

kindred quest
#

i will try to cancel the events again

valid burrow
white anchor
kindred quest
#

sure but i have removed the cancel

#

wait

valid burrow
#

he wont learn anything

white anchor
#

what?

white anchor
#

if you manually making your menu using events thats bad advice

#

its like telling someone to build a house with only hands

kindred quest
valid burrow
white anchor
#

so yeah he should use a menu api and check how it works

blazing ocean
#

Using a GUI API at least doesn't get you that vulcan exploit concern

white anchor
valid burrow
white anchor
#

what is he learning?

#

how to cancel an event

valid burrow
#

im 100% sure you use python

white anchor
#

nah

#

its just your point isn't correct

blazing ocean
#

javascript ecosystem moment

valid burrow
#

just pointing him to the next best gui api will fix his problem but not teach him the spigot api

#

and the fundamentals of Guis

white anchor
#

can you just chill out god damn

#

Your the one not being helpful what is he learning internally? his whole issue is cancelling an event

#

there is nothing wrong with using a menu api

#

?gui

kindred quest
#

..

valid burrow
kindred quest
#

i just want my code work ig

pliant topaz
#

If he doesnt know how its done, do it atleast once so you understand how its done.
If he knows how it works, then he can use an API

A good rule to know:
Don't use anything you don't understand

white anchor
#

maybe its not the correct one

valid burrow
#

bro please get of the help channel

#

💀💀💀

#

?nocode

undone axleBOT
#

It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.

valid burrow
#

show us ur code brother

kindred quest
#

i did

valid burrow
#

?paste

kindred quest
undone axleBOT
kindred quest
#

here again

valid burrow
#

put it in here

kindred quest
#

like this ?

blazing ocean
#

Making a little statistic tracking system for my game instances, what would be the best way to store/track them? I was just gonna roll with something like this for the statistic itself: ```kt
public fun interface TrackableStatistic<G : GameInstance<G>, T> {
public fun get(instance: G, player: UUID): T
}

eternal oxide
#

.fFA. is not as valid package path

valid burrow
kindred quest
#

i can edit it anytime anyways

eternal oxide
#

package names are specified to be all lower case

kindred quest
#

i dont think so

#

its works

blazing ocean
#

They are in maven

kindred quest
#

i use gradle

blazing ocean
#

for group/artifact IDs at least

rotund lotus
#

hey guys, is it still not possible to add custom enchantments to the enchantment table/anvil, even with a custom language pack?

eternal oxide
#

it may work but some IDEs will error

valid burrow
#

okay so first things first

#

tracking by name does work

#

but its not the recommended practice

blazing ocean
kindred quest
#

so items and names will be differenet everytime

blazing ocean
#

Spigot doesn't have API for registering them but you can use datapacks

valid burrow
#

every time a gui is opend

#

cache it

blazing ocean
valid burrow
#

hashmap will work

#

or normal list even

#

depending on how you approach it

blazing ocean
#

voss are you talking to me or the other person

valid burrow
blazing ocean
#

Statistic tracker

valid burrow
blazing ocean
#

heh

#

surely you have an idea on how to track these

valid burrow
#

@kindred quest what i recommend u do is everytime a gui opens u add the inventory to a list and then when an event is fired you look for the inventory in the list if its not there its not a custom gui

rotund lotus
blazing ocean
#

I don't really wanna like Map<UUID, Map<StatisticKey, Object>> or something

kindred quest
#

Okay, I want to do the following, and tell me if it's possible or not:

My inventory cannot have items moved from the GUI.
Items cannot be moved from the GUI to my inventory.
Items in the GUI cannot be dropped.
There are some slots in the GUI that I want to always remain empty.
There are some slots in the GUI where I only want armor to be placed. Is this possible?

valid burrow
blazing ocean
kindred quest
#

all of that possible?

valid burrow
#

u just need to check what slots are cliked

#

e.getSlot

valid burrow
kindred quest
#

okey

#

i will try and back

valid burrow
#

sure thing

smoky oak
#

do item entities retain information about how they've been generated?

#

ie, block drop, player corpse etc

blazing ocean
#

things like chests contain data but for most items, no

amber fjord
#

you can make it do so tho

#

In a complicated way

smoky oak
#

ye but that wont work retroactively

blazing ocean
#

PDC

smoky oak
#

see above

amber fjord
#

but stacked items breaks it

smoky oak
#

that works the other way around actually

#

data breaks item stacking

amber fjord
#

I meant via hashmap and yml file

#

if you wanted to do it that way you could easily put a custom model data and be done

smoky oak
#

wait are you saying that itemstacks retain coherence between ticks?

blazing ocean
#

custom model data is a horrible way to store data like that

#

use the PDC

grim hound
#

how do I get the mojang yaw from bukkit's yaw?

blazing ocean
#

what

smoky oak
#

?mappings

undone axleBOT
smoky oak
#

ya looking for this?

grim hound
pliant topaz
#

whats wrong with it?

grim hound
#

the client and the server have two different yaws

#

I guess I should just read player flying and call it a day

misty ingot
#

guys is it possible to delete a review
like if i sent a review on someones plugin can i change/delete my review

grim hound
#

yes

soft hound
#

Troubles with library causing me issue to the plugins I add.

bronze laurel
#

How do you do rank prefixes, rank prefixes on nametags, prefixes in tab, and tab sorting. All without scoreboard teams?

#

Because my sidebar keeps overriding teams.

mortal hare
#

law of demeter is bs

#

you end up with many static methods which act as a getters for the sake of avoiding chained getters

misty ingot
#

is there a way to get a list of all Blocks in the game?
i am trying to select a random block type but Material has stuff like AIR and DEBUG_STICK and VOID_AIR and whatnot

blazing ocean
#

Registry.BLOCK

slender elbow
#

not all Materials are blocks, that's why Material#isBlock and #isAir exist

#

and air is a block lol

red sedge
#

why is Note#getId deprecated?

#

Is it not the value minecraft uses

remote swallow
red sedge
#

yeah but is it not the intenral id used by minecraft too

worldly ingot
#

Yes but you shouldn't ever need to use it

mortal hare
#

inside NMS its not being used, instead those ids are being wrapped into namespaced string based keys

#

its actually even hard to even use them raw nowadays 😄

smoky oak
#

can you pretend (to the server) that more blocks exist than in vanilla, or do plugins load too late for that?

mortal hare
#

afaik you can't, i asked this about half a year ago on this discord server and someone said sadly no but i might be wrong

#

iirc you can register blocks, but server and the client will be just confused, you can't just add new blocks gracefully as the block types are still not tied to data driven components completely afaik, but minecraft is trying to make this happen (for example enchantments, mob variants are data driven)

smoky oak
#

idc about the client tbh

#

i was just wondering if i could do some internal nonsense waaaay easier using new blocks

misty ingot
#

why cant i remove blocks in an async task?

mortal hare
#

because NMS is mostly single threaded

#

you need to synchronize the threads on scedule to run the removal of blocks at next tick

misty ingot
#

then what does FAWE do

mortal hare
#

FAWE does some nimbly NMS hacking to achieve async removal of blocks

#

Bukkit API removes blocks as NMS servers intends, FAWE does its own way by hacking through NMS code and achieving it

#

correct me if im wrong

misty ingot
#

what can i do to make removing a ton of blocks faster?

wet breach
smoky oak
#

intermediate data so i dont have to handle that separately

wet breach
#

intermediate data?

smoky oak
#

aka, 'this is a light that knows what kind of air it was b4'

#

that kinda stuff

wet breach
#

so...why does it need to be a new block?

misty ingot
#

when clearing an area of every instance of a specific block, i have to check the entire chunk (16x16xheight) times however many chunks which is a lot of processing to do sync
i mean sure it doesnt crash the server but it definitely lags it

smoky oak
#

im just throwing ideas at the wall to see whats feasible

misty ingot
#

wym

wet breach
#

the processing time is however many actual blocks occupy the chunk, not the entirety of the chunk itself

misty ingot
wet breach
#

air and bedrock can be excluded

smoky oak
#

no but you can scan async

#

chunksnapshot

#

then rejoin main with the list of blocks to remove

misty ingot
wet breach
#

no

misty ingot
#

enlighten me

wet breach
#

I am not sure if the API provides the methods for it as its been a while since I have looked at it, however you can read the region file for the relevant chunk data. Air blocks are denoted at the end of the data. However the other way, (think you might be able to do it on the chunk loading with NMS) is listening for the chunk packet which also contains this

#

in other words the region file and packets have the info optimized and easily excludes the air blocks 🙂

smoky oak
#

how do chunk snapshots work anyway?

#

do you just copy the area in memory?

wet breach
#

yes, its a clone that isn't the same reference as the chunk so they are not linked

#

the downside of snapshot is that whatever happens in the chunk object is not reflected in the snapshot

smoky oak
#

i mean

#

ain that a better option than having to learn how region files work

wet breach
#

so instead of scanning all of the blocks, we just check the blocks that actually exist

#

so its like 1/3 of the chunk you need to scan

#

and all the blocks presented is not air

mortal hare
mortal hare
#

there must be some kind of serialization method lying there

smoky oak
#

how do you access the mca files anyway?

#

do you just... directly scan them?

wet breach
#

just use a File object

smoky oak
#

so parse the data yourself

blazing ocean
#

aren't they just nbt

smoky oak
#

i am going to do async chunksnapshot then

wet breach
blazing ocean
#

is it at least codecified now

wet breach
#

we already have the format documented etc

wet breach
blazing ocean
#

do they use codecs

wet breach
#

maybe for the compression if there is any

misty ingot
#

In #getLoadedChunks
does loaded refer to chunks that were loaded ever or only chunks that are loaded for some player actively right now

wet breach
#

gets the current loaded chunks

misty ingot
#

so if i load a huge area then go stand somewhere it will only give me the chunks loaded in my render distance

wet breach
#

no

#

it gives the current loaded chunks in the server at the time you invoke the method

#

chunks don't instantly unload

misty ingot
#

when do chunks unload

wet breach
#

when the server has seen that nothing is needing it, and then it semi unloads it if it thinks it might be needed later

bronze laurel
#

How do I use scoreboard teams and a scoreboard at the same time?

wet breach
#

then fully unloads

bronze laurel
#

My scoreboard is overriding my teams.

smoky oak
#

what about lazy loaded chunkks

wet breach
mortal hare
#

i wonder if there's a fork of Paper or Spigot which is based on fabric loader

#

basically vanilla minecraft with bunch of optimization patches from Paper/Spigot and without bukkit api

#

it would be cool to make private mods for a server using mixins but have better performance than vanilla minecraft server

#

i just dislike bukkit api overall, so im wondering if there's any way to skip that altogether for a native way of developing serverside mods using fabric's mixins

shadow night
mortal hare
#

give me folia's patches with fabric modloader

#

pls

shadow night
#

worst idea ever

mortal hare
#

why

shadow night
#

folia breaks everything imaginable

#

developing on top of it without the paper api would be meeh

mortal hare
#

it breaks because its not designed for bukkit api

#

im looking for a way to skip any api's provided

#

and use straight up NMS

#

with mixins to develop what i need on top of NMS + optimization patches

shadow night
#

with mixins you will suffer

mortal hare
#

i've already tried mixins and i think they are fine for private plugins

#

i like them tbh

shadow night
#

mixins are great

#

but not with folia patches

#

or paper patches

mortal hare
#

sure version compat is ass, but the ability to do what i want and not follow the api is just pefect

shadow night
#

just install lithium on your server and do your mixin stuff

mortal hare
#

is there any benchmarks for paper vs fabric + optimization mods

#

all i want is fast af NMS + mixins

blazing ocean
#

ignite exists

#

should wrok with folia

mortal hare
#

the removal of bukkit api in favour of native code should result in some minor gains as well since you wouldnt have to create separate objects for bukkit api and overall sync the state of api and the NMS

#

but that's just premature optimization

remote swallow
#

most of the stuff leaf added to paper perf wise is now available as a mod called moonrise

mortal hare
#

paper devs really need to make headless-api versions of their patches

red sedge
#

how would i get the current tick time of the server

#

ie how long (in ticks, or millis i guess works too) the server has been runing

red sedge
#

just need it for simple timers that the scheduler is too overkill for

misty ingot
#

is there a way to check if a Material is naturally generate-able? as in, it can generate in a chunk naturally

remote swallow
mortal hare
#

i really want to develop a whole server private core on top of NMS using mixins

#

at least try to

#

with the introduction of mojang mappings its easier than ever to patch the server

#

we dont have to guess method functionality anymore

#

so why bother with 14 yr old api

#

im not trashing bukkit api or anything but i feel like its aging not well (there's plenty of info of how NMS works nowadays, also we have our almighty https://wiki.vg/ for packet and world related information)

#

its a good way to develop plugin across multiple implementations but besides i feel like its kinda meh

#

sponge is kinda ok'ish api, but its always marked as unstable. sure fabric mixins are not stable in terms of compatibility too, but if you're developing an api, you shouldn't mark your API as unstable for years

#

nvm

#

they seem to fixed that we now have recommended builds for 1.21.3 (like a year ago, sponge's recommended build was for minecraft 1.12.2, like wtf, im not changing API for that old version)

young knoll
#

That domain that totally still exists

mortal hare
# misty ingot .

im not sure what's the solution but if i had to guess you can check NMS BiomeRegistry for the generator block types

mortal hare
#

omg

#

it got merged with minecraft wiki??

#

god damn

#

that's a good thing

misty ingot
#

how the hell do i make a blockmask in FAWE

silver robin
misty ingot
#

i see

#

i shall ask in their discord

silver robin
#

I'm trying to figure out how to clone a world (have one template world then make a full copy of it), obviously the only feasible way to do it is copy the files but I'm not sure if there's any data inside the folder which i have to be careful about

here's my code so far https://paste.md-5.net/jagedobepe.coffeescript, it runs in onEnable, it works except the middle of the world (from chunks -14, -14 to 14, 14, within r.0.0.mca and r.-1.-1.mca) ends up empty where there should be blocks

rapid nexus
#

How to include Spigot server as a dependency in Gradle?

eternal oxide
#

server or api?

rapid nexus
#

server

eternal oxide
#

?maven then run Buildtools

undone axleBOT
orchid furnace
#

I've only noticed this what even is it 😭

eternal oxide
#

what that is is a log prefix prompt

rapid nexus
#

i can do it now

mortal hare
#

can someone cure me from perfectionism in programming overall. I feel like trying to avoid tech debt for me at first is trapping me so much in terms of trying to think ahead of time

#

it feels as if im wasting more time in abstractions and not real logic

#

but at the same time writing shitty code just feels wrong

#

even if you know you'll refactor it

#

but i believe writing shitty code first and the refactor it is quicker approach to solve it and to write the code productively

#

because then you know the context where to apply refactoring

#

am i the only one here who's in the same trap?

eternal oxide
#

Yep its just you. We are all perfect devs who make no mistakes.

paper viper
orchid furnace
#

Does anyone know how I can stop saveConfig() and reloadConfig() from deleting code notes in config.yml?

#

Figured it out

#

just did saveDefaultConfig(); instead of saveconfig

mortal hare
#

im just putting mental barrier for myself to think about the future

echo basalt
#

Over time your code will improve

#

And you'll develop new patterns

#

Now, you must ask yourself: Will you really touch this code again in the future?

nova notch
echo basalt
#

I usually experiment with code style changes when doing commission projects because it gives me room to rack up teck debt I'll never pay off

#

And keep in mind that even big properly written projects rack up tech debt and often end up reworking things dozens of times

nova notch
#

my problem is the prototype ends up becoming the final product then i come back 3 months later like wtf is this shit

echo basalt
#

once I get to the "proof of concept" stage I just rewrite it all

echo basalt
#

broke nitro spotted

young knoll
#

Shut

wind sorrel
#

Hi! I'm trying to implement Libby into my project, as some transcendent dependencies of my plugin conflicted with a different version of themselves that are in use by the Spigot server. I'm using AlessioDP's Libby 2.0 snapshot, which allows to manage transitive dependencies.
I've ran into an issue. First, when I download a library (A) with all its transitive dependencies (B,C) it will only relocate the main library but not its other dependencies. But, if I try to add the dependencies (B,C) as libraries, the "main" library (A) will fail to use the relocated version of B,C and instead will use the server's version, which causes conflicts as are not compatible versions.
What should I do?

echo basalt
#

oo pikamug's here

soft hound
#

Data doesn't get read from the library when loading it in a different plugin.

smoky oak
wet breach
#

in this manner you can extract/copy it to where you need it then load it

#

also, if you are going to do async stuff make sure to use NIO file package

#

otherwise you will have to do it sync

smoky oak
wet breach
smoky oak
#

is it some file lock nonsense then?

wet breach
#

probably, but you can't just use syncronized stuff in async without repercussions sometimes. Spigot creates another thread to run the async tasks

wind sorrel
wet breach
#

so, you are dealing with an additional thread, not just asynchronization

smoky oak
#

ah

#

wait

#

isnt bukkit async on a separate thread anyway?

wet breach
#

I said that just in a way to that denotes async doesn't mean an additional thread but in spigots case it does

vast kelp
wind sorrel
vast kelp
#

Another option is AlessioDP's discord, there's a libby channel with more recent discussion

sullen marlin
#

can you not just use libraries in plugin.yml?

wet breach
wind sorrel
wet breach
#

if you shade and relocate both twitch4j and Jackson it should make use of the relocated dependency

#

the maven shade plugin changes the imports to reflect that

#

or should anyhow

wind sorrel
#

I cannot shade them in, as that will increase the jar size up to like 16MB (this btw works, but it's not what I'm looking for). Instead I would like them to be relocated by Libby, as it downloads dependencies at runtime and it's very light so it can be shaded without issues

wet breach
#

if it works not sure what the issue is

quaint mantle
#

How do I cancel an armor equip event if it's in the boots slot?

eternal oxide
#

Spigot has no armor equip event

quaint mantle
#

Oh?

#

*I mean any way to detect it?

#

Through inventoryclickevent

soft hound
valid burrow
#

im not reading all that

blazing ocean
#

voss stop turning into neon

valid burrow
#

sorry :c

upper hazel
#

i need money

#

i need work

remote swallow
undone axleBOT
upper hazel
#

i cant

#

i get ban

blazing ocean
#

¿

polar forge
#

Hi ppl

remote swallow
#

Uh oh

#

1 blocked message

polar forge
#

Hi

#

I have a question about my plugin

#

Actually 2

#

So i had this ban plugin from 1 year ago

remote swallow
polar forge
#

?paste

undone axleBOT
polar forge
#

When i run the command /isplayerbanned "player" and that player isnt banned it doesnt say "Player isnt banned or not existent"

#

and idk where the problem is

fickle spindle
#

i made thehide nametag stuff with the team but if i put the plugin TABS in the server i can still see my nametag how can i fix that?

wet breach
#

nott just the code that tries to obtain it

polar forge
#

its in another file

#

C file

wet breach
#

I know your issue

polar forge
#

oh

wet breach
#

if you look at your two methods you provided you should spot it

#

specificially what you are inputting and what you are trying to obtain 😉

polar forge
#

is it the dot in banned_players?

wet breach
# polar forge oh

if its not obvious, you are putting the players UUID in which is correct, but you are trying to obtain the players name which is not what you put in and instead should be checking if the UUID is in there instead

#

player.getName() != player.getUniqueId()

polar forge
#

yes but theproblem is

#

if the player is banned

#

it sends me a message saying that player is banned

#

but if he isnt

#

it doesnt send me anything

wet breach
#

you are checking for a player name when you don't put a player name in the config to begin with

polar forge
#

then why it works the other way around

#

?

wet breach
#

idk what you are talking about. You came here asking why it doesn't work and I told you what the problem is

#

you are looking for data that you never put in

smoky oak
#

is there a simple way to transform a mined container's inventory into NBT? i want to make Shulkers for/out of bookshelves

chrome beacon
smoky oak
#

ah

#

i thought that was only for shulkers

#

ill take a look

chrome beacon
#

Listen to the BlockDropItemEvent grab the state of the bookshelf and put it in to the dropped itemstack

mortal hare
#

is there any runtime penalty for referencing static methods like this?

#

return GenericFX.button("Registration", FormButtonFX::primary)

#

does does the function gets inlined

#
    public static Button button(final Button button, final Consumer<? super Button> consumer) {
        consumer.accept(button);

        return button;
    }

this is the function which accepts Consumer<>

#

it should in theory create runtime consumer object right

#

i wonder if that's true or if that's something that compiler optimizes

#

but if it will get optimized, how would it represent consumer overall as a heap object if i reference it in code

chrome beacon
#

JVM optimization internals is quite complex

#

It wouldn't suprise me if that got inlined after being run enough

#

That doesn't seem to be something that runs very often so it might not be since it's not worth the time to do so

mortal hare
#

im using it kinda as a macro across various classes since java doesnt support macros

#

eh fuck it im gonna use it still

#

it saves me like 40 lines of code

chrome beacon
#

The performance cost is negligable

#

If you want macros and stuff you can look in to the Manifold project

#

but I'd say that's quite overkill

mortal hare
#
public static Button login() {
    final Button button = new Button("Prisijungimas");
    FormButtonFX.secondary(button);

    return button;
}

get converted into:

public static Button login() {
  return GenericFX.button("Prisijungimas", FormButtonFX::secondary)
}
#

shorter and i have like 8 static methods like this

chrome beacon
#

You can make that secondary method private static

#

if you don't plan on accessing it anywhere else

mortal hare
#

i have multiple form windows

#

that's why its public

#

this is a class of one of the form's elements (login form)

#

basically im doing react on JavaFX

chrome beacon
#

React 💀

smoky oak
#

baaaack with this
I'm trying to query the first value in a result set. why do i get this: ResultSet is TYPE_FORWARD_ONLY
as error?

try(PreparedStatement statement = connection.prepareStatement(queryString)) {
            insertKeys(statement);
            ResultSet result = statement.executeQuery();
            if(!result.first()) return null;
            return result.getString(1);}
#

shouldn't the cursor be at, i dont know, the start of the result set lol

#

fixed it, though i have no idea why saying select data instead of select * helps

wet breach
#

because one is specific, the other means all

#

they produce different results

smoky oak
#

........ and? the table here is PK string | string
so getString(1) should be where the cursor is

#

im clearly missing something but i cant tell what

chrome beacon
#

Can't use first on forward only

smoky oak
#

i - sure

#

but why does changing * to the column name fix this?

#

wouldnt it still be the first value

#

and the same kind of result set?

chrome beacon
#

Might be some vendor specific fun

#

Explicitly tell it that you do not want a forward only rs or just use the next method which will work

smoky oak
#

wait so its at index 0

#

god damn it databases are such nonsense

wet breach
#

mysql starts at 0 as you just learned

smoky oak
#

OH COME ON

#

augh i cant even check if the result set EXISTS

#

wait

#

it says this errs on forward only, but how am i supposed to check if it conntains anything then

chrome beacon
#

Call next

smoky oak
#

ah double duty methods. fun...

#

i hate everything about this

insertKeys(statement);
ResultSet result = statement.executeQuery();
if(!result.next()) return null;
return result.getString(2);
#

but it works. hooray?

#

by the way, this gets closed by the statement being in try(Statement...) right?

chrome beacon
#

It's a cursor, it starts at the position before the first element (if there is one)

smoky oak
#

wait. the result set is ROWS

chrome beacon
#

calling next will move it forward

chrome beacon
smoky oak
#

welp that explains it

worldly ingot
#

Well, yeah, it's a collection of results lol

slender elbow
#

a set, even

worldly ingot
#

A set :0

worldly ingot
smoky oak
#

well i did write the query and access such that the set size should always be 0 / 1 depending if it exists

smoky oak
worldly ingot
#

Yes

#

Or use a connection pool, but those also require you to "close" the connection

smoky oak
#

the connection in the twr then?

worldly ingot
#

Never seen try-with-resources shortened to twr lol, but yes, that would go in the twr. You could put both in there if you wanted

smoky oak
#

someone else in here did it when talking to me + i do it now coz lazy

#

probably either frosthalf or olivio

#

wym both?

#

isnt that limited to one java statement?

worldly ingot
#

I'm gonna blow your mind

#
try (Connection connection = getConnection();
        Statement statement = connection.createStatement()) {

} catch (blah) {

}```
smoky oak
#

huh

chrome beacon
#

It's an SQLite file

worldly ingot
#

Oh then definitely close your connection each time

smoky oak
#

im using .db but i guess thats the same thing

worldly ingot
#

Yeah that's SQLite

smoky oak
#

this about data corruption or file locks?

worldly ingot
#

File locks. If there's a connection open, nothing else can read/write it

chrome beacon
#

You can keep the connection open for the lifetime of your program that's fine

#

Just nothing can write to it in the mean time

#

or read for that matter

worldly ingot
#

You can, but I would try to get into the habit that you shouldn't

smoky oak
#

oh i see why this didn't cause problems for me

#

I'm passing around the same connection as reference

#

and since access to this database is supposed to go via the interface i made it SHOULD lock too lol

#

im really unsure if i should move it into the try with resource now

worldly ingot
#

Yeah you won't run into issues there, and you probably wouldn't ever run into issues, even in MySQL or another flavour. It's just not really great practice to keep open a connection stream that you're not actively using because it's consuming resources. Databases only allow a limited amount of connections, so if you're constantly keeping open connections, you're limiting the amount of simultaneous queries you can make

#

Again, SQLite only has a limit of one connection so simultaneous queries aren't a problem, but other databases do

#

As your program gets larger and larger, simultaneous queries are pretty much a necessity

#

Otherwise you might query for something that takes longer than expected and your other query fails

smoky oak
#

tbh im now trying to figure out how to use synchronized to prevent async threads crashing into each other, but is that even necessary?

chrome beacon
#

For other databases you'd definitely want to close your connections. They can timeout themselves if you don't after a while causing issues

worldly ingot
#

Probably not here tbf

smoky oak
#

wait

#

lemme check somehting rq

#

right i make the databases based on the plugin trying to store something lol

worldly ingot
#

A class' thread safety only becomes a problem when you're actively using a class between multiple threads :p

smoky oak
#

so unless you pass another plugin instance the 'one connection per file' wont cause issues in this case

#

what's the resource consumption for that one open connection tho

chrome beacon
#

Not much

worldly ingot
#

The resource consumption I was referring to wasn't RAM or CPU cycles or anything, but the "bandwidth" of the database, for lack of a better word

smoky oak
#

ah. i'll just add the capability to manually tell it 'close the connection you have' so that if the accessing plugin wants threads they can deal with the synchronization demanded by one connection only + async themselves lol

#

how fast/slow is it to create that connection btw?

worldly ingot
#

It's not normally the bottleneck in a program

smoky oak
#

fair enough

#

guess its an issue if you're using remote but you do not care for local mysql

#

well this is furbar lol
time to refactor
again