Search in sources :

Example 1 with State

use of com.github.sirblobman.combatlogx.api.expansion.Expansion.State in project CombatLogX by SirBlobman.

the class CommandCombatLogXAbout method sendExpansionInformation.

private void sendExpansionInformation(CommandSender sender, Expansion expansion) {
    String name = expansion.getName();
    String prefix = expansion.getPrefix();
    State state = expansion.getState();
    ExpansionDescription information = expansion.getDescription();
    String description = information.getDescription();
    List<String> authorList = information.getAuthors();
    String authorString = String.join(", ", authorList);
    String version = information.getVersion();
    List<String> messageList = new ArrayList<>();
    messageList.add("&f");
    messageList.add("&f&lExpansion Information for &a" + name + "&f&l:");
    messageList.add("&f&lDisplay Name: &7" + prefix);
    messageList.add("&f&lVersion: &7" + version);
    messageList.add("&f&lState: &7" + state);
    messageList.add("&f");
    messageList.add("&f&lDescription: &7" + description);
    messageList.add("&f&lAuthors: &7" + authorString);
    List<String> colorList = MessageUtility.colorList(messageList);
    for (String message : colorList) {
        sender.sendMessage(message);
    }
}
Also used : State(com.github.sirblobman.combatlogx.api.expansion.Expansion.State) ArrayList(java.util.ArrayList) ExpansionDescription(com.github.sirblobman.combatlogx.api.expansion.ExpansionDescription)

Example 2 with State

use of com.github.sirblobman.combatlogx.api.expansion.Expansion.State in project CombatLogX by SirBlobman.

the class ExpansionManager method enableExpansion.

public void enableExpansion(Expansion expansion) {
    State state = expansion.getState();
    if (state == State.ENABLED)
        return;
    ICombatLogX plugin = getPlugin();
    Logger logger = plugin.getLogger();
    try {
        ExpansionDescription description = expansion.getDescription();
        String fullName = description.getFullName();
        logger.info("Enabling expansion '" + fullName + "'...");
        expansion.setState(State.ENABLED);
        expansion.onEnable();
    } catch (Exception ex) {
        logger.log(Level.SEVERE, "An error occurred while enabling an expansion:", ex);
    }
}
Also used : State(com.github.sirblobman.combatlogx.api.expansion.Expansion.State) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) Logger(java.util.logging.Logger) IOException(java.io.IOException) InvalidConfigurationException(org.bukkit.configuration.InvalidConfigurationException)

Example 3 with State

use of com.github.sirblobman.combatlogx.api.expansion.Expansion.State in project CombatLogX by SirBlobman.

the class ExpansionManager method disableExpansion.

public void disableExpansion(Expansion expansion) {
    State state = expansion.getState();
    if (state != State.ENABLED)
        return;
    ICombatLogX plugin = getPlugin();
    Logger logger = plugin.getLogger();
    try {
        ExpansionDescription description = expansion.getDescription();
        String fullName = description.getFullName();
        logger.info("Disabling expansion '" + fullName + "'...");
        List<Listener> listenerList = expansion.getListeners();
        listenerList.forEach(HandlerList::unregisterAll);
        listenerList.clear();
        expansion.setState(State.DISABLED);
        expansion.onDisable();
    } catch (Exception ex) {
        logger.log(Level.SEVERE, "An error occurred while enabling an expansion:", ex);
    }
}
Also used : HandlerList(org.bukkit.event.HandlerList) Listener(org.bukkit.event.Listener) State(com.github.sirblobman.combatlogx.api.expansion.Expansion.State) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) Logger(java.util.logging.Logger) IOException(java.io.IOException) InvalidConfigurationException(org.bukkit.configuration.InvalidConfigurationException)

Example 4 with State

use of com.github.sirblobman.combatlogx.api.expansion.Expansion.State in project CombatLogX by SirBlobman.

the class HookPlaceholderAPI method getNewbieHelper.

private Expansion getNewbieHelper() {
    ICombatLogX plugin = this.expansion.getPlugin();
    ExpansionManager expansionManager = plugin.getExpansionManager();
    Optional<Expansion> optionalExpansion = expansionManager.getExpansion("NewbieHelper");
    if (optionalExpansion.isPresent()) {
        Expansion expansion = optionalExpansion.get();
        State state = expansion.getState();
        if (state == State.ENABLED)
            return expansion;
    }
    return null;
}
Also used : ExpansionManager(com.github.sirblobman.combatlogx.api.expansion.ExpansionManager) State(com.github.sirblobman.combatlogx.api.expansion.Expansion.State) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) NewbieHelperExpansion(combatlogx.expansion.newbie.helper.NewbieHelperExpansion) PlaceholderExpansion(me.clip.placeholderapi.expansion.PlaceholderExpansion) Expansion(com.github.sirblobman.combatlogx.api.expansion.Expansion)

Example 5 with State

use of com.github.sirblobman.combatlogx.api.expansion.Expansion.State in project CombatLogX by SirBlobman.

the class HookMVdWPlaceholderAPI method getNewbieHelper.

private Expansion getNewbieHelper() {
    ICombatLogX plugin = this.expansion.getPlugin();
    ExpansionManager expansionManager = plugin.getExpansionManager();
    Optional<Expansion> optionalExpansion = expansionManager.getExpansion("NewbieHelper");
    if (optionalExpansion.isPresent()) {
        Expansion expansion = optionalExpansion.get();
        State state = expansion.getState();
        if (state == State.ENABLED)
            return expansion;
    }
    return null;
}
Also used : ExpansionManager(com.github.sirblobman.combatlogx.api.expansion.ExpansionManager) State(com.github.sirblobman.combatlogx.api.expansion.Expansion.State) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) NewbieHelperExpansion(combatlogx.expansion.newbie.helper.NewbieHelperExpansion) Expansion(com.github.sirblobman.combatlogx.api.expansion.Expansion)

Aggregations

State (com.github.sirblobman.combatlogx.api.expansion.Expansion.State)5 ICombatLogX (com.github.sirblobman.combatlogx.api.ICombatLogX)4 Expansion (com.github.sirblobman.combatlogx.api.expansion.Expansion)2 ExpansionManager (com.github.sirblobman.combatlogx.api.expansion.ExpansionManager)2 NewbieHelperExpansion (combatlogx.expansion.newbie.helper.NewbieHelperExpansion)2 IOException (java.io.IOException)2 Logger (java.util.logging.Logger)2 InvalidConfigurationException (org.bukkit.configuration.InvalidConfigurationException)2 ExpansionDescription (com.github.sirblobman.combatlogx.api.expansion.ExpansionDescription)1 ArrayList (java.util.ArrayList)1 PlaceholderExpansion (me.clip.placeholderapi.expansion.PlaceholderExpansion)1 HandlerList (org.bukkit.event.HandlerList)1 Listener (org.bukkit.event.Listener)1