#help-development

1 messages · Page 922 of 1

worthy yarrow
#

Well at least that's a positive in your eyes 😄

echo basalt
#

no clue why I only commented that one method

#

I gotta actually document and comment shit at some point

worthy yarrow
#

I'm having fun with this project

#

I'm finally getting out of the damn slump which is nice

echo basalt
#

I barely worked yesterday woeisme gotta do shit

wet breach
#

this is true

echo basalt
#

but it's like 8am and I hate working in the morning

wet breach
#

was only going based off the limited code I saw 😛

wet breach
worthy yarrow
#

@wet breach I mean this should limit the UUID's to 2 every instansiation

#

It's like the bracket system if you will, just pairs the players that have joined, I also have yet to handle the case when no player can be matched... I'll have to give them a bye or something like that

worthy yarrow
quaint mantle
#

Hello There, There is a problem while launching my own server that is-" -Xmx8G -Xms8G -jar Server.jar 1 nogui
Error: Unable to access jarfile Server.jar"

worthy yarrow
#

Unable to access jar

worthy yarrow
quaint mantle
worthy yarrow
quaint mantle
#

ok

worthy yarrow
#

@echo basalt @lost matrix @wet breach @earnest forum thank you all for the notes ❤️

lost matrix
#

No idea what i did but ok

worthy yarrow
#

.

#

Oh also I have an idea for the countdown before the match starts, I'll use text displays to make a cool looking countdown in-between the players

dawn flower
#

is it possible to change the value of a final variable using reflection?

green prism
#

Hello, I am trying to set MongoDB's driver logging level to WARNING but this method does not seem to work anymore. This is what I've tried to far:

MongoDB Sync Driver Version = 5.0.0
Spigot Version = 1.20.4

@Override
    public boolean connect() {

        ServerApi serverApi = ServerApi.builder()
                .version(ServerApiVersion.V1)
                .build();

        String uri = this.getUri();

        MongoClientSettings settings = MongoClientSettings.builder()
                .applyConnectionString(new ConnectionString(uri))
                .serverApi(serverApi)
                .build();

        // Changing debugging level for MongoDB Driver
        Logger mongoLogger = Logger.getLogger("org.mongodb.driver");
        mongoLogger.setLevel(Level.WARNING);
        
        this.mongoClient = MongoClients.create(settings);
        this.database = mongoClient.getDatabase(uriBuilder.getDatabase());

        try {
            Bson command = new BsonDocument("ping", new BsonInt64(1));
            Document commandResult = database.runCommand(command);
            LoggerUtil.log(
                    Level.INFO,
                    LoggerUtil.LogSource.DATABASE,
                    "Pinged your deployment. You successfully connected to MongoDB!"
            );
        } catch (MongoException me) {
            LoggerUtil.log(
                    Level.SEVERE,
                    LoggerUtil.LogSource.DATABASE,
                    "Error while connecting to MongoDB: " + me.getMessage()
            );
            return false;
        }```

What am I trying to hide?
DB Connection message

[09:24:27 INFO]: [org.mongodb.driver.cluster] Adding discovered server *** to client view of cluster
[09:24:27 INFO]: [org.mongodb.driver.client] MongoClient with metadata {"application": {"name": "WidenCoins"}, "driver": {"name": "mongo-java-driver|sync", "versio...```

tardy delta
#

yes

#

why havent you tried out

dry hazel
#

you can't change a final field without egregious hacks

undone axleBOT
tardy delta
dry hazel
#

doesn't work either

#

not even the hacks work for static finals if the compiler inlines it as a constant

tardy delta
#

ok it cannot even be final

#

laughs in C

lost matrix
sullen marlin
#

Not for primitives

lost matrix
#

Yeah true. They get inlined either way.

smoky anchor
sterile flicker
lost matrix
dawn flower
#

can you store a bytearray list in a fileconfiguration

lost matrix
dawn flower
#

should i use json then, if yes what apis do i use

lost matrix
#

That would be an option

#

Gson is already bundled with spigot

dawn flower
#

alright

#

thanks

lost matrix
# dawn flower alright

One problem you will encounter here: Generics.
Solution: TypeTokens

    Gson gson = new GsonBuilder().disableHtmlEscaping().create();
    List<byte[]> list = new ArrayList<>();
    
    String json = gson.toJson(list);
    
    List<byte[]> deserialized = gson.fromJson(json, new TypeToken<List<byte[]>>(){}.getType());
dawn flower
#

k 👍

sterile flicker
#

and you talking about initPathfinder(); method?

lost matrix
#

No idea. Old versions are very different from todays.

sterile flicker
lost matrix
#

There are some resources out there that write about pathfinder goals and ai goal selectors.

smoky adder
#

Hi, how can i get the current item that player have in hand? I've tried getItemInHand and getItemInMainHand but this two method doesn't work. spigot 1.8.8

lost matrix
#

?1.8

undone axleBOT
lost matrix
#

This ancient version is highly unsupported.
However: getItemInHand() should work for this very old version.

smoky adder
#

is deprecated and doesn't get the item in hand

dawn flower
#

can you make gson use pretty json? so it isn't a nightmare for me to debug something if it isn't being properly saved

lost matrix
lost matrix
dawn flower
#

👍

green prism
#

I understand what you mean, however, I've already pasted my code

smoky adder
#

Because this ItemStack itemInHand = p.getInventory().getItemInHand();should understand the item I have in my hand and through this p.getInventory().addItem(itemInHand); he should put it in his inventory but he doesn't

#

@lost matrix

smoky adder
#

ok

drowsy helm
#

have you tried debugging any values

dawn flower
#

uh i got a tiny tiny problem, each thingi is like 28kb cuz "setPrettyPrinting" is adding a new line for each byte

lost matrix
dawn flower
#

is there a way to just turn the byte[] into a string and back to a byte[]

drowsy helm
#

yes use a TextDecoder

lost matrix
#

Sure, usually you would base64 encode this byte[]

mortal hare
#

who tf coded this at gitlab

lost matrix
drowsy helm
smoky adder
smoky anchor
#

itemInHand.setAmount(0);
p.getInventory().addItem(itemInHand);

#

What do you want that to do ?

smoky adder
#

@lost matrix sorry the message is not send to the player

lost matrix
#

And setting the amount to 0 can lead to ghost items in those old minecraft versions.

smoky adder
#

but the block placed is changed with air

#

the condition is true i think

drowsy helm
#

show the whole event handler

lost matrix
#

Then you have an exception in your console

smoky adder
#

nothing

smoky adder
lost matrix
#

Code doesnt just stop running. If you dont get a message then you either have an exception or the whole codeblock wasnt executed.

lost matrix
drowsy helm
#

what about it is bugged?

#

this just looks like a hacky way to cancel the event

lost matrix
#

Anyways 1.8 is ancient and scuffed, buoo maybe helps you out. Ill pass.

smoky adder
#

if I delete the event the block in my hand is not placed but disappears from my inventory and when I right click it appears again

smoky anchor
#

I wonder why the permission is "destroy" when you seeminly remove a block the player placed

drowsy helm
smoky adder
smoky anchor
#

so.. change the name to "modify" at least

smoky anchor
#

don't confuse ppl

lost matrix
smoky adder
#

I'm stupid there were definitely some lines that interfered with the setCancelled method before, now it works thanks for everything ahaha

ivory sleet
#

cuz else u could just use getBytes and String#new(byte[])

lost matrix
ivory sleet
#

yea, ofc you’d presuppose the source is trusted

#

but that’s somewhat same if u opt w b64 on a basic level 😅

lost matrix
#

Its less about trust and more about murphys law. Imagine serializing a POJO with java serialization api
and it produces some unthinkable byte[] which explodes your json when put into a String.

#

Just random garbage in byte[] is weird sometimes

ivory sleet
#

Then again the java serialization api is kinda meh

#

Not the best example but yea

wet breach
#

especially if you are accepting all kinds of characters or there isn't like restrictions

dawn flower
#

back

lost matrix
#

Ugh, im so undecided on the combat system im currently writing.
For example bows: Should i keep the minecraft bowstring pull or should i create a custom one?
I wouldnt know how to increase the drawback in a clean way for the vanilla bow system...

dawn flower
#

is 4kb reasonable per thing? there can be like 50 or 60 of that thing but def not more

lost matrix
#

1MB per "thing" would be reasonable if you only have 50 or 60 of them. Could as well load them all into memory then.

drowsy helm
#

4kb * 60 is 240kb

#

thats not even a mb

ivory sleet
#

Assuming u use a resource pack ^^

drowsy helm
#

would save a lot of processing to keep in mem

lost matrix
ivory sleet
#

Oo, oddly handy rn :^)

