#help-development

1 messages · Page 1732 of 1

opal juniper
#

its not needed

#

its static cause i just yoinked the method

glossy venture
#

its not bad either

#

so why not

#

you should just straight up generate the blocks

#

not first collect all of them

opal juniper
#

onMove you can use the boolean return of add rather than call the contains and then add

glossy venture
#

smort

lavish hemlock
#

why? they look like util methods

glossy venture
#
    public HashSet<Long> generated = new HashSet<>();
    public Material[] materials;

    static {
      // collect block materials
      List<Material> mat = new ArrayList<>(50);
      for (Material m : Material.values()) {
        if (m.isBlock()) mat.add(m);
      }
      materials = mat.toArray(new Material[0]);
    }

    static long getChunkKey(int x, int z) {
        return (long)x & 4294967295L | ((long)z & 4294967295L) << 32;
    } // using olijeffersOn's key function
  
    @EventHandler
    public void onMove(PlayerMoveEvent e){
        Chunk chunk = e.getTo().getChunk();
        if (!(e.getFrom().getChunk().equals(chunk))){
            long key = getChunkKey(chunk);
            if (chunks.add(key)) {
               chunks.add(key);
               regenerate(chunk, new Random());
            }
        }
    }

    static void regenerate(Chunk c, Random r) {
      // get world
      World world = c.getWorld();
      
      // get min and max height
      int mn = world.getMinHeight();
      int mx = world.getMaxHeight();

      int l = materials.length;
      
      // loop over blocks and set them to random material
      for (int x = 0; x < 16; x++) {
        for (int z = 0; z < 16; z++) {
          for (int y = mn; y < mx; y++)
            Block block = c.getBlock();
            if (!block.isEmpty() && !block.isLiquid()) 
              block.setType(materials[r.nextInt(l)]);
        }
      }      
    }
glossy venture
lavish hemlock
#

static is invoked faster anyway iirc

glossy venture
#

no need to make it instance reliant

