#development
1 messages · Page 64 of 1
^ whenComplete is not necessarily a terminal operation
(albeit it should)
Why just keep throwing it further down the chain if it can't be printed?
Except for standard logger ofc
you are meant to print it
or, well, more appropriately, handle it, if printing it is your way of handling it, then print it
"should never happen" i've heard that one before
Yeah lol, but as in there shouldn't be anything to handle it, it's just an error in the code
Oh lol https://paste.helpch.at/zifuredite.rb yeah that worked
🎉
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
Forgot to reupload the config file
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.
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
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
?help
» Give the helpers some details
» Ask suitable questions
» Be polite
» Wait
I want to send a photo about my curiosity
?imgur
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.
/upload
pump
i mean bump
I'm curious, what command do I use to make my npc look like the photo with those boxes?
wrong chat please go to #general-plugins / #1007620980627230730
Okay
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
Full error: https://paste.helpch.at/patexenito.less
This only happens when the database is empty and just the table has been setup
what does the initializer do?
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
how can I prevent water from destroying redstone while still allowing it to flow? when i cancel the BlockFromToEvent the water stops flowing
U can’t
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
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...
.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
Ohhh yeah that’s a good idea! Will test when home and update you if it works :))
seem like this would only happen if initializer was closing the statement or openConnection closes the connection
double check both of those dont happen
How would I check that? Not sure where to look, in the lambda implementation?
The weird thing is that it only happens after the database file has been created and the table is empty though
Well yeah lol it’s your code
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
can u show the code of the lambda
Oh my phone rn so a bit difficult but this should show it https://paste.helpch.at/agodogetak.js
The resultset is closed when using getInt
It’s already closed before using rs.next
what if you comment out initializer.consume(statement)
Yeah, that seems to work. Tho now I have exceptions which from what I understand are caused by the library using outdated endpoints... xD
Will try when I get home, thanks :))
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,
r u a bot?
its not java
also sprinig is java framework
;l
what lol
that is Java, that's Spring's JDBC stuff
Spring Data iirc, or JPA or something
Wtf tony?
var
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?
is PAPI is an opensource?
PAPI = PlaceholderAPI
I think yeah, i mean how can i add myself expansions 😉
did u even learn to code?
yeah
just wondering
because u dont need papi opensource
to make xpansions
expansions
i read the wiki, i think i have to add code in the package at.helpch.placeholderapi.example.expansions;
https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/PlaceholderExpansion#onrequestofflineplayer-string
There you see what i have read
yeah
and how would you add this to your project?
i ask u questions so u can answer on them
so you think, this is the class i have to add in my project and not in the papi project?
in my project maven
add PAPI to pom.xml
ahh okayyy, now i understand how thats works
then update it gonna download
i dont need to add my expansion into papi
ahhh lollll
PAPI just passes strings
between plugins
like vault passes a value between plugins
okayyy, thank you so muchhhhhhh, its so early in the morning
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
thankssss
funnily enough var is actually in Java, but you're right it is Kotlin lol
i didn't even see it, but it does work basically the same with both
is there some one expert on mcmmo factions can you help me setup please dm me
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())
Doesn't that already return the base64? .getPlayerProfile().getTextures().getSkin()
It's not valid. I can't convert it to playerhead
Ah it gets the URL of the skin.
GetSkin return url?
yes
yes, if you want to read the docs first
You can get the base64 from GameProfile.
I already know that but how?
((CraftPlayer) player).getHandle().getProfile()
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
What query are you actually running?
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
This is the error if that helps https://paste.helpch.at/jalolareqo.less
It does create the default data, and when the player joins next time it's all good (no errors)
I'm a unique Discord bot created especially for HelpChat.
I was created and I'm maintained by @robust crow with support from the Staff team.
I'm created in Javascript using Discord.JS
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.
Any idea @icy shadow ?
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
its kotlin, a much it compiles to java, and is arguably better
um actually it compiles to jvm bytecode 🤓
and kotlin can inerop with any jvm language?
and spring has additional support for kotlin
that's fine, allOf is a straight up "I just want a future that completes when all these complete", thenCombine is for processing (and combining) the futures' results which for your case it doesn't seem relevqnt
Okay
For some reason it fixed it if I run https://paste.helpch.at/omobapeciy.js one tick after https://paste.helpch.at/cucipacada.kotlin but I've got no clue why
Before it ran on the same tick
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?
I mean idk why you don't use a datasource
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();
if that exists, you can use it I guess
Yeah well nvm using datasource didnt fix it lol
But it's definitely something to do with opening two connections at the same time or something
Not sure if that's race condition or not
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
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
Hello Tony, Could you please read my dm. Thanks
when looping through #getContents(), how would I be able to check if it was offhand or not? since it returns an itemstack
DocDex is currently under maintenance.
big bruh
doesn't it return an array?
If so, then you can use the i probably... somehow
¯_(ツ)_/¯
question is, is that order by slot?
if so, what slot even is offhand lmao
should be yeah
this is still happening to me 
¯_(ツ)_/¯
What is implementationRelocate?
Why not just use shadowJar, and have
build {
dependsOn(shadowJar)
}
What's the benefit of that over shadowJar
he is using shadow
it is shadowjar
it just automatically sets the relocation
^
Why?
so that you don't have to manually add the relocation line
good idea tbh
forgot to copy it
smh
thanks for the reminder 👍
:(
hey u copied me too :))
make sure to copy both as first one is for project implementations and bottom is for strings
wdym?
first: implementationRelocate(project, project(":AnnoyingAPI", "shadow"), ...)
second: implementationRelocate(project, "xyz.srnyx:java-utilities:1.0.0", ...)
@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)
When you use it how do you build your project?
gradle build publishToMavenLocal
Can you send an example project where you've used it?
used what?
It would be less work to just spin your own reposilite repo on a cheap vps than trying to work with shitpack
Try adding dependsOn(shadowJar)
Also, why are you publishing the example plugin?
its not being published
just built at same time
Why not just exclude it?
how 
doesnt fix
Can you give me a TLDR of the issue?
Building their example-plugin module causes an error because it can’t find classes from the API
Try removing it from settings.gradle.kts
example-plugin? if so, yea it builds
So it’s working now?
well its not building the example plugin now
That’s what removing it was for lol
i know but i still want it to be built 
What happens when you build it individually?
api works, example plugin doesnt
Can you try with regular shadow jar just to see whether it has anything to do with that
nope same issue
with:
dependencies {
implementation(project(":AnnoyingAPI", "shadow"))
}
```and `gradle shadowJar`
this is when it stopped working btw https://srnyx.needs.rest/chrome_wz4v6Dq2Oh.png
Idk what the issue is then and I’m on my phone now so it’s hard for me to look
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
But why would they prevent compile
so to still use implementationRelocate i just have to do implementationRelocate(project, "xyz.srnyx:java-utilities:1.0.0", relocateFrom = "xyz.srnyx.javautilities") instead
it isnt
Oh
example-plugin just cant find annoyingapi
import xyz.srnyx.annoyingapi.AnnoyingCooldown;
should actually be:
import xyz.srnyx.annoyingapi.libs.srnyx.AnnoyingCooldown;
cause its relocating xyz.srnyx to xyz.srnyx.annoyingapi.libs.srnyx
But why is it relocating in source?
...
no this is in the example-plugin
Idk
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?
I made a new spigot wiki article today that is totally beyond my mind to maintain
just wanted to send it here, every contribution is welcome. but please feel free to read the code of conduct https://www.spigotmc.org/wiki/spigot-api-changelog/?noRedirect=1
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
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?
If you don't explicitly state the plugin supports bedrock/geyser, they have no right for refund imo
They shouldn't
yeah but I'd rather give back 5,99€ than getting a 1 star review haha
that plugin is exclusively is related bedrock issues
I think there's no rule gainst me linking a spigotmc link right?
No idea
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
Tbh maybe add it in caps and bold into the plugin description
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 🙂
I dont give a shit ab bedrock, easy
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.
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.
If You are using triumph-gui:
ItemStack skull = ItemBuilder.skull().texture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzU3NDcwMTBkODRhYTU2NDgzYjc1ZjYyNDNkOTRmMzRjNTM0NjAzNTg0YjJjYzY4YTQ1YmYzNjU4NDAxMDVmZCJ9fX0=").build();
not using any api's
ok keep reinventing the wheel 👍 👍 👍
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
wut? why would I use a GUI API intended for something else to do one thing? makes no sense at all.
cuz
bukkit inventory api 👎
(most) gui libraries 👍
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
alr! thanks 🙂 am hooking headdatase as I use it for a diff thing on the server ^^
https://github.com/triumphteam/triumph-gui look at SkullItemBuilder - you need to use mojang's auth lib
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...
you have to use an array (cuz morphia is shit apparently) https://github.com/MorphiaOrg/morphia/blob/c2035ed0d9efee508731209d867fff6c2d903eae/core/src/main/java/dev/morphia/mapping/codec/MorphiaTypesCodecProvider.java#L43-L49
why not use mongos object mapper that comes with the java drivers
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
Sparky called you monkeys
wrong person pal
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.
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 (?, ?)
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?
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?
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);
}
what units are those?
Hashrates
This is what I use https://stackoverflow.com/questions/4753251/how-to-go-about-formatting-1200-to-1-2k-in-java
👍 will look into it in a bit thx.
CompactNumberFormat moment
TRUE
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!
except for the fact it isn't thread safe which is absolute bonkers
Is it a costly process?
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
I don't remember setting a pattern lol
oh I am very silly, I put them in the compact patterns 
ah that's what the javadoc show lmao
Seems like a lot more then just the if statements
it, uh, it isn't ??
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
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
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<...>
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'.
[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
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
If you‘re fine with that rounding mode, yeah
But I don’t see how this is simpler than the proper tool
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?
In the one you showed its looping and has more lines. So in my opinion, mine is the cleaner option.
The loop isn’t relevant for the formatting itself, you can simply hardcode it or whatever
And now count arithmetic operations and branching in the code actually relevant for the formatting
Well for simplicity my code did exactly what I wanted. But for future projects I'll keep CompactNumberFormat in mind.
ok CompactNumberFormat is very cool actually
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;
}
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
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
leftOvers.isEmpty()
right, will change that
nitpicker

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
no
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
That sounds like you installed geyser on your server but not on the proxy
well fixed that thankyou
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
Does anyone know how to cancel a task timer inside of the task timer itself?
#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)
I don't know what the id is and whenever I assign the runnable to int id or BukkitRunnable or anything it claims I cannot because it returns void
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
You can not reference the variable you assign a value to in that function
BukkitTask task = null;
task = Bukkit.getScheduler().scheduleTaskTimer(() -> {
task.cancel();
}, 0, 1);
``` should work
but the Consumer<BukkitTask> method clears
Variable used in lambda expression should be final or effectively final
🤓
Looking for dev can help me setup my server while im learning
No access
Because you are service muted
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 )
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
I see
uhm am I the only one confused on how adding groups to an user in lp works?
yes
lp user (user) permission set group.(name of group)
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 🤓
with the api..........
I am probably blind lol, ty
i did not see the channel name mb lol
I just make it into a method at that point lol
BukkitTask task = null;
public void runTask() {
task = Bukkit.getScheduler().scheduleTaskTimer(() -> {
task.cancel();
}, 0, 1);
}
I wouldn't consider that great code tbh
the scheduling api from folia is far better there imo
or make a class that extends BukkitTask and then you can call cancel() in run()
What Yapperyapps mentioned first
Right?
ye but perhaps not an anonymous class xD
consumer method zzz
u should be able to post images
or is this a some kind of a bug
¯_(ツ)_/¯
send it
cant
lol xd
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
easy, stop using mysql
what do you suggest then
Mariadb over mysql
Shouldn't this only insert if uuid is missing? "INSERT OR IGNORE INTO " + TABLE_NAME + "(uuid, active_chat) VALUES(?, ?)"
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.
Postgres
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?
I dont see you handling any errors, if the request couldn't be completed then the future is empty, isn't it?
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
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?
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
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.
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
There are also int lists. Like for max player count
put it all into a class then
// or write class version if necessary
record SLPConfig(List<List<String>> motds, List<Integer> maxPlayerCountEtc){}```
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
does your debug print the Granting kit items to player for
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
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
true i didnt even realize that 😂
i just noticed
?
in console?
yes
no i dont get that message
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
👍 tysm
I changed it around and still nothing
Its calling future.complete, and it is completing, but the listener on that doesnt run, the whenComplete
hey, I'm thinking about Thread.wait();
how do you know for sure it's completing? also pls show current code
I found the initial issue, its good now
just for experience xd
why not just do return response.thenApply(HttpResponse::body).thenApply(body -> all the stuff) instead of creating a new future
might not fix the issue but certainly simpler
For some people its easier typing what is in there Head at the moment, I do it to 😄
well sure, but you can still make improvements
fair point
amount: X
ty
also #general-plugins
oh srr
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
@umbral stone (?<!"[^"]),(?![^"]")
thankyou!!
regex is never the best way to do something tbh
Hand writing the code is basically always faster and often easier to understand
any spring related minecraft project ideas?
wanna learn the framework
i just need some examples to make sense of it
challenge accepted
Which are the other 2? 🤣
Spigot and what else
spigot, hangar, the hypothetical new one
You may come to regret that
🤷 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.
Hehehe
It would still be fun
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)
Looking for feedback on this PR. Especially regarding Configurate handling as I'm not sure if that is the bes solution here....
Having issues with GSON right now. (last 2 methods of KitsFile)
Error:
https://paste.helpch.at/ecazobilut.scss
Code:
https://paste.helpch.at/vesekibeqi.java KitsFile.java
Is there still an API for namemc or something? You could maybe cache the latest name changes and pick a random one or something
Or look for massive lists of old names, I’m sure they’re out there somewhere
They're looking for one that can send like the skin change packets
I think
Since namemc api was already mentioned
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
oh what-
you gotta be specific
Ahh how would searching the name give away that they’re a disguise, since legit players are on there too
I'm not sure if that's possible
there's no official way though
and because of ratelimits you might not even be able to spam mojang api with random usernames 🥲
Me trying to find a new name for my account
Maybe you could go for “popular skins” and then somehow query for players using those skins
namemc seems to use strict cloudflare though so you prob can't use that
Hmm okay, thanks
Bump
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
what should I do then?
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
not even base64, just save it as a blob
oh or that
how long/big (in terms of number of char) can a base64 serialization of hashmap<integer, itemstack> with like atleast 40 items that all have like 3 enchantments?
just a rough guess
^ better if you are using paper
there is no reason to use base64 if the data store supports saving raw bytes directly
alright
compileOnly("me.clip:placeholderapi:2.11.4")
No erros, but can't find me.clip package xD
Can't import anything
Did you reload gradle after adding that
Of course, I'm not a newbie. Tried also to reload all dependencies
Did you add the repo?
Don't ask me why, deleting gradle cache fixed it
Similar things sometimes happen to me too, I change the version for example make it 2.11.0 reload gradle, change again and reload again
Really can't understand how gradle has these kind of problems
the IDE couldn't find it, or gradle itself wouldn't compile?
because IJ itself choking up sometimes is pretty normal unfortunately
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
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
it gets wiped on server closure, so you dont have to get rid of it, even if it wasnt temporary, more then likely spigot wouldve made a patch to clear all custom recipes from the game before hand
oh thank you 🙂
i dont have enough knowledge but you may need to merge them manually because of conflicts
if you find someone to do something like that you can offer players merged ones
just an idea if you fail
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...
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!
Just use names at this point
using DisplayNames or just normal Names?
(Also don't mind my spaghetti code, I'm still relatively new)
I think you should call .toString then check equality. You are checking if a UUID object equals a String object which is false
np
Just checked and the mongodb driver is def. in the jar, so no idea what's happening, if anyone has any ideas, quite desperate rn
ah lol didnt catch my eye
though the IDE should definitely show a warning there
it does
yeah so since this is pretty niche you could use player names instead and they’d be easier to read
Try to set all your names as constants so it’s a bit cleaner
What’s the point in starting a repeating task every time a player joins?
OH FUCK
it’s not any different so you could maybe just make 1 task when your plugin starts up
lol chill
I didn't mean to do it on join LOL
Mis clicked mb
yeah might wanna get rid of that
just a little suggestion, use statics for the uuids so that u know who each one is 🙃
yeah I said that up
o
but then again
I have variables that use their names
like short versions of their names
it would be all caps
gotta get faster
😠
no but if you don’t want spaghetti code then yes
I want spaghet
u can just create a player variable at the beginning of the event (would make code cleaner too)
your choice truly
Theres a lot that can be done tbh
I would personally move most of it in a config
💀
same, but if its not for production it doesnt rly matter
yeah true
please remember that this is for a private smp
ye
that I'm hosting for my friends LOL
make an abstract object hierarchy inheritance structure for Minecraft effect plugin
i would 100% create a player and uuid variable
Now.
cause every time u check the uuid ur re-getting the player & their uuid
also u could store the potion effects as constants
that’d probably be ugly I don’t think he reuses them much anyway
well they're being re-used every 10 ticks no?
i thought the repeating task was correct but not on join
we can just wait for new correct code ig
https://github.com/dkim19375/dkim19375JDAUtils/actions/runs/6292601864/job/17082167874
Anyone know what this error means?
Unable to make progress running work. The following items are queued for execution but none of them can be started:
...
There are a bunch of deprecated stuff in my code, but I don't think that deprecations are able to stop compilation
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
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
Since this is mainly a spigot server, I would try to ask in the forge server
or you can try asking here as well
oh i didnt know there was a forge server do you happen to have the link?
Official MinecraftForge Discord | 1796 members
thank you
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.)
i was gonna say to ask wherever xseries support is given, but u already have 🙃
the top one is correct and the bottom is incorrect right?
and how did u temporarily fix it?
hey no advertising
yes
by just using regular itemstacks and not the XItemStack system
i'd look into the source code of XSeries to see where it applies the extra part and such
and double-check javadocs
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
because it can't stack otherwise, i need the items to be exactly the same as before
Use your own (de)serialization logic then
why cant i post pictures
You won't be able to upload images here directly to avoid spam, so please use https://imgur.com/upload or similar service to upload images/screenshots.
right
so i am coding a plugin that replaces netherrack in the nether with bedrock once broken, although i dont know how to actually drop the netherrack, can anoyone help.
https://cdn.discordapp.com/attachments/628666725847793684/1158106548917248110/image.png?ex=651b0a45&is=6519b8c5&hm=39759b973de00dcd585843e5cd165dbb2a4804cb991aefc7695e297cf6f1684a&
If you want the netherrack to drop then either stop cancelling the event or manually drop netherrack using Word#dropItemNaturally
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. ?
contains on a list isn't a great idea to begin with
but if all locations are block coordinates, it might work
the real question is what exactly the list of locations are doing?
like why a list of locations
it's going to open a gui. sort of like an interactive block in spawn @proud pebble. am making a custom cooking thing
just to speed it up a bit and not check every block of these cooking stations over the entire world, you could save them per chunk, then check the loaded stations of that chunk
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.
ah, then if theres only gunna be a couple you dont have to do the per chunk thing
ok, but are there better ways of doing this simply? rather than checking every? is there a different event or method?
not really
simply looping through the list and finding one that matches works pretty well
which is exactly what contains does
keep in mind that "contains" will check yaw/pitch too
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
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?
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
Get enchants, remove using removeEnchantment
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);
weird
You don't even need meta
yeah i can use regular getEnchantmants
Chat GPT answer
tf does removeEnchant do if its immutable, just overwrite it?
No the get Enchantments map is immutable so that there doesn't have to be a custom map
ah
It's just a regular HashMap (or similar)
Doesn't send packets or anything (to clarify what I meant by "custom map")
i'll go with itemStack.getEnchantments().keySet().forEach(itemStack::removeEnchantment);
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));
}
a user
Have you tested it yourself? Or unable to right now
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
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
I think it's more the toLowercase?
No what I mean is that if there's only 1 "param" (ex testing) then it'll return TESTING
Makes no sense because I use substring
before substring - the very first condition
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
That's because the placeholder is either %formatter_text_capitalize_<text>% or %formatter_text_capitalize_!strict!_<text>%
I made it like that on purpose
ah, then the values array is either empty {}, or a single string {"!strict!"}
maybe i misunderstand
It shouldn't be empty.... Actually, should add a safety check for that
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
blud just use apache commons StringUtils.capitalize 
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
I don't understand what you're describing but it doesn't sound like you want a bitwise and
i believe that would the force whatever value is inputted to show up as a range between 0 and 9
like if the number was 10 for example, it would become 0
i dont, just want it to range between 0 and 9 since the array size is 10
that sounds like you want to wrap around 10
i just wanted to use whatever value the counter currently is to get the placement in the list but wanted it to wrap around
yes that is literally what modulo does
ive seen the bitwise and used to convert BlockPos to the relative block position in chunk section
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
ic so the bitwise works for anything that would be a power of 2 and for everything else use modulo
there is one more subtle difference: negative values
& in such case works like Math.floorMod
afaik the counter should never been a negative number so thats not a massive issue
yeah if it overflows you probably have other issues
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
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?
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."
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
Hello, As a web developer, if there anyone need website just dm me
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?
iirc you use it with try-with-resources
how i can auto tab complete when i try to use
/papi parse -null %test%
anyone can sugestion
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?
if you want to set an id to the itemstack that can be used to identify it from other items of the same material, you could use persistentdatacontainers
i personally just use nms to set nbt manually, but pdc does basically the same thing
Deluxe menus have support with MMOITEMS?
If yes how can i set a MMOItems item on them?
Can anyone explain me whats the difference between LongOpenHashSet(); and LongArraySet; ?
Does anyone know what versions triumph gui supports?
Instances ... use a hash table
vs
based on a backing array
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....
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
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)
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
imports can cause that?
i thought they didnt 
I added more info in my edit, but yes. If you're pointing to a class that is not available on runtime, it should from my understanding
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
you're still referring to something that is not available
then it'd throw NoClassDefFoundError and be ignored
no, it would only do that if an error occurred due to that code being executed
also yeah imports dont cause exceptions, i have the same sort of thing in my api
I don't have a deep understanding of how class loading works, but I did give you the solution
but it is due to that code, no?
it tries to get the WorldGuard class, if it doesnt exist, it should throw NoClassDefFoundError which is then caught by the try-catch, and ignored, which stops the rest of the code in that try-catch from executing
also weird how it says its cause of the Flag class when WorldGuard comes before it
it is due to the code, but it didn't get the chance to execute because it's failing immediately once an attempt is made to load the class. If you were right, then the error would have a reference to that code you linked, but it doesn't. Check your stacktrace
It's actually pointing to PluginClassLoader#loadClass
just commented out the flag lines, so it's just this:
try {
final WorldGuard instance = WorldGuard.getInstance();
} catch (final NoClassDefFoundError ignored) {
// Ignored
} catch (final RuntimeException e) {
log(Level.WARNING, "&cFailed to register WorldGuard flag!");
}
```error doesnt occur, this doesnt make sense 😭
why is it failing when it tries to load the class?!
wait what
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
You have WorldGuard installed?
no
interesting
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
ahhh
heres all the code btw: https://github.com/srnyx/limited-lives/blob/master/src/main/java/xyz/srnyx/limitedlives/LimitedLives.java
the catches r different tho, and i use my api so it might be a tad confusing
Thanks! I would still recommend you to give my solution a try, it should work in your case
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.
There's an onLoad method, and you could use Bukkit.getPluginManager().getPlugin("WorldEdit") != null to check whether the plugin is present on the server
wont it only be returned if that plugin is loaded/enabled tho?
I checked, and not according to this thread: https://www.spigotmc.org/threads/how-to-check-if-a-plugin-is-installed-before-it-is-enabled.529259/
Checks if the given plugin is loaded and returns it when applicable
hmmm
ill try it
enables*
think that may be the solution 🤞
Yeah
btw
I'm pretty sure it'd be ClassNotFoundException, and NoClassDefFoundError is used for something else (not sure tho, would have to google it)
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.
then theres also like MethodNotFoundException
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.
🤷 maybe its classnotfound for reflection? would have to test, not sure
so i was using the right one
(it also said it couldnt throw ClassNotFoundException)
¯_(ツ)_/¯
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!");
}
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
they dont but hes saying the code
anyways i gtg i cant get distracted by discord help
but still it shouldnt matter
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();
}```
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
i hate java im never programming again
it worked
I keep telling you that but for some reason it wasn't working. Glad it worked out either way
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?
Is it a global scoreboard or per-player?
Also this is a coding question, not a plugin configuration question, right?
coding i think
You think? 🤨
what's the difference
What's the plugin name
ohh, yeah it's coding
i just understood what you mean
Did you code it? Or buy it/download it from somewhere
here's the code: https://pastebin.com/CXNYvgFH
Ohh ok
code
Global or per player?
I also don't know the differnce lol
OK either way you'll need a boolean variable to store whether the scoreboard is currently being shown
k
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);```
if you want it to update, you just set the scoreboard again
so ig recreate the scoreboard object, then player.setScoreboard(scoreboard)
now i've seen others do this but i've never been able to figure it out. i'm guessing it involves NMS (sending a update to the item and forcing it to show item amount)
so lets say we have an item in a chest inventory that has a amount of 2
(attachment)
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
This is a client limitation, you can't
i've literally seen others be able to do that
nevermind i was wrong
i'm dumb i thought it said 1 instead of 2
clearly i need to get my eyes checked
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.
try it and see?
Well, if I am asking, it's for a reason, literally on a train rn on my school laptop...
well, no.
you give a placeholder to TAB, it calls onRequest for your placeholder and you return another, the onRequest was already called, it wont call it again for the returned value. the plugin author would need to implement that functionality.
why return a placeholder and not just parse it and return the value yourself?
apparently it does has that functionality
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?
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
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
that's controlled client-side, why not use spaces?
I need a fixed tab between 2 string
why not fixed spaces?
the client doesn't know how to render the tab
For a custom name, i need all to be fixed and alligned independent of the lenght
but whats that have to do with tabs?
Does it not work like that?
Like intead of
Hunger: 23
Current Health: 30
Use
Hunger: 23
Current Health: 30
I don't think that tabs can do that
"%s%-20s" This doesnt do anything either
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?
what I've done in the past is generate it over a period of time instead of 1 tick
and also disable physics (ex sand won't fall) which gave pretty good results (although FAWE probably does this automatically)
actually when I did it, I think I did the opposite - removing blocks instead of adding/copying
but same idea
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)
Are you actively using the FAWE API?
I have a bit of experiance in it
it is pretty similar to regular World Edit
Yes
I don't know why it would be that laggy, ask the developer to go to their discord and ask for help
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 ;
you should read a book about basic java
I don't think that's possible with papi expansions
So i use this for my custom crafting plugin:
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/RecipeChoice.html
But then i saw this
declaration: package: org.bukkit.inventory, interface: RecipeChoice
what does it mean exactly? Like can't i use it anymore?
if you're implementing it, thats bad