lost matrix
#

Its not as hard to get into as i thought. As long as you keep it basic.
But i always forget what attribute, uniform and variyng is...

chrome beacon
#

Ah old opengl

#

I try to use newer versions

lost matrix
#

Well im not starting with hlsl if thats what you mean

chrome beacon
#

No I'm just talking OpenGL version

#

Varying for example is just in and out

lost matrix
#

Ah you mean the in and out replacements

#

well attribute is in and varying is out if my guide is correct

chrome beacon
#

Ah maybe

#

I don't remember exactly

lost matrix
#

Aaand its broken...

dawn flower
#

one more thing, how do i instantiate an object without calling its constructor (if thats possible)? people say 'Unsafe' but just from the name it doesnt feel very safe

lost matrix
dawn flower
#

do i use it then?

lost matrix
#

Do you absolutely need to?

wet breach
dawn flower
#

if i dont it'll get insanely complicated

#

and prob not even possible

lost matrix
#

Elaborate

#

What are you trying to do?

dawn flower
#

so uh

#

basically

#

well

#

idk how to explain this, i'm trying to make a pet creator plugin, it uses "activators" which are exactly like code blocks, some "activators" like conditional and repeat can have an activator inside an activator aka a map inside a map and can be a map inside a map inside a map which would be very complicated to save without serialization

#

also pet objects can only have 1 that exists

lost matrix
#

Just... throw the pet into Gson.

dawn flower
#

how do i just "throw" the pet into gson

lost matrix
#
    Pet someComplicatedPet = ...;
    String json = gson.toJson(someComplicatedPet);
    
    // Or if you have a map of pets
    Map<UUID, Pet> petMap = ...;
    String json = gson.toJson(petMap);
dawn flower
#

oh-

torn shuttle
#

to jon snow

dawn flower
#

:-:

#

i feel so dumb

#

ty

native nexus
#

I love me some json

dawn flower
#

when the server stops sometimes it's to slow to save the pets so it just throws

java.lang.NoClassDefFoundError: missing/plugins/executablepets/pets/Pet
        at missing.plugins.executablepets.ExecutablePets.onDisable(ExecutablePets.java:55) ~[ExecutablePets-1.0.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:290) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.disablePlugin(PaperPluginInstanceManager.java:223) ~[paper-1.20.4.jar:git-Paper-430]
        at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.disablePlugins(PaperPluginInstanceManager.java:147) ~[paper-1.20.4.jar:git-Paper-430]
        at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.clearPlugins(PaperPluginInstanceManager.java:153) ~[paper-1.20.4.jar:git-Paper-430]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.clearPlugins(PaperPluginManagerImpl.java:97) ~[paper-1.20.4.jar:git-Paper-430]
        at org.bukkit.plugin.SimplePluginManager.clearPlugins(SimplePluginManager.java:594) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]```

what do i do?
#

(Pet is loaded correctly)

chrome beacon
#

Send the entire error in a paste

#

?paste

undone axleBOT
drowsy helm
#

and your saving code

dawn flower
#

https://paste.md-5.net/coconovota.bash

@Override
public void onDisable() {
    Pet.cancelTasks();
    for (Player player : Bukkit.getOnlinePlayers()) {
      playerManager.removePlayer(player);
    }
    storage.set("global.pets", getPetManager().getPets());
    saveStorage();
}```
drowsy helm
#

whats in saveStorage and storage.set

dawn flower
#
    private final Gson gson;
    private final File storageFile;

    public Storage(ExecutablePets instance) {
        this.data = new HashMap<>();
        this.gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();;
        this.storageFile = new File(instance.getDataFolder(), "storage.json");
        try {
            this.load();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public void set(String path, Object obj) {
        data.put(path, obj);
    }```

```    public void save() throws IOException {
        try (Writer writer = new FileWriter(storageFile)) {
            gson.toJson(data, writer);
        }
    }```

```    public void saveStorage() {
        try {
            storage.save();
        } catch (IOException e) {
            throw new RuntimeException();
        }
    }```
#

sometimes it throws it and sometimes it doesnt

smoky anchor
#

I see some async stuff there so just try to not do something async ?

dawn flower
#
            Bukkit.getScheduler().cancelTask(taskId);
            tasks.remove(taskId);
        }``` this is cancelTasks, all tasks are sync so im not sure what's async in the code
#

should i put the code in synchronized ()

ivory sleet
#

synchronized sucks imo

ivory sleet
ivory sleet
#

Strange error

#

Hmm

#

Dou use reload?

dawn flower
ivory sleet
#

Might be the reason

dawn flower
#

wouldn't it be abit disappointing if someone loses all the pets and the player pets due to reloading? especially that this isn't a private plugin

ivory sleet
#

Hmm

#

Yea i have some theory why it happens tho

dawn flower
#

why?

ivory sleet
#

One factor is gson

#

Not sure what u’ do w gson, but maybe u force it to look up classes reflectively for u

#

In which it maybe fucks things up foru

drowsy helm
#

I tend to avoid gson serialisation in most cases, it’s pretty slow. You might benefit from manually scraping your classes and writing to a json object

ivory sleet
#

^ in any case its fairly advantageous to write custom type adapters for all ur types

#

When in the environment of spigot

chrome beacon
#

Configurate ❤️

ivory sleet
#

with jackson as backend?

chrome beacon
#

yeah if you want json

dawn flower
drowsy helm
#

Gson uses serialisation

#

reflection*

dawn flower
#

i didn't know that so i made my own but then 7smile guy told me gson has serialization

ivory sleet
#

well more so, it may take a reflective approach which if u do classloading can mess things up

dawn flower
ivory sleet
#

and spigot precisely do load and unload classes more or less

drowsy helm
#

Past bedtime for me my bad lmao

dawn flower
#

i can prob make my serialization system not use reflection if that'd make it better

ivory sleet
#

pass type adapters to gson

dawn flower
#

alright

drowsy helm
#

Yeah using a type adapter can avoid reflection completely

dawn flower
#

how tho?

ivory sleet
#

at the gsonbuilder stage

#

pass the type adapters

drowsy helm
#

It tells gson how to serialize the object without gson having to use reflection to find the variabls

river oracle
dawn flower
#

like this .registerTypeAdapter(Pet.class, new PetTypeAdapter())?

river oracle
#

Yes

dawn flower
#

👍

river oracle
#

If your dealing with interfaces and inheritance chains check out the hierarchical adapter too

dawn flower
#

the only thing im having trouble with is deserialization rn

        List<?> list = getList(path);
        List<T> deserializedList = new ArrayList<>();
        if (list == null)
            return null;
        for (Object o : list) {
            try {
                T deserialized = gson.fromJson((String) o, clazz);
                deserializedList.add(deserialized);
            } catch (JsonSyntaxException e) {
                return null;
            }
        }
        return deserializedList;
    }```

```    private void loadPets() {
        if (storage.contains("global.pets")) {
            for (Pet pet : storage.getDeserializedList("global.pets", Pet.class)) {
                getPetManager().addPet(pet);
            }
        }
    }```
#

it's saving properly tho

#
        at missing.plugins.executablepets.pets.PetManager.addPet(PetManager.java:30) ~[ExecutablePets-1.0.jar:?]
        at missing.plugins.executablepets.ExecutablePets.loadPets(ExecutablePets.java:95) ~[ExecutablePets-1.0.jar:?]
        at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.20.4.jar:git-Paper-430]
        at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:482) ~[paper-1.20.4.jar:git-Paper-430]```
echo basalt
#

prob a formatting issue

prisma shadow
#

Best way to learn development

native ruin
#

maybe a JsonSyntaxException

#

or list being null

dawn flower
native ruin
#

and the json is correct?

dawn flower
#
    "pets": [
      "stuff here"
    ]
  }```
native ruin
dawn flower
#

JSON is valid!

native ruin
#

the json you sent isn't valid for me unless you put it in a { }

earnest forum
#

?paste

undone axleBOT
quaint mantle
#

I used build tools to use NMS, but can't import anything related to it. why??

#

compileOnly "org.spigotmc:spigot:1.20.4-R0.1-SNAPSHOT"

mighty gazelle
#

How can I create a menu where there are two toggle items and when you call up the menu again the buttons are still the same as previously set?

dawn flower
native ruin
mighty gazelle
native ruin
dawn flower
dawn flower
#

smh

#

how do i make the type adapter's deserialization work

#
                .setPrettyPrinting()
                .disableHtmlEscaping()
                .registerTypeAdapter(Pet.class, new PetTypeAdapter())
                .create();```
mighty gazelle
inner mulch
#

@echo basalt are entities still memory leaks? or did they fix it? (your good habit post)

echo basalt
#

they're still leaks

inner mulch
#

do they save the world in them?

echo basalt
#

they save the whole entity and the world

#

why are you concerned ab this just store uuids

inner mulch
#

so basically like locations back in the days

echo basalt
#

they store the nms world

inner mulch
echo basalt
#

yes

dawn flower
# mighty gazelle But I will save it the properties
public class MyCustomMenu extends Menu {
  private MyCustomMenu2 myCustomMenu2;
  private Player player;
  
  public MyCustomMenu(Player player, MyCustomMenu2) {
    this.myCustomMenu2 = myCustomMenu2;
    this.player = player;
  }
  
  public int getSize() {
    return 54;
  }

  public void handleClick(InventoryClickEvent e) {
    if (e.getRawSlot() == 0) {
          myCustomMenu2.open();
    }
  }

  public void setMenuItems() {
    inventory.setItem(0, new ItemStack(Material.BUTTON));
  }
}```

same with MyCustomMenu2 but change all 'MyCustomMenu2' with 'MyCustomMenu'

is that what you want?
echo basalt
#

that is one raw menu util

inner mulch
#

yo does someone know what kinda api i need to use to create and delete worlds on runtime?

#

on a server

chrome beacon
#

deleting worlds at runtime is a bit janky

dawn flower
chrome beacon
#

yeah you can use that

#

deleting the world (as in the files) might be a bit tricky

dawn flower
#

oh my god im so dumb

chrome beacon
#

iirc the file remains locked in use

#

Even though it's not loaded anymore

inner mulch
#

which intellij settings does this stuff to me?

chrome beacon
#

but you can give it a try

dawn flower
#

getList is returning a list of null

#

😭

#

why do i never debug properly

chrome beacon
inner mulch
#

the marking 5 lines part

#

there is something wrong with this

chrome beacon
#

oh you hold middle click and drag

#

to select multiple lines like that

inner mulch
#

no i do not

#

no middle click

#

how to i turn this shit off 😢

dawn flower
#

click anywhere

quiet ice
#

How am I supposed to know

inner mulch
#

didnt help

dawn flower
#

close project and reopen

#

intellij bugs for me sometimes

inner mulch
quiet ice
#

Few know IJ beyond "clear caches and restart"

dawn flower
#

no way it's eclipse

inner mulch
#

restart worked

quiet ice
#

Although to be honest I am not a real eclipse power-user either, I barely know how to make my own eclipse plugins

chrome beacon
#

Intellij does have some good documentation

quiet ice
#

Eclipses docs are like 15-20 years old by now

#

It really is something from a different era in style and everything

mighty gazelle
mighty gazelle
shadow night
river oracle
#

I don't even use the IJ keybinds lol. Eclipse keybinds >>>>>

shadow night
#

I hated vs code so much for this one single simple reason: it didn't tell me the options I have

river oracle
#

It does? Maybe you had a shit setup. The main issue I had with VSC and java is it was slower than intellij and it would crash if your classes got massive

shadow night
#

no idea tbh, as soon as I started coding in java I switched to IJ because of how much more convenient it was than vsc

river oracle
#

It was a pain but one day I sat down and spent like 5 hours converting all my VSC settings to intellij and holy fuck was It worth it

#

Only initial issue with intellij is the unused method stuff which is beyond brain dead to have enabled lol

#

Its like yeah no shit it's unused it's API or a library etc

shadow night
#

damn I feel that

river oracle
#

Dayun blood just go ghost ping

inner mulch
#

whats so suspicious about this call?

novel canyon
#

java.sql.SQLException: No value specified for parameter 1
How is this possible? Happened only on some servers with MySQL.
Here is the code:

this.saveQuery = "INSERT INTO " + this.databaseManager.getUsersTable() + " (uuid, data) VALUES (?, ?) ON DUPLICATE KEY UPDATE data = VALUES(data)";
Connection connection = null;
PreparedStatement preparedStatement = null;
try
{
    connection = this.databaseManager.getConnection();
    preparedStatement = connection.prepareStatement(this.saveQuery);
    preparedStatement.setString(1, this.uuid);
    String data = GsonUtils.getGson().toJson(this.dataSave);
    preparedStatement.setString(2, data);
    preparedStatement.executeUpdate();
}
catch (SQLException sqlException)
{
    sqlException.printStackTrace();
}
finally
{
    this.databaseManager.close(connection, preparedStatement, null);
}```
Anyone SQL expert?
dawn flower
chrome beacon
novel canyon
smoky adder
inner mulch
#

you are using bungeecord api on a spigot server

#

bungeecord is just a proxy and has nothing to do with spigot, your spigot server doesnt support bungee methods and bungee does not support your spigot methods

smoky adder
#

therefore how i can send an actionbar??

inner mulch
#

(trying to achieve)?

smoky adder
#

i send the full code?

#

one moment

inner mulch
#

@smoky adder just use the spigot player.sendActionbar and not th e bungee one

slender elbow
#

yeah I don't think that method existed in 1.8

#

the joys of old asf crap

smoky adder
echo basalt
#

it is nms' Component

slender elbow
#

