#dev-general

1 messages · Page 608 of 1

steel heart
#

I mean streams are a bit slow but they do not cause inherent memory leaks

sweet cipher
#

Actually I read it wrong, they said streams allocate new collections and objects which cause memory leaks

#

Still doesn’t make sense though

steel heart
#

Like are they just claiming it? Or have they done some actual research (like read written code, and used a profiler etc)

obtuse gale
#

Arguably the only "real" overhead is the inherent abstraction, which is full of method calls, vtables are slow yada yada

#

Not to mention the jvm has decades of experience in optimizing for-loops as well

potent nest
#

Not good enough!

viral grove
#

Why do people prefer IDEA over VSCode? What features make IDEA better? I'm thinking of switching to VSCode as its less heavy on the system

hot hull
#

You mean VS?

wintry plinth
#

No he means VS Code

#

For Java etc

#

Here’s my truthful opinion on VS Code vs Jetbrains products..

It’s decent, but take it from experience auto completions and suggestions are not as good on VSCode, no matter how many extensions you throw at it

#

I tried to use VSCode to replace PHPStorm, it was a no no, auto completions sucked, and you lose productivity

hot hull
#

Using VS atm cause not sure if IJ has the extension I need, and I gotta say, VS is garbage compared to IJ

wintry plinth
#

Yeah, only only time I like VS Code is for JavaScript based projects

#

Admittedly does well there

#

But for anything else it’s awful

hot hull
#

I mean I only use vsc for editing configs

wintry plinth
#

Oh I use jetbrains CLI for that

hot hull
#

It opens up rq so it's nice

wintry plinth
#

“pstorm <file/folder>” opens up in a lite mode

#

Like what fleet has

#

Any jetbrains product works the same

#

Once it’s setup from CLI it opens in a less feature rich window (for quick editing)

viral grove
#

I'm personally using VSCode for CPP, and I've had a much better time on that compared to on Clion. It's lightweight enough that I can install TabNine (at least till I get copilot), which has better complete than Clion imo

#

That's all right? IJ just has better autocomplete?

wintry plinth
#

I’ve tried doing similar in the PHP realm, I end up always going back to PHPStorm, maybe fleet will change that - as I agree rn often most jetbrains stuff is heavy

#

Thankfully I no longer suffer any form of battery drain with jetbrains IDEs but I used to

hot hull
#

Oh yea, laptop noob

wintry plinth
#

Ye lol, my old laptop I suffered drain, my new one takes forever to go down even with jetbrains shit open etc

wintry plinth
#

Yeah I think it was Hypixel article

#

Because I remember them mentioning

sweet cipher
prisma wave
#

streams have memory (and therefore cpu) overhead but they don't leak

steel heart
#

Unless

#

You make them leak

sweet cipher
#

It looks like their exact words are from that Hypixel post lol

obtuse gale
#

streams have memory

#

and therefore cpu

#

more streams = more memory and more cpu

wintry plinth
#

I use streams

#

Twitch dot tv /s

ocean quartz
#

They just spin some streams in the background!

static zealot
#

indeed

#

wait actually?

#

damn. that's cool

#

I've been using this website for a few years now. it helped a lot

obtuse gale
#

question

#

anyone know how to set a player head in deluxe menus as a material?

sly sonnet
viral grove
#

Made my first post on Stack Overflow

#

I shall be hiding in a bunker for the next few days

sly sonnet
#

send link

viral grove
tepid sedge
#

Hey, I need help making a loop to go thru all of the colors I've set in my config and take all the info that I've done for each one of color and put it in GUI.
I have the GUI thing set already but I need the loop that'll take all the info. can someone explain me how can I do that?

EXAMPLE OF CONFIG

colors:
  red:
    material:
    displayname:
    lore:
      - "test"
      - "test"
  blue:
    material:
    displayname:
    lore:
      - "test"
      - "test"

Also if you can help me with that too,
How can I get the color he choose easier so when I want to actually change it to his chatcolor I'll have to put the variable?

        switch (e.getCurrentItem().getType()){
            case RED_DYE:
                HashMap<Player, String> colorinfo = new HashMap<Player, String>();
                Player p = (Player) e.getWhoClicked();
                String color = e.getCurrentItem().toString();
                colorinfo.put(p, color);
                e.getWhoClicked().closeInventory();
                e.getWhoClicked().sendMessage(Colors.color("&e&lChatColor &8» &7You've changed your chat color to &c&l&nRED&7!"));
        }

that's what I've done so far

*Please mention me if you've got a solution, thanks everyone. 😄

primal crystal
tepid sedge
primal crystal
# tepid sedge what?
        final ConfigurationSection section = this.getConfig().getConfigurationSection("colors");
        section.getKeys(false).forEach((colorName) -> {
            final String material = section.getString(colorName+".material");
            final String displayname = section.getString(colorName+".displayname");
            final List<String> lore = section.getStringList(colorName+".lore");
        });

If i didn't misread the question this was what you asked right?

tepid sedge
#

Yes, thank you 🙂

#

but it'll get the colorName?

primal crystal
#

yep..its getting the parent keys from the config section

tepid sedge
#

or external file?

primal crystal
#

it can do both FileConfiguration has this method

brittle leaf
#

After some testing ive come to a conclusion on the PlayerInteractEvent:
Throwing item at air
Equiping item at air
Teleporting on the same tick you click a block

When you right click with these actions they all fire the event with the same hand twice.
while doing these actions with the item in the offhand its not completely expected behaviour either.

#

Version 1.18.1
using paper or spigot makes no difference to the result as they both do the same thing.

sweet cipher
#

I’m pretty sure I’ve heard of that bug with teleporting

brittle leaf
#

at this point i might aswell just implement a check that returns if the hand is the same as the last hand in a space of like 50ms

#

should nullify the duplicates since they seem to occur on the same or 1 millisecond as the first

#

a check on a per player basis

#

for left and right air and block click.

olive grove
#

Yea I noticed some weird behavior with the interact event like that

#

It seems to fire twice sometimes and a bunch of other weird stuff

brittle leaf
#

multiple events firing when you teleport on the same tick is a bug thats already been reported on the spigot jira,
throwing and equiping items when clicking air just firsts a left and right click of air because of how the client handles it which means its expected behaviour

#

for now my fix is to just run the teleport on the next tick instead of the same tick

#

and im guessing just cancel whichever section of the event doesnt want to be used for everything else

#

there will be a range of checks that i can deal with

#

after all this debugging ive actually gained a slightly better understanding of when this event fires and what it fires

viral grove
#

CPP: Let's make types complicated

short: minimum 16 bits
int: minimum 16 bits (but usually 32 bits)
long: minimum 32 bits
long long: minimum 64 bits

All of the types above can have the int suffix, except for int. So you can short int, which is exactly the same as short

Then you have integers with fixed limits

std::int8_t: Guaranteed 8 bits (but treated as a char)
std::int16_t: Guaranteed 16 bits
std::int32_t: Guaranteed 32 bits
std::int64_t: Guaranteed 64 bits

But on some system, creating 32 bit integers could take longer than 64 bit integers. So you also have fast integers, which chooses the fastest integer bit value, with a minimum you specify.

std::int_fast8_t: Minimum 8 bits, can be increased for optimisation
std::int_fast16_t: Minimum 16 bits, can be increased for optimisationstd::int_fast32_t: Minimum 32 bits, can be increased for optimisation
std::int_fast64_t: Minimum 64 bits, can be increased for optimisation

And because you have absolutely no idea of how many bits an integer type takes, there are least types

int_least8_t: The smallest possible integer value offered by the system that's at least 8 bits
int_least16_t: The smallest possible integer value offered by the system that's at least 16 bits
int_least32_t: The smallest possible integer value offered by the system that's at least 32 bits
int_least64_t: The smallest possible integer value offered by the system that's at least 64 bits

And there are "unsigned" variants of all these values, which means that it cannot store negative numbers, but allows for more whole numbers to be stored.

And ofc int_fast#_t and int_least#_t is discouraged cause not a lot of people know how to use them :/

#

Rant over

potent nest
#

isn't unsigned a type itself too?

viral grove
#

unsigned without a type defaults to unsigned int, which ig is fairly logical

#

Till you realise that you have not idea what an int is

obtuse gale
#

I mean short and long aren't in themselves types

#

they're modifiers or whatever they're called

#

that's why you can do short int, because... it is a short int ShockedPikachu

prisma wave
#

you're not a type in yourself

obtuse gale
#

Then you have integers with fixed limits
those are not required by the standard to exist in any particular stl, the fast and least variants instead are

#

realistically they will exist, but it's not required

obtuse gale
#

just stick with the std::int8_t etc and you'll be fine lol

potent nest
#

just stick with a different language

obtuse gale
#

nah

potent nest
#

☹️

prisma wave
#

Dead chat

quiet depot
#

rip

half harness
#

rip

remote goblet
gusty glen
#

what do you use to (easily) SSH into linux machines on windows? I have putty installed but I'm struggling A LOT to configure it

half harness
#

termius 😌 🙃

#

what issues r u getting tho?

quiet depot
#

I used to just use the ssh cli

#

super easy

#

clients like putty, termius, bitvise aren't really useful on desktop imo

gusty glen
#

my issue is that idk what user I should use to SSH

oblique heath
#

yeah i just use the windows command prompt

#

with the openssh addon installed

gusty glen
#

also this

quiet depot
#

fr just use the ssh cli

#

it's the way to go imo

gusty glen
quiet depot
#

ssh is on windows too

half harness
quiet depot
#

^ that depends on the image ur using

half harness
#

true

#

im using raspberry pi os (lite)

#

but it was the same with raspbian

gusty glen
quiet depot
#

the login will be accessible somewhere

#

perhaps emailed to you

half harness
#

nice 🙂

oblique heath
#

darn

#

doesnt get embedded

half harness
#

29mb 👀

gusty glen
#

oh nice they emailed me with the credentials

half harness
#

🥲

gusty glen
#

bruh

half harness
gusty glen
#

ok I have more issues than I thought\

oblique heath
#

oh yeah

half harness
#

😮

#

😮

quiet depot
#

~/.ssh/config

oblique heath
#

there's a .ssh folder in your user directory

half harness
#

i thought u had to type ip/username/password every time

oblique heath
#

makes life so incredibly easy

quiet depot
#

I used to have icons on my task bar for commonly used servers

#

personal vps, helpchat vps, etc

#

click em and they opened ssh windows

half harness
#

ooh

oblique heath
#

use rsa keys instead of a string password

#

always

#

it makes life easy

quiet depot
#

rsa

#

smh

half harness
#

hm?

oblique heath
#

rsa keys let you ssh without entering a password

quiet depot
#

there's newer and better formats

prisma wave
#

can you show me your id_rsa file as an example please?

oblique heath
#

of course santa

prisma wave
#

Thanks

oblique heath
#

right here officer

prisma wave
#

no I mean what the actual contents is

agile galleon
prisma wave
#

mzungu

quiet depot
#

^

half harness
agile galleon
#

mzungu or ovh

quiet depot
#

mzungu

agile galleon
#

ohh yess

#

very cool

#

ive seen that one already

gusty glen
agile galleon
gusty glen
#

is there a way to set up ssh host with a login that uses string password?

quiet depot
#

not a way to automatically input the password, switch to ssh keys

#

passwords + ssh = no

gusty glen
#

I know, but I need to get in my server before I can do anything

oblique heath
#

you can allow string passwords after you first ssh in, probably

quiet depot
#

then just ssh in normally

#

ssh root@ip

#

you can put the host in the config, it'll just prompt you for the password when you ssh with the alias

gusty glen
#

also how do I link my registrar domain with my vps?

quiet depot
#

point the root record (@) to the ip

gusty glen
#

I already put the website on the VPS config, but I'm guessing I need to configure something on the registrar side

quiet depot
#

unless you're wanting to manage the domain entirely through your vps? as in dns too

#

I don't recommend doing that

gusty glen
quiet depot
#

standard is to use cloudflare for dns

gusty glen
quiet depot
#

make an a record

#

with the name as @

#

pointing to your vps

#

yes

#

just change that one

gusty glen
#

changed, now I just have to wait I guess?

slender remnant
#

Hello i'm a fullstack dev i create website in PHP symfony, discord bot in JS, and many other things like apps, API etc

i'm searching a SPIGOT and BUNGEECORD dev for one of my projet if you are one, contact me ;)

slender remnant
#

thanks

wind patio
#

got covid

#

pog

agile galleon
#

pog

wind patio
#

exams postponed, have to get the fuck out of dorm, go back home, at risk of infecting my family, more stress, more depression

#

lets gooo

#

time to code

static zealot
#

sounds fun /s 😦

gusty glen
#

I basically know nothing about linux, I was upgrading my Ubuntu VPS from 18.04 (painfully) to 20.04, but at some point on 19.10 -> 20.04, I did ended up killing the terminal. I have screen installed (whatever it might be, I just installed it because of a guide), and apt update doesn't work because E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 13863 (apt) N: Be aware that removing the lock file is not a solution and may break your system. E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it? How can I safely resume the upgrade process?

#

screen says that there are no screens to be resumedroot@secretx:~# sudo screen -D -r There is no screen to be detached.

viral grove
gusty glen
#

it say that there are no screens, I guess I'll have to install the OS again to be sure

oblique heath
#

try killing the process

#

or restarting the system

viral grove
#

Restart fixes all

oblique heath
#

indeed

lost edge
#

I want to make a deep storage unit using barrels and I'm wondering what would be best way to store such data? Should I use a database or should I just use a barrels nbt data to save the large amount of items there are

#

When you click the barrel it would open a custom menu not the normal inventory and noting would actually be stored in it

oblique heath
#

if you're storing a lot of items i think a database makes more sense

#

it'll make it much easier to modify how you treat the items if you decide to add more functionality down the line

primal crystal
#

