#development

1 messages · Page 64 of 1

minor summit
#

that will cause the CF to pass it further down the chain
to be handled in a exceptionally/whenComplete

icy shadow
#

^ whenComplete is not necessarily a terminal operation

minor summit
#

(albeit it should)

icy shadow
#

mm

#

little bit odd but

#

here we are

atomic trail
#

Why just keep throwing it further down the chain if it can't be printed?

#

Except for standard logger ofc

minor summit
#

you are meant to print it

atomic trail
#

I see

#

Alright

minor summit
#

or, well, more appropriately, handle it, if printing it is your way of handling it, then print it

atomic trail
#

This is an error that should never happen so ye, I'll just print it

#

Thanks

icy shadow
#

"should never happen" i've heard that one before

atomic trail
#

Yeah lol, but as in there shouldn't be anything to handle it, it's just an error in the code

minor summit
#

🎉

atomic trail
#

And then ofc

#

It's some stupid easy mistake

icy shadow
#

now imagine if there was a language with no exceptions and we could emulate it with some sort of "error" type which automatically propagates the error case

atomic trail
#

Forgot to reupload the config file

icy shadow
#

that would be nice i think

#

we could name it after a famous logician

warm steppe
#

Bertrand Russell

#

Russell Lang

icy shadow
#

Hell yeah man

#

that’s exactly what I was thinking

somber gale
#

Wondering if this is a good-ish way to handle uploads.... I mainly talk about the changes made to the version-uploader, as I'm not sure if using CompletableFutures like that is really a good idea... And before asking, I did it because the Library I use to upload to Modrinth is returning a CompletableFuture.

https://codeberg.org/Andre601/AdvancedServerList/pulls/144

sterile hinge
#

Well 🤓 in the OpenJDK there is no such thing as LTS, LTS is something vendors can freely decide to provide for any version 🤓

#

So for Mojang it likely only matters what Microsoft is doing with their Java builds

sonic nebula
#

so after a while

#
                String updatedLASTName = meta.getDisplayName().replaceFirst("LAST=\\w+", "LAST=" + last);
                meta.setDisplayName(updatedLASTName);
                item.setItemMeta(meta);
                player.setItemInHand(item);
#

can anyone explain me why it does not work

lyric gyro
#

Who can help me with something?

#

@leaden plume

#

there is support here?

leaden plume
#

?help

neat pierBOT
#
FAQ Answer:
» Give the helpers some details
» Ask suitable questions
» Be polite
» Wait

Source

lyric gyro
leaden plume
#

?imgur

neat pierBOT
#
FAQ Answer:

You won't be able to upload images here directly to avoid spam, so please use https://imgur.com/upload to upload images/screenshots.
You can also use a screenshot service like gyazo or jinx and post those links here.

lyric gyro
#

/upload

lyric gyro
lyric gyro
lyric gyro
#

Okay

atomic trail
#

How can this resultSet already be closed? It's in the twr but should only close after returning?

    private <T> CompletableFuture<T> query(String query, @NotNull SafeConsumer<PreparedStatement> initializer, @NotNull SafeFunction<ResultSet, T> process) {
        return openConnection().thenApply(connection -> {
            try(Connection newConnection = connection;
                PreparedStatement statement = newConnection.prepareStatement(query);
                ResultSet resultSet = statement.executeQuery()) {
                initializer.consume(statement);
                if(resultSet.isClosed()) {
                    throw new RuntimeException("ResultSet is closed - check logs");
                }
                return process.apply(resultSet);
            } catch(Exception e) {
                LOGGER.error("Error when preparing statement for query: " + query);
                throw new RuntimeException(e);
            }
        });
    }
#

It's throwing the exception that the resultset is closed btw

#

This only happens when the database is empty and just the table has been setup

sterile hinge
#

what does the initializer do?

river solstice
# atomic trail How can this resultSet already be closed? It's in the twr but should only close ...

maybe try this

private <T> CompletableFuture<T> query(String query, @NotNull SafeConsumer<PreparedStatement> initializer, @NotNull SafeFunction<ResultSet, T> process) {
    return openConnection().thenApply(connection -> {
        try (Connection newConnection = connection;
             PreparedStatement statement = newConnection.prepareStatement(query)) {
            initializer.consume(statement);
            try (ResultSet resultSet = statement.executeQuery()) {
                if (resultSet.isClosed()) {
                    throw new RuntimeException("ResultSet is closed - check logs");
                }
                return process.apply(resultSet);
            }
        } catch (Exception e) {
            LOGGER.error("Error when preparing statement for query: " + query);
            throw new RuntimeException(e);
        }
    });
}
#

@atomic trail

frozen grove
#

how can I prevent water from destroying redstone while still allowing it to flow? when i cancel the BlockFromToEvent the water stops flowing

sonic nebula
#

It’s hard coded

#

Oh I mean u won’t be able to let it flow

#

Over red stone

#

Do a check when ever the event is executed I guess

#

A loop of 1x r and if it’s == then cancel

#

But it will kinda heavy so find a way to optimize that

#

Like to freeze it or so not sure how to do it

#

Since u will have to call it off every tick

#

Or freeze all the water

somber gale
#

What would be a good way to delay the closing/shut down of an executable jar when using a CompletableFuture?
I currently encounter the issue that the jar finishes its executions in the main void method while CompletableFuture's are still running....
So I have to delay it somehow until they complete... either successfully or with a throwable...

And the reason why I use CompletableFutures is that one of the libraries I use is returning a CompletableFuture for its task....

The code is here....
https://codeberg.org/Andre601/AdvancedServerList/src/branch/master/version-uploader/src/main/java/ch/andre601/advancedserverlist/versionuploader/VersionUploader.java

Necessary Logs:

+ java -jar VersionUploader.jar --all
[ 20.09.2023 21:40:04 INFO  ] [main] [VersionUploader] - Starting release uploader... 
[ 20.09.2023 21:40:04 INFO  ] [main] [CodebergReleaseFetcher] - Using tag v3.5.0... 
[ 20.09.2023 21:40:04 INFO  ] [main] [ModrinthVersionUploader] - Starting ModrinthVersionUploader... 
[ 20.09.2023 21:40:04 INFO  ] [main] [ModrinthVersionUploader] - Creating release for platform bukkit... 
[ 20.09.2023 21:40:04 INFO  ] [main] [ModrinthVersionUploader] - Creating release for platform bungeecord... 
[ 20.09.2023 21:40:04 INFO  ] [main] [ModrinthVersionUploader] - Creating release for platform velocity... 
[ 20.09.2023 21:40:04 INFO  ] [main] [HangarVersionUploader] - Starting HangarVersionUploader... 

Looking at the logs it seems to start the Uploaders but then skips the whenComplete(...) part of the CF...
Googling tells me that join() might work... But I wonder if that would delay the thread until the future completes or throws.... or if I have to add some delay thing myself...

Help is greatly apreciated... Also in terms of if my aproach in the ModrinthVersionUploader is okay, as I can't think of any better solution here...

minor summit
#

.join() will block the current thread until the future completes, which sounds exactly like the kind of issue you're having, it seems sensible to .join() there i'd say, given that the default CF thread pool uses daemon threads, which is what is making the VM exit even though those threads might not be done running

atomic trail
icy shadow
#

double check both of those dont happen

atomic trail
#

The weird thing is that it only happens after the database file has been created and the table is empty though

icy shadow
#

Well yeah lol it’s your code

atomic trail
#

I’ve been looking through it all, just can’t see how the rs would be closed

#

It’s not closed in the lambda implementations

dusky harness
#

can u show the code of the lambda

atomic trail
#

The resultset is closed when using getInt

#

It’s already closed before using rs.next

dusky harness
somber gale
minor summit
#

lol

#

errors are good!

atomic trail
umbral stone
#

Hello I'm just looking for some help with spring framework,
I am receiving a Caused by: java.lang.NullPointerException: Cannot invoke "com.myexample.NightShift.hashCode()" because "this.shift" is null, and I am unsure why, the shift object should not be null.
Code causing the error: https://paste.helpch.at/apecohapak.bash
PCA class: https://paste.helpch.at/lonifopigu.less
NightShift class: https://paste.helpch.at/cocijeqeru.less

I've tried changing around the order things are saved in and whatnot but am still experiencing the issue, I initially believed it to be as we were saving one thing before the other but it does not appear to be that,

sonic nebula
#

its not java

#

also sprinig is java framework

#

;l

dusty frost
#

that is Java, that's Spring's JDBC stuff

#

Spring Data iirc, or JPA or something

spiral prairie
#

Wtf tony?

sonic nebula
#

var

worldly parcel
#

Heyyy.... I am sorry to ask, but when i open PAPI in IntelliJ from Github, i get this error: Unsupported class file major version 64

Can someone pls help me?

sonic nebula
#

wdym

worldly parcel
#

PAPI = PlaceholderAPI

sonic nebula
#

oh

#

what r u doing trying to do with PAPI?

worldly parcel
#

I think yeah, i mean how can i add myself expansions 😉

