Java Code Examples for cn.nukkit.utils.MainLogger#logException()

The following examples show how to use cn.nukkit.utils.MainLogger#logException() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluginManager.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
public void enablePlugin(Plugin plugin) {
    if (!plugin.isEnabled()) {
        try {
            for (Permission permission : plugin.getDescription().getPermissions()) {
                this.addPermission(permission);
            }
            plugin.getPluginLoader().enablePlugin(plugin);
        } catch (Throwable e) {
            MainLogger logger = this.server.getLogger();
            if (logger != null) {
                logger.logException(new RuntimeException(e));
            }
            this.disablePlugin(plugin);
        }
    }
}
 
Example 2
Source File: PluginManager.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
public void disablePlugin(Plugin plugin) {
    if (plugin.isEnabled()) {
        try {
            plugin.getPluginLoader().disablePlugin(plugin);
        } catch (Exception e) {
            MainLogger logger = this.server.getLogger();
            if (logger != null) {
                logger.logException(e);
            }
        }

        this.server.getScheduler().cancelTask(plugin);
        HandlerList.unregisterAll(plugin);
        for (Permission permission : plugin.getDescription().getPermissions()) {
            this.removePermission(permission);
        }
    }
}
 
Example 3
Source File: PluginManager.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public void enablePlugin(Plugin plugin) {
    if (!plugin.isEnabled()) {
        try {
            for (Permission permission : plugin.getDescription().getPermissions()) {
                this.addPermission(permission);
            }
            plugin.getPluginLoader().enablePlugin(plugin);
        } catch (Throwable e) {
            MainLogger logger = this.server.getLogger();
            if (logger != null) {
                logger.logException(new RuntimeException(e));
            }
            this.disablePlugin(plugin);
        }
    }
}
 
Example 4
Source File: PluginManager.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public void disablePlugin(Plugin plugin) {
    if (plugin.isEnabled()) {
        try {
            plugin.getPluginLoader().disablePlugin(plugin);
        } catch (Exception e) {
            MainLogger logger = this.server.getLogger();
            if (logger != null) {
                logger.logException(e);
            }
        }

        this.server.getScheduler().cancelTask(plugin);
        HandlerList.unregisterAll(plugin);
        for (Permission permission : plugin.getDescription().getPermissions()) {
            this.removePermission(permission);
        }
    }
}
 
Example 5
Source File: PluginManager.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public void enablePlugin(Plugin plugin) {
    if (!plugin.isEnabled()) {
        try {
            for (Permission permission : plugin.getDescription().getPermissions()) {
                this.addPermission(permission);
            }
            plugin.getPluginLoader().enablePlugin(plugin);
        } catch (Throwable e) {
            MainLogger logger = this.server.getLogger();
            if (logger != null) {
                logger.logException(new RuntimeException(e));
            }
            this.disablePlugin(plugin);
        }
    }
}
 
Example 6
Source File: PluginManager.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public void disablePlugin(Plugin plugin) {
    if (plugin.isEnabled()) {
        try {
            plugin.getPluginLoader().disablePlugin(plugin);
        } catch (Exception e) {
            MainLogger logger = this.server.getLogger();
            if (logger != null) {
                logger.logException(e);
            }
        }

        this.server.getScheduler().cancelTask(plugin);
        HandlerList.unregisterAll(plugin);
        for (Permission permission : plugin.getDescription().getPermissions()) {
            this.removePermission(permission);
        }
    }
}
 
Example 7
Source File: FormattedCommandAlias.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    boolean result = false;
    ArrayList<String> commands = new ArrayList<>();
    for (String formatString : formatStrings) {
        try {
            commands.add(buildCommand(formatString, args));
        } catch (Exception e) {
            if (e instanceof IllegalArgumentException) {
                sender.sendMessage(TextFormat.RED + e.getMessage());
            } else {
                sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.exception"));
                MainLogger logger = sender.getServer().getLogger();
                if (logger != null) {
                    logger.logException(e);
                }
            }
            return false;
        }
    }

    for (String command : commands) {
        result |= Server.getInstance().dispatchCommand(sender, command);
    }

    return result;
}
 
