Search in sources :

Example 1 with LibraryFileList

use of riskyken.armourersWorkshop.common.library.LibraryFileList in project Armourers-Workshop by RiskyKen.

the class GuiSkinLibrary method fileExists.

private boolean fileExists(String path, String name) {
    LibraryFileList fileList = getFileList(fileSwitchType);
    ArrayList<LibraryFile> files = fileList.getFileList();
    for (int i = 0; i < files.size(); i++) {
        LibraryFile file = files.get(i);
        if (file.getFullName().equalsIgnoreCase(path + name)) {
            return true;
        }
    }
    return false;
}
Also used : LibraryFileList(riskyken.armourersWorkshop.common.library.LibraryFileList) LibraryFile(riskyken.armourersWorkshop.common.library.LibraryFile)

Example 2 with LibraryFileList

use of riskyken.armourersWorkshop.common.library.LibraryFileList in project Armourers-Workshop by RiskyKen.

the class EntitySkinHandler method getRandomSkinOfType.

public LibraryFile getRandomSkinOfType(ISkinType skinType) {
    ILibraryManager libraryManager = ArmourersWorkshop.getProxy().libraryManager;
    LibraryFileList fileList = null;
    if (ArmourersWorkshop.isDedicated()) {
        fileList = libraryManager.getServerPublicFileList();
    } else {
        fileList = libraryManager.getClientPublicFileList();
    }
    ArrayList<LibraryFile> typeList = fileList.getCachedFileListForSkinType(skinType);
    if (typeList == null) {
        return null;
    }
    ArrayList<LibraryFile> validFiles = new ArrayList<LibraryFile>();
    for (int i = 0; i < typeList.size(); i++) {
        if (typeList.get(i).filePath.startsWith(ConfigHandler.enitiySpawnSkinTargetPath)) {
            validFiles.add(typeList.get(i));
        }
    }
    // touhou
    Random random = new Random();
    if (!validFiles.isEmpty()) {
        return validFiles.get(random.nextInt(validFiles.size()));
    }
    return null;
}
Also used : Random(java.util.Random) LibraryFileList(riskyken.armourersWorkshop.common.library.LibraryFileList) ILibraryManager(riskyken.armourersWorkshop.common.library.ILibraryManager) ArrayList(java.util.ArrayList) LibraryFile(riskyken.armourersWorkshop.common.library.LibraryFile)

Aggregations

LibraryFile (riskyken.armourersWorkshop.common.library.LibraryFile)2 LibraryFileList (riskyken.armourersWorkshop.common.library.LibraryFileList)2 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 ILibraryManager (riskyken.armourersWorkshop.common.library.ILibraryManager)1