opal juniper
regal moat
#
    @EventHandler
    public void onMove(PlayerMoveEvent e){
        if (!(e.getFrom().getChunk().equals(e.getTo().getChunk()))){
            if (!(hasBeenGenerated.contains(e.getTo().getChunk().getChunkKey()))) {
                hasBeenGenerated.add(e.getTo().getChunk().getChunkKey());
                World world = e.getTo().getChunk().getWorld();
                int maxY = Math.abs(world.getMinHeight()) + world.getMaxHeight();

                for (int x = 0; x < 16; x++) {
                    for (int y = 0; y < maxY; y++) {
                        for (int z = 0; z < 16; z++) {
                            Block block = e.getTo().getChunk().getBlock(x, y, z);
                            BlockState state = block.getState();
                            if (!(block.isEmpty()) && !(block.isLiquid()) && !(state instanceof TileState)) {
                                Material random = Material.values()[new Random().nextInt(Material.values().length)];
                                if (random.isBlock() && !(random.isEmpty())){
                                    block.setType(random);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
#

There

glossy venture
regal moat
#

i think != i know

#

sfhsjdafhd

regal moat
#

Ah, so sets doesn't let duplicate items

#

thanks

#
            boolean isExisting = hasBeenGenerated.add(e.getTo().getChunk().getChunkKey());
            if (!(isExisting)) {
#

like this then?

glossy venture
opal juniper
#

well you can inline it

regal moat
#

ohh

#

i dont need a variable

#

right?

opal juniper
regal moat
#

We did optimize the code a bit

#

But it's still laggy

#

How Is this so laggy, but when you are setting blocks with worldedit its not

glossy venture
#

@regal moat there are some more optimizations you need to do

#

ur constructing a random every time

regal moat
#

Sigh

#

I am randomizing it when the player moves to a new chunk that has been never entered before

opal juniper
#

ThreadLocalRandom

glossy venture
#
Material random = Material.values()[new Random().nextInt(Material.values().length)];
#

for every single block ur making a new random

regal moat
#

Uh

#

Yeah

#

Because all the blocks are going to be randomized

glossy venture
glossy venture
opal juniper
#

ThreadLocalRandom.current()

regal moat
lavish hemlock
#

Random is expensive to instantiate

#

you should create a single Random or use the instance of ThreadLocalRandom returned by current

glossy venture
opal juniper
#

What the man said

glossy venture
#

as the seed is always the same

regal moat
#

thanks

#

Any more optimizations I should do?

opal juniper
#

i like threadlocalrandom cause it has a lower bound iirc

glossy venture
#

remove the block.getState()

dense remnant
#

How do I send a actionbar message in 1.17?

glossy venture
#

ur not using it

regal moat
#

Bruh

#

i am fucking using it

#

dumbass

dense remnant
#

wtf

lavish hemlock
#

I believe ThreadLocalRandom may be slower in some way? Idk, I'd have to benchmark.

opal juniper
#

woah

regal moat
#

state instanceof TileState

ivory sleet
opal juniper
#

oh greate

regal moat
opal juniper
#

he’s here to shit on muh party

glossy venture
#

just construct a new one for every chunk

#

for maximum randomness

regal moat
#

what

ivory sleet
#

SplittableRandom snooze

opal juniper
#

what is so bad with ThreadLocalRandom

#

smh

ivory sleet
#

It’s bound to the thread

glossy venture
#

or use

if (this.random == null)
  this.random = new Random();
ivory sleet
#

0 reproducibility if something goes wrong

regal moat
#

Uh

#

Random r = new Random();

regal moat
#

I have this in the class

opal juniper
#

just make a field var

#

yeah

glossy venture
ivory sleet
#

And SplittableRandom can be used in a parallel environment by splitting it which creates a new instance but isn’t that expensive

opal juniper
#

well it won’t be null then

#

it will be defined on instantiating

regal moat
#

I have 3 projects to manage

glossy venture
#

no but if you instantiate it when the class is loaded

#

then the seed might be the same

lavish hemlock
glossy venture
#

as it uses the uptime in nanoseconds right?

ivory sleet
#

Probably the case for TLR also if you share it across threads that is

opal juniper
#

meh whatever then

#

don’t use it

lavish hemlock
#

but yeah just private static final Random random = new Random();

regal moat
#

I am trying to create my own programming language from scratch, with I am not good at, I am also trying to make a game using GameMaker Studio, I am also doing... this!

ivory sleet
#

Oo

#

Gl

lavish hemlock
#

I am trying to create my own programming language from scratch
good fuckin' luck mate

#

I made my own lang a while back

#

lemme find it

#

it's easy to parse bc it's an assembly lang but

opal juniper
#

we

#

ew

lavish hemlock
#

it's still special :)

opal juniper
#

delete

#

fury lang

lavish hemlock
#

like me, in many different ways

ivory sleet
#

Lmao

lavish hemlock
#

you can't argue that it doesn't work

opal juniper
#

why the hell are the file endings .fur

#

i hate it

lavish hemlock
#

it's just not very fun to use

#

it's like
the worst assembly lang in terms of QoL

#

(which is ironic)

ivory sleet
#

maow it’s a good language lol

regal moat
ivory sleet
#

^

tardy delta
#

meow

lavish hemlock
#

: )

glossy venture
#
Random random = new Random(System.currentTimeMillis() * System.nanoTime());
#

maybe this

lavish hemlock
#

oh

#

yeah that's not, I don't think?

glossy venture
#

?

regal moat
lavish hemlock
ivory sleet
#

orby you probably want to have a seed where you store it somewhere in case something goes really bad and you screw up, you can at least reuse the seed for reproducibility shrug

lavish hemlock
regal moat
#

gonna name it lunar

lavish hemlock
#

it has a Python-like language

#

called GDscript, very nice

regal moat
#

Nah

#

I already did a lot in gamemaker

#

i dont wanna do it all again

lavish hemlock
#

it's not a hard engine to learn

glossy venture
lavish hemlock
#

there's a "Your first game" tutorial you can complete in like

#

30 minutes?

regal moat
#

i am most familiar with gamemaker

lavish hemlock
#

I mean you can keep using GameMaker if you want

#

but I urge you to at least try out Godot

regal moat
#

i did

#

i cant send an image

#

oof

lavish hemlock
#

you're not verified

#

just send it to me

opal juniper
#

or just get verified

glossy venture
opal juniper
#

lol

glossy venture
#

oops duplicate chunks.add

#

fuck

#

use services on the forums if its minecraft related

#

otherwise seek help at another discord server

#

for web development

ivory sleet
#

?services

undone axleBOT
golden turret
#

forgot how to do a delay system using maps

#

always false

ivory sleet
#

Uh

golden turret
#

context: blocking twice break block

ivory sleet
#

Well you store a timestamp

#

And then when you need to, compare the current time against the timestamp by checking if the stored timestamp summed with the delay is greater than or equal to the current time millis, if that’s the case then the cooldown is still on.

#

remember to have everything in the same time unit

glossy venture
#

@golden turret

private static final int DELAY = 2 * 1000; // 2 seconds in ms
private static final Map<Player, Long> times = new HashMap<>();

... // in method or something
if (System.currentTimeMillis() - times.getOrDefault(player, DELAY) >= DELAY)
  times.put(player, System.currentTimeMillis());
  /* do stuff */
#

i think this may work

#

arena ur searching doesnt exist

#

idk

#

getArena is null

#

thats what it sais in the error description

undone axleBOT
glossy venture
#

thats the same error

#

you will need to figure out why getArena(int) is returning null

#

no but why is getArena giving null

#

you are appereantly trying to get an arena that doesnt exist

#

yeah so the id that you are passing as a parameter is of a nonexistant arena

#

so figure out where that id is coming from

#

and handle it

twin sapphire
#

hey, i tried to implement an update check for my plugin

chrome beacon
#

Don't use legacy api

twin sapphire
#

@chrome beacon what else?

alpine urchin
quaint mantle
#

hello I need help with Itemstack I was not able to find anything online

#

buy I have a customenchantplugin that adds enchants to items and I also have a kit plugin whitch so how to I add custom enchant to an item

#

I don't mean like adding sharpness 10

#

I mean like a custom enchanment

#

tried this customItem.addUnsafeEnchantment(Enchantment.getByName("Speed"),1);

quaint mantle
#

kk let me try this

#

1.8.8?

young knoll
#

Oh

#

Gross

quaint mantle
#

ok I get it not supported

young knoll
#

No idea how you get custom enchantments in 1.8

#

static instance? idk

quaint mantle
#

some plugin able to do it

#

advancedenchantment

#

I think I can try to find how they add it to items in the first place system.out.print the content and use setdata

tight hedge
#

Ayo so i wanna disable iridium skyblock shop and use another one how do i do it?

#

ive been trying for a while now cant figure it out

quaint mantle
#

you use ugly numeric ids in 1.8 iirc

#

Fuck 1.8

twin sapphire
#

how long does it take to get the latest version from spiget? just some minutes?

opal juniper
#

the latest version of what?

quaint mantle
#

lmfao

chrome beacon
grave kite
#

Hi, what is the best way to scan all loaded chunks for blocks without freezing the main thread? runTaskAsynchronously seems to drop TPS significantly while also dropping a lot of warnings in the console

quaint mantle
#

just sounds funny to me every time

opal juniper
#

not all tasks are async friendly

young knoll
#

You could get a snapshot of each chunk to scan async

#

But that would still be expensive

grave kite
chrome beacon
grave kite
opal juniper
grave kite
# opal juniper that will take a while depending on what you do
    public static int checkChunk(Set<Material> materials, Chunk c) {
        int count = 0;
        int cx = c.getX() << 4;
        int cz = c.getZ() << 4;

        for (int x = cx; x < cx + 16; x++) {
            for (int z = cz; z < cz + 16; z++) {
                for (int y = 0; y < 256; y++) {
                    if (materials.contains(c.getBlock(x, y, z).getType())) {
                        count++;
                    }
                }
            }
        }
        return count;
    }
#

I run this method for each chunk

young knoll
#

Yeah that is gonna take a bit

#

Hopefully materials is a set and not a list

grave kite
#

should I take a snapshot of the chunk?

opal juniper
young knoll
#

I knew that

#

I can read I swear

opal juniper
#

😉

grave kite
opal juniper
#

yeah dw

#

he is having a moment

grave kite
#

Is runTaskAsynchronously the best way to run async tasks?

ivory sleet
opal juniper
#

hmmm, there are many ways

grave kite
grave kite
opal juniper
#

i mean you are gonna have to take a chunk snapshot i imagine if you wanna do this off main thread

ivory sleet
#

yes

#

you allocate less memory negligibly

#

and its more readable

opal juniper
#

it is not really more readable lol

ivory sleet
#

it is tho lol

grave kite
#

ok, thanks guys

opal juniper
#

splitting hairs at this point lol

ivory sleet
#

Sets::newHashSet decouples instantiation

#

by using that you really dont know how the instantiation is which is polite to the reader if it just want to know what you're doing in high, abstract terms

ivory sleet
grave kite
ivory sleet
#

?scheduling

undone axleBOT
ivory sleet
#

I suggest looking into that

#

but anyways, if you do async stuff which has no correlation to spigot, then using the executor api and future api might be a better choice than unintentionally growing craft schedulers cached thread pool

grave kite
#

it's really complex stuff. I run this thing just a couple of times a day, I'll probably use craft schedulers anyway due to lack of free time

ivory sleet
#

Sure

grave kite
#

but thanks for your advices

young knoll
#

If you run it that infrequently you could stagger it

#

Check 1 chunk per second or something

#

Of course you have to worry about loading and unloading

grave kite
young knoll
#

Right, but will they stay loaded

grave kite
#

I could probably unload them manually, but I think it's even more complex

warm mica
#

Bukkit has implemented runTaskAsynchronously very poorly where it creates a new thread whenever it runs your task

#

That's bad as the creation is a more or less heavy task

#

Before you're working with that many blocks you should create - if possible - a chunk ticket (1.14) so that the chunk doesn't get randomly unloaded

warm mica
ivory sleet
#

it doesnt necessarily create a new thread

warm mica
#

I'm pretty sure that it does that, or at least that's how I remember it when I checked the code of it

ivory sleet
#

afaik cached thread pools might reuse an already created thread assuming it isn't already working on a task

warm mica
#

Oh I'm wrong, it's not that bad

ivory sleet
#

Yeah well Idk, I mean it could easily get out of control as its essentially a fixed thread pool with the upper thread bound limit as Integer%MAX_VALUE so yeah the implementation is arguably poor (since threads arent just free ofc which ya know) no doubt about that, was just picking on ur words a bit

warm mica
ivory sleet
#

yeah

#

but even so, short tasks, even a work stealing pool would suit more, in most cases

bright jasper
#

Time to start back with my plugin 😆 new branding gives me motivation

young knoll
#

Better discordsrv?

bright jasper
#

yep

#

also forge/fabric support later on

#

already migrated everything away from spigot API and made my own API which spigot implements

#

so core functionality is in one package and platform providers are in their own and a jar is built for each platform

#

took a while but yeye

warm mica
ivory sleet
#

You can create a cached variant of a work stealing pool tho also

#

Anyways I myself would have created a thread pool per plugin if I were to design it but anyways its hard to generalize the pool implementation if we don't know the exact tasks which will run in the pool, and most percent of the times specifying your own implementation will most likely benefit you assuming you're knowledgeable enough about Java's concurrency api.

mellow edge
#

Is it possible to see or to decomplie java server, Im asking it here because is more tehnical question to ask

opal juniper
#

yep

ivory sleet
#

java server?

#

as in the spigot jar?

mellow edge
#

to get source code from .jar file

ivory sleet
#

not source

warm mica
#

I'm not sure if a cached/non fixed variant of a stealing pool would be better as it has a larger overhead the more threads there are. I think that what spigot has right now isn't that bad

ivory sleet
#

but you can get decompiled compiled code

opal juniper
#

you can’t get verbatim the source back

warm mica
#

Bungee is actually creating one for each plugin

opal juniper
#

but you can get back the equivalent src

mellow edge
#

ok

#

so is it possible?

warm mica
#

But that method is deprecated as ig it's better when the plugin is creating its own

opal juniper
#

yep

#

just run it thru a decompiler

#

there are online ones

#

or something like fernflower works

mellow edge
#

So that I can just upload a file and decompile it

opal juniper
#

yep

ivory sleet
mellow edge
#

it sounds good lol I want to see socket handling and that sort of stuff

ivory sleet
#

With a cached thread pool you literally cant stop it from growing, and small tasks are from what I have experienced less efficiently handled than a fjp

warm mica
#

If I'd have created and I'd be certain that that method is only being used with the knowledge that you shouldn't do anything that might block it (like with io things or whatever) then I'd have implemented it the same

ivory sleet
#

yes but should and want to handle io tasks in a separate thread pool than the cached thread pool craftscheduler uses

#

and assuming you know the blocking coefficient then a fjp would work great with io or whatever "big" tasks you may use it for

#

thats probably the biggest flaw of having a generic cached thread pool in the first way and people who aren't educated enough about common pool, spigot devs will use it for anything including IO

warm mica
#

I think the best solution would be to just make the thread pool accessible

#

The real benefit of what Spigot has created is a solution that allows you to start something at a given time

#

People who know what they're doing could just access the thread pool and create their queues from that one

ivory sleet
#

Paper does expose it

warm mica
#

Instead of having each plugin creating their own pool that just do nothing the most time

warm mica
ivory sleet
#

And thread pools generally do create threads lazily, not eagerly iirc

ivory sleet
warm mica
#

I'm thinking of the way we used to do that on a previous larger server I worked for

#

We had a thread pool for every plugin

#

And there were hundreds of them

#

Meaning that we had hundreds of threads that basically just did nothing most the time

ivory sleet
#

sounds like an implementation flaw

#

but yeah having stuff just idling isn't great

young knoll
#

Can you swim in a thread pool

ivory sleet
#

legend says you can 👀 🏊‍♂️

warm mica
#

Allowing devs to just access the pool and do whatever they want with their thread is a so much greater solution, I wish spigot had that

ivory sleet
#

well

#

you cant do whatever you want

young knoll
#

Not with that attitude

ivory sleet
#

and that'd break liskov substition principle which is quite essential for most apis

#

but they do expose it as an Executor

#

so in other words, you could use it when for instance creating completablefutures

#

Ig ExecutorService could be fine

#

but they'd have to create a delegate to block termination methods etc

barren nacelle
#

Can someone help me with this

ivory sleet
#

lm have a look

#

custom name

barren nacelle
#

wdym

ivory sleet
#

or nvm

#

@barren nacelle

#

what does not work btw?

barren nacelle
#

Yes

ivory sleet
#

what does not work?

lavish hemlock
#

Y e s

barren nacelle
#

It just isnt working

ivory sleet
#

what isnt working

barren nacelle
#

I dont know what

ivory sleet
#

so what goes wrong?

barren nacelle
#

oh yeah the HOLOGRAM isnt working

lavish hemlock
#

VHAT WHAPPANS WHIN START PLOOGIN?

ivory sleet
#

wym by isnt working

#

does it spawn?

#

or does it not?

#

what exactly is NOT working?

barren nacelle
barren nacelle
ivory sleet
#

you might have forgotten to drop your plugin jar into ur plugins folder

lavish hemlock
#

have you tried turning it off and on again?

young knoll
#

Does that work for humans

lavish hemlock
#

hopefully

barren nacelle
#

No its in the folder but not being used I can delete it without a warning

fading lake
#

if I listen to the PacketType.Play.Server.CHAT packet through protocollib, will this include messages they've received from their internal client/server broadcasts (like join messages, server broadcasts or responses from commands)

ivory sleet
#

iirc yes

young knoll
#

I wonder if I should bother replacing protocollib with my own Injector

#

Would free me from waiting when version updates come

ivory sleet
#

ooo

#

yaa

young knoll
#

It will be a bit slower because of reflection

#

Also not sure if it will be async

ivory sleet
#

but ya sounds like smtng I could use if u'd acc do it

paper viper
young knoll
#

I’ve done it before with reflection

#

Based on a forum tutorial

#

Since the fields are final in a packet iirc

ivory sleet
#

Unsafe snooze

sage pine
#

Hey guys!

I have a question for all you developers out there. What are some questions I can ask to weed out inexperienced developers from hiring on a project?

Looking to bring on a lead engineer to handle the entire backend of a large-scale java network (with kubernetes or an alternative form of automated scaling) so it is fairly difficult for me to know who is really good and motivated compared to those who can talk out their ***

barren nacelle
#

But the thing is the hollogram isnt spawning

paper viper
#

Are you listening to packets?

paper viper
#

Or creating them

barren nacelle
paper viper
#

No

ivory sleet
#

So ask them about flaws surrounding some of Bukkit

paper viper
#

Ask them also basic interview questions too

young knoll
#

I’m listening and modifying them

paper viper
ivory sleet
paper viper
#

From netty

ivory sleet
#

You probably want to ask non googleable questions xD

paper viper
#

Lol

#

Like me

ivory sleet
#

Cap

paper viper
#

I showed up to an interview for an organization once

#

I improvised everything

#

I still got in tho

#

XD

#

But it was bad replies

ivory sleet
#

Ya

sage pine
#

See, I don’t want to ask stupid questions that even I won’t know the answer to haha

paper viper
#

Maybe also ask like a problem too

#

Like a spigot problem

#

And let them describe the solution

sage pine
#

Its so hard to find competent developers with serious experience with automated deployment or generally, just backend

young knoll
paper viper
#

It’s private

young knoll
#

Ah, yes it is

#

?paste

undone axleBOT
paper viper
#

Scroll down to the PacketListener part

#

I extended the ChannelDuplexHandler, so I can see all packets being sent out and received with Netty

#

The downside is that you are left with Objects you know

sage pine
#

Finding people who know how to code in a way that is easy to work off of/make changes are a pain too

paper viper
#

And also you have to inject:uninject players too

ivory sleet
#

Why should we avoid using common pool in terms of spigot?
|| Blocking other tasks the server is queuing on the common pool ||

Is one also

young knoll
sage pine
#

I think thats more important

paper viper
#

Great minds think alike

ivory sleet
#

Gokor

lavish hemlock
#

I am soooo far beyond on Bukkit API knowledge, holy shit.

ivory sleet
#

The best way to learn if someone’s is experienced is by gaining the experience yourself

lavish hemlock
#

What is the best way to learn the entire API? :)

young knoll
#

Is that async like the protocollib listeners?

ivory sleet
#

Try use every api method maybe, Maow

paper viper
lavish hemlock
#

I want like

#

docs

#

or not docs but tutorials

paper viper
#

It’s hard to do it asynchronous tho

lavish hemlock
#

examples actually

young knoll
#

Hmm darn

#

Don’t really want to loop 1024 values in a fairly hot packet on the main thread

ivory sleet
sage pine
#

But you’re right

ivory sleet
#

Hire me

paper viper
#

Maybe you are better off hiring devs

#

Yeah hire me and Conclure

ivory sleet
#

I can tell if someone’s experienced I’d say lol

paper viper
#

I don’t need pay

#

Lol

#

We do it for fun and interesting

lavish hemlock
#

plus I find docs to be a lil overwhelming if you're just trying to learn something

ivory sleet
#

Well I have worked professionally under a company which had a spring project but else than that everything I do is more or less unprofessional, so you’ll just have to trust this bloke

#

But I love code reviews so ya

paper viper
#

Conclure vouch for me

#

I hope

#

I vouch for him

paper viper
#

For staff

#

xD

ivory sleet
#

Yeah I vouch you

paper viper
#

You should first have them fill out a google form of some sort

#

Get some basic info

#

Then setup an actual interview

young knoll
#

Have them make a join message plugin

#

Will probably weed out more people than you would expect

paper viper
#

If they struggle making 1 listener

#

🥲

ivory sleet
paper viper
#

Yeah

#

Fork the repo

lavish hemlock
#

oh no, not DAJLM

paper viper
#

Ez acceptance

#

My contribution is the greatest

lavish hemlock
#

oh my god that's a real repo what the fuck

paper viper
#

I shall contribute another 100k blank lines for hacktoberfest

lavish hemlock
#

OH

#

IT'S BY YOU (Conclure)

#

YOU FUCK-

paper viper
#

Yes by Conclure lmao

#

Approved by md too

lavish hemlock
#

event™️

young knoll
#

Define approved

paper viper
#

#general message

young knoll
#

I never expected to see that type of message from md

#

And I never want to again

lavish hemlock
#

OH GOD

#

I LOOKED INTO THE MAIN CLASS

#

crying why

#

whyyyyy

paper viper
#

You want enterprise?

#

You get enterprise

ivory sleet
#

Hahaha

lavish hemlock
#

but how fast is it?

young knoll
#

Does it run and is it async

ivory sleet
#

Uh

#

I think it’s async

#

And it’s possibly slow but since async it must be fast!

young knoll
#

Sold, I’ll take 12

ivory sleet
#

🥲

young knoll
#

You’ve gone beyond heretere levels of annotation

ivory sleet
quaint mantle
#

if async, it's fast™️

ivory sleet
#

Some facts right there!

young knoll
#

It’s a sink, it’s fast

lavish hemlock
#

if you open it in an IDE

#

and remove SuppressWarnings

#

is the entire thing just yellow on the right

#

if not, you're doing something wrong

#

it should look like Kraft cheese if it runs properly

quaint mantle
#

Kraft cheese

formal dome
#

i know how im' gonna make my app different from scarz's

#

he has everyone make their own bot

#

im gonna see if i can make one bot that everyone can use

young knoll
#

Probably not cheap is the issue

formal dome
#

who's charging?

#

discord?

#

does discord charge for api usage at a certain point

hasty prawn
#

You have to host the bot

paper viper
hasty prawn
#

Where as DiscordSRV uses the server instance to host it, which is definitely ideal IMO

paper viper
#

^

young knoll
#

Yeah hosting isn’t free

#

No idea how much the shard system costs

formal dome
#

🤔

#

well maybe i won't be better than scarz's

#

but at least i'll have a fun project

#

cuz the point of it is to learn anyways

lavish hemlock
#

what the fuck is org.bukkit.conversations?

true perch
#

When a player dies or logs in, this is executed:

World world = Bukkit.getWorld("world");
if (world != null){
    player.teleport(world.getSpawnLocation());
    player.sendMessage("You have teleported to world spawnpoint.");
}``` The very first time a player joins they do not get teleported there. Why is that?
young knoll
#

Basically you ask the user for input and they reply and then you can ask for more input etc

lavish hemlock
#

does anything actually use it?

young knoll
#

Not often

#

But some things do, yes

young knoll
formal dome
#

my computers pretty beefy, wonder how much it could handle reasonably

hasty prawn
#

You'd have to leave your PC on 24/7

young knoll
#

Plus you need the network to handle that

young knoll
hasty prawn
#

Does Discord force you to use shards after 2500 or is that just recommended?

young knoll
#

Sharding is only required at 2,500 guilds—at that point, Discord will not allow your bot to login without sharding.

hasty prawn
#

Interesting

formal dome
#

you can't charge for spigot plugins i'm betting

#

gotta look into pricing and see if its cheap or expensive

#

like $10/mo

#

for a coulpe hundred servers or somethin

#

i'd do that

#

that'd be fun

#

like from my own money

young knoll
#

You can charge for spigot plugins

#

But people will probably just use discordsrv in that case

formal dome
#

does spigot get some of that profit?

young knoll
#

Don’t think so

formal dome
#

xD

#

i like md5 anyways

#

if i made any money i'd donate

#

he's a good dude

#

wonder if mojang has any restrictions

#

didn't they sell to microsoft?

young knoll
#

You aren’t suppose to sell things you make for minecraft

#

But I remember hearing they were okay with spigot so ¯_(ツ)_/¯

quaint mantle
#

i dont think so man, microsoft even collected data for total money that the community got over the year by selling mod (idk if they count plugin as "mod")

formal dome
#

All I'm saying is, if it cost money to run and it's worth it

quaint mantle
#

people really cant be mad about developers charging for their work, the plugins take a long time and motivation to create

paper viper
#

Yeah. Many plugins that are expensive usually took months of work

quaint mantle
#

that is the dev choice

#

even if the plugin not expensive or hard to make, the dev still have the choice to charge it

#

now the rest is that he will get a very little money from it, or maybe the resource would get delete b4 someone see it

formal dome
#

well i'll make an alpha

#

and all that

#

so i don't go wasting my time lol

#

i gotta lot to learn before i get there anyways lol

#

and all i'm really wondering is if its legal lol

#

seems like it is

quaint mantle
#

guys can we do this?

onenable
registerconstructor();

}
public void registerconstructor() {
something = new someevenweirdthing(this);
}```
zinc monolith
worldly ingot
quaint mantle
golden turret
#

hello

#

i want to show some data in the player's chat

#

and i want to use pages

#

and i want it to be automatic

#

like

#

if you type, /command 3 <- the page

#

it will show the page 3

#

:o

#

context: the player can have a lot of spawners

echo basalt
#

next page runs /command <page + 1>
previous page runs /command <page - 1>

golden turret
#

i did it

#

?paste

undone axleBOT
golden turret
valid solstice
#

is there a remove method for the FileConfiguration class?

#

i want to remove path with its value in my file config

drowsy helm
#

im pretty sure setting it to empty does the same thing

valid solstice
#

ill set it to null?

#

won't it be {value : null}

drowsy helm
#

just an empty string

valid solstice
#

so the key is still there

drowsy helm
#

if i remember correctly, i havent used file config in a while

valid solstice
#

correct me if im wrong, but setting the value to null will make the key still exist right?

drowsy helm
#

not null

#

empty string

young knoll
#

Setting it to null will remove the key

valid solstice
rotund patio
#

is using the the bungeecord plugin channel needed for plugin channels to work with bungee?

golden turret
#

maybe yes maybe not

rotund patio
#

that doesnt help

waxen plinth
#

Yeah it doesn't remove the key

#

To my knowledge this is an implementation detail though

#

Different maps work differently, but HashMap is the most commonly-used implementation and setting null as the value does not remove the key

#

To remove a key you have to explicitly call remove

sullen marlin
#

@waxen plinth config not map

#

Bukkits config api will remove with null

waxen plinth
#

Ah, yeah

last ledge
#

how do i make a command executable only once by a player?

waxen plinth
#

Cooldown?

#

Or you want them to run it once and never be able to run it ever again?

young knoll
#

If it’s just 1 you are probably fine just sticking a tag into the players pdc

#

If it’s several you probably want something external

last ledge
#

just once

young knoll
waxen plinth
#

Then you need to save it somewhere persistent

#

The simplest way to do this?

#

Give the player a tag

#

player.addScoreboardTag("usedCommand")

#

Then later you can do player.getScoreboardTags().contains("usedCommand") to check if they have used the command already

young knoll
#

Forgot about scoreboard tags

waxen plinth
#

They can be quite useful

last ledge
#

ah ok thank you so much dude

young knoll
#

Do those change if you change the players scoreboard

waxen plinth
#

I don't think so

#

I think that one only changes what is displayed to the player

#

It doesn't erase any data from the main scoreboard

tacit drift
#

i think the safest way would be to save in a json/db

young knoll
#

Fair

hasty prawn
#

What if they change their username?

tacit drift
#

or yml

waxen plinth
#

It's attached by uuid not username

waxen plinth
#

That's so much more effort than just attaching a scoreboard tag

young knoll
#

PDC is another option

#

Don’t really need a file for 1 thing

waxen plinth
#

For something simple like this, a scoreboard tag makes sense

#

Yeah PDC also works

#

Probably better practice honestly

hasty prawn
#

Good. I know like /scoreboard is still saved by Username for whatever reason so they break when someone changes their name.

waxen plinth
#

But a scoreboard tag is also a perfectly usable solution, you might just want to namespace the tag so there's no chance of collision

young knoll
#

What

young knoll
#

X

waxen plinth
#

Same

hasty prawn
#

I think so, atleast in 1.16.4 they still were. I had a death counter and if someone changed their name it went to 0

#

If they changed back, they got their old death count

young knoll
#

Oh wow it is

#

That is dumb

hasty prawn
#

It sure is lmao

waxen plinth
#

If that's the case I would worry scoreboard tags work the same way

#

Use PDC in that case

young knoll
#

You can just use a byte and the has() method

#

The value doesn’t even matter

waxen plinth
#

wasting 7 bits there

#

Make a Bit class

young knoll
#

Still has to resolve to primitives

last ledge
#

do i do with scoreboard

#

or what

young knoll
#

PDC

last ledge
#

what is pdc now

hasty prawn
#

?pdc

pastel stag
#

whats the correct object you must use for UUIDs in arraylists

#

is it just UUID ?

#

from java.util?

young knoll
#

Yes

pastel stag
#

any ideas as to why this isn't working when my UUID is in the arraylist? i also tried if(!array1.contains(player.getUniqueID())){
just in case it was an issue w/ my array handling

    private Main plugin;
    public ToggleBlockDebugger(Main plugin) {
        this.plugin = plugin;
        plugin.getCommand("wblockdebugger").setExecutor(this);
    }

    ArrayList<UUID> array1 = new ArrayList<UUID>();

    @EventHandler
    public void onBreak(BlockBreakEvent event) {
        Block block = event.getBlock();
        Player player = event.getPlayer();
        Location b_loc = block.getLocation();
        if (array1.contains(player.getUniqueId())) {
            player.sendMessage(ChatColor.GREEN + "[/wblockdebugger] You broke: " + block.getType());
            player.sendMessage(ChatColor.BLUE + "[/wblockdebugger] Location: ");
            player.sendMessage(ChatColor.GOLD + "[/wblockdebugger] World: " + b_loc.getWorld().getName());
            player.sendMessage(ChatColor.DARK_RED + "[/wblockdebugger] X:" + b_loc.getBlockX());
            player.sendMessage(ChatColor.DARK_RED + "[/wblockdebugger] Y:" + b_loc.getBlockY());
            player.sendMessage(ChatColor.DARK_RED + "[/wblockdebugger] Z:" + b_loc.getBlockZ());
        }
    }
    public void onPlace(BlockPlaceEvent event) {
        Block block = event.getBlock();
        Player player = event.getPlayer();
        Location b_loc = block.getLocation();
        if (array1.contains(player.getUniqueId())) {

            player.sendMessage(ChatColor.GREEN + "[/wblockdebugger] You placed: " + block.getType());
            player.sendMessage(ChatColor.BLUE + "[/wblockdebugger] Location: ");
            player.sendMessage(ChatColor.GOLD + "[/wblockdebugger] World: " + b_loc.getWorld().getName());
            player.sendMessage(ChatColor.DARK_RED + "[/wblockdebugger] X:" + b_loc.getBlockX());
            player.sendMessage(ChatColor.DARK_RED + "[/wblockdebugger] Y:" + b_loc.getBlockY());
            player.sendMessage(ChatColor.DARK_RED + "[/wblockdebugger] Z:" + b_loc.getBlockZ());
        }
    }
#

no events getting passed through or something idk, nothing happens on blockplace or break rn

drowsy helm
#

is it registered

pastel stag
#

new ToggleBlockDebugger(this);

and

getServer().getPluginManager().registerEvents(new SQLLogger(this), this);

in main class

#

sec

drowsy helm
#

thats instantiating it but is it being registered

sullen marlin
#

you also didnt annotation BlockPlaceEvent

pastel stag
#

@drowsy helm getServer().getPluginManager().registerEvents(new ToggleBlockDebugger(this), this); included in main class

young knoll
#

Yeah the lack of annotations would do it

pastel stag
#

@sullen marlin ah i see that now, onBreak is not working either tho 😒

young knoll
#

Where is the onCommand code

pastel stag
#
    public boolean onCommand(CommandSender sender, Command cmd, String s, String[] args) {
        Player player = (Player) sender;
        if (!(sender instanceof Player)) {
            sender.sendMessage(ChatColor.RED + "Only players in-game may execute this command!");
            return true;
        }
        if(player.hasPermission("watchblock.blockdebugger")){
            if(args.length == 0) {
                if(!array1.contains(player.getUniqueId())){
                    array1.add(player.getUniqueId());
                    player.sendMessage(ChatColor.DARK_GREEN + "[WATCHBLOCK] Block debugger enabled, repeat cmd to disable.");
                    Bukkit.getLogger().info(ChatColor.YELLOW + "[WATCBLOCK] Block debugger enabled for " + player.getName());
                }
                else if(array1.contains(player.getUniqueId())){
                    array1.remove(player.getUniqueId());
                    player.sendMessage(ChatColor.DARK_GREEN + "[WATCHBLOCK] Block debugger disabled, repeat cmd to enable.");
                    Bukkit.getLogger().info(ChatColor.YELLOW + "[WATCBLOCK] Block debugger disabled for " + player.getName());
                }
                return true;
            }
            else{
                player.sendMessage(ChatColor.RED + "[WATCHBLOCK] You have specified too many arguments.");
                return false;
            }
        }
        if(!player.hasPermission("watchblock.blockdebugger")){
            player.sendMessage(ChatColor.RED + "[WATCHBLOCK] You do not have permission to use that command!");
            Bukkit.getLogger().info(ChatColor.RED + "[WATCHBLOCK] " + player.getName() + " was denied access to " + cmd.getName());
            return true;
        }
        return false;
    }```
#

further down in the class, all the command does is add/remove people from array1

#

and the command is successfully adding/removing from the array because my command output is flipping from disabled/enabled when i use /wblockdebugger

quaint mantle
#

heyo, i cant use NMS in 1.17 - im wondering how i should use a nickname system then

mainly because, im not sure how i can change their skin, nametag, etc.

#

ok english

pastel stag
#

@young knoll any thoughts or no clue, im stumped lol i feel like this constructor somehow is related?? public ToggleBlockDebugger(Main plugin) { this.plugin = plugin; plugin.getCommand("wblockdebugger").setExecutor(this); }
idk tbh this is the one part of java coding i still fail to understand exactly how it works lol

#

i dont see how that constructor would be stopping the EventHandler from doing its thing tho

quaint mantle
#
  • the classes are obfusicated, which i could just de-obfusocate im sure but i really cbb
#

if i have to de-obfusacate i'm sure that's just gonna need constant work

young knoll
#

You don’t have to, just use obfuscated stuff

#

Or use the maven remapper

last ledge
#

ok my PDS worked, but i have a query. If i delete my world, will the NBT values reset?

young knoll
#

If you delete the player data, yes

last ledge
#

so, if i have multiple worlds

#

for example i am in Abcd world

young knoll
#

Player data is stored in the main world

last ledge
#

and i use a command which sets player's nbt value

#

now if i go to another world

#

will the values be different?

young knoll
#

No

last ledge
#

different worlds have same nbt values?

young knoll
#

The value is stored on the player

#

The player data is the same across worlds

last ledge
#

uh kk thanks

maiden mountain
#

Hey guys, i need some help. So i'm storing player data by their UUID. Now when i try to check if the playerUUID exists in the data. it returns false

#

Even tho its inside the data

#

@pastel stagAre you having the same issue?

quaint mantle
#

md_5, wat is the first thing you guys do when a new version come out huh

drowsy helm
#

we can't just guess

maiden mountain
#
  public boolean isOwner(UUID playerID) {
        boolean isOwner = this.Settings.MasterAdminUUID.toString() == playerID.toString();
        Bukkit.getLogger().info("Admin = " + isOwner);
        return isOwner;
    }
#

I've checked the data and the masterAdminUUID is indeed the playerID

#

But it returns false

drowsy helm
#

why do you need to compare them both .tostring

#

if they are both uuids they dont need to be converted

#

and its probs because you are using == and not .equals

maiden mountain
#

I tried that aswell, doesnt work

#

hmm

#

I'm to used to C# i guess

#

ahahah

young knoll
#

== generally will not work for strings

maiden mountain
#

Yep, it works now

#

I'm just to used to C#

drowsy helm
#

yeah its a stupid java quirk

maiden mountain
#

thanks for the quick help ❤️

vague oracle
#

How is it a stupid "java quirk"

#

One checks to see if its the same object, other checks if they have equal value

pastel stag
#

@maiden mountain no my issue isnt w/ the array or UUID storage

vague oracle
#

What is your problem atm? The events not firing or the contains not working

pastel stag
#

do i have to separate an @EventHandler from my toggle and put it into a different class?

#

i still am clueless as to why my toggle eventhandler is straight up not working

glossy venture
#

Sorry field i mean

ivory sleet
#

That looks alright tho

#

lowerCamelCase

#

Oh nvm

#

Just spotted it

valid solstice
#

i have a file configuration named "config" what method do i use to get all the contents from it?

eternal oxide
#

if it is config.yml you call in your onEnable() saveDefaultConfig()

valid solstice
#

no its not my config.yml

eternal oxide
#

then you can access it from yoru main class with getConfig()

valid solstice
#

no, i already have the file configuration object

#

what method do i use to get all the contents from it?

eternal oxide
#

then use it the same as you do the default config

#

its exactly the same

valid solstice
#

yes but i want to get the contents of it

#

all of the keys

#

and values

eternal oxide
#

config.getKeys(false)

valid solstice
#

as string

eternal oxide
#

etc

#

just the same as a normal config

valid solstice
eternal oxide
#

yes

#

?jd-s read the javadoc on FileConfiguration

undone axleBOT
tardy delta
#

when are enum values loaded into the enum?

#

or better wehn a make a value with two paramaters when is the constructor called?

quaint mantle
#

Huh? Those are just public static final fields, those are initialized when class loaded

tardy delta
#

ah

quaint mantle
#

What are you trying to do

tardy delta
#

i was putting all the values indside a map so i can read from that

#

and i was wondering if the map was filled correctly

quaint mantle
#

Ah yes that would work without any problems

tardy delta
#

what is more efficient: getting a value from config or getting it from a map?

eternal oxide
#

negligible difference

hazy linden
tardy delta
#

and uh if try to get a value from the config that doesnt exist? does that return null or an empty string?

#

ah null

#

?paste

undone axleBOT
tardy delta
#

well the parsing in get0() doesnt work because no arguments are given so i can clear that

eternal oxide
#

change get0 to a static block

fading lake
eternal oxide
#

so you fill your map when teh class is instanced

tardy delta
#

because if the given value doesnt exists it takes a default

fading lake
#

make it not static :)

tardy delta
#

a static block which is not static 🧠

fading lake
#

fivehead

eternal oxide
#

its an enum class so your values shoudl be static

tardy delta
#

i have to make them static explicitaly?

rigid hazel
#
@Override
    public void onDisable()
    {
        for(Guild guild : this.getGuilds())
        {
            for(GuildChunk guildChunk : guild.getOwnedChunks())
            {
                guildChunk.getChunk().load(true);
                this.getLogger().info("Chunk loaded successfully!");
                for(Entity entity : guildChunk.getChunk().getEntities())
                {
                    this.getLogger().info("Located entity");
                    if(entity.getCustomName() != null)
                    {
                        this.getLogger().info("Has custom name");
                        if(entity.getCustomName().startsWith("Verteidiger von "))
                        {
                            entity.remove();
                            this.getLogger().info("Is a guardian: Removed!");
                        }
                    }
                }
            }
        }
    }

Output:

Chunk loaded successfully!
Chunk loaded successfully!
Chunk loaded successfully!
#

There is an unloaded chunk, which the plugin loads and then remove the entities. But after loading, the plugin don't recognize the entities in there. How do I remove entities in an unloaded chunk?

eternal oxide
#

you can;t remove entities in an unloaded chunk, however when the chunk is loaded the entities are not actually loaded at the same time. You have to wait a while for the entities to be available.

rigid hazel
#

Hm. I will try with a schedule.

#
@Override
    public void onDisable()
    {
        for(Guild guild : this.getGuilds())
        {
            for(GuildChunk guildChunk : guild.getOwnedChunks())
            {
                guildChunk.getChunk().load(true);
                this.getLogger().info("Chunk loaded successfully!");
                new BukkitRunnable()
                {
                    @Override
                    public void run()
                    {
                        for(Entity entity : guildChunk.getChunk().getEntities())
                        {
                            getLogger().info("Located entity");
                            if(entity.getCustomName() != null)
                            {
                                getLogger().info("Has custom name");
                                if(entity.getCustomName().startsWith("Verteidiger von "))
                                {
                                    entity.remove();
                                    getLogger().info("Is a guardian: Removed!");
                                }
                            }
                        }
                    }
                }.runTaskLater(this, 40L);
            }
        }
    }```
eternal oxide
#

you can try it

rigid hazel
#

I hope, the server doesn't stop while this is executing.

#

I knew it: org.bukkit.plugin.IllegalPluginAccessException: Plugin attempted to register task while disabled

eternal oxide
#

um, you ran it in onDisable?

#

oh yeah, no you can;t do that.

#

no scheduler

#

and chunks will not be loaded in onDisable

rigid hazel
#

Okay. Then I do it in onEnable.

eternal oxide
#

I thought you said you wanted to remove all entities when the chunk loads

rigid hazel
eternal oxide
#

That makes no sense

rigid hazel
#

Why?

eternal oxide
#

English

rigid hazel
#

Oh. sorry.

#

Then ignore it. xD

eternal oxide
#

you can;t load chunks in onDisable

rigid hazel
#

Okay. Sorry. My bad

marble granite
#

I am using 1.8.8, and need to get the packet in NMS that teh client sends to tell the server it hit something. what packet is that?

#

oh wait

#

i think it is PacketPlayInUseEntity

idle grotto
#

Hi, I have a few questions about 1.17 nms.

  1. Are Spigot mappings no longer used at all?
  2. Running BuildTools with --remapped generates two jars, remapped-of and remapped-mojang. Is remapped-obf equivalent to the jar generated when running without --remapped?
  3. Internally, is CraftBukkit coded against Mojang mappings or obfuscated code?
pastel stag
#

can anyone help me understand why @EventHandler in that ^ is not doing its job?

#

its as if events are not being passed through to that class but i have

#

getServer().getPluginManager().registerEvents(new ToggleBlockDebugger(this), this);
in main class

#

so i dont get it

eternal night
#
  1. Spigot mappings are still used for spigot development (e.g. the craftbukkit and bukkit source code are developed against a spigot mapped server version)
  2. I think the obf mappings are full obfuscation and closer resemble the original server layout you'd get in a vanilla jar (e.g. classnames are obfuscated as well)
  3. See answer 1
    @idle grotto
eternal night
#

but creating two instances of your ToggleBlockDebugger means they obviously do not share their state

pastel stag
#

it doesnt do anything 😒

eternal night
#

oh wait you are not creating two instances

#

mb

#

well, I guess grab a debugger or spam broadcasts to validate your code being called/not called

scenic zenith
eternal night
#

a small armorstand ?

scenic zenith
#

its small already

pastel stag
#

can you run if() statements in an @EventHandler?

eternal night
#

in an event handler ?

#

in the method, obviously

pastel stag
#

yeah in a method

#

like

#

blah

pastel stag
#
public void onBreak(BlockBreakEvent event) {
if(){
}

like this

#

this is allowed?

eternal night
#

yes

pastel stag
#

it only breaks when i add the if statement

#

lmao

eternal night
#

are you sure you are not registering your command in some other way with a second instance ?

pastel stag
#

nah

#

im going to rewrite a big chunk of this

#

maybe i made a mistake here im just missing

#

does event.getPlayer(); somehow work differently than pulling CommandSender from a command executor

#

this is definitely where my problem is i feel like now after rewriting this

#

onBreak is looking for my uuid in the array and not finding it FOR SURE

#

something is different about the data UUID the event.getPlayer().getUniqueID() method from the CommandSender.getPlayer().getUniqueID() data

#

shouldnt they produce the same exact UUID object

#

omg

#

ok so you cant add object UUID you HAVE to use event.getPlayer().getUniqueID().toString()

tender shard
#

I need some git help

#

why does it show all those class files etc

#

.gitignore looks like this:

# Project exclude paths
/target/
*.lst
*.class
/.idea/workspace.xml
*.iml
target/
compile/
*/target
*/compile
#

somehow both IntelliJ and VSCode still want to commit all those files :/ I have no idea why

latent dove
#

e.getItem().getItemMeta().getDisplayName() - From an event

Why does this return a NullPointerException but the code still works?
Makes the console very hard to read..

vital yacht
#

Item or itemMeta could be null

tender shard
latent dove
#

so do I first check for the Item and ItemMeta not to be null?

tender shard
#

yes

latent dove
#

ah thank you

tender shard
#

np^^

tender shard
latent dove
#

if (e.getItem() != null && e.getItem().getItemMeta() != null) will this work

tender shard
#

all my plugin repos are fine, it's just the JeffLib repo that's causing problems

latent dove
#

Not sure tho..

wide coyote
tender shard
#

sorry I don't understand that sentence completely 😄

scenic zenith
tender shard
#

you mean a git project in another directory? that actually can't be because all my other projects are working fine and it also happens for other people who clone that repo

latent dove
#

parent = something like this
Files

SomeFile.java

tender shard
#

but it also happens when other people clone the repo :/

latent dove
#

that

#

hmm

#

that's some weird problem

tender shard
#

I posted the github link above in case someone wants to troubleshoot 😄

wide coyote
latent dove
#

Hmm sorry I don't know

tender shard
#

thanks anyway 🙂

latent dove
#

but just wondering what can your lib be used for? 🤔

crude sleet
pastel stag
#

is there a way to print an array inside a plugin

#

what method would you use for that

tender shard
#

it basically has a hundred functions that I need from time to time, like parsing recipes or itemstacks from human readable configs etc

latent dove
#

oh i see

tender shard
#

but 50% of the methods arent included there

latent dove
#

ah i see

#

do you know any library that can help me get working with config faster

#

my tiny brain can't handle the config stuff

#

specially because i just got into plugin development

tender shard
#

what problems do you have with configs?

#

I do it like this all the time:

#

I have a class called Config and it has public static final Strings with the config node names

#

like

#

public static final String USE_PERMISSIONS = "use-permissions";

#

and then everytime I do things like

if(main.getConfig.getBoolean(Config.USE_PERMISSIONS)) { ... ```
#

the config class also sets default values for missing config options

latent dove
#

ohhhhh

#

so im the one who made it super lengthy

tender shard
#

my angelchest plugin's config is 1700 lines lol

latent dove
#

what.

tender shard
#

yep

#

lol

#

and that's just the config.yml

latent dove
#

I'm definitely a junior

tender shard
#

there's some other yml files too

#

items.yml, blacklist.yml, protection.yml, ...

latent dove
#

oh damn

tender shard
#

yeah people like config options lol

#

but I have to add

#

there's many comments in the config.yml file

#

and also translations

#

that's the default main config file

latent dove
#

lemme see

#

yea

#

long af

tender shard
#

but yeah there are other config files too lol

latent dove
#

a

#

can you be my teacher

#

i could use one

tender shard
#

😄

#

just ask your questions 😄

latent dove
#

how to get started with config

#

:p

tender shard
#

create a yaml file inside resources and add all the things you wanna be configurable 😄

latent dove
#

im kinda dumb so bare with me

#

i can't find anything that helps me with the code on the internet

#

ye sure

#

ima do that

tender shard
#

okay sooo lemme try to summarize it

#

in onLoad(), call saveDefaultConfig

#

it will save your config.yml so people can edit it, unless that file already exists

latent dove
#

mhm

tender shard
#

and then you can simply do getConfig().getBoolean("my-option") etc

#

or getString, getList, getItemStack, etc ....

latent dove
#

get int

#

?

tender shard
#

sure

#

you can also provide default values, like

latent dove
#

and how to reload it

tender shard
#

getConfig().getInt("age",20);

#

that will return the age, or 20 if it's not set in the config

tender shard
latent dove
#

So that means

# Amount of zombies to spawn per player
zombies-amount: 50

and

getConfig().getInt("zombies-amount");
tender shard
#

yep it will return 50

latent dove
#

i see

tender shard
#

or 0 if the config doesn't include any "zombies-amount" setting

latent dove
#

thats pretty cool to know

#

so i set the 'def' to 50

#

as default