Search in sources :

Example 1 with EconomyLayer

use of com.earth2me.essentials.economy.EconomyLayer in project Essentials by EssentialsX.

the class Commandessentials method runVersion.

// Displays versions of EssentialsX and related plugins.
private void runVersion(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
    if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.version"))
        return;
    boolean isMismatched = false;
    boolean isVaultInstalled = false;
    boolean isUnsupported = false;
    final VersionUtil.SupportStatus supportStatus = VersionUtil.getServerSupportStatus();
    final PluginManager pm = server.getPluginManager();
    final String essVer = pm.getPlugin("Essentials").getDescription().getVersion();
    final String serverMessageKey;
    if (supportStatus.isSupported()) {
        serverMessageKey = "versionOutputFine";
    } else if (supportStatus == VersionUtil.SupportStatus.UNSTABLE) {
        serverMessageKey = "versionOutputUnsupported";
    } else {
        serverMessageKey = "versionOutputWarn";
    }
    sender.sendMessage(tl(serverMessageKey, "Server", server.getBukkitVersion() + " " + server.getVersion()));
    sender.sendMessage(tl(serverMessageKey, "Brand", server.getName()));
    sender.sendMessage(tl("versionOutputFine", "EssentialsX", essVer));
    for (final Plugin plugin : pm.getPlugins()) {
        final PluginDescriptionFile desc = plugin.getDescription();
        String name = desc.getName();
        final String version = desc.getVersion();
        if (name.startsWith("Essentials") && !name.equalsIgnoreCase("Essentials")) {
            if (officialPlugins.contains(name)) {
                name = name.replace("Essentials", "EssentialsX");
                if (!version.equalsIgnoreCase(essVer)) {
                    isMismatched = true;
                    sender.sendMessage(tl("versionOutputWarn", name, version));
                } else {
                    sender.sendMessage(tl("versionOutputFine", name, version));
                }
            } else {
                sender.sendMessage(tl("versionOutputUnsupported", name, version));
                isUnsupported = true;
            }
        }
        if (versionPlugins.contains(name)) {
            if (warnPlugins.contains(name)) {
                sender.sendMessage(tl("versionOutputUnsupported", name, version));
                isUnsupported = true;
            } else {
                sender.sendMessage(tl("versionOutputFine", name, version));
            }
        }
        if (name.equals("Vault"))
            isVaultInstalled = true;
    }
    final String layer;
    if (ess.getSettings().isEcoDisabled()) {
        layer = "Disabled";
    } else if (EconomyLayers.isLayerSelected()) {
        final EconomyLayer economyLayer = EconomyLayers.getSelectedLayer();
        layer = economyLayer.getName() + " (" + economyLayer.getBackendName() + ")";
    } else {
        layer = "None";
    }
    sender.sendMessage(tl("versionOutputEconLayer", layer));
    if (isMismatched) {
        sender.sendMessage(tl("versionMismatchAll"));
    }
    if (!isVaultInstalled) {
        sender.sendMessage(tl("versionOutputVaultMissing"));
    }
    if (isUnsupported) {
        sender.sendMessage(tl("versionOutputUnsupportedPlugins"));
    }
    switch(supportStatus) {
        case NMS_CLEANROOM:
            sender.sendMessage(ChatColor.DARK_RED + tl("serverUnsupportedCleanroom"));
            break;
        case DANGEROUS_FORK:
            sender.sendMessage(ChatColor.DARK_RED + tl("serverUnsupportedDangerous"));
            break;
        case UNSTABLE:
            sender.sendMessage(ChatColor.DARK_RED + tl("serverUnsupportedMods"));
            break;
        case OUTDATED:
            sender.sendMessage(ChatColor.RED + tl("serverUnsupported"));
            break;
        case LIMITED:
            sender.sendMessage(ChatColor.RED + tl("serverUnsupportedLimitedApi"));
            break;
    }
    if (VersionUtil.getSupportStatusClass() != null) {
        sender.sendMessage(ChatColor.RED + tl("serverUnsupportedClass", VersionUtil.getSupportStatusClass()));
    }
    sender.sendMessage(tl("versionFetching"));
    ess.runTaskAsynchronously(() -> {
        for (String str : ess.getUpdateChecker().getVersionMessages(true, true)) {
            sender.sendMessage(str);
        }
    });
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) EconomyLayer(com.earth2me.essentials.economy.EconomyLayer) VersionUtil(com.earth2me.essentials.utils.VersionUtil) PluginDescriptionFile(org.bukkit.plugin.PluginDescriptionFile) Plugin(org.bukkit.plugin.Plugin)

Example 2 with EconomyLayer

use of com.earth2me.essentials.economy.EconomyLayer in project Essentials by EssentialsX.

the class EssentialsPluginListener method onPluginDisable.

