#y2k commons

1 messages · Page 1 of 1 (latest)

lavish bane
#

u2k please join the thread

clever swan
#

hm

lavish bane
#

Hi

#

What would contain the lib?

clever swan
#

uhm I put everything I'll use in there

#

the only thing that I have right now that isn't on the github is menus

#

but thats because I'm finishing up testing

lavish bane
#

Oh nice

#

I was planning to make my own one

#

But i always have problems with paginated menus

clever swan
#

ahh I haven't done paginated yet

#

thats next I suppose

#

should still be fairly easy

lavish bane
#

y2k what do you think something like this

clever swan
#

I'm bored of coding right now so I'm going to write wiki for my lib lol

#

I wanna make art for my lib but I suck at art :(

#

whatever I'll worry about that later

#

I still need to get around to getting good at art

strange crater
#

menus aren't too hard

#

my menu util isn't the best but it worky

#

wish I actually had a good way to make menus easily

#

command framework is based tho

clever swan
# strange crater menus aren't too hard

I just tried to replicate to the best of my ability what they used for my job. I made sure when I worked their I didn't look at their source so I can actually make my own lib without infringing on anything

strange crater
#

I really like the command framework

clever swan
#

my command framework kinda sucks atm but its okish

#

it does what I need

strange crater
#

I also like my messages util

#

basic messages.sendMessage(player, "no-permission");

#

supports placeholders n all

#

I gotta start putting more work into my utilities fr

#

I keep redoing the same code over and over

#

might make some raycasting utils

#

I even made utils for treating database data like a hashmap

#

put(uuid, object) fetch(uuid) fetchAll type deal

#

that checks both redis and mongodb, does caching

clever swan
#

I just started making my api I'm hoping it'll be as extensive as my works in a month or two

lavish bane
#

What do you think about the impl?

MenuHandler handler = new MenuHandler(this);

MenuAction action = handler.getBuilder().newAction().(event -> event.getPlayer.sendMessage(event.getSlot()));
MenuButton button1 = handler.getBuilder().newButton().setItem(item).setClick(ClickType.LEFT_CLICK).setAction(action).build();
InventoryMenu inventory = handler.getBuilder().newMenu().setName("&6Menu").setRows(1).setButton(1, button1).build();

inventory.open(player);
inventory.close(player);
clever swan
#

you can take a look at mine verano

lavish bane
#

oh really?

clever swan
#

its a bit rough around the edges yet as I haven't used any of it in practice

#

but this is what I got

clever swan
strange crater
clever swan
#

neat to see someone else do it

strange crater
#

I can call menu.open(player) directly but that breaks the menu chain

#

menu chain is just a linkedlist used for those "Go back" buttons

#

I got tired of coding the "go back" buttons that have to pass metadata back

#

so now I just rebuild the menu but with the metadata there

lavish bane
clever swan
#

oh one thing I want to do is make a lot of stuff with textures packs in my API but I hate making texture packs xD

strange crater
#

never messed with them but I guess I'll just make an alias system

#

where multiple slots serve the same purpose

#

actually the custom gui stuff can just be a picture overlayed on the title

lavish bane
#

Ilussion how many years of java coding you have?

strange crater
#

doesn't have to be the items

strange crater
clever swan
strange crater
#

working on some goofy stuff rn

clever swan
#

I had one where you could generate a image on a gui from an image file 1 for 1 pixel by pixel but as you can imagine it caused lag

#

the client I ran couldn't get above 3fps

#

the server was fine but damn lol

lavish bane
#

oh that why

#

Imagine may i ask what does the metada thing and chain?

strange crater
#

metadata is just a fancy map that allows you to associate some objects with a menu

lavish bane
#

Mainly for caching values right?

strange crater
strange crater
clever swan
lavish bane
#

yeah

#

Y2k i will try make my self the menu api

#

And then we see if you like more mines or which

clever swan
strange crater
clever swan
#

I can't wait to do DB stuff but atm haven't had an actual reason

#

I'm less than enthused for something like SQL but mongo has awesome java drivers

strange crater
#

mongo is based

#

I'm using both mongo and redis on the example

#

data is fetched from mongo, cached in redis

#

and goes back to mongo

lavish bane
#

ilusion did you delete your data-sync library?

#

I cannot find it

strange crater
#

the GUIs fetch data from redis every time they're open

strange crater
#

it clearly did not work

#

I also need to update it

#

because mongo brokey

lavish bane
#

oh said

strange crater
#

and data syncing itself also brokey

lavish bane
#

i was planning to base on it

#

😬

strange crater
#

yikes

#

I got a much better database system now

#

What part of it do you need?

lavish bane
#

I was just looking for the full source code just to see how you implement it

strange crater
lavish bane
#

Ilusion i really want to understand async and non blocking into java

strange crater
#

CompletableFuture

lavish bane
#

But i still cannot understand the diff ways fior implementing it

strange crater
#

the easiest is just CompletableFuture

lavish bane
#

ok

#

And what about for an evenet-driven?

strange crater
#

such as?

lavish bane
#

I was planning to implement an event driven system for making event-listener

strange crater
#

ehhhhhhhhhh

#

that's a pain

#

bit useless

#

I made it once, not fun

#

Here's a useful class for CF

#
public final class MainThreadExecutor implements Executor {

    public static final MainThreadExecutor MAIN_THREAD_EXECUTOR = new MainThreadExecutor();
    private static JavaPlugin plugin;


    private MainThreadExecutor() {
    }

    public static void init(@NotNull JavaPlugin main) {
        MainThreadExecutor.plugin = main;
    }

    @Override
    public void execute(@NotNull Runnable runnable) {
        if (Bukkit.isPrimaryThread()) {
            runnable.run();
            return;
        }

        CountDownLatch latch = new CountDownLatch(1);
        Runnable task = () -> {
            runnable.run();
            latch.countDown();
        };

        Bukkit.getScheduler().runTask(plugin, task);

        try {
            latch.await();
        } catch (InterruptedException e) {
            e.printStackTrace(); // if this happens, something is very very very very wrong
        }
    }
}
#

you just use it to run CFs in the main thread

lavish bane
#

In my case i would really use it because i will implemet it then on my future redis api

#

And then on networking based project

strange crater
#
CompletableFuture.supplyAsync(() -> {
  Object databaseObject = fetchThroughBlockingMethod(playerId);
  databaseObject.doSomething();
  return databaseObject;
}).thenAcceptAsync((databaseObject) -> {
  // back in main thread
  world.spawnEntity(location, databaseObject.getEntityType());
}, MAIN_THREAD_EXECUTOR);
#

type deal

lavish bane
#

i have a duded

#

Is there a really big diff btween having 2 methods static vs the class itself static?

#

no no thing im weird today

#

Only nested classes can be static

#

Ilussion im really fascinated about your menu api

#

Its looks pretty amazing the implmentation

strange crater
#

it's something I hacked together in like 2 hours

#

and it's held together by glue and hate

lavish bane
#

oh lol

#

Amazing

#

I dont think its open source right

strange crater
#

probably not

lavish bane
#

ok

strange crater
#

by open source it's like

lavish bane
#

But thanks tho

strange crater
#

do I have any projects that actively use it

lavish bane
#

because i was looking for a good menu api

#

And yours is amazing

strange crater
#

use lucko's helper

#

Mine's on its second iteration, I'm still improving it every day

#

I tried adding dynamic titles but it tripped my client up lol

lavish bane
#

would you sell a copy of it once its done?

strange crater
#

you really think you can bribe me with 5$

#

I already gave you the scheduler util and database code

#

I accept tips, but no point in "selling a copy"

lavish bane
#

ok

#

im not wondering to bribe you

#

Dont think that i was playing with that

#

I don't laugh at anyone, much less for money.

strange crater
#

¯_(ツ)_/¯

#

I earn enough through my work

lavish bane
#

and there i can find the photos?

#

🤣

strange crater
#

this is not onlyfans.

#

that's a different link

lavish bane
#

oh h ok

#

I have seen many girls on instagram saying buy me a coffe

#

And i associate all buy me a coffe with only fans

#

My bad 👉 👈

strange crater
#

imagine looking at girls on instagram

#

I got like 18 followers

#

follow a whole 4 people

lavish bane
#

weird i have a friend which has more girls of best friend than all my followers + followed people

#

I think there is not really common instagram they use more snapchat

strange crater
#

well

#

girls don't find me particularly interesting on snapchat

#

yo
Hey
waz good
Working
what you do
Programming
k bye

#

What am I gonna snap about? my triple monitor setup and how I'm always grinding?

lavish bane
#

neither me haha i mean i just have instagram to be on the line because society is so shity that they swear everything

strange crater
#

I got instagram because some people don't have discord

#

I actually got 2 instagram accounts

#

one is just for spam and general interest, the other is more of a personal brand

#

I like looking at those motivational twitter quote accounts

lavish bane
#

oh me too

strange crater
#

Ben meer type of accounts

lavish bane
#

I follow those accounts which have motivation phrases

strange crater
#

check out systemsunday

lavish bane
#

Right now I am very happy because I am starting to get into a very important project in my city which will be financially supported by a high ranking leader of a dam in my country. And the objective of the project is decentralization.

#

Ilussion going back to coding you are saving every menu with a name right?

strange crater
#

it's the file name

lavish bane
#

oh ok

strange crater
#

so you have this

#

then you call getGUI(name) and it gets from the file

#

all cached n all

#

the GUIs aren't as clever as my imageboard system

#

I made this yml parser system where you can add overlays into an image, hold metadata

#

Then render it all and easily code buttons

lavish bane
#

weird amazing

#

And its possible to make it fill with a color

strange crater
#

yeh

lavish bane
#

LOL

#

Fucked amazing

strange crater
#

all client-sided too

lavish bane
#

oh

#

client sided

#

A texture pack?

strange crater
#

no

#

just packets

lavish bane
#

oh

#

I thought you need smth extra on the client to make that work

strange crater
#

no you just need packets

#

and a frame buffer

#

and lots of optimizations

#

because bukkit is slow

clever swan
strange crater
clever swan
#

what is this mfing thing

#

like how does that even work

strange crater
#

uhhhhhh

#

oddly specific

clever swan
#

are you using maps or something?

strange crater
#

Yes

clever swan
#

ok makes more sense though I would assume ratracing is difficult

strange crater
#

item frames and maps, raycasting, frame buffer, custom color conversion

#

you can read about raycasting here

lavish bane
#

Ilussion i have a question

#

How did you associate the menus with the player then?

strange crater
#

metadata

lavish bane
#

oh ok

strange crater
#

etc etc

lavish bane
#

Because i have done this simple code for the menus but i just realzie how do itrack them on the listener

strange crater
#

oh that

lavish bane
#

Oh you are using holders

strange crater
#

yeah

lavish bane
#

I never understand holders

strange crater
#

they're just an object (often null) that serve as a basic metadata object to the gui

#

in this case my Menu class implements InventoryHolder and I pass the entire menu on the gui

#

process just parses associated placeholders

lavish bane
#

perfect it should work the same if my Menu class is an abstract class which implements InventoryHolder

strange crater
#

There's a method I really like

#

that's great for concurrency

#
public void doSomething(Player player) {
  if(!Bukkit.isPrimaryThread()) {
    Bukkit.getScheduler().runTask(plugin, () -> doSomething(player));
    return;
  }

  player.doSomething();
}
#

ensures it's always sync

#

you can pair that with my executor if you want to ensure order of operations

#

anyways im sleepy

#

got a coding session in 6 hours

lavish bane
#

ok

#

See you soon

#

Nice to talking with you

lavish bane
#

Ilussion, how are you?

#

How is your LinkedList chain setup?

#

Map<Player, LinkedList<Menu>> ?

#

@strange crater sorry for pinging

strange crater
#

Map<UUID, MenuChain>

lavish bane
#

ok

#

And MenuChain contains the data right?

#

Thanks for being so helpful

strange crater
#

Ye

lavish bane
#

Thanks

lavish bane
#

Hi @strange crater, how are you? I was wondering if can i get an explanation about MenuChain class form your old menu api?

#

Thanks

strange crater
#

ehh it's a bit cancer

#

Basically the idea is that a MenuChain is a linked list

#

of menus that were open

#

Opening a menu adds it to the chain, clicking on the "back" button gets the last element on the chain n does stuff

#

and when you close the inventory, if the chain isn't aware of "transitional data" the chain breaks (because you force-closed, remember that opening a new inventory still fires close events)

#

I completely removed that feature on the new engine because it would somewhat break dynamism

#

as it used snapshots of old menus that could be outdated

#

@lavish bane

lavish bane
#

oh right really thanks

#

So what is the best option for keeping track of menu and child menus opened?

strange crater
#

I mean it's odd because in my case, each menu has context

#

like if I'm managing a classroom, I must know what classroom it is

#

in my old system I had metadata for it

#

in my new system I just use constructors and method params

lavish bane
#

Hmn right

#

Im confused, but dont worry then i ill give a try to the menu api

#

Once i finish the current comission i have

clever swan
strange crater
#

no ❤️

lavish bane
clever swan
strange crater
#

Well

#

There might be a chance that one day I just decide to move on from minecraft plugins and magically decide to open-source all my utilities and provide sample projects

#

or I might just get depressed and cry myself into posting tutorials and being popular

lavish bane
#

Imlussion

#

Do you coder on any lang?

#

I mean any other none related to Java

strange crater