sonic nebula
#

did u even learn to code?

worldly parcel
#

yeah

sonic nebula
#

just wondering

#

because u dont need papi opensource

#

to make xpansions

#

expansions

worldly parcel
#

i read the wiki, i think i have to add code in the package at.helpch.placeholderapi.example.expansions;

sonic nebula
#

yeah

#

and how would you add this to your project?

#

i ask u questions so u can answer on them

worldly parcel
#

so you think, this is the class i have to add in my project and not in the papi project?

sonic nebula
#

do u use maven

#

or

#

gradle

worldly parcel
#

in my project maven

sonic nebula
#

add PAPI to pom.xml

worldly parcel
#

ahh okayyy, now i understand how thats works

sonic nebula
#

then update it gonna download

worldly parcel
#

i dont need to add my expansion into papi

sonic nebula
#

and u gonna be able to use it

#

no

#

no reason

worldly parcel
#

ahhh lollll

sonic nebula
#

PAPI just passes strings

#

between plugins

#

like vault passes a value between plugins

worldly parcel
#

okayyy, thank you so muchhhhhhh, its so early in the morning

sonic nebula
#

yeah i know

#

first time u will get used to it

#

its also kinda confusing so if u got any questions i can help u with ill be glad

worldly parcel
#

thankssss

dusty frost
#

i didn't even see it, but it does work basically the same with both

lyric gyro
#

is there some one expert on mcmmo factions can you help me setup please dm me

shy canopy
#

Hello!

How I can get player skin in base64?


private String encodeToBase64(String data) {
        // Convert the data to bytes
        byte[] dataBytes = data.getBytes();

        // Encode the bytes to Base64

        return Base64.getEncoder().encodeToString(dataBytes);
    }


encodeToBase64(Bukkit.getOfflinePlayer(record.get(0)).getPlayerProfile().getTextures().getSkin().toString())
hoary scarab
shy canopy
#

It's not valid. I can't convert it to playerhead

hoary scarab
#

Ah it gets the URL of the skin.

shy canopy
#

GetSkin return url?

river solstice
hoary scarab
#

yes

river solstice
#

yes, if you want to read the docs first

hoary scarab
#

You can get the base64 from GameProfile.

shy canopy
#

I already know that but how?

hoary scarab
atomic trail
# dusky harness what if you comment out `initializer.consume(statement)`

It's closed already before that, not sure how

            try(Connection newConnection = connection;
                PreparedStatement statement = newConnection.prepareStatement(query);
                ResultSet resultSet = statement.executeQuery()) {
                if(resultSet.isClosed()) {
                    throw new RuntimeException("ResultSet is closed - before consuming statement");
                }
                initializer.consume(statement);
                if(resultSet.isClosed()) {
                    throw new RuntimeException("ResultSet is closed - check logs");
                }
                return process.apply(resultSet);
            } catch(Exception e) {
                LOGGER.error("Error when preparing statement for query: " + query);
                throw new RuntimeException(e);
            }
#

I guess the connection isn't working properly?

#

This only happens after the database file is created, on next startup it doesn't give any errors

#

I've check, the statement or connection is not closed, so not sure why the result set would be

icy shadow
#

What query are you actually running?

atomic trail
#

It's from this, but I've found out that it only errors when I run this before

#

As in if 2nd ss runs before 1st ss

#

It should just create some default data if the player is not already in the database

#

It does create the default data, and when the player joins next time it's all good (no errors)

neat pierBOT
#
Hey, I'm Barry!

I'm a unique Discord bot created especially for HelpChat.

Authors:

I was created and I'm maintained by @robust crow with support from the Staff team.

Code base:

I'm created in Javascript using Discord.JS

Source code:

At this stage I'm closed source due being a mess and some secret internals. However you can contribute to my links/version knowledge here.

somber gale
#

Is CompletableFuture.allOf(...) followed by CompletableFuture#join() a good aproach here?
Because checking what good solutions are, people recommend to use CompletableFuture#thenCombine(otherCompletableFuture, BiFunction<T, U, V>) and then probably join...

I basically want to wait for multiple CompletableFutures to finish properly and don't know if the allOf is the best aproach here... Especially since one of the methods generates three individual ones I need to combine with a separate one....

Also, yes, it's related to the previous question I asked here... Check the code I linked there... Especially the ModrinthVersionUploader and HangarVersionUploader classes as I'm not sure if there isn't a more elegant solution here...

Message Link: #development message

umbral stone
royal hedge
royal hedge
#

and spring has additional support for kotlin

minor summit
somber gale
#

Okay

atomic trail
#

Before it ran on the same tick

atomic trail
#

This is my current code that works, but seems weird that I need to make it like that

        /* Create default data if player is not in database */
        database.createDefaultData(uuid);
        /* Load player data 1 tick after creating default data */
        Bukkit.getScheduler().runTask(bossEvents, () -> {
            database.deserializePlayerData(uuid).thenAccept((BePlayer data) -> {
                Bukkit.getScheduler().runTask(bossEvents, () -> {
                    bePlayers.put(data.getUniqueId(), data);
                });
            }).whenComplete((input, exception) -> {
                if(exception != null) {
                    LOGGER.error("Exception when deserializing player data for " + uuid, exception);
                    throw new RuntimeException(exception);
                }
            });
        });

It doesn't work if I don't run database.deserializePlayerData 1 tick later

#

Looks like I need a proper connection pooling system?

sterile hinge
#

I mean idk why you don't use a datasource

atomic trail
#

Yeah looking into that right now actually, but then I should change the Connection to a PooledConnection right? Like this or something

                SQLiteConnectionPoolDataSource dataSource = new SQLiteConnectionPoolDataSource();
                PooledConnection pooledConnection = dataSource.getPooledConnection();
sterile hinge
#

if that exists, you can use it I guess

atomic trail
#

Using Just SQLiteDataSource fixed all the issues...

#

Instead of the DriverManager

icy shadow
#

hm

#

my theory was some sort of race condition

#

not sure if this backs that up or not

atomic trail
atomic trail
#

Not sure if that's race condition or not

icy shadow
#

possibly

#

the big red flag is the ignoring of returned futures

#

eg you're ignoring the result of update()

#

i dont really know if thats gonna cause the issue or not

#

if you want you can push it all to a gh repo and i'll play around

atomic trail
#

That would be amazing if you're willing to do that

#

Can I dm you the repo?

#

Changed to use the result of update()

#

But that should not be an issue in this case

lime sequoia
dusky harness
#

🤨

#

Why no ask here

worn jasper
#

when looping through #getContents(), how would I be able to check if it was offhand or not? since it returns an itemstack

minor summit
#

DocDex is currently under maintenance.

worn jasper
#

big bruh

dusky harness
#

¯_(ツ)_/¯

dusky harness
#

🪦

worn jasper
#

if so, what slot even is offhand lmao

dusky harness
dark garnet
#

this is still happening to me Sadge

dusky harness
leaden sinew
leaden sinew
#

What's the benefit of that over shadowJar

dusky harness
#

he is using shadow

dark garnet
dusky harness
#

it just automatically sets the relocation

dark garnet
#

^

leaden sinew
#

Why?

dusky harness
#

so that you don't have to manually add the relocation line

#

good idea tbh

#

forgot to copy it

dark garnet
#

smh

dusky harness
#

thanks for the reminder 👍

dark garnet
#

:(

dusky harness
dark garnet
dusky harness
#

wdym?

dark garnet
# dusky harness wdym?

first: implementationRelocate(project, project(":AnnoyingAPI", "shadow"), ...)
second: implementationRelocate(project, "xyz.srnyx:java-utilities:1.0.0", ...)

dusky harness
#

oh right

#

🙃

dark garnet
#

@leaden sinew ive been using implementationRelocate for a while and havent had any issues btw (also i tried switching it to just implementation but still didnt work)

leaden sinew
#

When you use it how do you build your project?

dark garnet
leaden sinew
#

Can you send an example project where you've used it?

dark garnet
#

used what?

leaden sinew
#

implementationRelocate

#

That works

pulsar ferry
#

It would be less work to just spin your own reposilite repo on a cheap vps than trying to work with shitpack

dark garnet
#

its not jitpack thats the issue

#

its not building on github or local either

leaden sinew
#

Also, why are you publishing the example plugin?

dark garnet
#

just built at same time

leaden sinew
#

Why not just exclude it?

dark garnet
dark garnet
pulsar ferry
#

Can you give me a TLDR of the issue?

leaden sinew
leaden sinew
dark garnet
leaden sinew
#

So it’s working now?

dark garnet
#

well its not building the example plugin now

leaden sinew
#

That’s what removing it was for lol

dark garnet
#

i know but i still want it to be built FLOOSH

leaden sinew
#

What happens when you build it individually?

dark garnet
leaden sinew
#

Can you try with regular shadow jar just to see whether it has anything to do with that

dark garnet
#

nope same issue

#

with:

dependencies {
    implementation(project(":AnnoyingAPI", "shadow"))
}
```and `gradle shadowJar`
leaden sinew
#

Idk what the issue is then and I’m on my phone now so it’s hard for me to look

dark garnet
#

its when i replaced a lot of my classes with:
implementationRelocate(project, "xyz.srnyx:java-utilities:1.0.0")

#

changing this to implementation fixed it ^

#

but i wanna know why 😩

#

wait i know why and its the DUMBEST thing ever

#

if not provided, implementationRelocate will automatically get the group of the provided dependency (in this case, xyz.srnyx), and use that as the relocation thing

#

so, since my api is xyz.srnyx.annoyingapi, it was relocating it to xyz.srnyx.annoyingapi.libs.srnyx

dusky harness
#

But why would they prevent compile

dark garnet
#

so to still use implementationRelocate i just have to do implementationRelocate(project, "xyz.srnyx:java-utilities:1.0.0", relocateFrom = "xyz.srnyx.javautilities") instead

dark garnet
dusky harness
#

Oh

dark garnet
#

example-plugin just cant find annoyingapi

#

import xyz.srnyx.annoyingapi.AnnoyingCooldown;
should actually be:
import xyz.srnyx.annoyingapi.libs.srnyx.AnnoyingCooldown;

dusky harness
#

Why tho

#

Oh

#

What

#

Whh

#

Why*

dark garnet
#

cause its relocating xyz.srnyx to xyz.srnyx.annoyingapi.libs.srnyx

dusky harness
#

But why is it relocating in source?

dark garnet
#

wdym

#

like why is it relocating the project itself?

dusky harness
#

Relocations shouldn't affect source cods

#

Code

#

Oh qait

#

Wait

dark garnet
#

...

dusky harness
#

Oh you mean in the api

#

Like the api api

#

In the api

dark garnet
dusky harness
#

Idk

dark garnet
#

but the api is being relocated like in itself 💀

#

so the example-plugin cant find where the api should be (when compiling)

#

api: im gonna relocate xyz.srnyx.annoyingapi to xyz.srnyx.annoyingapi.libs.srnyx
example-plugin: i want to import xyz.srnyx.annoyingapi but its not there wtf???
gradle: yeah u guys r weird imma fail now

#

@dusky harness ^ u get now?

dusky harness
#

sure 🥲

light pendant
#

I made a new spigot wiki article today that is totally beyond my mind to maintain

light pendant
#

how do you people deal with customers who have issues only with bedrock issues? do you blatantly tell them "no spigot/no java = not my issue, or just refund them instantly, or check out the problem and only refund if you notice they need bedrock support but it's not possible with just spigot api/ .... ?"

#

once I figured out the issue really only occurs for bedrock users, and I notice it's important for the buyer that they care about bedrock users not having issues, I just refund them, no questions, asked, even if their purchase is like >3 months ago. However this is getting annoying. why do server owners take it for granted that plugin devs have to care about geyser issues? 😢

#

ofc I do understand the server owner but if they plugin purchase is like 3 months ago, I would have imagine they had tested it right away?

hazy nimbus
#

If you don't explicitly state the plugin supports bedrock/geyser, they have no right for refund imo

light pendant
#

yes I know

#

but imagine being a customer

#

they expect it to work

hazy nimbus
#

They shouldn't

light pendant
#

yeah but I'd rather give back 5,99€ than getting a 1 star review haha

hazy nimbus
#

Well that's a different one

#

But that isn't exclusive only to bedrock issues, is it?

light pendant
#

that plugin is exclusively is related bedrock issues

#

I think there's no rule gainst me linking a spigotmc link right?

hazy nimbus
#

No idea

light pendant
#

it's this plugin

#

and it seems like bedrock does not accept any recipes added by THIRD PARTY (not mine, but an additional third party plugin) recipes that have altered max-stack size recipes to recipes that usually only allow 1 stack size

hazy nimbus
#

Tbh maybe add it in caps and bold into the plugin description

light pendant
#

let's just do it in law speak:

My plugin is called X.
Other plugin is called Y.
Plugin X and Y work nice together

But adding a recipe that both uses manipulated stack sizes, and a custom recipe from plugin called Y, works fine too.

Only on bedrock, X + Y causes issues

#

but because I'm too tired I just offered a refund instead of investigating it at all

#

the plugin price is 6€, so even thinking about it for > 1 minute isn't really worth it

#

I just wanted to heart general opinions 🙂

dense drift
indigo kestrel
#

Hey guys,
I tryed to add my own texturepack and it worked but only some, is there any pixel requearmint lime max 128x128?
Please help me and ping me if you’ve anwsered.

spiral mural
#

hey, how can I handle custom skulls? like using minecraft-heads or whatever. like how do you get a texture from the value provided by heads eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODQ4YTRjMzg1ZTNiNDMzM2NlN2IwOGY1NWI0NGUwZjZlNjBiOTc1MDZjOTdjYmYzMTkyMzk2ZmZiZWJmOTk2MyJ9fX0=?

#

this is how far I got ``` private ItemStack getSkull(ItemStack item) {
if(item.getType() == Material.PLAYER_HEAD) {
SkullMeta meta = (SkullMeta) item.getItemMeta();

    }
    return null;
}``` not sure how specifically to get the custom value in there.
warm steppe
#

If You are using triumph-gui:

ItemStack skull = ItemBuilder.skull().texture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzU3NDcwMTBkODRhYTU2NDgzYjc1ZjYyNDNkOTRmMzRjNTM0NjAzNTg0YjJjYzY4YTQ1YmYzNjU4NDAxMDVmZCJ9fX0=").build();
spiral mural
#

not using any api's

warm steppe
#

ok keep reinventing the wheel 👍 👍 👍

sudden sand
#
                this,
                ListenerPriority.NORMAL,
                PacketType.Play.Client.USE_ENTITY
        ) {

            @Override
            public void onPacketReceiving(PacketEvent event) {
                EnumWrappers.EntityUseAction useAction = event.getPacket().getEnumEntityUseActions().read(0).getAction();

                if(useAction != EnumWrappers.EntityUseAction.ATTACK) {
                    return;
                }

                Player player = event.getPlayer();
                int entityId = event.getPacket().getIntegers().read(0);


           }
        };```
#

Hey

#

Is there a way to check the entity type of USE_ENTITY packet

#

because the packet doesn't propose it

#

and I can't use async with bukkit

#

and even if I could

#

it lose speed

#

I need it to stay async

spiral mural
royal hedge
#

basically the bukkit api doesnt expose any api for setting the texture of a skull (afaik) so unless u wanna interface with nms directly use some library

spiral mural
dense drift
worn jasper
#

Any idea why morphia doesn't support List<String> types? I mean, in theory it should, but idk why, it isn't saving in the mongodb, which is causing it, when I fetch it, to not get the object since the constructor contains that...

#

the field is simply not present in the mongodb doc

#

unsure why...

formal crane
#

So i am trying to connect a websocket from my minecraft server to my nodejs site, this is my socket code class:
https://paste.helpch.at/sigoxigahu.typescript

The problem is that the method "logEvent()" only works when it is called in the onEnable & onDisable in the code. When i use the function somewhere else it wont work and just prints out "Socket is not connected!" Here is the code where it doesn't work:
https://paste.helpch.at/aqovifuyuj.java

untold panther
#

Sparky called you monkeys

royal hedge
#

wrong person pal

prisma briar
#

Hello, I need help in fixing a database issue that I have, I kept getting error and deadlock issue, I have the code that I used below to show some methods that I'm using, the database type that I used is SQLite and MySQL.

Code: https://paste.helpch.at/xawinevicu.typescript
deleteGenerator(ActiveGenerator)
This method is used everytime the generator (block) is being removed.
saveGenerator(ActiveGenerator)
This method is used everytime the player placed down a generator or the generator being upgraded.
saveGenerator(Collection<ActiveGenerator)
This method is used on plugin disable and auto-save system.

I don't know what's wrong with it and I'm stuck.

tight junco
#

whats the error

#

although id say when using REPLACE INTO, id try having the actual table names in the statement

#

example REPLACE INTO my_table (name, age) VALUES (?, ?)

river solstice
#

what's the buildStatement

#

I'd guess that would most likely be the issue

vagrant phoenix
#

im using trying to use NMS but i have a problem, when i use paperweight.paperDevBundle("1.19-R0.1-SNAPSHOT") it errors (im making a 1.19 plugin), but when i try using paperweight.paperDevBundle("1.20.1-R0.1-SNAPSHOT") it works (although it doesnt actually). how do i use paperweight 1.19?

ionic seal
#

For deluxe menus, is it possible to make it so when someone buys an item in the gui, it increases the price and shows the increased price in the GUI or would that have to be its own plugin?

hoary scarab
#

What was a better way of formatting a number? It was brought up before but can't remeber.

public static String formatCount(double amount) {
    if(amount < 1000L ) { return format(amount)+" H"; }
    if(amount < 1000000L ) { return format(amount/1000L)+" kH"; }
    if(amount < 1000000000L ) { return format(amount/1000000L)+" MH"; }
    if(amount < 1000000000000L ) { return format(amount/1000000000L)+" GH"; }
    if(amount < 1000000000000000L ) { return format(amount/1000000000000L)+" Th"; }
    if(amount < 1000000000000000000L ) { return format(amount/1000000000000000L)+" PH"; }
    return String.valueOf((double) amount);
}
hoary scarab
#

Hashrates

dense drift
hoary scarab
#

👍 will look into it in a bit thx.

minor summit
#

CompactNumberFormat moment

sterile hinge
#

TRUE

minor summit
#

I used it recently for some custom units

#

it was pretty epic

#

and if you're lucky you don't even need a formatter altogether and use the correct format pattern!

minor summit
fading stag
#

Is it a costly process?

sterile hinge
#
  public static void main(String[] args) {
    NumberFormat.getCompactNumberInstance(Locale.US, NumberFormat.Style.SHORT);
    CompactNumberFormat format = new CompactNumberFormat("#,###.00", DecimalFormatSymbols.getInstance(Locale.US), buildFormat("H", "kH", "MH", "GH", "Th", "PH"));
    format.setMinimumFractionDigits(2);
    format.setMaximumFractionDigits(2);
    System.out.println(format.format(1.0));
    System.out.println(format.format(1234567890000000000.0));
  }

  private static String[] buildFormat(String... suffixes) {
    String[] result = new String[suffixes.length * 3];
    for (int i = 0; i < suffixes.length; i++) {
      String suffix = suffixes[i];
      for (int j = 1; j <= 3; j++) {
        result[i * 3 + j - 1] = "0".repeat(j) + " " + suffix;
      }
    }
    return result;
  }

I don't understand why the decimal pattern is ignored and you have to set the fraction digits yourself but that's indeed pretty simple I guess

minor summit
#

I don't remember setting a pattern lol

#

oh I am very silly, I put them in the compact patterns OMEGALUL

#

ah that's what the javadoc show lmao

hoary scarab
#

Seems like a lot more then just the if statements

minor summit
#

it, uh, it isn't ??

sterile hinge
#

the most complex part is to set up the compactPatterns, I did it with a method because otherwise you have a long ass array of strings in your code

#

but other than that, it seems pretty simple

#

but I guess counting zeroes to see if you got it right is fun

hoary scarab
#

I'll check it out when I can.

I think the way I had in mind might be a bit simpler though...

An array of suffixes then just check the length divided by 3 and get that index in the array.

#

Don't really need the decimal format

light pendant
#

hi everyone. I'm having a gradle issue again

#

the file is saved as UTF-8

#

it does fix it if I switch to using the \u00A7 notation

#

I have tried setting options.encoding = "UTF-8" in all JavaCompile tasks

#

the funny thing is though that it's still the compileJava task that fails

#

the javadocs also have that issue but first of all I'd like to get it compiled without this stupid workaround lol

#

fixed it. had to do configureEach { on the tasks.withType<...>

light pendant
#

I got a gradle module that only exists for the package-info.java files, but the plugin complains about no classes being found - any way to fix this?

> Task :javadoc:javadoc FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.3/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
80 actionable tasks: 42 executed, 38 up-to-date
error: No public or protected classes found to document.
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':javadoc:javadoc'.
> Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): 'C:\Users\mfnal\IdeaProjects\cesspool\modules\javadoc\build\tmp\javadoc\javadoc.options'

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 17s
02:27:04: Execution finished 'build'.
minor summit
#

[22:29]Emily: that's just javadoc
[22:30]Emily: a package without classes does not really exist
[22:30]Emily: it isn't a package per se

hoary scarab
#

My "divide by 3" option works ;)```java
private String[] suffixes = new String[] {"H", "kH", "MH", "GH", "TH", "PH"};
public String format(long amount) {
String value = String.valueOf(amount);
int length = value.length();
int div = length/3;
return value.substring(0, length >= 3 ? 3 : length) + suffixes[(length/3.0)-(div) > .3 ? (div) : (div)-1];
}

ConsoleFeed.debug(format(900));
ConsoleFeed.debug(format(900999));
ConsoleFeed.debug(format(900999999));
ConsoleFeed.debug(format(Long.valueOf("900999999999")));
ConsoleFeed.debug(format(Long.valueOf("900999999999999")));
ConsoleFeed.debug(format(Long.valueOf("900999999999999999")));
Output
[Debug] 900H
[Debug] 900kH
[Debug] 900MH
[Debug] 900GH
[Debug] 900TH
[Debug] 900PH

sterile hinge
#

If you‘re fine with that rounding mode, yeah

#

But I don’t see how this is simpler than the proper tool

sleek wedge
#

The mob canno't move, but can attack, need help to find solution.

guardian.setAI(false);
so the mob doesn't move, but the guardian like that doesn't attack.

for (Guardian guardian : guardians) {
                    for (Player player : guardian.getWorld().getPlayers()) {
                        if (player.getLocation().distance(guardian.getLocation()) <= 15) {
                            guardian.setTarget(player);
                        }
                    }
                }

i did using even an custom task for checking if the player is in 15 block range and make it as target, but that doesn't work either, any ideas?

hoary scarab
sterile hinge
#

And now count arithmetic operations and branching in the code actually relevant for the formatting

hoary scarab
#

Well for simplicity my code did exactly what I wanted. But for future projects I'll keep CompactNumberFormat in mind.

dense drift
#

ok CompactNumberFormat is very cool actually

signal grove
#

best way to check if an inventory has room for a list of itemstacks before actually putting them in?

#

maybe i could copy the inventory, try adding them all to the copy, and check if the returned hashmap is empty?

#
public boolean hasRoomFor(Inventory inventory, ItemStack[] items)
    {
        Inventory invCopy = copyInv(inventory);
        HashMap<Integer, ItemStack> leftOvers = invCopy.addItem(items);
        return leftOvers.size() == 0;
    }
river solstice
#

well, theres .firstEmpty() I think

#

it will return first empty slot else -1

#

if no empty slot, then loop over the inventory and look for the item, check if added amount doesnt exceed the max item amount

signal grove
#

i want to check if there's room for a list of itemstacks, not just 1

#

i could do that way for each item, but then i'd have to find "similar" itemstacks for each one that can be combined

#

it's probably what inventory.addItem(ItemStack...) does anyways, but i trust the builtin to be better than what i can implement

dense drift
#

leftOvers.isEmpty()

signal grove
#

right, will change that

river solstice
dense drift
floral beacon
#

is it possible to detect if a player (mostly asking for newer MC versions or latest) is using specific resourcepack or some property of that resourcepack? asking for both spigot and bungeecord

minor summit
#

no

restive horizon
#

i was setting up bungee cords but only java players are able to join it

#

before that bedrock players were able to join the server

sterile hinge
#

That sounds like you installed geyser on your server but not on the proxy

restive horizon
#

well fixed that thankyou

restive horizon
#

another issue

#

if i am leaving in for example server 2 and when i rejoin i am not in server 1 and spawns me back to server 2

vapid island
#

Does anyone know how to cancel a task timer inside of the task timer itself?

hoary scarab
#

#dev-general is probably a better channel. Just kidding.

If it's within the BukkitRunnable you can use cancel() if not use Bukkit.getScheduler().cancelTask(id)

vapid island
hoary scarab
#
new BukkitRunnable() {
    public void run() {
        cancel()
    }
}.runTaskTimer(<JavaPlugin>, 0, 1);

BukkitTask task = Bukkit.getScheduler().scheduleTaskTimer(() -> {
    task.cancel();
}, 0, 1);
```I'm not on PC so the second one might need to be adjusted
dense drift
#

