org.bukkit.Bukkit.isHardcore()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(131)

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

Bukkit.isHardcore介绍

暂无

代码示例

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

@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
  if (!testPermission(sender)) return true;
  if (args.length != 1 || args[0].length() == 0) {
    sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
    return false;
  }
  Difficulty difficulty = Difficulty.getByValue(getDifficultyForString(sender, args[0]));
  if (Bukkit.isHardcore()) {
    difficulty = Difficulty.HARD;
  }
  Bukkit.getWorlds().get(0).setDifficulty(difficulty);
  int levelCount = 1;
  if (Bukkit.getAllowNether()) {
    Bukkit.getWorlds().get(levelCount).setDifficulty(difficulty);
    levelCount++;
  }
  if (Bukkit.getAllowEnd()) {
    Bukkit.getWorlds().get(levelCount).setDifficulty(difficulty);
  }
  Command.broadcastCommandMessage(sender, "Set difficulty to " + difficulty.toString());
  return true;
}

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

@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
  if (!testPermission(sender)) return true;
  if (args.length != 1 || args[0].length() == 0) {
    sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
    return false;
  }
  Difficulty difficulty = Difficulty.getByValue(getDifficultyForString(sender, args[0]));
  if (Bukkit.isHardcore()) {
    difficulty = Difficulty.HARD;
  }
  Bukkit.getWorlds().get(0).setDifficulty(difficulty);
  int levelCount = 1;
  if (Bukkit.getAllowNether()) {
    Bukkit.getWorlds().get(levelCount).setDifficulty(difficulty);
    levelCount++;
  }
  if (Bukkit.getAllowEnd()) {
    Bukkit.getWorlds().get(levelCount).setDifficulty(difficulty);
  }
  Command.broadcastCommandMessage(sender, "Set difficulty to " + difficulty.toString());
  return true;
}

相关文章