Resource A Resource Pack API

Discussion in 'Spigot Plugin Development' started by fihgu, May 11, 2016.

  1. I have developed an API that does the following:
    • Construct a resource pack on the server with resource provided by multiple plugins
    • Host the constructed resource pack on the server itself with a custom light weight HTTP server.
    • Allow plugins to make custom items with their own texture/model
    • Option to kick players if their server resource pack is not enabled.
    It also has these features:
    • Constructed resource pack are cached through sessions, unless server owner add/remove plugins that uses this API, it will not be reconstructed.
    • Server owners can still use their server resource pack, it will be automatically merged into the constructed resource pack.
    • Damage values are automatically assigned to each custom item, which means multiple plugins can base their custom item on the same vanilla item.
    • Constructed resource pack has a build number which means when it changes, clients doesn't need to delete their local cache to get the new resource pack.
    To download the compiled jar: click here
    The source code is available on

    You may contact me with skype: fihgus

    First you want to have a working resource pack, in the form of a zip file.
    Then you want to put it at a reachable location for the client, for example inside your plugin's jar file.
    Finally you want to register the resource, you can do so with something like this:
    Code (Text):

    InputStream source = this.getResource("");
         ResourcePackManager.registerResource(this, source);
    catch (IOException e)

    You want to register the resource in your plugin's onEnable() method, otherwise it will not be included.
    If you change the content of your resource pack, you need to change the version of your plugin, otherwise servers with a cached resource pack might not get the change.

    First you want to add your texture to the resource pack with method mentioned above.
    Then you want to make a CustomItem and register it like this:
    Code (Text):

    Model model = Model.CreateSimpleModel("items/iron_boots");
    item = new CustomItem(DamageableItem.DIAMOND_BOOTS, "name", "displayName", new String[]{"lores"}, model);
    ItemStack stack = item.createItemStack();

    You need to call this code in your plugin's onEnable() method as well.
    The Model class is a json object, witch you may edit it for a more advanced model, in this example I'm just creating a simple model that uses 1 texture.

    The CustomItem class represents a custom item type, to create a custom item, you need to provide a DamageableItem as it's base item, DamageableItems are items with a durability bar.

    for parameters: the name is a unique item name, every custom item in your plugin must have a different name.
    Then there is the displayName and lores, and the model, which multiple CustomItem may share.

    upon registering, the custom item will be assigned a damage value as it's id, witch is unique to every CustomItem.
    After it is registered, you may get an itemstack with the createItemStack() method.

    How do I install this on my server?
    Just drop the compiled jar inside your plugins folder like you do with most other plugins, but it will not do anything on its own, you also need another plugin that uses this API.

    Where is the resource pack hosted?
    Resource pack is hosted on the server itself, and by default it is hosted on port 80, you may change that in the config file, just edit "http.port".

    Why aren't my clients downloading the resource pack?
    There can be multiple causes:
    • Failed to get host name, this API uses a web service to get your server's host name, sometimes the service is not available, then you have to give the API your host name(public IP) though the config file, change "" to your public IP address should solve this.
    • Fialed to get localhost name, this is not likely to happen, but everyone's computer is different, your firewall might be doing tricks on you, to solve this, set "http.localhost" to your local IP address, make sure you did NOT put a loopback IP(for example: there, a loopback IP is not reachable from anywhere other than your own PC.
    • Port is not open to public, might be your firewall, or you didn't port forward the http server port(default:80)
    #1 fihgu, May 11, 2016
    Last edited: May 15, 2016
    • Like Like x 4
  2. I'm curious if your "force" option simply kicks if they decline, or have you been the one person in 2 years to find a way to actually force it?
    • Like Like x 1
    • Optimistic Optimistic x 1
  3. it's just simple kicking, You can not "force" them to turn server resource pack on. unless mojang come up with some new packets for that.
  4. I know. The way you worded it though. :S I was hoping you were the chosen one... :p
    • Funny Funny x 3
    • Like Like x 2
  5. I have just released this API, please leave your feedback here, or contact me on skype.
  6. working on a demo plugin.
    • Winner Winner x 1