All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.cwcode.tkach.config.commands.ReloadCommand Maven / Gradle / Ivy

The newest version!
package ru.cwcode.tkach.config.commands;

import ru.cwcode.commands.executor.CommonExecutor;
import ru.cwcode.tkach.config.base.Config;
import ru.cwcode.tkach.config.base.manager.ConfigManager;

import java.util.function.Consumer;

public class ReloadCommand> extends CommonExecutor {
  ConfigManager configManager;
  Consumer onReload = c -> {};
  
  public ReloadCommand(ConfigManager configManager) {
    this.configManager = configManager;
  }
  
  public ReloadCommand(ConfigManager configManager, Consumer onReload) {
    this(configManager);
    this.onReload = onReload;
  }
  
  @Override
  public void executeForPlayer() {
    configManager.findConfig(argS(0)).ifPresent(config -> {
      
      if (configManager.reload(sender, config)) {
        configManager.findConfig(argS(0)).ifPresent(onReload);
      }
    });
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy