#help-development

1 messages Β· Page 395 of 1

lament swallow
#

colors that aren't the default minecraft ones? how?

tardy delta
lament swallow
#

with ChatColor.of(java.awt.Color)? That doesn't work :/

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

lament swallow
#

i'm getting wrong colors

tardy delta
#

ChatColor.of, the package name is smth with md5 in the name

lament swallow
#
//WARNING is a custom md5 chat color (close to gold)
TextComponent context = new TextComponent(
  Colors.WARNING.getChatColor() + "You are about to override your blablabla"
);```

And this what i get :
icy beacon
#

i can't figure out what this would look like in kotlin?

for (int x = -radius; x <= radius; x++)

i've been trying stuff like

for (x in -radius .. radius step 1)
for (x: Double in radius downTo -radius)

and more, but it's all invalid syntax

#

do i just do a while loop?..

lament swallow
#

1.19.3-R0.1-SNAPSHOT

regal scaffold
lament swallow
#

thanks i'll try that

icy beacon
#

tried that too i think

#

not sure what that means

tardy delta
#

shit weird

icy beacon
#

i'll look this error up

tardy delta
#

just use java

icy beacon
#

no thanks

#

i'll use what i prefer to use

undone axleBOT
tall dragon
crimson mulch
#

Java Gradle Submodule Compiling

coral kelp
#

can anyone do this for me

#

Create or find a rainbow animated text that you want to use.

Open your Minecraft texture pack in an image editing software, such as Photoshop or GIMP.

Locate the textures that you want to modify, such as the font or GUI.

Open the texture file you want to modify in your image editing software.

Paste the rainbow animated text onto the texture file, making sure that it is positioned correctly.

Adjust the opacity of the rainbow animated text to match the texture and make it blend in more seamlessly.

Save the modified texture file and add it to your Minecraft resource pack.

Test the texture pack in Minecraft to make sure that the rainbow animated text displays correctly.

If necessary, adjust the rainbow animated text to better fit the texture and repeat the process until you are satisfied with the results.

By following these steps, you should be able to merge a rainbow animated text with a Minecraft texture pack and create a unique and colorful look for your Minecraft game.

undone axleBOT
coral kelp
#

There all for paying I need a free one :{

tardy delta
#

now i understand why people say mojangs code goes brr

azure cape
#

anyone know how to use hex codes on scoreboard in 1.19.2? i tried the method below but it didn't work properly for some reason, it just seemed to inherit the last integrated color code and use that:

public static String translateHexColorCodes(String text) {
        Matcher matcher = hexPattern.matcher(text);
        StringBuffer buffer = new StringBuffer(text.length() + 4 * 8);
        while (matcher.find()) {
            var group = matcher.group(1).toCharArray();
            if (group == null)
                group = matcher.group(2).toCharArray();

            matcher.appendReplacement(
                    buffer, org.bukkit.ChatColor.COLOR_CHAR + "x"
                            + org.bukkit.ChatColor.COLOR_CHAR + group[0] + org.bukkit.ChatColor.COLOR_CHAR + group[1]
                            + org.bukkit.ChatColor.COLOR_CHAR + group[2] + org.bukkit.ChatColor.COLOR_CHAR + group[3]
                            + org.bukkit.ChatColor.COLOR_CHAR + group[4] + org.bukkit.ChatColor.COLOR_CHAR + group[5]
            );
        }

        return matcher.appendTail(buffer).toString();
    }
tawdry echo
#

IridiumColorAPI

azure cape
#

so i just add that as a dependency in my plugin and then call the proper method?

#

bet, thanks yall

#

is it compatible with variables instead of the actual hex code?

#

to prevent myself from updating hexes in a million different places, i have variables set in my main class and then i just use those variables everywhere else in my plugin

#

yeah should be fine. thanks πŸ‘

charred blaze
#

lmao

#

here u go

quaint mantle
#

anyone knows how to get the id of a sound?

#

it returns a string, i need the int one for nms

charred blaze
#

Integer.valueof()

quaint mantle
#

what

rotund ravine
#

ahahahah

charred blaze
quaint mantle
#

yeah, chatgpt says .ordinal() makes it but i'm not hearing anything

charred blaze
#

whats wrong with my gui?

glossy venture
#

why not Integer.valueOf

#

or Integer.parseInt if you prefer

#

wtf

charred blaze
#

ah

rotund ravine
#

there is probably no clea nway to get the nms id

charred blaze
#

so replace some things and then do integer.valueof?

glossy venture
#

shouldnt getKey().getKey() at least return only x.x

rotund ravine
#

no @charred blaze

tawny remnant
charred blaze
#

that hurt

quaint mantle
undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

charred blaze
#

xd

glossy venture
#

or do you have to do Integer.valueOf(lastOf(getKey().getKey().getPath().split("\\.")))

charred blaze
#

i already did described

#

^

charred blaze
#

uh

#

magic

tawny remnant
rotund ravine
#

show us

azure cape
#

do you happen to have the gradle dependency for it? i cant find it anywhere and im not used to gradle enough to convert it over myself

tawny remnant
charred blaze
#

were u also talking to me there?

#

whats wrong with my code?

azure cape
#

yeah im not finding one anywhere in any plugin that uses the api (that i can find), so im just gonna have to figure out how to convert it over myself. thanks tho

#

that'll work, sure

undone yarrow
#

How can I get 1 random item from List<ItemStack> items

charred blaze
#

create a random

#

and

#

items.get(random.nextInt(items.size()))

#

or something like that

#

thought about it

eternal oxide
#

you don;t as random is upper exclusive

charred blaze
#

so you dont need to?

eternal oxide
#

no

charred blaze
#

i was waiting for this moment

#

long time

eternal oxide
#

nextInt(5) shoudl give you 0-4

charred blaze
#

?learnjava

undone axleBOT
charred blaze
#

xD

thorn crypt
#

Is it possible to get the exact pack of a player ?

charred blaze
#

you bet me fixing my code

charred blaze
#

:D

thorn crypt
charred blaze
undone yarrow
# eternal oxide you don;t as random is upper exclusive

Im storing my items like this though (not sure if it's the best method)

                    List<ItemStack> items = new ArrayList<>();
                    String[] itemStrings = args[3].split(",");
                    for (String itemString : itemStrings) {
                        Material material = Material.matchMaterial(itemString.trim());
                        if (material != null) {
                            ItemStack item = new ItemStack(material);
                            items.add(item);
                        }
                    }``` so is it possible that the player fills in an item that does not exist?
thorn crypt
charred blaze
#

looks like me

#

but how do i keep inventory variable

thorn crypt
#

i'll send you the code it'll be better

charred blaze
thorn crypt
# charred blaze yeah i understand code more than english D: (fr)
public class Menu implements Listener {
    private static Inventory inventory;
    