@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(final PluginDisableEvent event) {
    if (event.getPlugin().getName().equals("EssentialsChat")) {
        ess.getSettings().setEssentialsChatActive(false);
    }
    ess.getPermissionsHandler().checkPermissions();
    ess.getAlternativeCommandsHandler().removePlugin(event.getPlugin());
    if (EconomyLayers.onPluginDisable(event.getPlugin())) {
        final EconomyLayer layer = EconomyLayers.getSelectedLayer();
        if (layer != null) {
            ess.getLogger().log(Level.INFO, "Essentials found a new compatible payment resolution method: " + layer.getName() + " (v" + layer.getPluginVersion() + ")!");
        } else {
            ess.getLogger().log(Level.INFO, "Active payment resolution method has been disabled! Falling back to Essentials' default payment resolution system!");
        }
    }
}
Also used : EconomyLayer(com.earth2me.essentials.economy.EconomyLayer) EventHandler(org.bukkit.event.EventHandler)

Example 3 with EconomyLayer

use of com.earth2me.essentials.economy.EconomyLayer in project Essentials by EssentialsX.

the class EssentialsPluginListener method onPluginEnable.

@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(final PluginEnableEvent event) {
    if (event.getPlugin().getName().equals("EssentialsChat")) {
        ess.getSettings().setEssentialsChatActive(true);
    }
    ess.getPermissionsHandler().setUseSuperperms(ess.getSettings().useBukkitPermissions());
    ess.getPermissionsHandler().checkPermissions();
    ess.getAlternativeCommandsHandler().addPlugin(event.getPlugin());
    if (EconomyLayers.isServerStarted()) {
        final EconomyLayer layer = EconomyLayers.onPluginEnable(event.getPlugin());
        if (layer != null) {
            ess.getLogger().log(Level.INFO, "Essentials found a compatible payment resolution method: " + layer.getName() + " (v" + layer.getPluginVersion() + ")!");
        }
    }
}
Also used : EconomyLayer(com.earth2me.essentials.economy.EconomyLayer) EventHandler(org.bukkit.event.EventHandler)

Example 4 with EconomyLayer

use of com.earth2me.essentials.economy.EconomyLayer in project Essentials by drtshock.

the class EssentialsPluginListener method onPluginDisable.

@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(final PluginDisableEvent event) {
    if (event.getPlugin().getName().equals("EssentialsChat")) {
        ess.getSettings().setEssentialsChatActive(false);
    }
    ess.getPermissionsHandler().checkPermissions();
    ess.getAlternativeCommandsHandler().removePlugin(event.getPlugin());
    if (EconomyLayers.onPluginDisable(event.getPlugin())) {
        final EconomyLayer layer = EconomyLayers.getSelectedLayer();
        if (layer != null) {
            ess.getLogger().log(Level.INFO, "Essentials found a new compatible payment resolution method: " + layer.getName() + " (v" + layer.getPluginVersion() + ")!");
        } else {
            ess.getLogger().log(Level.INFO, "Active payment resolution method has been disabled! Falling back to Essentials' default payment resolution system!");
        }
    }
}
Also used : EconomyLayer(com.earth2me.essentials.economy.EconomyLayer) EventHandler(org.bukkit.event.EventHandler)

Example 5 with EconomyLayer

use of com.earth2me.essentials.economy.EconomyLayer in project Essentials by drtshock.

the class EssentialsPluginListener method onPluginEnable.

@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(final PluginEnableEvent event) {
    if (event.getPlugin().getName().equals("EssentialsChat")) {
        ess.getSettings().setEssentialsChatActive(true);
    }
    ess.getPermissionsHandler().setUseSuperperms(ess.getSettings().useBukkitPermissions());
    ess.getPermissionsHandler().checkPermissions();
    ess.getAlternativeCommandsHandler().addPlugin(event.getPlugin());
    if (EconomyLayers.isServerStarted()) {
        final EconomyLayer layer = EconomyLayers.onPluginEnable(event.getPlugin());
        if (layer != null) {
            ess.getLogger().log(Level.INFO, "Essentials found a compatible payment resolution method: " + layer.getName() + " (v" + layer.getPluginVersion() + ")!");
        }
    }
}
Also used : EconomyLayer(com.earth2me.essentials.economy.EconomyLayer) EventHandler(org.bukkit.event.EventHandler)

Aggregations

EconomyLayer (com.earth2me.essentials.economy.EconomyLayer)10 VersionUtil (com.earth2me.essentials.utils.VersionUtil)4 EventHandler (org.bukkit.event.EventHandler)4 Plugin (org.bukkit.plugin.Plugin)4 PluginDescriptionFile (org.bukkit.plugin.PluginDescriptionFile)4 PluginManager (org.bukkit.plugin.PluginManager)4 CommandSource (com.earth2me.essentials.CommandSource)2 EssentialsUpgrade (com.earth2me.essentials.EssentialsUpgrade)2 I18n.tl (com.earth2me.essentials.I18n.tl)2 User (com.earth2me.essentials.User)2 UserMap (com.earth2me.essentials.UserMap)2 EconomyLayers (com.earth2me.essentials.economy.EconomyLayers)2 DateUtil (com.earth2me.essentials.utils.DateUtil)2 EnumUtil (com.earth2me.essentials.utils.EnumUtil)2 FloatUtil (com.earth2me.essentials.utils.FloatUtil)2 NumberUtil (com.earth2me.essentials.utils.NumberUtil)2 PasteUtil (com.earth2me.essentials.utils.PasteUtil)2 Charsets (com.google.common.base.Charsets)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 Lists (com.google.common.collect.Lists)2