Search in sources :

Example 1 with BanEntry

use of cn.nukkit.permission.BanEntry in project Nukkit by Nukkit.

the class BanListCommand method execute.

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!this.testPermission(sender)) {
        return true;
    }
    BanList list;
    boolean ips = false;
    if (args.length > 0) {
        switch(args[0].toLowerCase()) {
            case "ips":
                list = sender.getServer().getIPBans();
                ips = true;
                break;
            case "players":
                list = sender.getServer().getNameBans();
                break;
            default:
                sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
                return false;
        }
    } else {
        list = sender.getServer().getNameBans();
    }
    StringBuilder builder = new StringBuilder();
    Iterator<BanEntry> itr = list.getEntires().values().iterator();
    while (itr.hasNext()) {
        builder.append(itr.next().getName());
        if (itr.hasNext()) {
            builder.append(", ");
        }
    }
    if (ips) {
        sender.sendMessage(new TranslationContainer("commands.banlist.ips", String.valueOf(list.getEntires().size())));
    } else {
        sender.sendMessage(new TranslationContainer("commands.banlist.players", String.valueOf(list.getEntires().size())));
    }
    sender.sendMessage(builder.toString());
    return true;
}
Also used : TranslationContainer(cn.nukkit.lang.TranslationContainer) BanEntry(cn.nukkit.permission.BanEntry) BanList(cn.nukkit.permission.BanList)

Example 2 with BanEntry

use of cn.nukkit.permission.BanEntry in project Nukkit by Nukkit.

the class Server method reload.

public void reload() {
    this.logger.info("Reloading...");
    this.logger.info("Saving levels...");
    for (Level level : this.levelArray) {
        level.save();
    }
    this.pluginManager.disablePlugins();
    this.pluginManager.clearPlugins();
    this.commandMap.clearCommands();
    this.logger.info("Reloading properties...");
    this.properties.reload();
    this.maxPlayers = this.getPropertyInt("max-players", 20);
    if (this.getPropertyBoolean("hardcore", false) && this.getDifficulty() < 3) {
        this.setPropertyInt("difficulty", difficulty = 3);
    }
    this.banByIP.load();
    this.banByName.load();
    this.reloadWhitelist();
    this.operators.reload();
    for (BanEntry entry : this.getIPBans().getEntires().values()) {
        this.getNetwork().blockAddress(entry.getName(), -1);
    }
    this.pluginManager.registerInterface(JavaPluginLoader.class);
    this.pluginManager.loadPlugins(this.pluginPath);
    this.enablePlugins(PluginLoadOrder.STARTUP);
    this.enablePlugins(PluginLoadOrder.POSTWORLD);
    Timings.reset();
}
Also used : Level(cn.nukkit.level.Level) BanEntry(cn.nukkit.permission.BanEntry)

Example 3 with BanEntry

use of cn.nukkit.permission.BanEntry in project Nukkit by Nukkit.

the class Server method start.

public void start() {
    if (this.getPropertyBoolean("enable-query", true)) {
        this.queryHandler = new QueryHandler();
    }
    for (BanEntry entry : this.getIPBans().getEntires().values()) {
        this.network.blockAddress(entry.getName(), -1);
    }
    // todo send usage setting
    this.tickCounter = 0;
    this.logger.info(this.getLanguage().translateString("nukkit.server.defaultGameMode", getGamemodeString(this.getGamemode())));
    this.logger.info(this.getLanguage().translateString("nukkit.server.startFinished", String.valueOf((double) (System.currentTimeMillis() - Nukkit.START_TIME) / 1000)));
    this.tickProcessor();
    this.forceShutdown();
}
Also used : QueryHandler(cn.nukkit.network.query.QueryHandler) BanEntry(cn.nukkit.permission.BanEntry)

Aggregations

BanEntry (cn.nukkit.permission.BanEntry)3 TranslationContainer (cn.nukkit.lang.TranslationContainer)1 Level (cn.nukkit.level.Level)1 QueryHandler (cn.nukkit.network.query.QueryHandler)1 BanList (cn.nukkit.permission.BanList)1