org.bukkit.Server.setIdleTimeout()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(2.7k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中org.bukkit.Server.setIdleTimeout()方法的一些代码示例,展示了Server.setIdleTimeout()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Server.setIdleTimeout()方法的具体详情如下:
包路径:org.bukkit.Server
类名称:Server
方法名:setIdleTimeout

Server.setIdleTimeout介绍

[英]Set the idle kick timeout. Any players idle for the specified amount of time will be automatically kicked.

A value of 0 will disable the idle kick timeout.
[中]设置空闲踢超时。任何在指定时间内空闲的玩家都将被自动踢出。
如果值为0,则将禁用空闲触发超时。

代码示例

代码示例来源:origin: Bukkit/Bukkit

/**
 * @see Server#setIdleTimeout(int)
 */
public static void setIdleTimeout(int threshold) {
  server.setIdleTimeout(threshold);
}

代码示例来源:origin: Bukkit/Bukkit

@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
  if (!testPermission(sender)) return true;
  if (args.length == 1) {
    int minutes;
    try {
      minutes = getInteger(sender, args[0], 0, Integer.MAX_VALUE, true);
    } catch (NumberFormatException ex) {
      sender.sendMessage(ex.getMessage());
      return true;
    }
    Bukkit.getServer().setIdleTimeout(minutes);
    Command.broadcastCommandMessage(sender, "Successfully set the idle timeout to " + minutes + " minutes.");
    return true;
  }
  sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
  return false;
}

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
public boolean execute(CommandSender sender, String label, String[] args,
    CommandMessages commandMessages) {
  if (!testPermission(sender, commandMessages.getPermissionMessage())) {
    return true;
  }
  if (args.length == 0) {
    sendUsageMessage(sender, commandMessages);
    return false;
  }
  final String stringTimeout = args[0];
  int timeout;
  try {
    timeout = Integer.parseInt(stringTimeout);
  } catch (NumberFormatException ex) {
    commandMessages.getNotANumber().sendInColor(ChatColor.RED, sender, stringTimeout);
    return false;
  }
  if (timeout <= 0) {
    new LocalizedStringImpl("setidletimeout.too-low", commandMessages.getResourceBundle())
        .sendInColor(ChatColor.RED, sender, timeout);
    return false;
  }
  ServerProvider.getServer().setIdleTimeout(timeout);
  new LocalizedStringImpl("setidletimeout.done", commandMessages.getResourceBundle())
      .send(sender, timeout);
  return true;
}

代码示例来源:origin: SpigotMC/Spigot-API

/**
 * @see Server#setIdleTimeout(int)
 */
public static void setIdleTimeout(int threshold) {
  server.setIdleTimeout(threshold);
}

代码示例来源:origin: SpigotMC/Spigot-API

@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
  if (!testPermission(sender)) return true;
  if (args.length == 1) {
    int minutes;
    try {
      minutes = getInteger(sender, args[0], 0, Integer.MAX_VALUE, true);
    } catch (NumberFormatException ex) {
      sender.sendMessage(ex.getMessage());
      return true;
    }
    Bukkit.getServer().setIdleTimeout(minutes);
    Command.broadcastCommandMessage(sender, "Successfully set the idle timeout to " + minutes + " minutes.");
    return true;
  }
  sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
  return false;
}

相关文章

Server类方法