    public static void menu(Player player) {
        inventory = Bukkit.createInventory(null, 5*9, "Β§cThe Title");
        player.openInventory(inventory);
    }

    public static Inventory getMenu() {
        return inventory;
    }
}
charred blaze
#

but my inventories are different every time

thorn crypt
#

something like that

charred blaze
#

doesnt inventory variable change when you add item in it?

#

no? then i dont need

thorn crypt
#

and then do if (inv.equals(getMenu()))

charred blaze
#

my brain

charred blaze
thorn crypt
#

No problem

thorn crypt
#

and ?

#

Just don't make it static ?

#

But when I don't make it static it wont compile

charred blaze
undone yarrow
#

I have a plugin that stores block locations and other variables. How can I prevent that data from being lost if the server restarts, gets reloaded, crashes, etc?

charred blaze
undone yarrow
#

Is it complicated?

#

Thanks Ill check it out

thorn crypt
eternal oxide
#

its not for a beginner

undone yarrow
#

oh

#

Well it needs to be done lol

eternal oxide
#

you'd be best to just store locations in a yaml file

undone yarrow
#

I finally got everything working btw

eternal oxide
#

nice

undone yarrow
icy beacon
eternal oxide
#

?configs

undone axleBOT
charred blaze
#

issue wasnt about that btw

tall dragon
#

as the majority here uses java

#

????????

icy beacon
#

please tell me ur joking

thorn crypt
#

πŸ˜‚

tall dragon
#

does it look like i read that?

icy beacon
#

I'd hope you did lol

tall dragon
#

jesus chill man i joined the conversation later

icy beacon
#

yeah but I did in fact mention that I use kotlin

thorn crypt
#

Anyway, now he know and will be able to try to help, chill y'all

icy beacon
#

I'm chill lol I'm just confused

tall dragon
#

fair enough

thorn crypt
tall dragon
#

anyway, idk. dont use kotlin

icy beacon
eternal oxide
#

πŸ’© Kotlin

icy beacon
#

cool

glossy venture
tall dragon
icy beacon
#

nah

icy beacon
#

my bad

glossy venture
#

who tf thought that was a good design idea lol

analog thicket
#

Yo if anyone knows Triumph gui, how would i set the first row to glass panes?

icy beacon
#

I'm totally fine with having some small inconveniences

icy beacon
#

I used triumph gui

#

give me 3 mins

tall dragon
tardy delta
icy beacon
#

oh yeah it's the filler

analog thicket
charred blaze
#

can anyone help me to

analog thicket
#

Thats my problem

charred blaze
#

Please

icy beacon
#

what ver are you using

analog thicket
#

Old old 1.8.9

icy beacon
#

ah

#

if ItemBuilder takes ItemStack for from, you could pass it in

#

does it?

#

create the stained pane with a byte magic value

analog thicket
#

i maybe found a fix

#

Gimme a in

#

min

icy beacon
#

I just checked

analog thicket
#

Nvm how would i add the byte stuff to this?

        ```

CrateGUI.getFiller().fill(ItemBuilder.from(Material.STAINED_GLASS_PANE).asGuiItem());```

icy beacon
#

one sec

quaint mantle
#

Bananis

#

Zbll

#

Can you make plugin free please?

icy beacon
#

no

#

ItemBuilder.from(new ItemStack(Material.STAINED_GLASS_PANE, 1, bytevalue))

#

look up the byte value

analog thicket
icy beacon
#

I think it's amount

analog thicket
#

Aaarh

icy beacon
#
new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.BLACK.getData())
#

according to a quick Google search

#

try that

calm robin
#

What event can I use to detect a change in a player's inventory

icy beacon
#

there's no such event I don't think, you can run a per-tick scheduler and see if there are changes and call your own event

#

actually Banannus

#

why don't you use XMaterial

#

for multiversion support

#

from XSeries

analog thicket
#

A library?

icy beacon
#

yeah

#

it's a great library

#

no need to reinvent the wheel, it'll basically cover all of your needs when working with multiversion sounds, particles, materials etc

analog thicket
#

Damn

#

Didn't even know it existed

icy beacon
#

haha live 'nd learn πŸ˜„

#

so yeah if you use it, just pass XMaterial.BLACK_STAINED_GLASS_PANE.parseMaterial() for ItemBuilder

#

smth like that

charred blaze
#

whats wrong with thisss

analog thicket
icy beacon
#

did you reload maven?

charred blaze
#

how many times do i need to paste same code to fix single issue?

icy beacon
#

bro

charred blaze
#

bruh

icy beacon
#

?cba

undone axleBOT
#

Pluggg#5737 definitely regrets to for the most part inform you that unfortunately, they essentially are unable to definitely assist with definitely your enquiry, which essentially is fairly significant. Please simply really ask again later or possibly kind of ask someone else about this enquiry, demonstrating that the person that ran this command generally regrets to kind of inform you that unfortunately, they for the most part are unable to generally assist with actually your enquiry in a subtle way. Thank you very sort of much for kind of your time and the person that ran this command specifically wishes you a really good day, so the person that ran this command really regrets to actually inform you that unfortunately, they literally are unable to definitely assist with very your enquiry, or so they particularly thought.

analog thicket
#

oh i need to shade it

icy beacon
#

@charred blaze

#

the entitlement

undone yarrow
# eternal oxide you'd be best to just store locations in a yaml file

Would something like this work? This is just a snippet

public class ParticleHandler {

    public static Plugin plugin;
    public static final String CHEST_DATA_FILE = "chest_data.dat";
    public Map<Location, ChestObject> chests = new HashMap<>();
    public ParticleHandler(Plugin plugin) {
        this.plugin = plugin;
        loadChestData();
    }

