Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

chests.yaml should allow symbolic names #24

Open
sshipway opened this issue Oct 2, 2016 · 1 comment
Open

chests.yaml should allow symbolic names #24

sshipway opened this issue Oct 2, 2016 · 1 comment

Comments

@sshipway
Copy link
Contributor

sshipway commented Oct 2, 2016

Currently, chest items need to be specified by their object ID. It would be better if it were to allow symbolic names.

Probably the place to do this is in ItemReader.read; if the first item is non-numeric then call matchMaterial()

        try {
            itemid = Integer.parseInt(split[0]);
        } 
        catch( Exception e ) {
            Material m = Material.matchMaterial(split[0].toLowerCase().trim());
            if( m == null ) {
                SurvivalGames.error("ItemReader: invalid id "+split[0]);
                return null;
            }
            itemid = m.getId();
        }
        try {
            if(split.length == 1){
                return new ItemStack(itemid);
            }else if(split.length == 2){
                return new ItemStack(itemid, Integer.parseInt(split[1]));
            }else if(split.length == 3){
                return new ItemStack(itemid, Integer.parseInt(split[1]), Short.parseShort(split[2]));
            }else{
@ThunderGemios10
Copy link
Owner

@sshipway Hmm, Yes it would be better if it allowed symbolic names, I might start working on it if i find enough Free Time.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants