Java Code Examples for cn.nukkit.Server#getDifficultyFromString()
The following examples show how to use
cn.nukkit.Server#getDifficultyFromString() .
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: DifficultyCommand.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!this.testPermission(sender)) { return true; } if (args.length != 1) { sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage)); return false; } int difficulty = Server.getDifficultyFromString(args[0]); if (sender.getServer().isHardcore()) { difficulty = 3; } if (difficulty != -1) { sender.getServer().setPropertyInt("difficulty", difficulty); SetDifficultyPacket pk = new SetDifficultyPacket(); pk.difficulty = sender.getServer().getDifficulty(); Server.broadcastPacket(new ArrayList<>(sender.getServer().getOnlinePlayers().values()), pk); Command.broadcastCommandMessage(sender, new TranslationContainer("commands.difficulty.success", String.valueOf(difficulty))); } else { sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage)); return false; } return true; }
Example 2
Source File: DifficultyCommand.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!this.testPermission(sender)) { return true; } if (args.length != 1) { sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage)); return false; } int difficulty = Server.getDifficultyFromString(args[0]); if (sender.getServer().isHardcore()) { difficulty = 3; } if (difficulty != -1) { sender.getServer().setPropertyInt("difficulty", difficulty); SetDifficultyPacket pk = new SetDifficultyPacket(); pk.difficulty = sender.getServer().getDifficulty(); Server.broadcastPacket(new ArrayList<>(sender.getServer().getOnlinePlayers().values()), pk); Command.broadcastCommandMessage(sender, new TranslationContainer("commands.difficulty.success", String.valueOf(difficulty))); } else { sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage)); return false; } return true; }
Example 3
Source File: DifficultyCommand.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!this.testPermission(sender)) { return true; } if (args.length != 1) { sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage)); return false; } int difficulty = Server.getDifficultyFromString(args[0]); if (sender.getServer().isHardcore()) { difficulty = 3; } if (difficulty != -1) { sender.getServer().setPropertyInt("difficulty", difficulty); SetDifficultyPacket pk = new SetDifficultyPacket(); pk.difficulty = sender.getServer().getDifficulty(); Server.broadcastPacket(new ArrayList<>(sender.getServer().getOnlinePlayers().values()), pk); Command.broadcastCommandMessage(sender, new TranslationContainer("commands.difficulty.success", String.valueOf(difficulty))); } else { sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage)); return false; } return true; }