    public void AddLoc(ChestObject chest, CommandSender sender){
        Location loc = chest.getLocation();
        if(chests.containsKey(loc)) return;        }
        chests.put(loc, chest);
        sender.sendMessage("Added (" + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ") to the list.");
        saveChestData(); 
    }

    public void RemoveLoc(Location loc, CommandSender sender) {
        if(chests.containsKey(loc)){
            chests.remove(loc);
            sender.sendMessage("Removed (" + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ") from the list.");
            saveChestData();
            return;
        }
    }``` This is only for the chests Map, I can do the same for the ChestObject class
icy beacon
#

jeez

charred blaze
#

lol

icy beacon
#

all of them

crimson mulch
#

bump

undone yarrow
#

?help

undone axleBOT
#
CafeBabe Help Menu
*Red V3*
**__Admin:__**

selfrole Add or remove a selfrole from yourself.

**__Cleanup:__**

cleanup Base command for deleting messages.

**__Core:__**

embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.

**__Downloader:__**

findcog Find which cog a command comes from.

**__Mod:__**

names Show previous names and nicknames of a member.
userinfo Show information about a member.

**__ModLog:__**

listcases List cases for the specified member.
reason Specify a reason for a modlog case.

**__Permissions:__**

permissions Command permission management tools.

undone yarrow
#

sad

icy beacon
#

?cc list in #bot-commands

charred blaze
#

bump

icy beacon
icy beacon
crimson mulch
icy beacon
#

alr

charred blaze
#

no one?

icy beacon
#

I'm sorry that you are not the center of attention on thy discord server and overall the spigot community

crimson scarab
#

i have a for each consumer of a path to follow, how can i make a projectile follow it exactly

calm robin
#

if i have an inventory, how do i determine if its a player inventory as opposed to a chest, hopper, etc

icy beacon
#

instanceof PlayerInventory

calm robin
#

thanks

rotund ravine
#

I am drunk

#

so noit gonna explain

icy beacon
#

plz help me 😭

#

I still can't find the way to do it

#

actually I could just copy and paste the code into the kotlin file and it'd convert it to kotlin code

crimson scarab
icy beacon
#

but I'm not at my pc rn 😦

crimson scarab
#
        pathfindingResult.thenAccept(result -> {


            if (result.successful() && !projectile.isDead()) {


                result.getPath().getPositions().forEach(position -> {
                    player.getWorld().spawnParticle(Particle.DRIP_LAVA, BukkitMapper.toLocation(position), 5);

                    Bukkit.getScheduler().runTaskLater(this, () -> {
                        Location block_target = BukkitMapper.toLocation(position);
                        Vector target_vector = block_target.add(0, 0, 0).toVector().subtract(projectile.getLocation().toVector()).normalize();


                        projectile.setVelocity(target_vector);
                    }, 3L);
                });
            } else {
                player.sendMessage("Path not found!");
            }
        });

this is the main part

icy beacon
#

nah sorry pal I can't help you here 😦

analog thicket
charred blaze
#

GUI not working as expected

twilit roost
#

is there something like AnvilRepairEvent/AnvilRenamEvent?
I want to check some things when player renames their item

rotund ravine
#

there is in paper/purpur

analog thicket
twilit roost
rotund ravine
#

arraydeque

twilit roost
tardy delta
#

List()?

analog thicket
twilit roost
analog thicket
quaint mantle
#

Anyone got good docs on updating json boolean values?

analog thicket
#

maven

undone axleBOT
analog thicket
#

xseries

#

Hmm how old of a version?

#

aint got any other errors

tardy delta
#

kinda works ig

#

mojang having fun referencing other groups in a certain group file

#

so i gotta make sure that one is loaded before and that i dont have any circular references

magic wharf
#

is Class ChatMessage renamed in 1.19.3?

#

yes

analog thicket
#

Same error

magic wharf
#

ya

undone yarrow
#

someone told me that private void writeObject() and private void readObject() are called during serialization and deserialization of an object, though IntelliJ doesnt say they are

#

it says they arent used

river oracle
#

Just intellij being useless

#

Disable the dumb usage things they are just fucking annoying and generally unhelpful IMHO

tardy delta
#

ignore it

#

or @SuppressWarnings("unused") on class level

undone yarrow
#

So these are being called?

river oracle
#

Yes

tardy delta
#

by internal java code yes

river oracle
#

Intellij just doesn't know it

undone yarrow
#

πŸ‘ good to know, thanks

river oracle
magic wharf
#

it exists

#

ah i see, ty!

analog thicket
rotund ravine
#

I heard maven @tender shard

kind hatch
analog thicket
#

?paste

undone axleBOT
analog thicket
charred blaze
#

how do i determine what caused InventoryCloseEvent? player or something forced it to?

twilit roost
#

how do I get Result Item from Anvil?

swift sequoia
twilit roost
#

This is what I just tried.
Workd fine with placed-down Anvils, but I'm using Plugin-opened Inventory.

My goal is to just get Value entered into that Text Field and confirm it on Rename

swift sequoia
#

this maybe ?

twilit roost
#

yeah, but I can't seem to get ClickEvent when clicking Result

crystal goblet
#

Hi
Does anyone know how to check if the player is on top of a certain block?

half bane
half bane
#

but it will only work if the player is standing on it

twilit roost
half bane
twilit roost
#

Czech here

half bane
#

o tak

tardy delta
#

what about contents[contents.length - 2]

twilit roost
tardy delta
#

ugh you dont need a stream?

undone yarrow
#

If you need to see any code tell me

#

The error happened after I implemented a data save system, that saves data

#
    public void loadChestData() {
        File file = new File(plugin.getDataFolder(), CHEST_DATA_FILE); // line 99 --------------------------
        if (file.exists()) {
            try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file))) {
                Object obj = ois.readObject();
                if (obj instanceof Map<?, ?> data) {
                    for (Map.Entry<?, ?> entry : data.entrySet()) {
                        if (entry.getKey() instanceof Location && entry.getValue() instanceof ChestObject) {
                            chests.put((Location) entry.getKey(), (ChestObject) entry.getValue());
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }```
#

but it needs to be not null obviously

tardy delta
#

why is it static

undone yarrow
#

jk

#

idk man, thought it might work

#

my brain fucks up sometimes

#

Sorry, most of the times*

undone axleBOT
undone yarrow
#

yeah doing that rn

#

yeah

magic wharf
#

ok so i actually misread and its called TranslatableContents

undone yarrow
#

Does this also work?

#

oh still need to remove static

#

or does it have to be public main pluginInstance

magic wharf
#

ya, so what im trying to do is adding a prefix to a scoreboardteam, and it wants me to pass a component. but i dont really understand what that component means

undone yarrow
#

I get this error at startup, but it doesnt seem to affect anything. Commands work java.io.FileNotFoundException: plugins\ScrapCollection\chest_data.dat (The system cannot find the path specified) ...

#

I guess it makes sense

#

that it cant be found, if it doesnt exist

#

huh