that new method will fail in the exact same way on an ancient server like 1.8

smoky adder
#

i use a spigot 1.8.8

slender elbow
#

you'll have to use nms or some odd library that handles it for you

smoky adder
#

yes

slender elbow
jagged quail
undone axleBOT
smoky adder
#

yes i know ahah

slender elbow
#

you'd have to send the packet manually or use a library for it

smoky adder
#

how, can I do it?

#

I tried to do it with packages but it doesn't let me import IChatBaseComponent

slender elbow
smoky adder
#

thanks

minor lark
#

I am getting this error when compiling
Unsupported class file major version 63

Here's my pom.xml file. Anyone has any idea on how to fix?

chrome beacon
#

?paste

undone axleBOT
minor lark
#

ah i used pastbin

chrome beacon
#

Update the shade plugin

minor lark
#

to what version?

chrome beacon
#

The latest version

#

let me check

#

3.5.2

minor lark
#

Still giving me the error

chrome beacon
#

I'd go through and make sure the other plugins are up to date too

minor lark
#

if I remove this

<plugin>
    <groupId>net.md-5</groupId>
    <artifactId>specialsource-maven-plugin</artifactId>
    <version>1.2.2</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>remap</goal>
            </goals>
            <id>remap-obf</id>
            <configuration>
                <srgIn>org.spigotmc:minecraft-server:1.20.4-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
                <reverse>true</reverse>
                <remappedDependencies>org.spigotmc:spigot:1.20.4-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
                <remappedArtifactAttached>true</remappedArtifactAttached>
                <remappedClassifierName>remapped-obf</remappedClassifierName>
            </configuration>
        </execution>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>remap</goal>
            </goals>
            <id>remap-spigot</id>
            <configuration>
                <inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
                <srgIn>org.spigotmc:minecraft-server:1.20.4-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
                <remappedDependencies>org.spigotmc:spigot:1.20.4-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
            </configuration>
        </execution>
    </executions>
</plugin>

it compiles

fallen lily
chrome beacon
#

Gradle 💀

fallen lily
#

Its more widely supported and there are some really neat plugins

chrome beacon
minor lark
chrome beacon
#

Also the shadow plugin is unoffical and looking for new maintainers

fallen lily
# chrome beacon Gradle 💀

You can laugh all you want but after experimenting with maven and gradle for a fair amount of years, I can safely say Gradle is definitely more dominant in it’s functionality

chrome beacon
#

It's also very good at breaking

#

but yes it does have more functionallity

minor lark
#

love how people fight over which one is better

chrome beacon
#

which is both a pro and a con

fallen lily
#

With an added bonus of being able to quickly script more functionality into the build steps, rather than having to make a “Mojo”

fallen lily
#

I agree the docs kinda suck

chrome beacon
#

I mean breaking in updates

#

They break stuff all the time

fallen lily
#

But you will quickly find disclaimers and best practices which address the issues

fallen lily
#

Or one of your plugins thereof

#

Its a race to update but definitely worth it

#

In my opinion and experience anyways

slender elbow
#

thankfully they follow semver

#

that's what major versions are for

minor lark
#

Changed in pom.xml and project settings

chrome beacon
#

Same error?

fallen lily
minor lark
#

Unsupported class file major version 63

chrome beacon
#

Wait why are you compiling with Java 19

fallen lily
#

<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
</properties>

#

I believe

chrome beacon
#

That won't change the jdk automatically

#

You don't want to be using JDK19

minor lark
fallen lily
chrome beacon
#

not for the error

lost matrix
chrome beacon
#

I was just talking about the JDK

#

you don't want to be using it

slender elbow
#

that's what the target flag is for

#

although should be using the release flag instead

lost matrix
#

Im suspecting that he is pulling a dependency with class file versions of 63

minor lark
#

I have both 21 and 17 installed but none of them works

#

It started doing this when I added the plugin part for the mojang remapped

fallen lily
#

Not the JDK

#

the runtime hes using is older than the compiler’s target version

#

The jdk has no effect as thats just to link the symbols together so you can actually write java code using a standard library

chrome beacon
#

Still doesn't change what I said?

#

You don't want to be using it since it's out of support

#

Stay on an lts version

minor lark
#

yep

#

found it

#

it was jda

#

by removing jda it compiles

#

Thing is I want to use JDA

fallen lily
#

And its unrelated to the error

#

Lol

#

It think I know what im saying

fallen lily
minor lark
#

I removed jda

#

And it compiles

green prism
#

I can't set a level using slf4j's logger

minor lark
#

But the thing is my project uses JDA, so what do I do now?

chrome beacon
fallen lily
#

mm

chrome beacon
#

not sure how this ended up in an argument

fallen lily
#

To get a better idea on which specific class is the issue

lost matrix
minor lark
#

LOL

minor lark
lost matrix
chrome beacon
#

^^

#

Something is trying to

lost matrix
#

If you had, there wouldnt be this error

minor lark
#

and i guess that was the dependency i was using which is jda... is there a way of making jda work? cause my plugin also hosts a discord bot

chrome beacon
#

Make sure you depend on the latest version of JDA

#

I don't think they are building with Java 19

minor lark
#

Says 5.0.0-beta.20 on github

#

Which is the one I'm using

lost matrix
#

Hm JDA shouldnt require java 19 tbh

green prism
lost matrix
minor lark
#
<dependency>
    <groupId>net.dv8tion</groupId>
    <artifactId>JDA</artifactId>
    <version>5.0.0-beta.20</version>
    <exclusions>
        <exclusion>
            <groupId>club.minnced</groupId>
            <artifactId>opus-java</artifactId>
        </exclusion>
    </exclusions>
</dependency>

if I add this it gives that error
Unsupported class file major version 63

smoky adder
#

Could you send me a guide on how to implement api well? I can't import bountifulapi

fallen lily
#

Check the dependency tree

chrome beacon
#

That's true

#

JDA has a TON of dependencies

#

which is why it's so big

green prism
smoky adder
lost matrix
chrome beacon
#

and not implement one

stark moss
#

Hello! I would like to make a bossbar that can countdown. I want it to countdown from 6 minutes each time and the countdown will start with /startclock, players can pause it with pause, and can resume it with /resumeclock. Another command that I would like to add would be "/final" which would set the text above the bossbar to "Final" and set the bossbar value to 0.
I would like the time to also be displayed like this: minutes: 9:30 :seconds
I am fairly new to Java and I don't know much about bossbars.

All help is appreciated. Thanks!

worthy star
#

how do i get the attacker, this doesn't seem to be working, and the ignoreCancelled = true means to ignore the event if its cancelled, right? ```java
@EventHandler(ignoreCancelled = true)
public void onDamage(EntityDamageEvent e) {
if (e.getEntity() instanceof Player) {
Player player = (Player) e.getEntity();

        Common.tell(player, "&3You damaged this guy !!!");
    }
}```
lost matrix
lost matrix
worthy star
#

oh ty,

#

is the getEntity() there for victim?

stark moss
lost matrix
#

Yes

worthy star
#

alr thx

lost matrix
lost matrix
#

Because its not

stark moss
#
package me.casualspeedruner.americanfootballpaper.otherutil;

public class bossbar {
    public void setCooldown(String key, long duration) {

    }

    public long getRemainingTime(String key) {

    }

    public void removeCooldown(String key) {

    }

    public void pauseCooldown(String key) {

    }

    public void resumeCooldown(String key) {

    }
}
lost matrix
#

Implement this class. If you cant: Start with something simpler

stark moss
#

not much help but thanks ig

worthy star
#

he means add some code to it

#

i think

stark moss
lost matrix
# stark moss not much help but thanks ig

Its literally the best help you can get. You need to learn the basics or else you will be asking others to write the code for you
in the next 3 years without learning much.

hollow vessel
#

Hi! Is there maybe a event that i called when someone take items to their inventory? I mean when someone take a sword from chest to their inventory and then event calls

stark moss
#

ik i just need some help with this rn. im still taking a java course

worthy star
#

Basically, when you go to school first time, they teach you then let you solve, not start solving for you

lost matrix
hollow vessel
tall dragon
#

yea

#

but you can make checks

hollow vessel
#

okey i'll try

#

you mean compare inventories?

worthy star
#

yes

hollow vessel
#

ahh i see

#

thx

worthy star
#

check if name inventory or metadata of player is that gui or set

tall dragon
#

you can figure out if the item goes from the player inv into the chest or the otherway around with the info provided in that inv

worthy yarrow
#
public interface Event {

    void matchSpawnLocation(Location location);
    void startMinigame(ChatMiniGames chatMiniGames);

    void stopMinigame();

    List<UUID> getCurrentPlayers();

    void join(UUID player);

    void leave(UUID player);

    boolean isFull();

    boolean isActive();

    boolean isMinimumPlayers();

}```

Is there anything else I should add? (minigames interface btw)
tall dragon
worthy star
#

if i want to like save a true value to player when he damages someone, should i use a pdc or metadata or smth else

hollow vessel
lost matrix
worthy yarrow
#

well

#

There's a reason I'm passing my main class to startMinigame

#
@Override
    public void startMinigame(ChatMiniGames chatMiniGames) {
        if (!(!isActive() && isMinimumPlayers())) return;

        isEventActive = true;
        pairPlayersForMatches();
            for (MatchPlayers match : matches) {
                notifyPlayersAboutMatch(match);

                new BukkitRunnable() {
                    @Override
                    public void run() {
                        isMatchActive = true;

                        for (UUID player : players){
                            Bukkit.getPlayer(player).teleport(matchSpawnLocation);
                        }

                        UUID player1 = match.getPlayer1UUID();
                        UUID player2 = match.getPlayer2UUID();

                        if (Math.random() < 0.5) {
                            handleMatchResult(player1, player2); // Player 1 wins
                        } else {
                            handleMatchResult(player2, player1); // Player 2 wins
                        }
                    }
                }.runTaskTimer(chatMiniGames.getInstance(), 0, 1);
            }
    }```

This was sorta the system I was gonna use for the minigames
lost matrix
#

Hmm, but this means you need to manually stop all tasks and unregister listeners in your stopMinigame() method...

worthy yarrow
#

It's only like 10% written rn...

worthy yarrow
lost matrix
#

Usually you wouldnt want this as an implementation detail because every minigame will have to register and unregister listeners and start/stop tasks.
And if every minigame has it, then there should be an abstracter way of handling this instead of your implementation.

dire blaze
#

does anyone know how to show the number of online VIP players in your tab list?

lost matrix
dire blaze
lost matrix
dire blaze
worthy yarrow
#
public enum MinigameType {
    PARKOUR("Parkour minigame", Difficulty.PEACEFUL, 16, 2),

    SPLEEF("Spleef minigame", Difficulty.PEACEFUL, 16, 2),

    SUMO("Sumo minigame", Difficulty.PEACEFUL, 16, 2),

    TNT_RUN("TNT Run minigame", Difficulty.PEACEFUL, 16, 2);

    private final String displayName;
    private final Difficulty difficulty;
    private int maxPlayers;
    private int minimumPlayers;

    MinigameType(String displayName, Difficulty difficulty, int maxPlayers, int minimumPlayers) {
        this.displayName = displayName;
        this.difficulty = difficulty;
        this.maxPlayers = maxPlayers;
        this.minimumPlayers = minimumPlayers;
    }

    public int getMinimumPlayers(){
        return this.minimumPlayers;
    }

    public int getMaxPlayers(){
        return this.maxPlayers;
    }

    public String getDisplayName() {
        return this.displayName;
    }

    public Difficulty getDifficulty() {
        return this.difficulty;
    }
    public void setMinPlayers(int minimumPlayers){
        if (!(minimumPlayers <= maxPlayers)) return;
        this.minimumPlayers = minimumPlayers;
    }

    public void setMaxPlayers(int maxPlayers){
        this.maxPlayers = maxPlayers;
    }
}```
Well I guess that's also the reason I have this enum, it's main purpose is to a: make the gamemodes a bit configurable and b: support system for my implantation ie: directing the listener to whatever minigame needs to be listened to
lost matrix
sand spire
lost matrix
dire blaze
#

ahh yeah i didn't realize it's called scoreboard

#

yeah im editing the config.yml file

#

for TAB

#

scoreboard-1.20.3+:
title: <#f678ff>Ricecakes Minecraft</#c778ff>
display-condition: '%player-version-id%>=765'
lines:
- '&7%date%'
- '%animation:MyAnimation1%'
- '&6Online:'
- '* &eOnline&7:||%online%'
- '* &eStaff&7:||%staffonline%'
- '* &evip&7:||%vip%'
- '&6Personal stuff:'
- '* &bPing&7:||%ping%&8ms'
- '* &bWorld&7:||%world%'
- '* &bMoney&7:||$%vault_eco_balance_fixed%'

lost matrix
lost matrix
worthy yarrow
#

Ehm yeah, currently the plan was only 4 games, sumo, spleef, tntrun, and parkour

#

I'll go with opt 1. then, considering my enum setup, would it be alright to use it in determining which game is currently active?

smoky adder
worthy yarrow
#

Er well not currently active I suppose, but whichever event needs to be referenced

sand spire
shadow night
worthy yarrow
#

I think they mean custom

#

in case that wasn't already clear

#

Sorry it's early

lost matrix
worthy yarrow
sand spire
#

oh alright

lost matrix
umbral ridge
#

that sucks

ivory sleet
#

compareTo

chrome beacon
#

No operator overloading in Java

umbral ridge
#

So

#

if it's less than zero

ivory sleet
#

if u want to simplifiy

#

u can use BigDecimal.ZERO.compareTo(x)

quaint mantle
#

That game that got #1 on gamejam:

ivory sleet
#

might add more readability

umbral ridge
#

I wish everyone would use BigDecimal instead of double

#

idk why vault api is all doubles

#

it sucks

#

I have to convert everything before I do anything

lost matrix
worthy star
#

what are the comments with @return and @param for, in codes

shadow night
#

It's javadoc

umbral ridge
#

It's to describe a function

worthy star
#

is it required?

worthy yarrow
#

Readability

umbral ridge
#

users preference

ivory sleet
#

and precision wasnt a goal directly I reckon

worthy star
#

is the @return for return value/type of code?

#

what abt @param

ivory sleet
#

as long as it is eventually precise

ivory sleet
shadow night
#

How does a bigdecimal work

ivory sleet
#

like maybe it returns an immutable copy of something

lost matrix
#

param is do describe params...

worthy yarrow
#

conclube would you like to give my start to sumo mini game a review? I'm trying to gather everyone's notes before I make changes

worthy yarrow
#

?paste

undone axleBOT
worthy star
ivory sleet
#

what dou want me to review in particular

worthy yarrow
#

That's basically the structure for the whole system, it's not just sumo... gonna be 4 minigames total as well as a chat prompt for entries / joining events

worthy yarrow
#

But also just any general things that may pop up

ivory sleet
#

there is one anti pattern I think its worth revising in particular

#

and that is ur mutability in the enum

chrome beacon
#

That looks like some bad web server code

ivory sleet
#

other than that, you might wna consider

  • have a separate function initialize() that populates the minigameEvents, to decouple it
  • maybe check out the state design pattern
  • else I think its good :)
#

potentially recordify MatchPlayers

#

but eh

#

its fine

lost matrix
#

I honestly dislike using enums now. I very rarely use them anymore. This is an alternative which lets me be more dynamic

worthy star
#

if i want to save a true value to player whats best way to do it, pdc or metadata

lost matrix
worthy star
#

ight thanks

ivory sleet
#

but like its more when u expose an enum to the api consumer, or use it as a dependency magnet

lost matrix
#

What if i wanted to create dynamic, temporary attributes on runtime?

ivory sleet
#

well then enum isn't the approach from the beginning

twin venture
lost matrix
#

I think this is the only enum i have currently

#

And thats just because i somehow need to serialize an operation

ivory sleet
#

i think it was talked about

#

but a good approach in general is to abstract over the enum w an interface

#

so that if u later on wna modify its purpose, its possible

#

altho u might wna seal the interface and have some restricted class consumers can derive from

lost matrix
#

Let me just seal DoubleBinaryOperator real quick with some ASM
squirtle

#

Should be fine

umbral ridge
#

How do you make sure 0 at the end, (eg.: 1,40) is kept and not removed

ivory sleet
#

u're just implementing functionality there

lost matrix
ivory sleet
#

@worthy yarrow one more thing, whenever u deal with a lot of state, u need to start caring about the notion of ownership

umbral ridge
#

I want to create like a function that returns a String and accepts a BigDecimal and if it's less than 1 it'll return cents in format 00, otherwise if it's more or equal to 1 it'll return 0.00 format. for cents, if it's less than 10, it should return cents, without any zeros, unless if its actually 0

chrome beacon
#

Why not always have the same format

lost matrix
umbral ridge
#

I think I need to do all of it manually

#

formatting it wont help me I think

ivory sleet
#

and well, Currency also

#

if u need to get the "currency" symbol or sth

worthy star
#

whats better

hollow vessel
#

hi, how can I check with InventoryClickEvent if player took item from his inventory but not move to other or drop (left click this item). This event works the same when player took item out and put item in from chest, I must have two conditionals one from taking out and one from putting inside

umbral ridge
#

I am kind of handling the currency symbol myself by checking if double is less than zero then it's in cents, if value is equal or more than 1 then it's euros

ivory sleet
#

uh sure

umbral ridge
#

I'll post the code in a few minutes.. xd

worthy star
lost matrix
# umbral ridge I am kind of handling the currency symbol myself by checking if double is less t...

You are aware that the biggest number you can store in a double with only 2 decimal points taken from the mantissa is about 10 to the power of 300 or ten centillion.
Thats...
100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000....
and more.

chrome beacon
worthy star
#

ight

chrome beacon
#

The namespacedkey is an immutable constant

chrome beacon
#

so no need for a getter

umbral ridge
#

Plus I do BigDecimal setScale

#

to 2

lost matrix
#

Im just questioning your BigDecimal choice

#

Its used if you need incredibly high precisions

umbral ridge
#

Yeah I need

#

for commands /pay mostly

#

Can't have number overflow like 0.799999

ivory sleet
#

i agree w smile partly here

#

like do u rly need bigdecimal

#

lol

umbral ridge
#

Yeah

#

for setScale

#

and rounding

worthy star
#

is it possible to check if the argument for a command is a boolean or not?

#

or i have to do it manually

lost matrix
#

If you have exponential scaling in your game and people will eventually only see 43T for their trillions, but you really need those
sweet 50 decimal points of precision, even with very high numbers, then maybe you need BigDecimal.
The main problem with double is that the FP precision is reduced a lot for very big numbers

lost matrix
# hollow vessel ???

You should be alble to just check with the operations. Eg if the bottom inv was clicked, and its a shift click, then the player tries to push it to the top inv.
And so on.

lost matrix
umbral ridge
#

But I'm using BigDecimal to avoid number overflow because when I had double only, I would always get weird numbers

ivory sleet
#

NaN

lost matrix
#

But getting some experience with BigDecimals is also fine

umbral ridge
#

Yes

umbral ridge
worthy star
#

are on/off considered as booleans in java?

#

or only true/false

umbral ridge
#

I have to say though, I had java but we never went through the BigDecimal class

#

which kind of sucks because it's great

river oracle
worthy star
#

Boolean.valueOf("on"/"off")?

umbral ridge
#

😿

worthy star
#

or should i just use a method to get true and false from the string

umbral ridge
#

you can use valueOf but it'll accept "true" or "false" as an input string

#

Not sure if it'll work for "1" and "0" I'd have to test but yeah