You can not reference the variable you assign a value to in that function

icy shadow
#
BukkitTask task = null;
task = Bukkit.getScheduler().scheduleTaskTimer(() -> {
    task.cancel();
}, 0, 1);
``` should work
#

but the Consumer<BukkitTask> method clears

sterile hinge
#

Variable used in lambda expression should be final or effectively final
🤓

lyric gyro
#

Looking for dev can help me setup my server while im learning

lyric gyro
pulsar ferry
#

Because you are service muted

stuck canopy
#

am I also muted in a channel? I think "EXTRA" category had more channels but I don't see them (I only see #chat-reaction )

wheat carbon
#

there used to be role request channels but we closed those quite a while ago

#

apart from that if you had access to more channels at one point you'd still have access to them now

worn jasper
#

uhm am I the only one confused on how adding groups to an user in lp works?

mellow pond
#

lp user (user) permission set group.(name of group)

minor summit
#

not the right answer for this channel lol

#

you add an inheritancenode to the user's node map

#

and save it, this is explained and shown in the wiki 🤓

worn jasper
worn jasper
mellow pond
hoary scarab
sterile hinge
#

I wouldn't consider that great code tbh

#

the scheduling api from folia is far better there imo

dense drift
#

or make a class that extends BukkitTask and then you can call cancel() in run()

dusky harness
#

Right?

dense drift
#

ye but perhaps not an anonymous class xD

minor summit
#

consumer method zzz

nimble vale
#

not allowed to paste images

#

is that changed

dusky harness
nimble vale
#

or is this a some kind of a bug

dusky harness
#

¯_(ツ)_/¯

nimble vale
#

ops

#

its actually an image

#

.png

warm steppe
#

send it

nimble vale
#

cant

warm steppe
#

lol xd

nimble vale
#

no there is a problem

#

tried multiple images

#

btw is there a way to define default values for types in mysql

#

like i don't want to type DEFAULT 0 for every boolean

dusty frost
#

easy, stop using mysql

nimble vale
#

what do you suggest then

dense drift
#

Mariadb over mysql

nimble vale
#

i might switch to something else maybe

#

postgre or maria

atomic trail
#

Shouldn't this only insert if uuid is missing? "INSERT OR IGNORE INTO " + TABLE_NAME + "(uuid, active_chat) VALUES(?, ?)"

nimble vale
#

not, if uuid is nullable i think

#

it says

However, if you use the INSERT IGNORE statement, the rows with invalid data that cause the error are ignored and the rows with valid data are inserted into the table.

atomic trail
#

Found it it's because it's not a primary key

#

ty tho

dusty frost
forest jay
#

I am doing some API requests with Completable Futures, and it is a pain in the ass. I have some code and I am trying to complete the completables and it just isnt registering. Here is the code: https://paste.helpch.at/eyehevihew.java

#

I want to open a GUI after the api request has been completed

#

so I am using complete() once a value is returned, and thenAccept() to open the GUI, but it isnt working.

#

Is there something I am doing wrong?

dense drift
#

I dont see you handling any errors, if the request couldn't be completed then the future is empty, isn't it?

icy shadow
#

Yeah that will go badly if any exceptions happen, it will just silently do nothing

#

You should use whenComplete rather than thenAccept in your “final” call, and then handle the exception if it’s present

somber gale
#

I want to make a SLP migrator for my plugin.... Thing is that I can't think of a proper system to convert the format SLP uses into mine...
Like, SLP uses this:

Default:
  Description:
    - |-
      Line 1
      Line 2
    - |-
      Line A
      Line B

which in my plugin would be this.

profiles:
  - motd:
      - Line 1
      - Line 2
  - motd:
      - Line A
      - Line B

not to mention the countless other options which allow single and multiple entries...
Has someone ever made a migrator for SLP?

icy shadow
#

create 2 ASTs (one for each syntax) and the conversion should be pretty trivial

#

By ASTs I mean typed, class representations of the data’s structure

#

Hardest bit will be turning the multiline string into a list, and even that is only 1 line

somber gale
#

Not quite sure how such an AST would look like.... Tho, maybe configurate could be helpful here... I already have a serializer to turn my own configuration into relevant options, so maybe I can do something similar here...

#

Biggest problem I have to look at in the future is to convert colours in SLP.... It uses this strange MineDown syntax that is just awful to look at... And I would need to convert that into the MiniMessage format my plugin uses to make it work.

icy shadow
#

tbh you can literally just turn this into 2 lists

#

parse the SLP stuff into a List<List<String>>, then you already have it in the same format as your yaml

#

unless of course, this is a small part of the overall problem

somber gale
#

There are also int lists. Like for max player count

icy shadow
#

put it all into a class then

#
// or write class version if necessary
record SLPConfig(List<List<String>> motds, List<Integer> maxPlayerCountEtc){}```
small arrow
#

Hey! I have an issue with my kits plugin...
When a player who HAS permission, and is NOT on a cooldown tries to access a kit, they dont get the item(s) added to their inventory. I put in debug messages, and everything seems to be fine. If anyone can help me out, I'd really appreciate it 😄
https://paste.helpch.at/teqabikahe.java
https://paste.helpch.at/etacukutog.java
https://paste.helpch.at/havupegipe.java
https://paste.helpch.at/umuyovapuy.yaml - kits.yml
https://paste.helpch.at/ugemamumew.yaml - plugin.yml

grim oasis
small arrow
#

No. I only get these messages:

[11:31:35 INFO]: [KitGUI] Adding kit item to inventory: kit2
[11:31:35 INFO]: [KitGUI] Player has permission and is not on cooldown for kit2
grim oasis
#

hmm

#

maybe add a few more debug around grantkit method

#

also, it might just be me: but I find it odd that you create new Kit objects every time the command is run

#

instead of creating them upon server start

#

to me, it looks like it would be impossible to be actually "on cooldown" because every time you run the command it creates a new Kit, with an empty list of cooldownPlayers

#

wait

small arrow
#

true i didnt even realize that 😂

grim oasis
#

i just noticed

small arrow
#

?

grim oasis
#

you don't see Left-clicked on kit:

#

or Right-clicked on kit:

#

?

small arrow
#

in console?

grim oasis
#

yes

small arrow
#

no i dont get that message

grim oasis
#

add more debugs to your onInventoryClick method

#

also

#

you are creating a brand new kit when doing that

#

sorry

#

when running findKitByDisplayName

#

you make a new Kit

#

i gotta head out

#

i wish you luck tho

small arrow
#

👍 tysm

forest jay
#

Its calling future.complete, and it is completing, but the listener on that doesnt run, the whenComplete

tall storm
#

hey, I'm thinking about Thread.wait();

icy shadow
tall storm
#

maybe start a talk with us ?

#

so you can show

forest jay
#

I found the initial issue, its good now

tall storm
#

inital issue ?

#

where

icy shadow
tall storm
#

just for experience xd

icy shadow
#

might not fix the issue but certainly simpler

tall storm
#

For some people its easier typing what is in there Head at the moment, I do it to 😄

icy shadow
#

well sure, but you can still make improvements

tall storm
#

truee tho

#

just because you said "why not just do"

#

sounds weird 😄

icy shadow
#

fair point

wooden bronze
#

how to change ammount in delux menu

#

ammount of items

proud pebble
wooden bronze
#

ty

proud pebble
wooden bronze
#

oh srr

umbral stone
#

hello looking for someone assistance splitting a CSV file at every comma, unless the comma is encased in double quotes, for example a,b,c,d,"e,f,g",h,i,"j,k" should split to a b c d e,f,g h i j,k

#

I suspect regex will be the best way to do this

grim oasis
#