#
    public void saveChestData() {
        if(plugin==null) return;
        File file = new File(plugin.getDataFolder(), CHEST_DATA_FILE);
        try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file))) {
            oos.writeObject(chests);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }```?
#

isnt that called saving

#

or am I doing something horribly wrong

#

ohh. Good point. My brain has been fried many so many times today I completely forgot that

#

Soo uh where should it be created

#

just in loadchestdata?

#

and check if it exists

#

if not, create one

magic wharf
#

omg ty!

undone yarrow
#

Alright so now I have this, but the createfile doesnt use a name right? So how can I load a file with a name if I created a file without that name?java public void loadChestData() { if(plugin==null) return; File file = new File(plugin.getDataFolder(), CHEST_DATA_FILE); // line 99 if (file.exists()) { try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file))) { Object obj = ois.readObject(); if (obj instanceof Map<?, ?> data) { for (Map.Entry<?, ?> entry : data.entrySet()) { if (entry.getKey() instanceof Location && entry.getValue() instanceof ChestObject) { chests.put((Location) entry.getKey(), (ChestObject) entry.getValue()); } } } } catch (Exception e) { e.printStackTrace(); } } else{ try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } }

pseudo hazel
#

you cant create a file with no name xD

#

thats still a name

undone yarrow
#

So like this?
file.createNewFile(name);

#

I dont see a parameter for name though

pseudo hazel
#

no

undone yarrow
#

ah

pseudo hazel
#

your File object

undone yarrow
#

🀨

undone axleBOT
pseudo hazel
#

new File()

#

like what is CHEST_DATA_FILE

#

well yeah

#

i know that

#

so thats the file name

undone yarrow
#

I've already done too much programming today. Understanding a new concept is too far-reached for me atm

#

I just wanted to finish this lol

pseudo hazel
#

its not new

#

you create the File using new File

#

which is where you specify the filename

undone yarrow
#

ohhh

#

OHHHH

#

I think I get it

#

let me test my code

#

Alright, so if I ignore the 593 errors, it's working

#

?paste

undone axleBOT
undone yarrow
#
    public void loadChestData() {
        if(plugin==null) return;
        File file = new File(plugin.getDataFolder(), CHEST_DATA_FILE); // line 99
        if (file.exists()) {
            try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file))) {
                Object obj = ois.readObject();
                if (obj instanceof Map<?, ?> data) {
                    for (Map.Entry<?, ?> entry : data.entrySet()) {
                        if (entry.getKey() instanceof Location && entry.getValue() instanceof ChestObject) {
                            chests.put((Location) entry.getKey(), (ChestObject) entry.getValue());
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        else{
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public void saveChestData() {
        if(plugin==null) return;
        File file = new File(plugin.getDataFolder(), CHEST_DATA_FILE);
        try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file))) {
            oos.writeObject(chests);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }```
smoky oak
#

question, how do i serialize an spigot class that implements ConfigurationSerializable as a byte array?
this is what I'd do if it'd implement java.io.Serializable, but the interfaces arent the same

ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(serializationInput);
byte[] objectBytes = bos.toByteArray();
#

the internal serialization just spits out a Map<String, Object>

pseudo hazel
#

why do you want byte arrays

smoky oak
#

sql blob

#

doesnt that only take byte arrays

pseudo hazel
#

ConfigurationSerializable cant be serialized to a byte array afaik, unless you serialize it yourself

undone yarrow
pseudo hazel
#

ConfigurationSerializable is meant for the yml serialization stuff

#

read the line with your classes in it

#

and then look for the class and line number

#

and show us the line where the error occurred

#

does that parse existing spigot classes?

smoky oak
#

im about as sure that im about to get hit by a meteor about the ability of this thing to parse either a itemstack or a map

undone yarrow
#

Also uh what are these things? Why are they being ignored?

pseudo hazel
#

you ignore them

undone yarrow
#

why

pseudo hazel
#

those methods return an object

smoky oak
pseudo hazel
#

which you discard

smoky oak
pseudo hazel
#

a boolean

undone yarrow
#

ohh alright, so those warnings dont matter

pseudo hazel
#

whatever, close enough

#

yeah they dont

undone yarrow
#

so thats not causing my java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.bukkit.Location error

pseudo hazel
#

no

#

but did you find the lines of code I am talking about?

undone yarrow
#

uhh you were talking about lines of code?

pseudo hazel
undone yarrow
#

ah alright

undone axleBOT
smoky oak
#

whats your point

pseudo hazel
#

it wont

undone yarrow
#

brb

pseudo hazel
#

you cant serialize a Map<String, Object> to a byte array atleast not like that

#

how do you save an itemstack as a byte array

#

without implementin serialization for an itemstack yourself

#

yeah exactly, so I guess you can turn anything into a byte array, you just need to serialize it yourself

quaint mantle
#

Idk can someone help, How do I compile .java from string?

pseudo hazel
#

why?

#

you mean at runtime?

quaint mantle
#

yes

pseudo hazel
#

have you googled it?

quaint mantle
#

I googled but didnt work 😦

pseudo hazel
#

what did you try

undone yarrow
#

But do I necessarily need to save that Map?

#

I think I do

pseudo hazel
#

?

#

I thought you were the person that was creating a file

tardy delta
#

just tested it and CopyOnWriteArraySet#addAll with 500 elements takes 20 times longer than calling #add on every element

#

1100Β΅s vs 54Β΅s

pseudo hazel
#

which one takes longer?

#

addall?

#

nice

tardy delta
#

rephrased it, ye

pseudo hazel
#

how did they even do that

#

also you need to test taht like a billion times to get some reliable result

tardy delta
#

didnt know that stuff called toArray which basically defeats my point, but i was still confused cuz add creates a new copy of the whole internal array

undone yarrow
pseudo hazel
#

what map

#

you still havent found where your errors are xD

undone yarrow
#

That you mentioned

tardy delta
#

i have no clue how i have 545 recipes loaded but minecraft only has 379 or smth :/

undone yarrow
#

The public Map<Location, ChestObject> chests = new HashMap<>();

pseudo hazel
#

okay

pseudo hazel
#

you want to save that to the file?

undone yarrow
tardy delta
#

only shaped recipes πŸ’€ so that cant be possible at all

pseudo hazel
#

oh well depending on how you did that its probably where you are making the mistake

undone yarrow
tardy delta
#

damn raw gold block is a thing

pseudo hazel
tardy delta
#

normally shouldnt

pseudo hazel
#

so where di you get the idea that mc only has 379 recipes

tardy delta
#

google ig πŸ’€

pseudo hazel
#

kay

#

well google is probably like 100 years outdated

tardy delta
#

well 1.16 but that doesnt matter

#

ugh we are on 1.19 already

pseudo hazel
#

yeah

#

a lot of stuff got added xD

tardy delta
#

they better havent added hundreds of items?

pseudo hazel
#

well they did add like 4-5 new biomes and reworked overworld terrain generation

#

they added a wood type

#

they added deepslate

tardy delta
#

lemme just assume its correct cuz i gotta load 1000 files

#

and all these things look pretty legit

pseudo hazel
#

yeah

tardy delta
#

tf is a pink_stained_glass_pane_from_glass_pane tho πŸ€”

pseudo hazel
#

why wouldnt it be

#

it means they painted it instead of crafting it from pink glass blocks

#

i.e. painting glass panes pink

tardy delta
#

this game is a brainfuck

#

somethow the recipe files also include this crap

#