Persistent data containers are also a good choice if the server version is 1.16 or something+

steel heart
#

Believe it was added in 1.13 or 1.14 acc

#

But yes

#

Very nice api

obtuse gale
#

@woeful mortar

#

Accept my friend request, please.

obtuse gale
#

PDC is cool

#

Old versions aren't

oblique heath
#

gradle is confusing me

#

i'm trying to exclude txt resources by doing:

sourceSets {
   main {
      java {
         srcDir 'src'
         exclude '**/*.txt'
      }
   }
}
#

but when i build the jar it still ends up packaging txt resources in

obtuse gale
#

Yikes no

oblique heath
#

oh no

#

what am i doing wrong

obtuse gale
#

eeh… what's your dir tree structure?

#

Screenshot

oblique heath
obtuse gale
#

Heretic

oblique heath
#

listen it's a fun technical challenge

#

no judgie

#

i've tried other combos for the exclude like exclude src/main/resources/*.txt

#

but to no avail

obtuse gale
#

Anyway, you'll want to edit the resources

sourceSets {
  main {
    resources {
      exclude "**/*.txt"
    }
  }
}

I'm not entirely sure if this will work, I don't really touch source sets unless I'm doing silly stuff. See if that works, if it doesn't hmu

oblique heath
#

lemme try it, tankya

#

oooo that did it

#

emily big brain

obtuse gale
#

Yeeeee

oblique heath
#

thank you 🙂

obtuse gale
#

Np

dim rampart
#

Why cant I see #offer-services?

#

Or any of the selling channels

quiet depot
#

you're service muted

rancid gazelle
#

Welp p-p

wintry plinth
#

rekt

dense dew
#

is there any twitter account that announce programming events?

dense dew
hazy eagle
#

can someone help me with gradle?

#

i dont see my build

#

i have only MANIFEST.MF

ocean quartz
#

How are you building it?

hazy eagle
#

im clicking build

#

i cant send screenshot ;/

ocean quartz
#

?imgur

compact perchBOT
#
FAQ Answer:

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

agile galleon
dense dew
agile galleon
dense dew
agile galleon
dense dew
hazy eagle
distant sun
#

/build/libs

hazy eagle
#

i dont see /libs

ocean quartz
#

Can you show all the folders of /build?

hazy eagle
#

thats all

ocean quartz
#

There is more under, i want to see all

distant sun
#

though libs should be above tmp

hazy eagle
#

there is no more under

#

in build folder

ocean quartz
#

Hmm, can you paste your build.gradle?

#

?paste

compact perchBOT
#
FAQ Answer:

Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
HelpChat Paste - How To Use

hazy eagle
#

thats my first time with gradle

obtuse gale
#

no and i don't care and both versions are ass anyway

#

if you're rating the entire game as a whole solely based on that one singular trivial minimal aspect, you're wrong

#

@obtuse gale i meant 1.9+, also 1.8 servers exist because of pvp

#

that's cool n all but my second statement still stands and 1.8 makes not even 7% of active servers lol

primal crystal
obtuse gale
#

that doesn't change the % a bit lol

primal crystal
#

Is hypixel still in 1.8?

obtuse gale
#

most likely

#

not all of their servers are 1.8 I know that

primal crystal
# obtuse gale that doesn't change the % a bit lol

Yeah... I just mentioned it... Its more of a player decision IG, we used to host both 1.8 and 1.16 pvp back in days... And players would hop on to 1.8 one, those 1.16 would have something like 2-5 while 1.8 have a reasonable no... Same goes for bw... Thats the reason IG still many servers wont port them into newer versions

ocean quartz
#

I bet most players joining hypixel don't even know the server is 1.8 they just play on the latest release

obtuse gale
#

I mean we know nothing about hypixel in reality

#

all we can say for sure is that they use their own fork of spigot and uh that's it

primal crystal
static zealot
half harness
#

1.7 😌

static zealot
#

shut up dkim

onyx loom
#

i HECKIN love minecraft pvp!!!!

ocean quartz
#

It's so good, i love spam clicking!

static zealot
#

I love spaghetti

oblique heath
static zealot
#

smh

oblique heath
#

you're right i'm sorry i shouldn't have stooped so low

static zealot
#

dw. there's still time for you. dkim however has been captured by the dark side and there's no way of getting him back

oblique heath
#

he will be missed

open shell
#

an error related to an undefined variable appeared while using custom javascript placeholders: https://pastebin.com/Hvuf16pn I never noticed it until now. Snippet of what we are using: ```javascript
var arenaRegion = PlaceholderAPI.static.setPlaceholders(BukkitPlayer, "%worldguard_region_name%");
var arenaState = PlaceholderAPI.static.setPlaceholders(BukkitPlayer, "%" + "mobarena_arena_" + arenaRegion + "state" + "%");
var arenaTwoState = PlaceholderAPI.static.setPlaceholders(BukkitPlayer, "%" + "mobarena_arena
" + arenaRegion + "2" + "state" + "%");
var arenaThreeState = PlaceholderAPI.static.setPlaceholders(BukkitPlayer, "%" + "mobarena_arena
" + arenaRegion + "3" + "_state" + "%");
var twoArenas = ["undeadtemple", "rattledmines"] // 2 arenas
var threeArenas = ["undeadtemple"] // 3 arenas
var fourArenas = ["undeadtemple"] // 4 arenas

function currentArenaInfo() {

var arenaInfo = PlaceholderAPI.static.setPlaceholders(BukkitPlayer, "%" + "mobarena_arena_" + arenaRegion + "_" + args[0] + "%");

if (arenaThreeState == "§6Running" && fourArenas.indexOf("arenaRegion") && arenaState == "§6Running" && arenaTwoState == "§6Running") {
var arenaRegionFour = arenaRegion + "4";
var arenaInfoFour = PlaceholderAPI.static.setPlaceholders(BukkitPlayer, "%" + "mobarena_arena_" + arenaRegionFour + "_" + args[0] + "%");
...

Does BukkitPlayer have to be defined somewhere, as I thought it was automatically set in the bukkit api
agile galleon
#

JavaScript pepecross

open shell
#

shush, my coding knowledge is like 0

#

actually, this could be related to the player disconnecting the same second PES_Think

distant sun
#

BukkitPlayer is from PAPI, yes

static zealot
half harness
#

So for some reason, this server keeps crashing and the crash logs (the paper's unresponding messages) keep referencing to one of my GUIs.. but it's not any specific part, it seems random
Anyone know how i'd fix this?

#

the server just randomly crashes :/

#

(plugin name is ZombiesVSHumans)

agile galleon
#

Dkim moment

timber oak
#

Is the best way to create a stopwatch to simply just create a runnable that adds 0.05 to a float every 1 tick or how are stopwatches made most effectively in spigot?

wintry plinth
#

Does it need to live tick up? If it doesn’t, just store date and time they do something, and the date and time they finish doing it

timber oak
wintry plinth
#

And get it on the fly

timber oak
wintry plinth
#

Then you can format it as needed

timber oak
#

Tyvm

wintry plinth
#

Anytime :) and I’d go for UUID and avoid storing the player object

half harness
#

id recommend using Long instead of DateTime

#

for timemillis

timber oak
sly sonnet
#

use Instant 😎

#

then you can convert it to anything

timber oak
half harness
#

ah

timber oak
#

Trying to avoid using stopwatches

half harness
#

btw

#

i didn't read anything up yet

#

so

timber oak
obtuse gale
#

don't use java.util.Date

#

it's deprecated and is ass anyway

timber oak
#

Oh, just created it using it... lol

timber oak
obtuse gale
#

Instant presumably

#

dunno exactly what you're on about but that's the most general purpose class for "a point in time"

timber oak
obtuse gale
#

d;Duration#between

ruby craterBOT
#
public static Duration between(Temporal startInclusive, Temporal endExclusive)
throws DateTimeException, ArithmeticException```
Description:

Obtains a Duration representing the duration between two temporal objects.

This calculates the duration between two temporal objects. If the objects are of different types, then the duration is calculated based on the type of the first object. For example, if the first argument is a LocalTime then the second argument is converted to a LocalTime.

The specified temporal objects must support the SECONDS unit. For full accuracy, either the NANOS unit or the NANO_OF_SECOND field should be supported.

The result of this method can be a negative period if the end is before the start. To guarantee to obtain a positive duration call abs() on the result.

Parameters:

startInclusive - the start instant, inclusive, not null
endExclusive - the end instant, exclusive, not null

Throws:

DateTimeException - if the seconds between the temporals cannot be obtained
ArithmeticException - if the calculation exceeds the capacity of Duration

Returns:

a Duration, not null

obtuse gale
#

Instant implements Temporal fyi

#

all of the "current"/"supported" api for time-related stuff is in java.time package

timber oak
obtuse gale
#

not in the slightest

#

this thing has been around for literally ages

timber oak
#

Oh, I just saw Java 17, but yeah. So if I don't have both times to begin with, I can store one of them as an Instant right?

#

Also, shouldn't this work if Instant implements Temportal?

#

Wait no... Only if it extends

obtuse gale
#

well because not every Temporal is an Instant

#

should be fine with using Instant btw

#

for the Map value type

timber oak
# obtuse gale for the Map value type

Ohhh

                        Instant instantStart = parkourManager.getPlayerTimers().get(player.getUniqueId());
                        Instant instantEnd = Instant.now();

                        Duration duration = Duration.between(instantStart, instantEnd);
#

I assume it's like this then

obtuse gale
#

yeeeeee

wintry plinth
#

Today I learnt about “instant” shows how long I’ve been out the Java game

static zealot
#

I've learnt last year.

wintry plinth
#

Oh at least I don’t feel as bad now

#

😂😂

#

Was expecting a “dude this came out in 2014” 😂😂

timber oak
#

Any tips on how I can store top 5 times on a parkour? I got the time differences and players stored separately atm.

static zealot
wintry plinth
prisma wave
#

It was with java 8 iirc

wintry plinth
prisma wave
#

So I think that was 2014?

#

Or earlier

static zealot
prisma wave
#

Close enough

timber oak
#

might've misunderstood but "There are currently, as of 2013, two segments in the Java time-scale. "

timber oak
# wintry plinth How do you store the parkour times rn?
                        Duration duration = Duration.between(instantStart, instantEnd);
                        long seconds = duration.toSeconds();
                        long millis = duration.toMillis();

                        player.sendMessage("Congratulations, you've finished the parkour in " + seconds + "." + millis + "s");
timber oak
oblique heath
timber oak
oblique heath
#

do you want them to still exist after the server restarts

#

or can the times be thrown away when the server goes down, if you're making like a minigame or something

timber oak
#

I'll store them in MongoDB later on, yeah

oblique heath
#

okay

wintry plinth
#

Honestly if this was me doing it

#

I’d store it into mysql

#

Bloody phone

timber oak
#

"myself" lmao

wintry plinth
#

Then you can use sql to sort it

#

And yeah lol

#

My phone wanted to replace mysql with myself

#

Very silly

timber oak
#

Kinda wanna learn mongodb though, already got plugins using mysql and sqlite

static zealot
timber oak
oblique heath
#

if you're asking how to store the 5 best times in memory, how about querying your db on startup for the 5 best times so far, then maintaining a sorted list of best times

#

where an element in the list is a PlayerTime object that has the player uuid or whatever, and the time

static zealot
#

well you can make a custom method to find the top 5. or you can do as Ivan said, have a different map for best 5 and just update that map whenever a new better time is found

oblique heath
#

^

#

i wouldn't use a map for best times though

#

that doesn't really make sense

timber oak
#

Why not?

oblique heath
#

why would you use a map

timber oak
#

I need the username as well

oblique heath
#

a list is all you need

#

okay if you need the username store a list of MyParkourPlayerTime objects

#

where the object has both the time and the name

#

no reason to use a map though

static zealot
#

yeah. if you have a PlayerTime object then a list is enough

timber oak
#

Ohhh like a class called "PlayerTime" mb, I misunderstood

oblique heath
#

no worries

timber oak
#

I don't see how that's easier than a map though

oblique heath
#

it's easier because it can be sorted according to the best time

#

so you can just compare the last element in the list to any new times and instantly know if the new time can be in the top 5 (or however many)

#

that is much harder to do if you have a map since maps are generally not sorted

timber oak
oblique heath
#

you don't need to loop through the list if you sort the list

#

your list will be sorted from best time to worst time

timber oak
oblique heath
#

you can implement the comparable interface to your MyParkourPlayerTime object and then use a built in sorting method (Collections.sort)

#

or you can just sort the list yourself

#

i mean it's a list you can do whatever you want to it

oblique heath
timber oak
oblique heath
#

well you have to loop through the list once in order to sort it initially, when you first build it onEnable

#

(unless you can request your times in sorted order from mongodb which saves this step)

timber oak
oblique heath
#

no

timber oak
#

?

oblique heath
#

okay let me make a list of times

#

lets say

1,23,47,399,456,459,600
#

they are sorted from best time to worst

timber oak
#

Yea

oblique heath
#

if i have a time 237

#

i only need to look at a single time in the list to determine whether or not my new time belongs in the list

#

i can compare 237 to the very last element in my ordered list, 600

#

since 237 is smaller i know that 237 qualifies to be in the leaderboard and i can insert it like normal, then kick out 600

prisma wave
#

Consider a TreeSet / TreeMap which will provide logn gets and adds (might behave weirdly if your objects are mutable though)

oblique heath
#

doesnt treemap sort by key

prisma wave
#

I haven't read any previous messages btw

#

Just saw sorting

prisma wave
oblique heath
#

treeset might be slightly better than a list then ye

#

but the concept for both is very similar

timber oak
oblique heath
timber oak
#

Or well, that list doesnt have to

oblique heath
#

you can use something else for the player's personal best

timber oak
#

Yeah true

oblique heath
#

as bm said you can use a treeset which gives you all the benefits of a sorted list except it offers faster insertion times for the new time

timber oak
oblique heath
#

yes if you implement the comparable interface as he said

#

treeset will sort objects within it by default

prisma wave
timber oak
prisma wave
#

It internally keeps itself sorted in a much more efficient way

#

based

oblique heath
#

they are required to be comparable

#

so based on whatever they choose to implement for that

prisma wave
#

based

oblique heath
#

based

#

basically you can choose how your objects are ordered

prisma wave
#

However as I said TreeSet can be weird when your objects are mutable so

#

Conclusion mutability bad

timber oak
#

mutable means they can change right?

#

Because these objects will be able to change

prisma wave
#

Yes

oblique heath
#

not the contents of the list

timber oak
#

They contain the players personal best

#

I guess

#

Not even sure

prisma wave
#

It won't automatically update the order if the objects internally change

oblique heath
#

you dont have to worry about mutability for this usecase valde

#

as long as you dont go crazy

timber oak
oblique heath
#

player times don't exactly change afterwards, just add a new PlayerTime object containing the new personal best

#

see that would be considered crazy

#

dont do that

timber oak
#

Ohhh

prisma wave
#

we do a little immutability

#

😌

timber oak
#

So you remove the old PlayerTime object and create a new one?

oblique heath
#

not necessarily

#

if it's a global best then is it not possible for a single player to have more than one high scoring time

#

like maybe i'm so godly i had 2 really good runs and got 2 of the top 5 times

#

so basically add the new time like you would any other time

#

the removal of the old 5th place time will be handled the same way as with any other time

#

this ^ changes a bit though if you only want each player to have one entry on the global leaderbord at most though

#

that makes things a lil harder

timber oak
#

But won't I then just end up with a ton of those objects?

oblique heath
#

well the idea is each time you add an object to the leaderboard treeset you then remove the worst time

#

to keep the size of the leaderboard constant

timber oak
#

So how would having more than one time on the leaderboard work? I think I'm confusing myself with personal best and leaderboard, you should be able to have only one personal best ofc.

oblique heath
#

have you watched minecraft mondays

timber oak
#

nope

oblique heath
#

okay well imagine this scenario

#

youtubers are racing around the track

#

at the end of the event, there is a leaderboard for the best times

#

one youtuber did so well that both of his laps got on the leaderboard as having the fastest times

#

lets say he got a 30 second and a 32 second lap

#

that is first and second place on the leaderboard

#

3rd place was someone else with 35, etc

#

another example is having a high score on an arcade machine

timber oak
oblique heath
#

the same person can get more than one score on the leaderboard for an arcade machine

#

okay

timber oak
#

Not sure if I want someone to be able to have more than one time on the leaderboard or not

#

What's easiest? lol

#

Having multiple or limiting to one

oblique heath
#

easiest is to allow more than one time

#

that is how it would work by default

#

with no extra effort

#

you need to do some extra checks if you only want one time per person

timber oak
#

Ah yeah

oblique heath
#

and at that point you lose a bit* of the benefits of the sorted list/set

#

well, not all

timber oak
#

Okay so this should be immutable comparable, but not sure how the comparable method works

public class PlayerTime implements Comparable {
    private final Duration duration;
    private final UUID uuid;
    private final String username;

    public PlayerTime(Duration bestTime, UUID uuid, String username) {
        this.duration = bestTime;
        this.uuid = uuid;
        this.username = username;
    }

    public Duration getDuration() {
        return duration;
    }

    public UUID getUuid() {
        return uuid;
    }

    public String getUsername() {
        return username;
    }

    @Override
    public int compareTo(@NotNull Object o) {
        return 0;
    }
#

I guess I have to specify the duration to sort

obtuse gale
#

implements Comparable<PlayerTime> pls

#

your IDE should be yelling at you real bad

oblique heath
#
int compareTo(T o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
timber oak
timber oak
obtuse gale
#

based on a value

#

an internal value

oblique heath
#

if you want it to compare based on duration then do that

obtuse gale
#

you're the one implementing the method, you can pick what it compares it to

timber oak
prisma wave
#

based? based on what?

#

ok that's enough

oblique heath
#

what you are doing right now is making a method for something else to use

timber oak
oblique heath
#

they tell you how they want the method to behave (return a negative, 0, or positive value)

#

you have to make that happen for your particular class

obtuse gale
# timber oak But how? lol I just don't understand what it compares to "internally" or how to ...

(Duration implements Comparable<Duration> anyway so you can just do return this.duration.compareTo(other.duration))
besides that, imagine you're making your own MyInteger class like so

class MyInteger {
  private int value;
  MyInteger(int value) { this.value = value; }

  int value() { return value; }
}

and now you want it to implement Comparable<MyInteger>, you can do this for instance

int compareTo(MyInteger other) {
  return this.value - other.value;
}
#

you're the one defining the method, how it behaves, what you're comparing from your object

timber oak
obtuse gale
#

yes

timber oak
#

I guess I'll have to convert it to int then

obtuse gale
#

read what I strikethrough'd lol

timber oak
#

oml... lol

#

Thank you...

#

I'm getting too tired it seems

obtuse gale
#

yeah it can be exhausting

timber oak
#

Wanna ask how I then check if a duration would be top 5 in the set but I'll just wait till tmr when I'm not half asleep ig.

oblique heath
#

well you asked now so:

#

just compare the new duration to the last element in the set

#

if the new duration is better than the last element, it deserves to be in the leaderboard

rancid gazelle
#

what can I use yo export my dc dms?

#

any idea?

static zealot
#

dc?

#

what's that? @rancid gazelle

rancid gazelle
#

discord p-q

static zealot
#

oh. don't think there's a way to do that?

rancid gazelle
#

there is?

#

one of the support said it but I didnt save the link p-q

static zealot
rancid gazelle
#

ya how do I use it

rancid gazelle
compact perchBOT
rancid gazelle
#

just curious p-p

static zealot
static zealot
#

just use that

rancid gazelle
static zealot
rancid gazelle
#

how do I download it

static zealot
#

they do offer step by step instructions

rancid gazelle
#

okie tysm

humble silo
#

Does Maven central have some sort of api i can use to fetch artifacts? I dont want to use search.maven.orgs

quiet depot
#

why don't you do it the exact same way gradle/maven do it

humble silo
#

is that somewhere i can see?

quiet depot
#

both tools are open source

#

but I doubt looking at their implementations would help you

humble silo
#

I dont wanna go digging around until i find something

quiet depot
#

maven repositories have a fairly simple structure, with metadata files that tell you everything you need to know

humble silo
#

that could take hours tbh

#

ya, just wanted to know if there was a cleaner way to do it...

#

Will the actual artifacts always be named "ID-VERSION.<whatever this is>"?

obtuse gale
#

wat

half harness
obtuse gale
humble silo
quiet depot
#

will be renamed

humble silo
#

ok ty

distant cipher
#

Anyone know why
"com.lunarclient.bukkitapi.LunarClientAPI.isRunningLunarClient(org.bukkit.entity.Player)" because "this.plugin.LunarAPI" is null

            player.sendMessage(ChatColor.BLUE + "You must be on Lunar Client to use this command");
            return false;
        }```

Main Class
```public LunarClientAPI LunarAPI = LunarClientAPI.getInstance();```
sly sonnet
marble plaza
#

Hello! Does anyone know which characters does PaperMC "feature-seeds" parameter accept? Only numbers or characters as well? Length?
I could create random strings consisting of alphanumeric characters, length 100 or something.

wintry plinth
pastel imp
#

Thoughts on toml file as config file?

sly sonnet
#

y tho

dim rampart
#

Whem can I get un service muted

obtuse gale
#

@echo steeple Accept my frienf request, please.

timber oak
#

nvm.. there's .last()

steel heart
cinder flare
#

better than yaml for sure

dense dew
#

but if its for public plugin i would go w yml

pastel imp
dense dew
#

yes

cinder flare
#

im sure anyone configuring a server can figure out toml

#

and if we can change the default file format to toml, that would be great

pastel imp
#

The mini issue is, we arent enough

#

To make an impact at least

cinder flare
#

Eh, I mean you say that now, but the more and more small people that do it, the better it gets

agile galleon
#

ye

distant sun
#

isnt toml the horrible one with [path.to.section]?

#

I kinda like Hocon tbh

steel heart
#

I mean that’s the nicety with toml

forest pecan
#

lol

distant sun
#

kappa

forest pecan
# distant sun kappa

It's not like JSON where it uses a shit load of curly brackets, but it isn't like YAML which uses spaces (which are horrible af). It also has the subsections which are readable rather than stupid spacing

#

if you misstype a space or something you get a load of parse errors

#

plus it may be easier for users to use because they don't have to focus on adding spaces and then complaining in support (why no work)

distant sun
#

yea, I see your point

timber oak
#

Is it possible to serialize and deserialize a hashmap? Containing UUID and an object

#

for mongodb

ocean quartz
#

My issue with JSON isn't really the brackets but the quotes, way too much quotes

tranquil crane
#

so many quotes

obtuse gale
#

Is there an api on deluxmenus? 🙂

distant sun
#

No

obtuse gale
ocean quartz
#

Hell yeah

sly sonnet
#

why config when you can hard-code things ??

pastel imp
#

Bruh

#

Idk hocon

obtuse gale
#

it's json for dummies

hot hull
#

Hocon best

wintry plinth
#

Get all the Ho’s

lavish notch
#

By premium, I mean like $100+ plugins that aren't featured on spigot or MCM resources (but rather advertised in threads)

obtuse gale
#

i mean

#

nothing especially wrong with that ¯_(ツ)_/¯

obtuse gale
#

i mean yaml is easier to use, it's just json without any brackets and quotes

hot hull
#

fuck yaml

#

heck out with yaml

#

outdated

pastel imp
forest pecan
#

people who use yaml to store data 🤸‍♂️ 🗑️

lavish notch
#

lets use txt files lol

agile galleon
#

No

#

Lets use....

#

Folders

pastel imp
#

sus ngl

#

I mean, it can work

#

xD

#

You name a folder players

#

then add a folder with the player's uuid

agile galleon
#

Yes it does work

#

Ive made a system like that once

pastel imp
#

then add whatever type of file with the name and value of each thing you wanna store

#

xD

#

voila

#

you don't even need to open the file

#

the name is the value

agile galleon
#

Yes

restive ravine
#

@obtuse gale is that ANOTHER redesign 👀

obtuse gale
long dagger
#

I have made the backend of a bedwars plugin, how would I go about sending players to a bedwars game? The bedwars game will be on a different server than the lobby, I know how to do that, but how do I select what world to send the player to based on the game status? The lobby cant access the bedwars plugin, maybe through bungeecord messaging?

#

and I want the player to choose a gamemode and map through a npc

oblique heath
#

you can also use a 'real' messaging service to do the same thing like redis or rabbitmq but they require you to run their dedicated server alongside the minecraft instances, this will not - all it requires is an open port (1+) for the plugins to talk through

#

regardless of what you choose to use, tracking the game status should be trivial: send a message to bungee / your minigame manager from the server where the game state has updated, including the server name and the new status as parameters. On the manager side, you can just listen for the messages and update your map or whatever you use internally accordingly

#

also out of curiosity, are you dynamically allocating minecraft instances for your minigame? or will you just have a set number of servers running

long dagger
#

idk

#

not for a while

#

for the start just a set number of servers running

#

what does Hypixel do?

oblique heath
#

i imagine they dynamically allocate, at least to some degree

#

i haven't kept up with their dev blogs enough to know if they ever confirmed anything about that though

#

I'm in the process of doing a very similar dynamic-allocation project where i deploy new minecraft instances using docker swarm (soon to be k8s)

oblique heath
#

if it's just that and no unique abilities then a yml file works great

#

i'm assuming class is going to be replaced with the name of the class

obtuse gale
#

ah tru

oblique heath
#

so you'll probably end up with something like

archer:
  name: "Archer"
  rank: "class.archer"
  color: RED
  effects:
    - type: RESISTANCE
      potency: 1
    - type: SPEED
      potency: 2
  dmgboost: 5.5
#

i would personally do effects as i showed there, where you store a list of them

obtuse gale
#

that does seem a lot cleaner

oblique heath
#

but you can also do

effects:
    resistance: 1
    speed: 2
obtuse gale
#

xD

#

thx for ur help btw @oblique heath :)

oblique heath
#

sure thing

obtuse gale
#

is there like a kudos system in this serverrr

oblique heath
#

only 12.99 a month

#

you can also @ everyone and tell them im really cool

obtuse gale
#

ofc ofc egwEgirlKiss

burnt path
#

hey is there a way I can make my placeholders work after a plugin is unloaded and loaded again?

#

I have the unregister method in my onDisable()

#

however when I do that, the placeholders just stop changing basically and stay the same until server restart

humble silo
#

Anyone know of a decent way to parse maven pom files on the fly? Or a way to load a dependency(with all of its dependencies) from maven central at runtime? Ive been trying to parse the pom files myself and the minute it gets into properties its literally impossible...

#

ugh, well i may have figured it out actually, just have to go looking through the parent pom too....

quiet depot
#

@humble silo maven provides an api

#

trying to find what it's called

humble silo
quiet depot
#

no..

humble silo
#

Ive seen that, couldnt find a way to load all dependencies

#

a http api?

quiet depot
humble silo
#

or a library

quiet depot
#

there's one for the pom

humble silo
#

can you send that one too?

quiet depot
#

i'm trying to find it

humble silo
#

oh ok cool

#

ty for the help

#

Its not too large is it?

quiet depot
#

no clue

humble silo
#

alr

#

ig i can check

humble silo
quiet depot
#

all maven docs are there

humble silo
#

This is kinda starting to look pretty heavyweight

#

ty for the help, ill look at it a bit longer, but I was almost done writing a implementation myself

#

Alright, thanks! I super appreciate it!

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

Source

distant sun
#

Any idea why when I add a new module, IIJ expands all the other modules?

wintry plinth
static zealot
#

seems safe to me

distant sun
wintry plinth
obtuse gale
#

Help me wit my server
this is Helpchat server right ?

agile galleon
#

no

#

this is Santa Clause Christmas Gift Studios

wary python
#

Where can I find the deluxechat dev builds?

obtuse gale
agile galleon
#

that was a joke pepered

ocean quartz
brittle leaf
distant sun
obtuse gale
#

Mutability bad

#

Why wouldn't you turn those into unmodifiable sets? You wouldn't want those to be changed

ocean quartz
#

Wouldn't that copy it to a different set and kinda lose the advantages of an EnumSet?

obtuse gale
#

No, Coll.unmodifiableSet wraps it and delegates to the given set (except mutating operations)

#

It's not Set.copyOf

ocean quartz
#

Ah gotcha

distant sun
#

I see there's also Sets#immutableEnumSet 🤔

#

I thought that EnumSets are already immutable, welp

obtuse gale
#

Effectively it's no different, it probably just skips the delegation part and is an immutable enumset impl itself

pastel imp
#

uh, anyone knows if saberfactions uses massive factions plugin/code?

distant sun
#

Yeah, very nice Emily

wary python
ocean quartz
#

You'll have to wait till the database updates, then you'll get access to the channel

wary python
#

Ok thanks

brittle leaf
#

Is 1.12.2 a more acceptable version to code for then 1.8?

#

i say this more in terms of performance since 1.13+ basically ruined server performance and hasnt caught up with 1.12 fully yet

agile galleon
#

just go with 1.18

obtuse gale
#

1.13 and 1.14 were disastrous for performance

#

from then on it's really solid and kept improving

agile galleon
#

yep

obtuse gale
#

@autumn stump can you accept my friend request?

static zealot
#

So today I've updated some packages using the Pop Store (on Pop OS) and now Jetbrains Rider recommends me to use stuff like is not instead of !(X is Y) but when I try to build it breaks and throws a "Type Or Namespace not found"... I'm not sure what packages got updated. Also its a C# project. could it be that dotnet got updated and now Rider reads that but it actually builds against an older version? If so how could I fix this? I know I can just ignore and not make the recommended changes but still.

timber oak
#

What's best, Bukkit Logger or slf4j logger - both in 1.17.1

prisma wave
#

"bukkit logger" is just the jdk logging library

#

i prefer slf4j personally but they do the same thing in most ways

obtuse gale
#

com.mojang:logging

#

with its amazing toString deferrer

#

mojussy

#

ate

prisma wave
#

?

timber oak
prisma wave
#

its log level names make sense

#

jdk with "fine" and "severe"

#

slf4j with "error" and "trace"

#

also it can do formatting for you to a degree

timber oak
#

Alright, I'll just keep using slf4j then

#

ty

half harness
timber oak
#

which I'll keep doing I think

half harness
#

unless u mean in a separate program?

timber oak
half harness
#

¯_(ツ)_/¯

#

idk

timber oak
#

Also the formatting is the same

half harness
#

idk what lib bukkit uses

timber oak
#

The warn was sent with slf4j

half harness
#

🤔

timber oak
#

Ye?

#
[21:38:25 WARN]: [net.valdemarf.parkourplugin.playertime.PlayerTimeManager] A document has been found! - Leaderboard
[21:38:25 WARN]: [net.valdemarf.parkourplugin.playertime.PlayerTimeManager] A document has been found! - PersonalBests
#

It just shows where it was sent from

#

Pretty nice imo

half harness
#

oh wait

#

spigot uses slf4j

prisma wave
#

it uses log4j actually

#

😏

half harness
#

but

#

oh

#

but

prisma wave
#

but slf4j too

half harness
#

okay

prisma wave
#

slf4j is the api

half harness
#

idk i still get confused with that

#

😖

prisma wave
#

iirc the jdk logger delegates to an slf4j logger anyway

#

so

shy pewter
#

hi, Ive got two questions about deluxe menus.

  1. when someone trade a object for other in a menu. He can have it in second hand and will get infinite of the item to get. Is there a way to fix it?

  2. how does the [sound] event-thing work?

#

ping me at response

shy pewter
#

oh.. thanks... sorry. Im new at this discord

obtuse gale
prisma wave
#

juul

timber oak
gusty glen
steel heart
#

Don’t think that matters in this case, like it’s just internal as well and I’d assume that listener is only instantiated once on the main thread.

obtuse gale
#

There's no reason for those to be modifiable

#

They're more like constants

timber oak
onyx loom
#

adding final to a class means that it cant be extended by other classes

#

so if ur not extending it, sure

timber oak
half harness
#

:)

timber oak
#

Oh, well no classes in my project are being extended, so should I make them final?

#

Or is it not as important as it is for variables?

forest pecan
#

except primitives

#

and Object is a class

timber oak
#

Oh yeah true

forest pecan
#

but by default you dont have to add to add extends Object

#

cause java already assumes

timber oak
#

So should I add the final to all my classes? I extend none of them

onyx loom
timber oak
cinder flare
humble silo
#

All of that is literally just for a couple spring dependencies... Im pretty sure alot of artifacts are gettting loaded twice tho

#

~1,500 dependencies

rancid gazelle
#

whats a good rtp plugin that allows configurable cooldowns? but like dif cooldowns for dif ranks. if u know pls let me know! ping me or dm me!

tardy knot
rancid gazelle
tardy knot
#

none that come to mind

#

but there's got to be a way right?

rancid gazelle
#

i think so?

rancid gazelle
tardy knot
#

i think both of the ones above have a bypass option

#

?

rancid gazelle
quaint isle
#

How tf do you send an HTML email if you only got source code?
I just wrote a nicely looking newsletter template, just to found out there is no way to paste code into outlook 😄
Do you know any software that can do it? I know I could code something but I suppose there's an easier way.

worldly anchor
#

mailchimp as a mail api also supports triggering html emails

quaint isle
#

I want to send from an already existing mail account, so imma give thunderbird a try, thank you.

glossy plover
#

@quick flume about ur deluxe shop, how does it work? How can I link it to gems economy money? How do I change the prices? Does it sell everything?

obtuse gale
#

Linked my spigot account and will not let me access deluxechat channel,so i can get a dev build?

compact perchBOT
#
FAQ Answer:

Have you linked your spigot account and don't have the premium plugin role yet?

Spigot doesn't allow us to check for buyers automatically, so we have to do it manually. This means that we can only update the buyers list in our system every 24-48 hours.

If you wish to see when the database was last updated, you can by using the /buyercheck status command.
Once the buyer's list has been updated for that plugin, you can recheck your roles by using the /spigot check command, then you should have the role, and will be able to view the respected plugin's channel!

static zealot
#

read this please ^^^

#

it just got updated

#

recheck your roles

#

there you go

obtuse gale
#

thanks much sir

hybrid isle
#

My essentialsX keeps removing all the userdata of who's on while server restart 2 times or /rl confirm 2 times. please help

quick flume
#

to link to gems economy should be as easy as changing the requirements/commands from essentials economy requirements/commands

#

oh shoot, you will also need to edit the dmshop-maxpurchase.js from%vault_eco_balance% to your placeholder

quaint isle
worldly anchor
#

¯_(ツ)_/¯

timber oak
#

Is it generally bad to have all managers and instances in the main class?

ocean quartz
#

The managers not really, the plugin instance yes

timber oak
ocean quartz
#

Yeah, use Dependency Injection instead

steel heart
#

Especially if you unit test, having direct rather than indirect dependencies will help with for instance "mock"-ability

timber oak
steel heart
#

And needless to say, I believe you achieve a class hierarchy where not every concretion is dependent on the highest ordered class, as such maintaining the overall system and having reusable classes will become easier and more accessible.

#

automated testing

#

not many devs do it for spigot plugins because just testing something (such as a command or that an event triggers) directly isn't that complicated

timber oak
#

Ah I definitely am passing most of the managers through DI, but sometimes it can be very messy and then I decide to use the getter from the main class, if I just need the instance once or smth.

steel heart
#

hmm 🤷

#

like I guess your main class can act like a context facade (problem is just, if its one of the highest classes, a lot of other classes will subsequently have to depend on that context facade)

tranquil crane
#

I typically have a method in my main plugin class called <T extends Manager> getManager(Class<T> managerClass) which fetches the instance of the manager class given from a map I initialize when the plugin loads, that way I can just do ExampleManager manager = plugin.getManager(ExampleManager.class); whenever I need it

#

it just keeps the number of getters down in the main class, though I'm sure there are some people out there who are going to flame me for it lol

timber oak
steel heart
#

so for instance you know how your main class has the function onEnable

#

which then in there, it instantiates all your managers in one or another way

#

so it bootstraps the plugin (sort of a self growing process)

timber oak
timber oak
# steel heart so for instance you know how your main class has the function onEnable

Yeah this

        // Register objects
        checkpointManager = new CheckpointManager(this);
        checkpointManager.setupDataFolder();

        ConfigManager configManager = new ConfigManager(this);
        configManager.instantiate();
        playerTimeManager = new PlayerTimeManager();
        database = new Database(configManager, this);

        PaperCommandManager manager = new PaperCommandManager(this);
        scoreboardManager = new ScoreboardManager(this);
        parkourManager = new ParkourManager(scoreboardManager);
steel heart
#

mhm

timber oak
steel heart
#

bootstrap - self growing process iirc

#

because once the bootstrap proceeds, a lot of other objects such as your managers will be created

#

now I call it highest ordered which might not be the perfect term, but its due to this, it has the responsibility setup your plugin either, directly or indirectly

timber oak
#

Like the order of instances

steel heart
#

by providing a set of accessors(getters) we give it yet another responsibility, thus yet another major reason it might have to be changed in the future, so arguably it breaks sth called the single responsibility principle as it acts as a context facade as well as the bootstrap

#

From wiki

In general, bootstrapping usually refers to a self-starting process that is supposed to continue or grow without external input.

timber oak
steel heart
#

yep

timber oak
#

And how about the context facade? Never heard of that before

steel heart
#

a context object is an object which couples a set of other objects

#

in simple terms, it simple acts like a vessel to access other objects

#

for instance, Event classes can usually be seen as that

#

a facade is a facade, its the face of something where you don't know what's, how and the complexity that happens behind it, a good example would be most interfaces in paper

#

your plugin main class isn't really a strong facade, but the methods do abstract away the way of reaching out to your plugin instance's internals directly

#

obv it can be quite nice to just pass the plugin instance along with all of its getters

timber oak
#

Ummm, this is very confusing but I think I understand, kinda. So the issue is really that I instantiate the objects in the main class, but it's also the "vessel" for the objects, which can cause problems when the new objects are initializing?

steel heart
#

it doesn't cause any direct issue

#

like having it that way is manageable

#

its just that your entire system becomes ridiculously coupled to that class of yours

timber oak
#

Because if the order is wrong it will cause errors, right? Or not that way coupled

steel heart
#

yes

#

I mean

#

you cannot call the function open() before the function close() for a file object or sth

#

since open causes a side effect

#

as well as close

timber oak
#

Makes sense

steel heart
#

(side effect is just when a function may return or do something differently in spite given the same input)

#

for instance this is a non side effect function

int multiply(x,y){
  return x*y;
}

this will be one:

static int i;

void setI(i) {
  self.i = i;
}

int getI() {
  return self.i;
}```
distant sun
#

self.i

steel heart
#

ye

#

its my own brogramming language

timber oak
steel heart
#

Well

#

if you have a side effect free function

#

You should be able to remember the given output for a given input

#

If you know the input, you know what output you’ll get

#

However getI for instance can return differently in spite of the same input (no input)

ocean quartz
steel heart
#

and the first one doesn’t even return anything

timber oak
#

So this would have side effect:
If playerTimeManager depends on database in the playerTimeManager constructor

        playerTimeManager = new PlayerTimeManager();
        database = new Database(configManager, this);

Since database hasn't been instantiated?

steel heart
#

Yes

timber oak
#

Like playerTimeManager uses a function from database or smth

steel heart
#

Assume that’s inside a function

#

It changed the state of your system

#

so it’s impure

#

Or well, not side effect free

#

Anyways Valdemar

#

There are cons and pros to everything

timber oak
steel heart
#

So having all those getters might not be entirely wrong

#

But it’s definitely something to think about

timber oak
#

Yeah, I can see how, I just need to look more into which of my managers are side-effect free I think

#

Because the order of the managers sometimes causes an error rn

steel heart
#

Oh no

#

Don’t try to avoid side effects but try to minimize them if possible

timber oak
#

Yeah yeah I know, I'm just running the side-effect free ones first, since the ones that are not side effect free might depend on them

steel heart
#

The classical sign of a side effect is where depending on the order of in which the functions are declared may lead to an explosion or not

timber oak
#

Yeah, I'll try and minimize my getters then, it'll also help later on if it gets more messy ig

steel heart
#

Well think about it

#

If your main class provides everything

#

then almost everything must depend on the main class simply

timber oak
#

Most of the classes at least

#

Which is not nice

steel heart
#

Yeah, the side effect thing isn’t as important rn

#

After all you write Java, object oriented code.

timber oak
#

I'd just like if I could use the main class yet, because it's included in pretty much all classes atm

#

I could avoid it with using more DI I guess

steel heart
#

The word di sounds very extravagant

#

But yeah, just passing objects directly can benefit you sometimes

#

Design choices always yield cons and pros

timber oak
steel heart
#

Actually that’s the wrong word

#

But it’s an advanced term for yet a simple thing

timber oak
steel heart
#

I mean you would get 1-2 dependencies normally

#

Or eventually 3

#

Sometimes even four or five

#

But it gets a bit hard to manage stuff that takes many inputs