#y2k commons
1 messages · Page 1 of 1 (latest)
hm
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
Oh nice
I was planning to make my own one
But i always have problems with paginated menus
y2k what do you think something like this
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
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
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
I really like the command framework
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
I just started making my api I'm hoping it'll be as extensive as my works in a month or two
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);
you can take a look at mine verano
oh really?
its a bit rough around the edges yet as I haven't used any of it in practice
but this is what I got
ehh
ahaha I had something like this a while back
neat to see someone else do it
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
Amazing
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
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
Ilussion how many years of java coding you have?
doesn't have to be the items
5-6
I have lots of experience with them xD I made some pretty insane API it just wasn't performant so the ideas were scrapped
working on some goofy stuff rn
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
metadata is just a fancy map that allows you to associate some objects with a menu
Mainly for caching values right?
ignore the menu not loading correctly, still looking into it
Yeah, holding context etc
if you want to contribute though verano i'm open for commits
yeah
Y2k i will try make my self the menu api
And then we see if you like more mines or which
you should check out using mine you might like it
all of this is synchronized with multiple databases in real time :)
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
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
the GUIs fetch data from redis every time they're open
I privated it so I can get more sales on spigot
it clearly did not work
I also need to update it
because mongo brokey
oh said
and data syncing itself also brokey
I was just looking for the full source code just to see how you implement it
here's the db stuff
Ilusion i really want to understand async and non blocking into java
CompletableFuture
But i still cannot understand the diff ways fior implementing it
the easiest is just CompletableFuture
such as?
I was planning to implement an event driven system for making event-listener
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
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
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
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
it's something I hacked together in like 2 hours
and it's held together by glue and hate
probably not
ok
by open source it's like
But thanks tho
do I have any projects that actively use it
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
would you sell a copy of it once its done?
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"
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.
¯_(ツ)_/¯
I earn enough through my work
If you want to support me, maybe get me some coffee, I got my https://ko-fi.com/illusionthedev kofi link
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 👉 👈
imagine looking at girls on instagram
I got like 18 followers
follow a whole 4 people
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
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?
neither me haha i mean i just have instagram to be on the line because society is so shity that they swear everything
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
oh me too
Ben meer type of accounts
I follow those accounts which have motivation phrases
check out systemsunday
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?
it's the file name
oh ok
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
and you can click stuff
yeh
all client-sided too
no you just need packets
and a frame buffer
and lots of optimizations
because bukkit is slow
what the fuck
made it in a weekend
are you using maps or something?
Yes
ok makes more sense though I would assume ratracing is difficult
item frames and maps, raycasting, frame buffer, custom color conversion
you can read about raycasting here
metadata
oh ok
Because i have done this simple code for the menus but i just realzie how do itrack them on the listener
yeah
I never understand holders
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
perfect it should work the same if my Menu class is an abstract class which implements InventoryHolder
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
Ilussion, how are you?
How is your LinkedList chain setup?
Map<Player, LinkedList<Menu>> ?
@strange crater sorry for pinging
Map<UUID, MenuChain>
Ye
Thanks
Hi @strange crater, how are you? I was wondering if can i get an explanation about MenuChain class form your old menu api?
Thanks
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
oh right really thanks
So what is the best option for keeping track of menu and child menus opened?
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
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
Are you ever going to open source your engine
no ❤️
oh sad
Pain
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
update: wait and see :)