like it doesnt even have data :/

pseudo hazel
#

lmao

#

yeah idk shit about recipes other than that there are a lot and they suck to parse

tardy delta
#

can anyone ask that bing bot how many items mc has lol, i dont trust google anymore πŸ’€

#

well the parsing for shaped recipes works for 100% now

pseudo hazel
#

what are you making btw

tardy delta
#

its just mojang that decided to be an idiot to sometimes use a json array, sometimes an object etc

#

a recipe loading system for minestom, as it doesnt have recipes by default

#

gotta implement crafting too

pseudo hazel
#

yikes

tardy delta
#

last time i checked there was just a big todo

pseudo hazel
#

I mean sounds like a fun project though

tardy delta
#

mmh

#

already got 350 lines and i still gotta deal with the other types

tardy delta
#

lol

undone yarrow
#

doesnt seem right lmao

tardy delta
#

and it isnt aware of 1.19

pseudo hazel
#

its outdated af

undone yarrow
#

so we went from 537 to 111

tardy delta
#

so my map tends to resize a lot lol, gave it an initial capacity of 380 places but if mc has a few thousand items πŸ’€

pseudo hazel
#

I think its talking about reciped added in 1.18

pseudo hazel
#

why even give it a capacity if you dont know how it should be yet xD

tardy delta
#

πŸ’€

#

uhh i assumed there were only 379 recipes so i gave it that many places

pseudo hazel
#

right

undone yarrow
#

oooof

pseudo hazel
#

which isnt gonna break for any other version of minecraft

#

ofc

tardy delta
#

should look at my memory dump

#

uhh minestom is 1.19.2

#

adding new recipes should work, that map is gonna get resized but not too big of a deal cuz it only happens at startup

#

as long as mojang isnt a bitch and changes the json format

pseudo hazel
#

what map are you using

tardy delta
#

hashmap lmao

pseudo hazel
#

oh

#

well capacity doesnt really matter then

#

like probably it's less fragmented

tardy delta
#

i was trying to figure that out a few hours ago

#

and to go to the conclusion, i have no damn clue if it matters

pseudo hazel
#

like its called initialcapacity meaning it will just scale up for more elements

tardy delta
#

ye

#

every single shaped recipe object seems to be 40B

#

22KB recipes, not bad at all

#

what

undone yarrow
pseudo hazel
#

well

#

what does it look like

undone yarrow
#

I need to save public Map<Location, ChestObject> chests = new HashMap<>(); public void loadChestData() { if(plugin==null) return; File file = new File(plugin.getDataFolder(), CHEST_DATA_FILE); // line 99 if (file.exists()) { try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file))) { Object obj = ois.readObject(); if (obj instanceof Map<?, ?> data) { for (Map.Entry<?, ?> entry : data.entrySet()) { if (entry.getKey() instanceof Location && entry.getValue() instanceof ChestObject) { chests.put((Location) entry.getKey(), (ChestObject) entry.getValue()); } } } } catch (Exception e) { e.printStackTrace(); } } else{ try { file.getParentFile().mkdirs(); // Create directory if it doesn't exist file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } }

undone yarrow
#

?'paste

#

?paste

undone axleBOT
undone yarrow
#

@pseudo hazel

#

I realize plugin is not properly assigned in the serializableLocation class, but thats because I gave up after already changing 50% of my code

pseudo hazel
#

I would reccomend using ConfigurationSerializable for the location serializer

#

and whats a ChestObject

undone yarrow
#

it stores variables for blocks

#

it has nothing to do with Chests

pseudo hazel
#

okay

#

so that should also implement ConfigurationSerializable?

undone yarrow
#

would that prevent me from having to change 50% of my code?

pseudo hazel
#

no

undone yarrow
#

...

pseudo hazel
#

if you want to write something that works properly you need to rewrite most of it anyways

#

but the goal in the end is to do more with less lines of code

#

if you created a serialization for teh ChestObject and SerializableLocation you can easily store those in a yml file

undone yarrow
#

Ill continue tomorrow. Too late now

crisp arch
#

is this a bug

#

where the result item of a smithing table recipe copies lore and display name of the base item

#

when in reality the barrier is supposed to say &cError

#

and no lore

#

easy fix because i just have to make an event for a PrepareSmithingEvent to intercept the result item, but its kinda annoying and seems like its unintential

crimson mulch
#

Why player.setMaxHealth is deprecated in the latest version ?

eternal oxide
#

it now uses attributes

crimson mulch
#

dude :#### i need to add so many wrapper

#

imma cry

dry yacht
somber hull
#

Everything i try data is null

    public GraveDataManager(Main plugin) {
        gson = new Gson();
        configFile = new File(plugin.getDataFolder(), "gravedata.json");
        initializeConfig();
    }
    
    private void initializeConfig() {
        try {
            FileReader fileReader = new FileReader(configFile);
            data = gson.fromJson(fileReader, GraveData.class);
            if (!configFile.exists() || data == null) {
                gson.toJson(new GraveData(), new FileWriter(configFile));
                data = gson.fromJson(fileReader, GraveData.class);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
#

I cant figure out why

crimson mulch
rough ibex
somber hull
somber hull
rough ibex
#

if it's blank then fromJson is functioning correctly

somber hull
#

but data is null

rough ibex
#

gravedata.json is empty yes

somber hull
#

yes

#

Does toJson write a null file when you have an empty class?

#

Like

#

Jackson Json i know puts {} so that it doesnt throw null when reading

rough ibex
#

you're calling fromJSON

#

I don't know, what do the docs say

somber hull
rough ibex
#

You're free to do that

#

but why do you expect data to not be null

#

if the contents of gravedata is nothing

somber hull
#

ok

#

so

#

i think i know how to fix it but you didnt need to be a dick abt it

rough ibex
#

I'm not sure how exactly I was being a dick, but you're free to think that.

somber hull
rough ibex
#

Any attitude you read from that is entirely your own

rough ibex
#

I legitimately do not know what toJson does in that scenario.

somber hull
#

alr

#

im tired i think imma hop off

rough ibex
#

so I simply advised you to check the documentation instead of offering bogus advice

#

I apologize if I came off as mean

somber hull
#

thank you i appologize for missreading the text

rough ibex
#

No problems man.

#

Good luck with your project.

somber hull
somber hull
#

ok im back with another weird thing

#
    public void saveData(){
        try{
            gson.toJson(data, new FileWriter(configFile));
            for(String str : data.getLocationList()){
                System.out.println(str);
            }
        } catch (IOException e){
            e.printStackTrace();
        }
    }
#

this is running correctly

#

its printing the string

#

but it doesnt save to the file

#

inside data is a list of strings

rough ibex
#

I misread, nvm

#

Are you sure that the second argument to toJson allows a FileWriter?

somber hull
rough ibex
#

and new FileWriter() is returning a writeable file?

crimson mulch
somber hull
#

it checks if it exists beforehand

somber hull
#

leme look up what flush does

rough ibex
#

Use try with resource

try ((FileWriter n = FileWriter(xxx))) {
  n.dostuff();
}``` I believe is the syntax.
remote swallow
#

or be lazy and @Cleanup new FileWriter

crimson mulch
rough ibex
#

Sugar is tasty though

bold vessel
#

Hi, i want to make unclickable menu in chest that make command when we interact with the item, anyone have example ?

crimson mulch
#

If you want without just open an inventory, and listen to InventoryClickEvent, verify if it is the good inventory and then check if it is the good item and then handle the command

bold vessel
#

Idk somethings like deluxemenu i want to make it myself

crimson mulch
#

Which version are you using ?

bold vessel
#

1.19.3

#

And i want everyone can open the menu

crimson mulch
#

With a command ?

#

or from an item

bold vessel
#

Command

crimson mulch
#

Create a command, than create and open the inventory to the player, handle the clicks to execute your command with a listener

bold vessel
#

Ok but som1 say me if i do this, only one person on the server can open the inventory

#

Its going to close it for other people

crimson mulch
#

Who said that ?

somber hull
rough ibex
crimson mulch
somber hull
#

Ok so its not writing the data but its writing json now.

rough ibex
#

to the file?

somber hull
#
{"locationList":[]}
#

yea

bold vessel
somber hull
#

so i have it save on disable

#

and i have it print on save

crimson mulch
somber hull
#

when disabling it it prints the correct information

#

but doesnt put it in the file

#
    public void saveData(){
        try (FileWriter fileWriter = new FileWriter(configFile)){
            gson.toJson(data, fileWriter);
            for(String str : data.getLocationList()){
                System.out.println(str);
            }
        } catch (IOException e){
            e.printStackTrace();
        }
    }
rough ibex
#

Can you show your updated code

#

Oh, thanks

bold vessel
rough ibex
#

and what is configFile

#

I don't see it defined here so it's somewhere else

somber hull
#

configFile = new File(plugin.getDataFolder(), "gravedata.json");

rough ibex
#

does it point to a valid file

somber hull
#

when it prints it does but ti doesnt save it

#

hhang on it might be an issue with how i reload the plugin

#

i cant find anything on it

#

what happens when using /reload

#

i would assume it runs the disable and enable functions of all plugins

rough ibex
#

and no errors print

somber hull
#

nope

#

ok

#

i found the issue

#

not the solution

#

but the issue

#

now its saving on disable but erasing on enable so where i initialize it smthng is wrong

crimson mulch
#

Show your Main class

somber hull
#

theres a lot going on ill just show you where i initialize the config

#
    private void initializeConfig() {
        try (FileReader fileReader = new FileReader(configFile)) {
            data = gson.fromJson(fileReader, GraveData.class);
            if (!configFile.exists() || data == null) {
                System.out.println("Hello");
                data = new GraveData();
                saveData();
            }
        }catch (IOException e){
            e.printStackTrace();
        }
    }
crimson mulch
#

?paste

undone axleBOT
crimson mulch
#

pase ur whole

#

class with that

#

I'll read it

#

dw

somber hull
#
package me.silentprogram.rees.data.graves;


import com.google.gson.Gson;
import me.silentprogram.rees.Rees;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class GraveDataManager {
    GraveData data;
    Gson gson;
    File configFile;
    
    
    public GraveDataManager(Rees plugin) {
        gson = new Gson();
        configFile = new File(plugin.getDataFolder(), "gravedata.json");
        initializeConfig();
    }
    
    private void initializeConfig() {
        try (FileReader fileReader = new FileReader(configFile)) {
            data = gson.fromJson(fileReader, GraveData.class);
            if (!configFile.exists() || data == null) {
                System.out.println("Hello");
                data = new GraveData();
                saveData();
            }
        }catch (IOException e){
            e.printStackTrace();
        }
    }
    
    public void saveData(){
        try (FileWriter fileWriter = new FileWriter(configFile)){
            gson.toJson(data, fileWriter);
        } catch (IOException e){
            e.printStackTrace();
        }
    }
    
    public GraveData getData(){
        return data;
    }
    
}
#

theres not a lot

#

but i have multiple "main classes"

#

its a plugin for a friend so i broke a few rules

crimson mulch
#

I just want the "onEnable" method and the "onLoad"

somber hull
#
    private void startup(){
        dataManager = new GraveDataManager(plugin);
        data = dataManager.getData();
        plugin.getServer().getPluginManager().registerEvents(new DeathChestListener(this), plugin);
        
        plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
            dataManager.saveData();
        }, 0, 1000);
    }
crimson mulch
#

😭

somber hull
#

this is run onEnable()

crimson mulch
#

ONENABLE

rough ibex
#

Is that all that's inside your onenable

somber hull
#
    @Override
    public void onEnable() {
        saveDefaultConfig();
        startup();
    }


    private void startup() {
        configManager = new ConfigManager(this);
        if (configManager.isGraveEnabled()) {
            gravesMain = new GravesMain(this);
        }
        
    }
    
#
package me.silentprogram.rees;

import me.silentprogram.rees.data.graves.GraveData;
import me.silentprogram.rees.data.graves.GraveDataManager;
import me.silentprogram.rees.listeners.DeathChestListener;

public class GravesMain {
    GraveData data;
    GraveDataManager dataManager;
    private final Rees plugin;
    
    public GravesMain(Rees plugin){
        this.plugin = plugin;
        startup();
    }
    private void startup(){
        dataManager = new GraveDataManager(plugin);
        data = dataManager.getData();
        plugin.getServer().getPluginManager().registerEvents(new DeathChestListener(this), plugin);
        
        plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
            dataManager.saveData();
        }, 0, 1000);
    }
    
    public void disable(){
        dataManager.saveData();
    }
    
    public GraveData getData(){
        return data;
    }
    
}

crimson mulch
#

yeah show me your "GraveDataManager" class

somber hull
#

the print hello is for testing

rough ibex
#

most reliable debugger

somber hull
#

honestly

#

ok i think its working but all i did was remove the print hello

#

so idk

#

πŸ˜‚

crimson mulch
#

Dude, I LOVE GITHUB COPILOT

somber hull
#

Whats the new way to get a minecraft skull

#

the material used to be SKULL_ITEM whats the updated material name?

#

cant find anyhting on the forums

#

its all outdated

#

nor the documentation

rough ibex
#

With or without a custom texture

#

It's Material.PLAYER_HEAD

remote swallow
#

PLAYER_HEAD iirc

rough ibex
#

Yep

somber hull
wet breach
#

it would be a string that has world,x,y,z,pitch,yaw

remote swallow
#

target if maven, out/build if ij build system

dry yacht
#

Is there any way to run code on the next tick if a plugin is being disabled, or is that absolutely impossible?

remote swallow
#

with world, pitch and yaw

#

and they would be doubles

tawdry echo
#

X,y,z also double to teleport to the center od block

remote swallow
#

xyz would also be doubles

#

but yeah

sterile token
#

You can also take in care that locations are serializable/deserializable objects, so you can directly do:

Location location = ;
Config config = ;
config.set("game-location", location);

Location loc = config.getLocation("game-location");
quartz relic
#

When you forget your login so you can’t verify

sterile token
#

Mainly contact a forum staff

#

They can help you

#

But don dm them

delicate lynx
sterile token
quartz relic
#

Anyways, I need some help🀣 I’m lost in the sauce with creating a plug-in that when you break a certain block that is listed in a custom yml after breaking so many of any of the blocks it drops an item

sterile token
#

πŸ€”

#

@delicate lynx he broken our brains hahaha

#

Now i dont know what he wants

delicate lynx
#

so you have a list of blocks, and if you break it x times, you want it to drop something?

sterile token
delicate lynx
#

it's all good

cobalt thorn
#

Hi, stupid question how can i get where’s the player is watching and spawn a particle in front of his visual?

sterile token
delicate lynx
#

could also getLineOfSight no?

cobalt thorn
delicate lynx
#

or getTargetBlock?

cobalt thorn
lost matrix
sterile token
delicate lynx
#

you can always just check

lost matrix
quartz relic
sterile token
lost matrix
cobalt thorn
quartz relic
#

I can explain my thing alittle more

lost matrix
delicate lynx
#

that doesn't return null tho

sterile token
#

Mainly 1.19 for sure πŸ’€

lost matrix
sterile token
#

I understand what you needing

quartz relic
lost matrix
delicate lynx
#

what part do you need help with specifically?

sterile token
#

@quartz relic what do you have so far?

#

Any code? If yes use

#

?paste

undone axleBOT
delicate lynx
# lost matrix

I was looking at getTargetBlock(), not exact which makes more sense

quartz relic
#

Ima be honest like the entire thing, this has me confused af, I spent like 8hours today watching a spigot coding course tryna just learn different shit about spigot and none of it has come together to help me get this thought into the code

sterile token
#

If you really want to code plugins, start from beggining

quartz relic
#

I am

sterile token
#

Learning Java

lost matrix
quartz relic
#

It has a Java basics section i have gone through

sterile token
#

I woud straight forward suggest learning Java, and not touching spigot api

quartz relic
#

I should have a general idea of the basic Java stuff that will get me through most of the stuff

sterile token
#

I would mainly recommend learning Java concepts, like fields, types, POO, sync and async, etc

#

There are lot of things more ofc but its a mess naming all

quartz relic
#

Well obviously there’s a lot more🀣

#

It’s a whole ass language

sterile token
#

No, python is whole ass

quartz relic
#

Hahaha

sterile token
#

Dont u agree? Hahaha

quartz relic
#

All languages do

#

It’s something I ain’t even close to familiar with🀣

sterile token
#

oh right, programing tis something you must really like

quartz relic
#

Get more familiar less ass it becomes

sterile token
#

If not, dont go there

quartz relic
#

I have an interest in it

#

Trying to stick with it

lost matrix
# quartz relic It has a Java basics section i have gone through

Well then just use 2 structures:
A Map
A List or Set

The Map contains players as keys and Integers as values.
Use the UUID of a Player instead of the Player itself.
Map<UUID, Integer>

When the player joins: Add him to the Map
When he leaves: Remove him from the Map

The value in the Map is your per-player counter.

On BlockBreakEvent: If broken block material is in your List/Set
-> Get the int of that player from the map, increment it by 1 and write it back in the map
-> If this counter is X then drop an item and write 0 back in the map again

sterile token
#

I didnt know you smile having that amazing patient

#

Such a god saver

quartz relic
#

Removing them would mean if they broke let’s say 20 blocks and the amount is set at 22 to give the reward, if they leave and join back does that progress reset?

sterile token
sterile token
#

All java types are memory mainly

quartz relic
#

Ok so noted, ima need to have that stored somewhere

#

I don’t want the progress to reset

sterile token
#

My bad its 3 am and im kinda sleeping

#

Cyao

quartz relic
#

You good

lost matrix
quartz relic
#

Ima need to get a lot of other stuff working before i even do that

#

I’m still stuck on square 1, the start🀣

tardy socket
#

I hope to add some advancements to my server, but I didn't found how to register them

#

besides I didn't found a function to set their parent

lost matrix
#

Gson πŸ˜„

#

Yes. But Spigot also provides Gson on default.

#

If you make a lib for spigot plugins then you should depend on Spigot

#

Ah ok

#

You can serialize everything with Gson

undone axleBOT
lost matrix
#

This doesnt block projectile attacks

#

Or flint&steel

#

Or lava buckets

#

BlockIgniteEvent or PlayerInteractEvent. Both work

hybrid turret
#

I want to create a 3 * 9 inventory for a confirmation-gui.
The only thing I can't wrap my head around is how I will automatically move the items to the slot I want (basically slot 11 and 15).

lost matrix
hybrid turret
#

oooh

lost matrix
# hybrid turret oooh

Well how much java knowledge do you have? Because there are some more advanced concepts in this guide.

hybrid turret
hybrid turret
#

just had a break lol

lost matrix
hybrid turret
#

This is actually super interesting, ty

hybrid turret
lost matrix
#

You need to cancel PlayerInteractEvent if the player holds a lava bucket

#

Unless you want to let them place the lava but only prevent the damage. This would be complicated but doable.

hybrid turret
#

rather the 2nd one tbh

lost matrix
#

Then you will need a manager that keeps track of placed lava blocks and where they flow using the BlockFromToEvent.

hybrid turret
#

oh yeah what i was wondering but never really researched tbh, when i implement a listener, can i just add multiple events in one method?

lost matrix
#

You are not allowed to ever create an instance of your JavaPlugin class

brave sparrow
#

?di

undone axleBOT
brave sparrow
#

It is, but you can still use dependency injection

hybrid turret
#

Wait you're supposed to parse null when setting the owner of a created inventory? o.O

hybrid turret
#

i'm reading the gui guide

#

whoops

#

wrong link

hybrid turret
lost matrix
tardy socket
#

Can I jusy leave 'getcriteria' null when creating a new advance ment

hybrid turret
#

naaaaah don't need that. i've just been using the player

tardy socket
hybrid turret
#

also if i wanted to create a vault-system... how would i save the inventories that belong to a player when restarting the server? or just saving the items in those inventories in general?

#

just saving them in a file?

brave sparrow
#

You’ll have to decide if you want to save it to files or a database or wherever

hybrid turret
#

ic

tardy socket
#

you can create a database i think

brave sparrow
#

You can, that’s not necessarily the best way

hybrid turret
#

database? o_o haven't done that yet at all

brave sparrow
#

Really depends on your use case

lost matrix
brave sparrow
#

^

hybrid turret
#

ahh

#

ic

#

so basically if it were a bungee-server it would be a database?

#

interesting

#

well not my use case tho

brave sparrow
#

Not as easy when you’re saving items

#

Lol

hybrid turret
#

lmao

brave sparrow
#

But that’s just serialization

#

It’s doable

lost matrix
#

Well you can just dump the whole inventory in a Base64 String and save it as blob.
Then DB is as easy as a File.

hybrid turret
#

soooo, would i just save it in a HashMap or sum?

#

:o

#

okay that's new land for me lmao

#

damn

brave sparrow
hybrid turret
#

really?

#

why?

brave sparrow
#

Could use an object store or something too

lost matrix
hybrid turret
#

yeah that would be my thinking as well

lost matrix
#
  • async saving the map every 15mins or so because of crashes
hybrid turret
#

or upon closing the inventory... but i guess that's not that... optimized?

brave sparrow
#

Depends how risk averse you want to be

#

You can save it periodically, or you can save when they close

hybrid turret
#

could it be funky when multiple players use it at once?

brave sparrow
#

If you save when they close it’s not quite as optimized for writes because you may be writing it a bunch of times, but you won’t lose any data if the server crashes

tardy socket
#

i suggest that if there'll be lots of players joining your server, it'll be faster to use a database

brave sparrow
lost matrix
#

The problem with writing on every close is properly handling all the IO.
IO shall not be done on the main thread or your server will just lag for sure.

hybrid turret
brave sparrow
hybrid turret
#

like every known server i know

lost matrix
#

*And you can not read it again while you are saving. So this has to be taken into consideration.

tardy socket
#

I mean, not just the online players but all players who have ever joined your server

brave sparrow
#

You wouldn’t be writing the whole server every time you write

tardy socket
#

Anyway you should not delete their data even if they haven't log in for a few month

brave sparrow
#

If you’re storing it in files I would also hope you’d compartmentalize it by player

hybrid turret
#

i haven't done ANYTHING with databases so that would be kinda out of the question for now

brave sparrow
#

The best time to learn something was yesterday

#

The second best time is today

#

Lol

hybrid turret
#

LMAO

#

Coder mindset xD

lost matrix
# brave sparrow That would have to be really slow IO to be an issue tbf

Average DB access on a DB on the same machine is >25ms
On decentralized machines its easily >100ms depending on the DB size, your connection
speed and what type of persistent storage is used.
Thats 50% of the servers tick up to 200% of the servers tick.
This will lead to lag, no matter what.

brave sparrow
tardy socket
#

you can try mysql i think

lost matrix
#

Ah ok XD

brave sparrow
#

You should never do IO on the main thread

lost matrix
#

Yeah i sure hope the OS handles this

onyx fjord
#

My database is called just another markup language

brave sparrow
#

But the chances of the player closing their vault inventory and being angry they can’t reopen it within those 100ms

#

Is very small

onyx fjord
#

Blazing fast

hybrid turret
#

wow okay i know so much less than i expected o_o

brave sparrow
#

There shouldn’t really be any user input for an sql injection to occur here to be fair

lost matrix
brave sparrow
hybrid turret
#

the whole files?

brave sparrow
#

One file per player yeah

onyx fjord
#

That's faster than 1 file for entire server

hybrid turret
#

really?

brave sparrow
#

Significantly

hybrid turret
#

i always thought the more files the worse

onyx fjord
#

Yeah cuz you get smaller files

hybrid turret
#

huh

lost matrix
#

sure. Create a folder in your plugins folder player-vaults and in there you have dozens of files. One per player.

hybrid turret
#

ohhh that makes sense

brave sparrow
onyx fjord
#

Just just werks

brave sparrow
#

But you’ll only be doing one at a time anyway

onyx fjord
#

That's how I do it in my plugin

lost matrix
brave sparrow
#

^

#

You’re doing more selective reads than mass reads so it makes sense to split it up

brave sparrow
#

If you were mostly going to be reading everybody then one file might be better

hybrid turret
#

OH MY, I got another idea for a new thing :D

lost matrix
# hybrid turret damn

With this you let the OS handle all the hard work:

    File playerFile = new File(pluginFolder, playerUid.toString() + ".yml");
    
    if(playerFile.exists()) {
      // load data from file
    } else {
      // create data for new player
    }
onyx fjord
#

Atomic?

lost matrix
#

-.-

hybrid turret
onyx fjord
#

Why atomic

brave sparrow
#

Wdym why atomic

onyx fjord
#

Why

brave sparrow
#

Why what

onyx fjord
#

What's the advantage

#

Oh

brave sparrow
#

Well I was making a joke that you can’t be sure the file still exists when you try to read from it after the check, and you can’t be sure the file doesn’t exist when you try to create it after the check

#

Because the operation there isn’t atomic

#

Now, in this use case that isn’t really required, so it was more a joke

onyx fjord
#

Resources

brave sparrow
#

In that resources folder

onyx fjord
#

Is that intellij thing rly?

brave sparrow
#

Looks like it

hybrid turret
#

I just have it in src lmao

brave sparrow
onyx fjord
#

Yeah

#

Yup

hybrid turret
#

bc i created the project before i was using intellij plugins and never bothered to change my system xD

brave sparrow
#

I mean you can theoretically have it anywhere

#

It’s just convention for it to be there

hybrid turret
#

like me in src 😎

tardy socket
#

wait a minute

#

what is translations.yml

onyx fjord
#

Probably messages

brave sparrow
#

I would assume it’s translations

#

Just a guess

hybrid turret
#

NO WAY

tardy socket
#

shouldn't the translations be placed in assets.lang.(**.lang)?

onyx fjord
#

😐

hybrid turret
#

i mean, ig it depends on how u implement it

brave sparrow
onyx fjord
#

Not everyone needs multi translations

#

Yeh

#

And it's more work

tardy socket
#

thanks

onyx fjord
#

I mean just recently I added translations to my lib

tardy socket
onyx fjord
#

Before I had everything in config

#

That's also a good way

#

I'd stick to en.yml or en-us.yml

tardy socket
#

Well I wonder can I just leave 'getcriteria' returning null when creating a new advancement

onyx fjord
#

Oh shit I had that too

#

Idk where it is

onyx fjord
#

Anonymous

#

Expect us