worthy star
#
    private Boolean getBoolean(String type) {
        if (type.equalsIgnoreCase("on")) {
            return true;
        }
        return false;
    }``` i made this
#

is it efficient

rough ibex
#

Its fine

#

Simple and stupid

worthy star
#

stupid

umbral ridge
worthy star
#

return type.equalsIgnoreCase("on") :)

worthy star
#

i made it like that

umbral ridge
#

you can use off, off123123, offspigotmc, etc.. and it'll be false

worthy star
#

its a command

#

and people can only use off and On

umbral ridge
#

can they?

worthy star
#

i don't use contains i use equalsignorecase

minor lark
#

I'm having some problems with this code. It gives me two errors.

ProtocolManager manager = ProtocolLibrary.getProtocolManager();

CraftPlayer cPlayer = (CraftPlayer) player;
ServerPlayer sPlayer = cPlayer.getHandle();

MinecraftServer server = sPlayer.getServer();
ServerLevel level = sPlayer.serverLevel();
GameProfile profile = new GameProfile(UUID.randomUUID(), "Herobrine");

ClientInformation info = ClientInformation.createDefault();

ServerPlayer npc = new ServerPlayer(server, level, profile, info);

PacketContainer playerInfoUpdate = new PacketContainer(PacketType.Play.Server.PLAYER_INFO, npc);

playerInfoUpdate.getPlayerInfoActions().write(0, EnumSet.of(EnumWrappers.PlayerInfoAction.ADD_PLAYER));
playerInfoUpdate.getPlayerInfoDataLists().write(1, Collections.singletonList(new PlayerInfoData(
    new WrappedGameProfile(profile.getId(), "Herobrine"),
    0,
    EnumWrappers.NativeGameMode.CREATIVE,
    WrappedChatComponent.fromText("Herobrine")
)));

manager.sendServerPacket(player, playerInfoUpdate);

Caused by: java.lang.IllegalStateException: Unable to set value of field private final java.util.EnumSet net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket.a

Caused by: java.lang.ClassCastException: Cannot cast net.minecraft.server.level.EntityPlayer to net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket

Any idea on how I could fix it? Thanks!

chrome beacon
#

I recommend just using Citizens for your NPCs

minor lark
#

Citizens was so easy to use

chrome beacon
#

It works fine

minor lark
#

Couldn't set the skin tho

chrome beacon
#

Well offline mode is for when you're offline

#

so when you're offline it can't fetch skins

#

because it's not connecting to the internet

#

also Minecraft really isn't that expensive

#

You should get your friends to buy the game

minor lark
#

And apply the skin with the file

chrome beacon
#

probably

#

not worth the effort though

worthy star
#

is there some api that has progress bars or a public method
like [|||||||||||]

#

with green and gray

chrome beacon
#

It's not hard to make that

lost matrix
worthy star
#

i have a code for that but not java, i'll try to convert into java

chrome beacon
#

Don't look at other code

#

try to figure out the logic yourself

#

It's a good exercise just like smile said

minor lark
worthy star
#

okay

chrome beacon
#

(or you buying them the game for that matter)

#

It is

#

sh

#

let them figure it out

lost matrix
#
  public static String progressBar(double progress, int length, String filledPrefix, String emptyPrefix, String element) {

  }

I got an implementation for this. Lets see your suggestions and ill follow up.

quaint mantle
#

What do you guys prefer

#

The verb naming or record style

worthy star
lost matrix
#

progress should be between 0.0 and 1.0

worthy star
#

why 0.0 and 1.0

#

can't i have custom one?

#

like 0 and 55

lost matrix
#

You would always map that to a normalized range

#

You can overload it like this:

  public static String progressBar(double current, double max, int length, String filledPrefix, String emptyPrefix, String element) {
    return progressBar(current / max, length, filledPrefix, emptyPrefix, element);
  }
  
  public static String progressBar(double progress, int length, String filledPrefix, String emptyPrefix, String element) {
    ...
  }

To allow a mapping from 0 to X
But you always normalize it 🙂

worthy star
#

i mean,

#

not really sure about that 0.0 and 1.0

#

but

#

for the rest

lost matrix
zinc moat
#

What are some good are some good intelliJ plugins for minecraft development?

quaint mantle
#

Light theme

quaint mantle
#

I think the suggestions are pretty nice sometimes (from what I've seen)

lost matrix
worthy star
#

can i like vb for (int i = 1; i < (length + 1); { if (i > [precent thing]) { myStringList.add(i, "prefix|"); } else { myStringList.add(i, "prefix|"); } return myStringList.toString(); :)

quaint mantle
#

Lol

#

The theme section of intellij is like a candy shop

worthy star
#

but is that good xD

lost matrix
lost matrix
#

This utilizes the internal optimization of String#repeat

  public static String progressBar(double current, double max, int length, String filledPrefix, String emptyPrefix, String element) {
    Preconditions.checkArgument(current <= max, "Current must be less or equal to max.");
    return progressBar(current / max, length, filledPrefix, emptyPrefix, element);
  }

  public static String progressBar(double progress, int length, String filledPrefix, String emptyPrefix, String element) {
    Preconditions.checkArgument(progress >= 0 && progress <= 1, "Progress must be between [0 ; 1]");
    int filled = (int) (progress * length);
    int empty = length - filled;
    return filledPrefix + element.repeat(filled) + emptyPrefix + element.repeat(empty);
  }
lost matrix
worthy star
#

Hmm

#

is the upper method for using max ?

#

so 0 and x

lost matrix
# worthy star is the upper method for using max ?

Imagine having a max of 10.0 and a current value of 3.74.
The progress bar should have 20 lines in it:

    double max = 10.0;
    double current = 3.74;
    int length = 20;
    String filledPrefix = "§a";
    String emptyPrefix = "§7";
    String element = "█";
    String bar = progressBar(current, max, length, filledPrefix, emptyPrefix, element);
worthy star
#

Hmm

lost matrix
worthy star
#

ok

#
    public static String progressBar(double current, double max, int length, String filledPrefix, String emptyPrefix, String element) {
        Preconditions.checkArgument(current <= max, "Current must be less or equal to max.");
        return progressBar(current / max, length, filledPrefix, emptyPrefix, element);
    }

    public static String progressBar(double progress, int length, String filledPrefix, String emptyPrefix, String element) {
        StringBuilder builder = new StringBuilder();

        for (int i = 0; i < (length + 1); i++) {
            if (i > progress) {
                builder.append(filledPrefix).append(element);
            } else {
                builder.append(emptyPrefix).append(element);
            }
        }
        return builder.toString();
    }```
lost matrix
#

Btw you can save a ton of if checks, if you simply calculate the amount of filled and the amount of empty elements before looping.
You simply create two loops which add your lines.

worthy star
#

i used .append(x + y) but it suggested to use another append

worthy star
#

i wanted to do that in first place but didn't know how :)

lost matrix
inner mulch
#

Guys is it even possible to update stuff in minecraft faster than a tick happens?

#

Or only every 50ms

lost matrix
# worthy star how?
  1. Calculate number of filled bars
  2. Calculate number of empty bars
  3. Add filledPrefix
  4. For loop: Add # filled bars
  5. Add emptyPrefix
  6. For loop: Add # empty bars
worthy star
#

ok

#

so 2 for loops, 1 for filled and another for empty

#

i tested your example rq, but it shows §7█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█

#

and

#
        double max = 10.0;
        double current = 10.0;
        int length = 20;
        String filledPrefix = "§a";
        String emptyPrefix = "§7";
        String element = "█";
        String bar = progressBar(current, max, length, filledPrefix, emptyPrefix, element);
``` i put this
#

max = current so all should be green

#

why first is always gray

lost matrix
#

Show your code

worthy star
#
    public static String progressBar(double current, double max, int length, String filledPrefix, String emptyPrefix, String element) {
        //Preconditions.checkArgument(current <= max, "Current must be less or equal to max.");
        return progressBar(current / max, length, filledPrefix, emptyPrefix, element);
    }

    public static String progressBar(double progress, int length, String filledPrefix, String emptyPrefix, String element) {
        StringBuilder builder = new StringBuilder();

        for (int i = 1; i < (length + 1); i++) {
            if (i > progress) {
                builder.append(filledPrefix).append(element);
            } else {
                builder.append(emptyPrefix).append(element);
            }
        }
        return builder.toString();
    }```
lost matrix
#

Follow these steps pls:

  1. Calculate number of filled bars
  2. Calculate number of empty bars
  3. Add filledPrefix
  4. For loop: Add # filled bars
  5. Add emptyPrefix
  6. For loop: Add # empty bars
worthy star
#

no i don't mean for that

#

i mean for first one being always gray

#

but ok

lost matrix
worthy star
lost matrix
worthy star
#

but why is that very required

#

i mean

#

i used current and max parameters and they work

#

if its like 5 current it does half of bar

lost matrix
#

If you dont normalize, then you will have quite confusing calculations that are simply not needed.
Always normalize.

ivory sleet
#

^

#

when its math, always make it work first

#

then optimize

worthy star
#

sorry im braindead today, and the i don't get how to normalize it, to make it 0.0 -> 1.0

twin venture
#

if i want to have a good structure for mysql user managing :

  • create a User entity class with some data ..
  • create UserManager with a concurrentMap [caching]
  • create DataUserManager [for mysql insert , update , load]
#

am i right?

ivory sleet
#

what relationship does user manager and data user manager have?

twin venture
#

no?\

lost matrix
umbral ridge
#

So that's kind of tricky though, or I'm just stupid. Here's what I want:
Input values are positive doubles.

  • if double is less than 1, it should contain only the 2nd part of the string, eg.: 0.50
  • if double is less than 0.10, eg.: 0.05, it shouldn't contain 05, but 5.
  • if double value is something like 1.50, it shouldn't be 1.5, but should be 1.50, with a zero at the end.
  • if double value is exactly the same as int, eg.: 1, 2, 3, 4, etc.., it shouldn't contain the 2nd part of the string, eg.: 1.00, zeros should be removed.
  • if double is 0, it shouldn't be something like 0.00, it should be just 0.

I think that's pretty much it, do I have to really manually code this if I want to make it like I described?

ivory sleet
#

now u're at the verge of compromising on single responsibility

twin venture
ivory sleet
#

I mean sth like

CompletableFuture<Void> saveUser(User user);

#

should be fine?

lost matrix
sullen canyon
worthy star
#

im annoying af 💀

ivory sleet
#

anyway killer, personally I am extremely against coupling database logic with caching and lookup logic

ivory sleet
#

thats a big no no for me

lost matrix
# worthy star sorry

You say in your head
"ok. so the value param will be a value between 0.0 and 1.0"
"This is now my assumption. Lets implement the method with this assumption in mind"

Thats how you assume something.

twin venture
#

is there a better more advanced system i can make?

ivory sleet
#

there is but that ofc adds complexity onto it

#

which can be a disadvantage

twin venture
worthy star
twin venture
#

hit me with your idea xD

ivory sleet
#

well Ill share u some code I wrote the other day as soon as I get home

twin venture
#

Alr thanks

lost matrix
# twin venture as long as it will be a good structured and fast in performance

Create a so called DAO -> DataAccessObject
It stores nothing.
All it has is:

public Value getData(Key)
public void saveData(Key, Value)
... and some utils you want

This DAO is then used for your DataManager.
The DataManager has a Map<> and simply lets you
ask the DAO for a value and put it into your map and vice versa.

#

Like described in the guide

twin venture
#

i can do save , load?

#

or if the getData is the load?

lost matrix
#

Hm? Add more words to those sentences pls. Im not sure what you mean.

twin venture
#

like for my situation , i have user class with kills ,deaths and some lobby settings like set day or night for that specfic user [boolean] , and so on ..
i can have :

  • loadUser method that return User
  • saveUser method [void]
#

correct?

lost matrix
#

Sure

twin venture
#

so something like this?

lost matrix
#

Functionality wise, yes. The naming is just scuffed.

#

Make the map final

twin venture
#

yeah sorry , so i can use CompletableFuture ?

#

with the loading part?

#

correct?

#

and i can do this insted?

lost matrix
#

I mean... myeah. This is fine i guess.

twin venture
#

how i can make it better? performance wise , and code sturcutre?

fallen lily
#

Not much you can do performance wise

#

You can early return from your map if its already populated

#

Thats one thing

lost matrix
#

Exceptions for your CF arent handled. I would not force embed an async call like that.
loadProfile should be sync callable. Same goes for loadUser.
Add a loadUserAsync method which uses the loadUser method async.

twin venture
#

like this?

lost matrix
inner mulch
#

Guys is it even possible to update stuff in minecraft faster than a tick happens?
Or only every 50ms

twin venture
#

iam not using it anymore :

inner mulch
#

thats why i ask

lost matrix
#

Return the user normally. Implement the loadUser method normally. Only use CF in your loadUserAsync method.

inner mulch
waxen plinth
fallen lily
waxen plinth
#

nothing meaningful can really happen on a shorter interval

inner mulch
#

minecraft api

fallen lily
#

Your code isnt just

waxen plinth
#

ok but WHAT

fallen lily
#

Running every 50ms

#

Lol

waxen plinth
#

it varies depending on what you're doing

#

you can send chat messages more than every 50ms

inner mulch
fallen lily
#

Your code runs at whatever speed is permissible by your jvm and system

waxen plinth
#

but block, world, entity

#

all of that will only be updated every tick

waxen plinth
inner mulch
#

okay does action bar counts as chat too?

fallen lily
#

no

waxen plinth
#

I believe those can be updated faster

#

but if you want to find out

#

?try

#

?tryitandsee

fallen lily
#

you can update it at whatever rate you like server-side, the server will still send the packets aligned to its tickrate

waxen plinth
#

not sure about that for action bar

fallen lily
#

and the client will process it at the same (fixed) tick-rate of 20tps (50ms per tick)

inner mulch
#

okay

inner mulch
#

is there a way to dynamically change a methods parameter?

hazy parrot
#

What

fallen lily
#

Repeat the question to yourself

#

😭

lost matrix
#

You can overload methods

inner mulch
#

overload?

fallen lily
#

Kotlin is so blessed in this regard

umbral ridge
#

have multiple methods with the same name, but different parameters

lost matrix
# inner mulch overload?
public int getAge(Dog dog)
public int getAge(House house)
public int getAge(House house, int flatCount)
inner mulch
#

but i need to enforce this, i have a data pipe and want that the next pipe attached to the pipeline enforces the input to be the others output.

fallen lily
umbral ridge
fallen lily
#

In a single line

inner mulch
lost matrix
fallen lily
#

Enjoy

fallen lily
#

You dont even need to call a method

lost matrix
#

Or simply take a look at javas functional interfaces. They are designed to be used in streams (or pipelines)

fallen lily
#

You just append 2 functions or blocks

#

Where one takes an inpit, and gives an output

#

And the next takes the input type

#

And produces another output type etc

lost matrix
#

Kotlin is noice for scripting or smaller projects for sure.

eternal night
#

operator overload my beloved

fallen lily
#

Yup

umbral ridge
#

my beloved grave

eternal night
#

certainly well defined what + does there

#

won't get weird if both methods yield an integer

#

🙏

fallen lily
#

I explained it pretty well tho

inner mulch
fallen lily
#

Its literally just a pipeline without aids

inner mulch
umbral ridge
#

does anyone know how to use record in java?

lost matrix
eternal night
shadow night
eternal night
#

if only there was a type system that could do this Sadge

fallen lily
eternal night
#

so you don't litter your syntax with random bs

inner mulch
fallen lily
#

This is just a gimmick

lost matrix
#

verbosity is the key to finding your inner piece

eternal night
#

rust vibes

fallen lily
#

I obviously dont use this in production code

shadow night
#

I like java

inner mulch
fallen lily
fallen lily
#

I just had to give next its name because it was confusing me

fallen lily
#

Afaik

lost matrix
# inner mulch <@220605553368498176>

Ah, thats a big topic. Try using streams and java functional interfaces a lot. It helps you understand.
Try replacing all your inheritance with composition. Then it will come naturally.

inner mulch
lost matrix
lost matrix
#

They are coupled. Making an interface functional, qualifies it for usage as a lambda expression.

fallen lily
#

Me and my homies HATE lambdas

shadow night
#

Lambdas are the best

#

Lambdas are my life

fallen lily
#

just Reciever.(Param…) -> Return

shadow night
#

Lambdas are forever

fallen lily
#

kotlin blocks op

#

Fuck java bro

shadow night
#

Heil the λαmbda

fallen lily
#

Imagine using MethodHandles

inner mulch
#

kotlin < java

fallen lily
#

What

#

What did blud just say

shadow night
#

It kinda is if you think about it

fallen lily
#

Kotlin is NOT java

shadow night
#

Kotlin compiles to jvm bytecode, jvm is JAVA virtual machine

fallen lily
#

Making it its own separate language

#

Thats just one of many backends

lost matrix
# inner mulch lambda?

If you want we can go into verified and ill show you the basics for streams and functional interfaces.

fallen lily
#

and it is basically nothing like java

shadow night
fallen lily
#

They took everything wrong with java

#

And made it right

fallen lily
#

What

#

Kotlin is functional by drfault

shadow night
#

The issue with jvm langs is, as hard as you try, you will always be stuck to some oop-iness

fallen lily
#

Not kotlin’s