Package fr.neatmonster.nocheatplus.compat

Source Code of fr.neatmonster.nocheatplus.compat.DefaultComponentFactory

package fr.neatmonster.nocheatplus.compat;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

import fr.neatmonster.nocheatplus.NoCheatPlus;
import fr.neatmonster.nocheatplus.checks.inventory.FastConsume;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.net.protocollib.ProtocolLibComponent;

/**
* Default factory for add-in components which might only be available under certain circumstances.
*
* @author mc_dev
*/
public class DefaultComponentFactory {
 
  /**
   * This will be called from within the plugin in onEnable, after registration of all core listeners and components. After each components addition processQueuedSubComponentHolders() will be called to allow registries for further optional components.
   * @param plugin
   * @return
   */
  public Collection<Object> getAvailableComponentsOnEnable(NoCheatPlus plugin){
    final List<Object> available = new LinkedList<Object>();
   
    // Add components (try-catch).
    // Check: inventory.fastconsume.
    try{
      // TODO: Static test methods !?
      FastConsume.testAvailability();
      available.add(new FastConsume());
    }
    catch (Throwable t){
      LogUtil.logInfo("[NoCheatPlus] Inventory checks: FastConsume is not available.");
    }
   
    // ProtocolLib dependencies.
    try {
      available.add(new ProtocolLibComponent(plugin));
    } catch (Throwable t){
      LogUtil.logInfo("[NoCheatPlus] Packet level access: ProtocolLib is not available.");
    }
   
    return available;
  }
}
TOP

Related Classes of fr.neatmonster.nocheatplus.compat.DefaultComponentFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.