Menu Icons

Does anyone know why menu icons take so long to load when using the URL type? They will load when grabbed from a URL, but it takes forever. I am also having issues with loading an icon from a file, it only shows the black/purple image (The same one that is displayed on a map when it is waiting to render) when attempting from a local path.

JavaScript:
               String path = button_data.getString("icon");
                File image = new File(this.getDataFolder().getPath()+"/"+path);
               String type = ElementButtonImageData.IMAGE_DATA_TYPE_URL;

               if(image.exists()){
                    type = ElementButtonImageData.IMAGE_DATA_TYPE_PATH;
                    path = image.getPath();
               }

                button.addImage(new ElementButtonImageData(type, path));
                button.setText(button_data.getString("text"));
I have noticed if I reload the server while the menu is open, the icons served from my back end server will be displayed instantly. The same happens if I run
JavaScript:
player.showFormWindow(menu);
twice, it will obviously show 2 menus on top of each other. The first will still be loading the icons but if I close that one, the second will already have them loaded. I have tried all different size images from 10px to 500px along with loading icons from other sources than just my back end server. Any ideas?
 
Last edited:

PetteriM1

Resource Mod
Staff member
Slow button image loading on first time is a client side thing and they will be saved for faster loading next time. Using 'PATH' is for in game/resource pack textures, not for files in your data folder.
 
Slow button image loading on first time is a client side thing and they will be saved for faster loading next time. Using 'PATH' is for in game/resource pack textures, not for files in your data folder.
That would make sense except they take just as long the second time around, I have checked out some other servers such as the hive and they seem to load almost instantly on the same connection/client I am testing it with. Could it just be from a slower network? I am running at about 85-90mbps download and 11-12 upload. Also, do you know where I can find the resource packs or an example of how to apply them as a button icon? I always thought that was purely client-side.
 

Linkraft

New Member
Man, dealing with menu icons can be a real headache, right? It's like you're playing a game of "wait and see" every time you try to load them.
 
At some point, I feel your frustration, man. Loading menu icons can be a real pain, especially when they're coming from URLs or local files. Your JavaScript snippet seems solid, but dang, those icons taking forever to show up are a bummer.
But there's one thing. Have you considered optimizing those icons? Sometimes, resizing them or converting them to AI vector images can speed things up big time. Plus, it'll ensure they look sharp no matter what size you need them.
 
Last edited:

PetteriM1

Resource Mod
Staff member
You can try sending player attributes a few ticks after opening the form as a workaround to make client refresh the form.
 
Top