Example 8
Source File: SimpleCommandMap.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean dispatch(CommandSender sender, String cmdLine) {
    ArrayList<String> parsed = parseArguments(cmdLine);
    if (parsed.size() == 0) {
        return false;
    }

    String sentCommandLabel = parsed.remove(0).toLowerCase();
    String[] args = parsed.toArray(new String[parsed.size()]);
    Command target = this.getCommand(sentCommandLabel);

    if (target == null) {
        return false;
    }

    target.timing.startTiming();
    try {
        target.execute(sender, sentCommandLabel, args);
    } catch (Exception e) {
        sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.exception"));
        this.server.getLogger().critical(this.server.getLanguage().translateString("nukkit.command.exception", cmdLine, target.toString(), Utils.getExceptionMessage(e)));
        MainLogger logger = sender.getServer().getLogger();
        if (logger != null) {
            logger.logException(e);
        }
    }
    target.timing.stopTiming();

    return true;
}
 
Example 9
Source File: FormattedCommandAlias.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    boolean result = false;
    ArrayList<String> commands = new ArrayList<>();
    for (String formatString : formatStrings) {
        try {
            commands.add(buildCommand(formatString, args));
        } catch (Exception e) {
            if (e instanceof IllegalArgumentException) {
                sender.sendMessage(TextFormat.RED + e.getMessage());
            } else {
                sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.exception"));
                MainLogger logger = sender.getServer().getLogger();
                if (logger != null) {
                    logger.logException(e);
                }
            }
            return false;
        }
    }

    for (String command : commands) {
        result |= Server.getInstance().dispatchCommand(sender, command);
    }

    return result;
}
 
Example 10
Source File: SimpleCommandMap.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean dispatch(CommandSender sender, String cmdLine) {
    ArrayList<String> parsed = parseArguments(cmdLine);
    if (parsed.size() == 0) {
        return false;
    }

    String sentCommandLabel = parsed.remove(0).toLowerCase();
    String[] args = parsed.toArray(new String[0]);
    Command target = this.getCommand(sentCommandLabel);

    if (target == null) {
        return false;
    }

    target.timing.startTiming();
    try {
        target.execute(sender, sentCommandLabel, args);
    } catch (Exception e) {
        sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.exception"));
        this.server.getLogger().critical(this.server.getLanguage().translateString("nukkit.command.exception", cmdLine, target.toString(), Utils.getExceptionMessage(e)));
        MainLogger logger = sender.getServer().getLogger();
        if (logger != null) {
            logger.logException(e);
        }
    }
    target.timing.stopTiming();

    return true;
}
 
Example 11
Source File: FormattedCommandAlias.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    boolean result = false;
    ArrayList<String> commands = new ArrayList<>();
    for (String formatString : formatStrings) {
        try {
            commands.add(buildCommand(formatString, args));
        } catch (Exception e) {
            if (e instanceof IllegalArgumentException) {
                sender.sendMessage(TextFormat.RED + e.getMessage());
            } else {
                sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.exception"));
                MainLogger logger = sender.getServer().getLogger();
                if (logger != null) {
                    logger.logException(e);
                }
            }
            return false;
        }
    }

    for (String command : commands) {
        result |= Server.getInstance().dispatchCommand(sender, command);
    }

    return result;
}
 
Example 12
Source File: SimpleCommandMap.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean dispatch(CommandSender sender, String cmdLine) {
    ArrayList<String> parsed = parseArguments(cmdLine);
    if (parsed.size() == 0) {
        return false;
    }

    String sentCommandLabel = parsed.remove(0).toLowerCase();
    String[] args = parsed.toArray(new String[parsed.size()]);
    Command target = this.getCommand(sentCommandLabel);

    if (target == null) {
        return false;
    }

    target.timing.startTiming();
    try {
        target.execute(sender, sentCommandLabel, args);
    } catch (Exception e) {
        sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.exception"));
        this.server.getLogger().critical(this.server.getLanguage().translateString("nukkit.command.exception", cmdLine, target.toString(), Utils.getExceptionMessage(e)));
        MainLogger logger = sender.getServer().getLogger();
        if (logger != null) {
            logger.logException(e);
        }
    }
    target.timing.stopTiming();

    return true;
}