@umbral stone (?<!"[^"]),(?![^"]")

umbral stone
#

thankyou!!

grim oasis
#

test it out

#

took me a while, but it should work!

sterile hinge
#

regex is never the best way to do something tbh

#

Hand writing the code is basically always faster and often easier to understand

nimble vale
#

any spring related minecraft project ideas?

#

wanna learn the framework

#

i just need some examples to make sense of it

icy shadow
#

Make hangar 2

#

Also known as spigot 3

worn jasper
nimble vale
#

there is also modrinth

#

which looks quite nice

dense drift
icy shadow
#

spigot, hangar, the hypothetical new one

hoary scarab
#

👋

#

Just not using spring or anything really lol

icy shadow
#

You may come to regret that

hoary scarab
#

🤷 I just like doing things from scratch.

#

It's fun to work out how to do things for myself and when it's achieved usually feels better then using a lib/api.

hoary scarab
#

Hehehe
It would still be fun

worn jasper
#

How would I get/generate a random "player"? (Basically nick, uuid and skin) from an existing player that never played in the server. For context, to make a random disguise plugin (picks a random nick & skin)

somber gale
#

Looking for feedback on this PR. Especially regarding Configurate handling as I'm not sure if that is the bes solution here....

serene cairn
signal grove
#

Or look for massive lists of old names, I’m sure they’re out there somewhere

dusky harness
#

I think

#

Since namemc api was already mentioned

worn jasper
#

I am actually specifically looking for a way to generate random nicks and skins rn, preferably from players that exist but haven't played in the server (avoid people discovering they are disguised by just searching the name on namemc lol)

#

@signal grove @dusky harness

dusky harness
#

oh what-
you gotta be specific

worn jasper
#

yeah my bad

#

xD

#

have issues expressing myself

signal grove
#

Ahh how would searching the name give away that they’re a disguise, since legit players are on there too

dusky harness
#

and because of ratelimits you might not even be able to spam mojang api with random usernames 🥲

signal grove
#

Maybe you could go for “popular skins” and then somehow query for players using those skins

dusky harness
#

namemc seems to use strict cloudflare though so you prob can't use that

worn jasper
#

Hmm okay, thanks

sterile hinge
#

you shouldn't rely on default serialization of objects you don't have control over (in this case, ItemStack)

#

but generally, it likely doesn't make much sense to write a json string into your database

dense drift
#

Items are usually serialized as base64 from what ive seen, there's no real need to save it on a human readable format like json

minor summit
#

not even base64, just save it as a blob

dense drift
#

oh or that

serene cairn
#

just a rough guess

dense drift
#

^ better if you are using paper

serene cairn
#

which is better, base64 or blob

#

from past experiences n stuff

minor summit
#

there is no reason to use base64 if the data store supports saving raw bytes directly

serene cairn
#

alright

modern thunder
#

compileOnly("me.clip:placeholderapi:2.11.4")

No erros, but can't find me.clip package xD

#

Can't import anything

fading stag
modern thunder
pulsar ferry
#

Did you add the repo?

modern thunder
fading stag
modern thunder
#

Really can't understand how gradle has these kind of problems

light pendant
#

because IJ itself choking up sometimes is pretty normal unfortunately

errant kite
#

so i have some hud that i can not use with shaders they have their own shaders, would it be possible for someone who worked on shaders be able to implement the shaders from the hud into a custom client side shader

formal crane
#

When i add a recipe to minecraft like this, do i still need to remove the recipe in the ondisable? Or is it just a temporary cache

proud pebble
formal crane
#

oh thank you 🙂

nimble vale
#

if you find someone to do something like that you can offer players merged ones

#

just an idea if you fail

worn jasper
#

Could anyone help me out here? Getting this basically spammed in the console: https://paste.helpch.at/jusaqesoke.rb
Using morphia, shading and relocating it, made a clean build, unsure what's causing it, tried adding a custom ClusterListener to disable the DefaultServerMonitor settings which is what is apparently causing this (stackoverflow says), didn't work though...

glass oar
#

heyo heyo

#

I'm making a simple plugin for a friends-only server, stuff is broken LOL

https://paste.helpch.at/idofojodim.java

none of the effects work at all, all the events have the eventhandler tag and they're being registered.

could it be that uuid's just don't work for this? If anyone would be able to help me out with this then I'd be greatful!

river solstice
#

Just use names at this point

glass oar
#

using DisplayNames or just normal Names?

#

(Also don't mind my spaghetti code, I'm still relatively new)

astral mauve
#

I think you should call .toString then check equality. You are checking if a UUID object equals a String object which is false

glass oar
#

oh my god

#

actual life saver

#

thank you!!

astral mauve
#

np

worn jasper
river solstice
#

though the IDE should definitely show a warning there

rich lance
#

Try to set all your names as constants so it’s a bit cleaner

glass oar
#

alr

#

thanks

rich lance
#

and maybe a switch statement

#

google all those if you don’t know

rich lance
glass oar
#

OH FUCK

rich lance
#

it’s not any different so you could maybe just make 1 task when your plugin starts up

glass oar
#

whoops

#

still

rich lance
#

lol chill

glass oar
#

I didn't mean to do it on join LOL

rich lance
#

Mis clicked mb

rich lance
dark garnet
#

just a little suggestion, use statics for the uuids so that u know who each one is 🙃

rich lance
#

yeah I said that up

dark garnet
#

o

glass oar
#

but then again

#

I have variables that use their names

#

like short versions of their names

rich lance
#

it would be all caps

dark garnet
#

constants r ca-

#

ur too fast A1

rich lance
#

gotta get faster

dark garnet
#

😠

glass oar
#

does it matter?

#

:trolley:

rich lance
#

no but if you don’t want spaghetti code then yes

glass oar
#

I want spaghet

dark garnet
#

u can just create a player variable at the beginning of the event (would make code cleaner too)

rich lance
#

your choice truly

rich lance
#

I would personally move most of it in a config

dark garnet
dark garnet
rich lance
#

yeah true

glass oar
#

please remember that this is for a private smp

dark garnet
#

ye

glass oar
#

that I'm hosting for my friends LOL

rich lance
#

make an abstract object hierarchy inheritance structure for Minecraft effect plugin

dark garnet
#

i would 100% create a player and uuid variable

rich lance
#

Now.

dark garnet
#

also u could store the potion effects as constants

rich lance
#

that’d probably be ugly I don’t think he reuses them much anyway

dark garnet
rich lance
#

yeah well that’s a mistake lmao

#

On every join

dark garnet
#

i thought the repeating task was correct but not on join

rich lance
#

idk anymore

#

Perhaps

dark garnet
#

we can just wait for new correct code ig

dusky harness
minor summit
#

does it run fine locally?

dusky harness
# minor summit does it run fine locally?

thought it did, but ran the exact same commands from github actions, and it doesn't work
Don't know why I set it up to test, then clean, then build even though I'm pretty sure that test builds anyways
But why am I unable to clean & build after running test? 🤔 ```
gradle test clean build < doesn't work
gradle test build < works
gradle test clean < works
gradle test < works, committed this change

fleet shale
#

does anyone here have knwledge in forge modding for 1.20.1 im trying to update a mod from 1.19.5 to 1.20.1 and getting all sorts of issues that ive never seen

dusky harness
#

or you can try asking here as well

fleet shale
#

oh i didnt know there was a forge server do you happen to have the link?

fleet shale
#

thank you

formal crane
#

Hey, i am currently using the XSeries library wich makes adding multiple verion support 3x as easy.

There is one problem i have tho, when i retrieve an itemstack from the config using the XItemStack.deserialize() function it puts a different nbt on it then minecraft does so it becomes a different item than was orginially put in, here is a screenshot of the nbt view.

Also here is the full code: https://github.com/RazerStorm/CustomCrafting

How would i fix this issue?

(Fixed it temporarly, still need this fixed because its a better way.)

dark garnet
dark garnet
#

and how did u temporarily fix it?

dark garnet
formal crane
dark garnet
#

and double-check javadocs

pulsar ferry
#

Instead of using xitemstack (i don't even know what this does, last time I used it this wasn't a thing I think?) use xmaterial then do parseItem and set the name there, you'd still keep the backwards compat and the name would probably be the same

#

Though why does it matter if the name component is different?

#

It should display the same

river solstice
#

maybe just dont use xseries

formal crane
dense drift
#

Use your own (de)serialization logic then

sullen acorn
#

why cant i post pictures

neat pierBOT
sullen acorn
#

right

stuck canopy
spiral mural
#

can you do this? contain location?

    public void interact(PlayerInteractEvent event) {
        Block block = event.getClickedBlock();
        if(block != null) {
            List<Location> locations = cookIt.getBlocks().getLocations();
            if(locations == null || locations.isEmpty()) {
                return;
            }

            if(!locations.contains(block.getLocation())) {
                return;
            }


        }
    }``` or do I have to match the cordinates like x,yz, world etc. ?
sterile hinge
#

contains on a list isn't a great idea to begin with

#

but if all locations are block coordinates, it might work

proud pebble
#

like why a list of locations

spiral mural
#

it's going to open a gui. sort of like an interactive block in spawn @proud pebble. am making a custom cooking thing

proud pebble
spiral mural
#

it's just going to be set a few predetermined places , don't really need more than 1 but want the option for a few more only.

proud pebble
spiral mural
proud pebble
#

not really

#

simply looping through the list and finding one that matches works pretty well

#

which is exactly what contains does

river solstice
#

keep in mind that "contains" will check yaw/pitch too

proud pebble
#

you could probably speed it up by doing the check for the parts you care about yourself, such as just the world, x,y,z and then dont care about the yaw and pitch since for block locations they would be 0 anyways

spiral mural
#

will it speed it up cause I will need to dig into the for loop or stream to catch those specifics also from the location list?

signal grove
#

best way to clear enchants from an ItemStack?

#

itemStack.getEnchantments().clear();

#

apparently the map is immutable

#

so that doesnt work

#

i guess i have to just change the meta then

dusky harness
#

Get enchants, remove using removeEnchantment

unkempt prairie
#

ItemStack item = new ItemStack(Material.DIAMOND_SWORD); // Replace with your desired item
ItemMeta meta = item.getItemMeta();
meta.getEnchants().keySet().forEach(meta::removeEnchant);
item.setItemMeta(meta);

signal grove
#

weird

dusky harness
#

You don't even need meta

signal grove
#

yeah i can use regular getEnchantmants

unkempt prairie
dusky harness
#

I assume that was from chagpt

#

Yeah

signal grove
#

tf does removeEnchant do if its immutable, just overwrite it?

dusky harness
#

No the get Enchantments map is immutable so that there doesn't have to be a custom map

signal grove
#

ah

dusky harness
#

It's just a regular HashMap (or similar)

#

Doesn't send packets or anything (to clarify what I meant by "custom map")

signal grove
#

i'll go with itemStack.getEnchantments().keySet().forEach(itemStack::removeEnchantment);

somber gale
#

Am I missunderstanding something or doing something wrong?
A user reports that the capitalization option of my expansion is returning the whole text uppercase....
Not sure what in the code could be wrong here.

    @Override
    public String parse(String raw, String option, String... values){
        if(values.length == 1){
            return values[0].toUpperCase(Locale.ROOT);
        }
        
        String str;
        boolean strict = false;
        if(values[0].equalsIgnoreCase("!strict!")){
            strict = true;
            str = String.join("_", Arrays.copyOfRange(values, 1, values.length));
        }else{
            str = String.join("_", values);
        }
        
        return str.substring(0, 1).toUpperCase(Locale.ROOT) + (strict ? 
            str.substring(1).toLowerCase(Locale.ROOT) :
            str.substring(1));
    }
dusky harness
#

a user
Have you tested it yourself? Or unable to right now

somber gale
#

Haven't tested yet and they tried it with the strict option (So %formatter_text_capitalize_!strict!_testing% in their case and that works as expected

dusky harness
#

If values is of size 1,it appears that itll just make the whole string uppercase

#

Strict prob works bc it makes the length more than 1

somber gale
#

I think it's more the toLowercase?

dusky harness
#

No what I mean is that if there's only 1 "param" (ex testing) then it'll return TESTING

somber gale
#

Makes no sense because I use substring

signal grove
#

before substring - the very first condition

somber gale
#

Ah.... Yeah

#

That's from before I added the strict thing.... 😓

signal grove
#

also, how many values can there be

#

it seems like you should want strict to be handled even if its not the first value

#

but you check if only value[0] is strict

somber gale
#

That's because the placeholder is either %formatter_text_capitalize_<text>% or %formatter_text_capitalize_!strict!_<text>%

#

I made it like that on purpose

signal grove
#

ah, then the values array is either empty {}, or a single string {"!strict!"}

#

maybe i misunderstand

somber gale
#

It shouldn't be empty.... Actually, should add a safety check for that

signal grove
#

oh i see - its the values after "capitalize"

#

are raw and option used?

somber gale
#

Not for capitalize.

#

Raw is the full, untranslated placeholder and option the second word of the placeholder (Splitting at _), so in this case would it be capitalize

#

Like, the placeholder follows a specific structure (With one exception): %formatter_<type>_<option>_<values>%
It first goes through the types (text or number) and then calls that type's own parse method, which itself cycles through the available options.
The only exception to this is the from-to number placeholder that has the %formatter_number_from:<time>_to:<time>_<value>% pattern, which goes against the normal pattern. It's also why option is passed.

https://codeberg.org/Andre601/Formatter-Expansion/src/branch/master/src/main/java/com/andre601/formatterexpansion/FormatterExpansion.java#L74-L77
https://codeberg.org/Andre601/Formatter-Expansion/src/branch/master/src/main/java/com/andre601/formatterexpansion/formatters/number/NumberFormatter.java#L30-L42

river solstice
proud pebble
#

lets say i have an array with a size of 10, and i have a counter that keeps track of the current loop iteration, if i want to use the number as an offset for which part of thr array to start on and to loop through the entire list, could i do counter & 10

sterile hinge
#

I don't understand what you're describing but it doesn't sound like you want a bitwise and

proud pebble
#

i believe that would the force whatever value is inputted to show up as a range between 0 and 9

sterile hinge
#

no

#

or well, kind of, but not the full range

proud pebble
#

like if the number was 10 for example, it would become 0

sterile hinge
#

1 & 10 is 0 for example

#

you want modulo if you just want to wrap around at 10

proud pebble
#

i dont, just want it to range between 0 and 9 since the array size is 10

icy shadow
#

modulo

sterile hinge
#

that sounds like you want to wrap around 10

proud pebble
#

i just wanted to use whatever value the counter currently is to get the placement in the list but wanted it to wrap around

icy shadow
#

yes that is literally what modulo does

proud pebble
#

ive seen the bitwise and used to convert BlockPos to the relative block position in chunk section

sterile hinge
#

yes, but that only works in cases of n = 2^m, then you can write value & (n - 1)

#

in that case the lower m bits are all set to 1 so you cut off everything above

proud pebble
#

ic so the bitwise works for anything that would be a power of 2 and for everything else use modulo

sterile hinge
#

there is one more subtle difference: negative values

#

& in such case works like Math.floorMod

proud pebble
#

afaik the counter should never been a negative number so thats not a massive issue

sterile hinge
#

yeah if it overflows you probably have other issues

proud pebble
#

i dont think the counter should ever overflow, cus its just being used for an inventory animation

#

the array is just for chest inventory positions going in a circle on the outer edges in a 5x5 grid

#

tho thats an array of 16 ints rather then 10

#

i wanted those slots to change to the itemstacks that were in the slots behind it and i thought of looping through the array of positions + the current counter as an offset but that value should wrap around,
0,1,2,3,4
1,2,3,4,0
2,3,4,0,1
etc

#

ill just use modulo

#

i wouldve just tested it to see if it gave the results i wanted, just not at home to test it and was wondering if the method before wouldve worked for non ^2 bitwise values

spiral prairie
#

How would I add attributes to a chestplate for example, and make it only for when on body and how would i remove the attributes later?

cobalt copper
#

Hello, I'd like to register an ecloud account

#

"Registration is currently locked. If you feel it is necessary to create an account, please join our discord and get in touch with us."

proud pebble
#

if the player is banned forever, you could just put the value or date as -1, and then check if the banned player's date is is equal to or below -1 and then just not do it

#

also if no time is specified you could automatically banned them for time -1 which is forever

#

its also possible that LocalDateTime.of is just returning an invalid number due to how its saved

grizzled pulsar
#

Hello, As a web developer, if there anyone need website just dm me

river solstice
#

yeah dont crosspost blud

spiral mural
#

could someone explain how to setup async hikaricp in my project? do I async the queries or the connection pools? and do I close each connection or how do I do that properly?

river solstice
#

google

dense drift
#

iirc you use it with try-with-resources

fair oyster
#

how i can auto tab complete when i try to use
/papi parse -null %test%

#

anyone can sugestion

stable topaz
#

Question; To create custom items that will be use to interact with entitys (Ex: Cow food) is it better to use inheritance from ItemStack or just use the customize the MetaData

#

Or is there any better way to create custom items?

proud pebble
#

i personally just use nms to set nbt manually, but pdc does basically the same thing

silent ibex
#

Deluxe menus have support with MMOITEMS?
If yes how can i set a MMOItems item on them?

molten venture
#

Can anyone explain me whats the difference between LongOpenHashSet(); and LongArraySet; ?

formal crane
#

Does anyone know what versions triumph gui supports?

icy shadow
somber gale
#

Does someone know if Path.resolve(String) in Java is case-sensitive or if it would find anything that matches the provided path?
Only thing I found so far is, that File stuff can be case-sensitive, but it depends on the OS (i.e. on Windows it's case-insensitive but on Linux it is case-sensitive), so I'm not sure here...

If it is case-sensitive... Is there a way to make it ignore case? I want to resolve the path of a plugin folder, but on velocity are plugin-folders lowercased, so if it is case-sensitive and there is no way to ignore it, I would need to make a separate check just for that....

minor summit
#

why not get the plugin folder from the platform instead of manually resolving to it?

#

getDataFolder on bukkit/bungee, inject the path on velocity etc

dark garnet
#

why is it screaming at me

// Register WorldGuard flag
try {
    final WorldGuard instance = WorldGuard.getInstance();
    final StateFlag flag = new StateFlag("limited-lives", true);
    instance.getFlagRegistry().register(flag);
    worldGuard = new WorldGuardObjects(WorldGuardPlugin.inst(), instance.getPlatform().getRegionContainer(), flag);
} catch (final NoClassDefFoundError ignored) {
    // Ignored
} catch (final RuntimeException e) {
    log(Level.WARNING, "&cFailed to register WorldGuard flag!");
}
```error: https://paste.srnyx.com/otekovirag.sql
i dont have worldguard installed, it shouldnt error tho (dont want to require worldguard)
#

btw i never even use the Flag class, only StateFlag (but StateFlag does extend Flag)

void orchid
# dark garnet why is it screaming at me ```java // Register WorldGuard flag try { final Wo...

Because you're referring to something that does not exist, which is all Worldguard related code. If I am not mistaken, ClassNotFoundException will immediately be thrown once, whatever the class that code resides in, is loaded. It's not even reaching that code you linked, it's failing due to the imports which isn't available in the classpath (hence why you couldn't catch it). What you could do instead is relocate Worldguard-related code elsewhere, and only refer to that new class when you verified that Worldguard is available

dark garnet
#

i thought they didnt FLOOSH

void orchid
dark garnet
#

just removed the imports and did this instead:

// Register WorldGuard flag
try {
    final com.sk89q.worldguard.WorldGuard instance = com.sk89q.worldguard.WorldGuard.getInstance();
    final com.sk89q.worldguard.protection.flags.StateFlag flag = new com.sk89q.worldguard.protection.flags.StateFlag("limited-lives", true);
    instance.getFlagRegistry().register(flag);
    worldGuard = new WorldGuardObjects(com.sk89q.worldguard.bukkit.WorldGuardPlugin.inst(), instance.getPlatform().getRegionContainer(), flag);
} catch (final NoClassDefFoundError ignored) {
    // Ignored
} catch (final RuntimeException e) {
    log(Level.WARNING, "&cFailed to register WorldGuard flag!");
}
```still getting the same error tho
void orchid
#

you're still referring to something that is not available

dark garnet
#

then it'd throw NoClassDefFoundError and be ignored

void orchid
#

no, it would only do that if an error occurred due to that code being executed

dark garnet
#

also yeah imports dont cause exceptions, i have the same sort of thing in my api

void orchid
#

I don't have a deep understanding of how class loading works, but I did give you the solution

dark garnet
#

also weird how it says its cause of the Flag class when WorldGuard comes before it

void orchid
#

It's actually pointing to PluginClassLoader#loadClass

dark garnet
#

why is it failing when it tries to load the class?!

void orchid
#

wait what

dark garnet
#

i think i know

#

and its the most

#

obvious thing

#

nope nvm i lied

#

this works:

try {
    final WorldGuard instance = WorldGuard.getInstance();
    final StateFlag flag = new StateFlag("limited-lives", true);
    //instance.getFlagRegistry().register(flag);
    worldGuard = new WorldGuardObjects(WorldGuardPlugin.inst(), instance.getPlatform().getRegionContainer(), flag);
} catch (final NoClassDefFoundError ignored) {
    // Ignored
} catch (final RuntimeException e) {
    log(Level.WARNING, "&cFailed to register WorldGuard flag!");
}
#

FlagRegistry.register(StateFlag) must be throwing it

void orchid
#

You have WorldGuard installed?

dark garnet
#

no

void orchid
#

interesting

dark garnet
#

so i have no idea how its getting passed the first 2 lines

#

actually it isnt even

#

cause i added debug msgs before the try-catch and they werent logged

void orchid
#

ahhh

dark garnet
void orchid
#

Thanks! I would still recommend you to give my solution a try, it should work in your case

dark garnet
#

i dont think i can

#

the flag has to be registered before worldguard loads

#

Registering has to be done before WorldGuard is enabled. Thus, it is highly recommended that you register when your plugin loads. After WorldGuard is enabled, the FlagRegistry is locked and no new flags can be registered.

void orchid
#

There's an onLoad method, and you could use Bukkit.getPluginManager().getPlugin("WorldEdit") != null to check whether the plugin is present on the server

dark garnet
void orchid
dark garnet
#

Checks if the given plugin is loaded and returns it when applicable

#

hmmm

#

ill try it

dark garnet
#

think that may be the solution 🤞

void orchid
#

Yeah

dusky harness
dark garnet
# dusky harness *btw* I'm pretty sure it'd be ClassNotFoundException, and NoClassDefFoundError i...

NoClassDefFoundError:

Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.
The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.

dusky harness
#

then theres also like MethodNotFoundException

dark garnet
#

ClassNotFoundException:

Thrown when an application tries to load in a class through its string name using:

  • The forName method in class Class.
  • The findSystemClass method in class ClassLoader.
  • The loadClass method in class ClassLoader.
dusky harness
dusky harness
#

haven't looked at your error either yet

#

just wanted to point it out in case

dark garnet
#

(it also said it couldnt throw ClassNotFoundException)

dusky harness
#

¯_(ツ)_/¯

dark garnet
#

i removed anyways, dont need if im checking if worldguard is installed

#

omg...

#

im still getting the error?!?!?

#

literally hate this thing

#
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) try {
    final WorldGuard instance = WorldGuard.getInstance();
    final StateFlag flag = new StateFlag("limited-lives", true);
    instance.getFlagRegistry().register(flag);
    worldGuard = new WorldGuardObjects(WorldGuardPlugin.inst(), instance.getPlatform().getRegionContainer(), flag);
} catch (final RuntimeException e) {
    log(Level.WARNING, "&cFailed to register WorldGuard flag!");
}
void orchid
#

you're still referring to something that is not available... You need to move that code to a separate class as I pointed out earlier

dusky harness
#

imports shouldn't cause errors though

#

i thought

dark garnet
#

they dont but hes saying the code

dusky harness
#

anyways i gtg i cant get distracted by discord help

dark garnet
#

i do a similar thing with placeholderapi in my api:

papiInstalled = Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI");
if (papiInstalled) {
    final PlaceholderExpansion expansion = options.registrationOptions.getPapiExpansionToRegister();
    if (expansion != null) expansion.register();
}```
minor summit
#

class loading is not as simple as it seems, consider doing something like

if (isPluginEnabled("WorldGuard")) {
  MyWorldGuardHook.init();
}

or whatever, but moving that logic into another class

dark garnet
#

it worked

void orchid
#

I keep telling you that but for some reason it wasn't working. Glad it worked out either way

sullen acorn
#

So i have a scoreboard that is enabled with the command /sb, how can i toggle it? So if it's enabled then /sb will disable and vice versa?

dusky harness
sullen acorn
#

coding i think

dusky harness
#

You think? 🤨

sullen acorn
#

what's the difference

dusky harness
#

What's the plugin name

sullen acorn
#

mzxcraft

#

it's the main plugin for my minecraft server

sullen acorn
#

i just understood what you mean

dusky harness
#

Did you code it? Or buy it/download it from somewhere

sullen acorn
dusky harness
#

Ohh ok

sullen acorn
#

I also don't know the differnce lol

dusky harness
#

OK either way you'll need a boolean variable to store whether the scoreboard is currently being shown

sullen acorn
#

k

sullen acorn
#

So I have made a custom scoreboard, although i want it to update every set period of time, I've tried using the BukkitScheduler in the onEnable() part of the main file, but i have no idea how to update the scoreboard for players, can someone help?

        scoreboardUpdate.scheduleSyncRepeatingTask(this, new Runnable() {
            @Override
            public void run() {
                
            }
        }, 0L, 60L);```
proud pebble
#

so ig recreate the scoreboard object, then player.setScoreboard(scoreboard)

warm steppe
#

Use fastboard

#

It supports adventure

serene cairn
#

how can i display this but with a amount of 1 while forcing the gui to show the count number on the bottom right of the item?

so like


1

(gray boxes is the icon of chest for example)

#

this is due to me attempting to make a duel system in 1-2 weeks (going VERY well)

and i've started the queueing system

grim oasis
serene cairn
#

nevermind i was wrong

#

i'm dumb i thought it said 1 instead of 2

#

clearly i need to get my eyes checked

worn jasper
#

Is is possible to have a placeholder in my plugin, return another placeholder? Will that placeholder then be parsed by a plugin like TAB?

#

For context, I want to make it so if X data isn't present, it will default to a placeholder of another plugin.

worn jasper
river solstice
#

why return a placeholder and not just parse it and return the value yourself?

worn jasper
atomic trail
#

Can I not use this API? It's made in Java 16 (class version 60) and my project is in java 8 (class version 52). Yes I know java 8 is bad, don't question it please

#

What I'm asking is, is it possible to use the API anyway while having the project Java version as 8?

spiral prairie
#

no

#

i mean there probably is a way but

#

there is always a way to do something but if it makes sense to do it is the other question

atomic trail
#

Ugh annoying

#

Well thank you! :))

stable topaz
#

Hello, question: Is there a reason or a way to avoid "'\t" in Bukkit to show a weird character
I need to tabulate a formatted string, but its showing me a weird character

dusky harness
stable topaz
#

I need a fixed tab between 2 string

dusky harness
#

why not fixed spaces?
the client doesn't know how to render the tab

stable topaz
#

For a custom name, i need all to be fixed and alligned independent of the lenght

dusky harness
#

but whats that have to do with tabs?

stable topaz
#

Does it not work like that?

#

Like intead of
Hunger: 23
Current Health: 30
Use
Hunger: 23
Current Health: 30

dusky harness
#

I don't think that tabs can do that

stable topaz
#

"%s%-20s" This doesnt do anything either

brazen rain
#

Anybody here good with the FAWE API? I know a little bit of Java and Kotlin, but I don't know much, so I have to hire a custom dev for each plugin I need for my server.

I got a custom plugin developed that makes rounds possible on my server, with a system for different lobbies running at the same time that are all in the same world. To copy the same map every time, FastAsyncWorldEdit is used to copy and paste each "lobby" of sorts in its own plot. The problem is, when these lobbies are created, the servers TPS drops from how big some of the maps are.

I told the dev about this issue and they said that they are not good with the FAWE API and don't know any other easy way to copy the builds over without lag. Any suggestions on this issue? I've thought up a system where the lobbies build is copied in chunks and pasted that way, but I don't know if thats even possible, does anybody know a way this kind of system would be possible without lag?

dusky harness
#

actually when I did it, I think I did the opposite - removing blocks instead of adding/copying

#

but same idea

dusky harness
# brazen rain Alright, thanks.

also note that I haven't used WorldEdit API much, and haven't used FAWE api at all, so I don't know if there's anything built-in etc

#

but for ex even if you do 2 ticks instead of 1 tick (the time difference is not noticeable), you should basically get 2x less lag (although it'd last for 2x as long)

forest jay
#

I have a bit of experiance in it

#

it is pretty similar to regular World Edit

brazen rain
forest jay
#

I don't know why it would be that laggy, ask the developer to go to their discord and ask for help

dusky harness
#

I would follow a guided example/tutorial first

#

but you need a { instead of a ;

#

ok emily

#

and things that don't have {} usually have ;

light pendant
#

you should read a book about basic java

spiral prairie
#

I don't think that's possible with papi expansions

formal crane
#

what does it mean exactly? Like can't i use it anymore?

icy shadow
#

if you're implementing it, thats bad