Search in sources :

Example 1 with IPatchBlockPropertiesSetup

use of fr.neatmonster.nocheatplus.compat.blocks.IPatchBlockPropertiesSetup in project NoCheatPlus by NoCheatPlus.

the class VanillaBlocksFactory method setupVanillaBlocks.

public Collection<String> setupVanillaBlocks(final WorldConfigProvider<?> worldConfigProvider) {
    // Vanilla blocks (abort with first failure, low to high MC version).
    final List<BlockPropertiesSetup> setups = new LinkedList<BlockPropertiesSetup>();
    final List<String> success = new LinkedList<String>();
    try {
        setups.add(new BlocksMC1_5());
        setups.add(new BlocksMC1_6_1());
        setups.add(new BlocksMC1_7_2());
        setups.add(new BlocksMC1_8());
        setups.add(new BlocksMC1_9());
        setups.add(new BlocksMC1_10());
        setups.add(new BlocksMC1_11());
        setups.add(new BlocksMC1_12());
    } catch (Throwable t) {
    }
    for (final BlockPropertiesSetup setup : setups) {
        try {
            // Assume the blocks setup to message success.
            setup.setupBlockProperties(worldConfigProvider);
            success.add(setup.getClass().getSimpleName());
        // TODO: Do logging from here ?
        } catch (Throwable t) {
            StaticLog.logSevere(setup.getClass().getSimpleName() + ".setupBlockProperties could not execute properly: " + t.getClass().getSimpleName() + " - " + t.getMessage());
            StaticLog.logSevere(t);
            // Abort further processing.
            break;
        }
    }
    // Patches for special circumstances.
    for (IPatchBlockPropertiesSetup patch : new IPatchBlockPropertiesSetup[] { new MultiClientProtocolBlockShapePatch() }) {
        try {
            if (patch.isAvailable()) {
                patch.setupBlockProperties(worldConfigProvider);
                String description = patch.getNeutralDescription();
                if (description == null || description.isEmpty()) {
                    description = patch.getClass().getSimpleName();
                }
                StaticLog.logInfo("Update block-info: " + description);
            }
        } catch (Throwable t) {
            StaticLog.logSevere(patch.getClass().getSimpleName() + " could not be processed: " + t.getClass().getSimpleName() + " - " + t.getMessage());
            StaticLog.logSevere(t);
        }
    }
    return success;
}
Also used : IPatchBlockPropertiesSetup(fr.neatmonster.nocheatplus.compat.blocks.IPatchBlockPropertiesSetup) MultiClientProtocolBlockShapePatch(fr.neatmonster.nocheatplus.compat.blocks.init.vanilla.special.MultiClientProtocolBlockShapePatch) LinkedList(java.util.LinkedList) BlockPropertiesSetup(fr.neatmonster.nocheatplus.compat.blocks.BlockPropertiesSetup) IPatchBlockPropertiesSetup(fr.neatmonster.nocheatplus.compat.blocks.IPatchBlockPropertiesSetup)

Aggregations

BlockPropertiesSetup (fr.neatmonster.nocheatplus.compat.blocks.BlockPropertiesSetup)1 IPatchBlockPropertiesSetup (fr.neatmonster.nocheatplus.compat.blocks.IPatchBlockPropertiesSetup)1 MultiClientProtocolBlockShapePatch (fr.neatmonster.nocheatplus.compat.blocks.init.vanilla.special.MultiClientProtocolBlockShapePatch)1 LinkedList (java.util.LinkedList)1