本文整理汇总了Java中cn.nukkit.lang.TranslationContainer类的典型用法代码示例。如果您正苦于以下问题:Java TranslationContainer类的具体用法?Java TranslationContainer怎么用?Java TranslationContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TranslationContainer类属于cn.nukkit.lang包,在下文中一共展示了TranslationContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResponse
import cn.nukkit.lang.TranslationContainer; //导入依赖的package包/类
private String getResponse(HttpURLConnection con) throws IOException {
InputStream is = null;
try {
is = con.getInputStream();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] b = new byte[1024];
int bytesRead;
while ((bytesRead = is.read(b)) != -1) {
bos.write(b, 0, bytesRead);
}
return bos.toString();
} catch (IOException exception) {
this.sender.sendMessage(TextFormat.RED + "" + new TranslationContainer("nukkit.command.timings.reportError"));
Server.getInstance().getLogger().warning(con.getResponseMessage(), exception);
return null;
} finally {
if (is != null) {
is.close();
}
}
}
示例2: execute
import cn.nukkit.lang.TranslationContainer; //导入依赖的package包/类
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Command.broadcastCommandMessage(sender, new TranslationContainer("commands.save.start"));
for (Player player : sender.getServer().getOnlinePlayers().values()) {
player.save();
}
for (Level level : sender.getServer().getLevels().values()) {
level.save(true);
}
Command.broadcastCommandMessage(sender, new TranslationContainer("commands.save.success"));
return true;
}
示例3: execute
import cn.nukkit.lang.TranslationContainer; //导入依赖的package包/类
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
if (args.length == 0) {
sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
return false;
}
String playerName = args[0];
IPlayer player = sender.getServer().getOfflinePlayer(playerName);
player.setOp(false);
if (player instanceof Player) {
((Player) player).sendMessage(new TranslationContainer(TextFormat.GRAY + "%commands.deop.message"));
}
Command.broadcastCommandMessage(sender, new TranslationContainer("commands.deop.success", new String[]{player.getName()}));
return true;
}
示例4: broadcastCommandMessage
import cn.nukkit.lang.TranslationContainer; //导入依赖的package包/类
public static void broadcastCommandMessage(CommandSender source, String message, boolean sendToSource) {
Set<Permissible> users = source.getServer().getPluginManager().getPermissionSubscriptions(Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
TranslationContainer result = new TranslationContainer("chat.type.admin", new String[]{source.getName(), message});
TranslationContainer colored = new TranslationContainer(TextFormat.GRAY + "" + TextFormat.ITALIC + "%chat.type.admin", new String[]{source.getName(), message});
if (sendToSource && !(source instanceof ConsoleCommandSender)) {
source.sendMessage(message);
}
for (Permissible user : users) {
if (user instanceof CommandSender) {
if (user instanceof ConsoleCommandSender) {
((ConsoleCommandSender) user).sendMessage(result);
} else if (!user.equals(source)) {
((CommandSender) user).sendMessage(colored);
}
}
}
}
示例5: execute
import cn.nukkit.lang.TranslationContainer; //导入依赖的package包/类
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
if (args.length == 0) {
sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
return false;
}
String name = args[0];
IPlayer player = sender.getServer().getOfflinePlayer(name);
Command.broadcastCommandMessage(sender, new TranslationContainer("commands.op.success", player.getName()));
if (player instanceof Player) {
((Player) player).sendMessage(new TranslationContainer(TextFormat.GRAY + "%commands.op.message"));
}
player.setOp(true);
return true;
}
示例6: execute
import cn.nukkit.lang.TranslationContainer; //导入依赖的package包/类
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
String online = "";
int onlineCount = 0;
for (Player player : sender.getServer().getOnlinePlayers().values()) {
if (player.isOnline() && (!(sender instanceof Player) || ((Player) sender).canSee(player))) {
online += player.getDisplayName() + ", ";
++onlineCount;
}
}
if (online.length() > 0) {
online = online.substring(0, online.length() - 2);
}
sender.sendMessage(new TranslationContainer("commands.players.list",
new String[]{String.valueOf(onlineCount), String.valueOf(sender.getServer().getMaxPlayers())}));
sender.sendMessage(online);
return true;
}
示例7: execute
import cn.nukkit.lang.TranslationContainer; //导入依赖的package包/类
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
long seed;
if (sender instanceof Player) {
seed = ((Player) sender).getLevel().getSeed();
} else {
seed = sender.getServer().getDefaultLevel().getSeed();
}
sender.sendMessage(new TranslationContainer("commands.seed.success", String.valueOf(seed)));
return true;
}
示例8: execute
import cn.nukkit.lang.TranslationContainer; //导入依赖的package包/类
@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;
}
String value = args[0];
if (Pattern.matches("^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$", value)) {
sender.getServer().getIPBans().remove(value);
sender.getServer().getNetwork().unblockAddress(value);
Command.broadcastCommandMessage(sender, new TranslationContainer("commands.unbanip.success", value));
} else {
sender.sendMessage(new TranslationContainer("commands.unbanip.invalid"));
}
return true;
}
示例9: dispatchCommand
import cn.nukkit.lang.TranslationContainer; //导入依赖的package包/类
public boolean dispatchCommand(CommandSender sender, String commandLine) throws ServerException {
// First we need to check if this command is on the main thread or not, if not, warn the user
if (!this.isPrimaryThread()) {
getLogger().warning("Command Dispatched Async: " + commandLine);
getLogger().warning("Please notify author of plugin causing this execution to fix this bug!", new Throwable());
// TODO: We should sync the command to the main thread too!
}
if (sender == null) {
throw new ServerException("CommandSender is not valid");
}
if (this.commandMap.dispatch(sender, commandLine)) {
return true;
}
sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.notFound"));
return false;
}
示例10: execute
import cn.nukkit.lang.TranslationContainer; //导入依赖的package包/类
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
if (args.length == 0) {
sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
return false;
}
String name = args[0];
IPlayer player = sender.getServer().getOfflinePlayer(name);
Command.broadcastCommandMessage(sender, new TranslationContainer("commands.op.success", player.getName()));
if (player instanceof Player) {
((Player) player).sendMessage(TextFormat.GRAY + "You are now op!");
}
player.setOp(true);
return true;
}
示例11: execute
import cn.nukkit.lang.TranslationContainer; //导入依赖的package包/类
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.owningPlugin.isEnabled()) {
return false;
}
if (!this.testPermission(sender)) {
return false;
}
boolean success = this.executor.onCommand(sender, this, commandLabel, args);
if (!success && !this.usageMessage.equals("")) {
sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
}
return success;
}
示例12: execute
import cn.nukkit.lang.TranslationContainer; //导入依赖的package包/类
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
if (args.length == 0) {
sender.sendMessage(new TranslationContainer("commands.generic.usage", new String[]{this.usageMessage}));
return false;
}
int gameMode = Server.getGamemodeFromString(args[0]);
if (gameMode != -1) {
sender.getServer().setPropertyInt("gamemode", gameMode);
sender.sendMessage(new TranslationContainer("commands.defaultgamemode.success", new String[]{Server.getGamemodeString(gameMode)}));
} else {
sender.sendMessage("Unknown game mode"); //
}
return true;
}
示例13: execute
import cn.nukkit.lang.TranslationContainer; //导入依赖的package包/类
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
String online = "";
StringBuffer onlineBuffer = new StringBuffer();
int onlineCount = 0;
for (Player player : sender.getServer().getOnlinePlayers().values()) {
if (player.isOnline() && (!(sender instanceof Player) || ((Player) sender).canSee(player))) {
onlineBuffer.append(player.getDisplayName() + ", ");
++onlineCount;
}
}
if (onlineBuffer.length() > 0) {
online = onlineBuffer.substring(0, onlineBuffer.length() - 2);
}
sender.sendMessage(new TranslationContainer("commands.players.list",
new String[]{String.valueOf(onlineCount), String.valueOf(sender.getServer().getMaxPlayers())}));
sender.sendMessage(online);
return true;
}
示例14: execute
import cn.nukkit.lang.TranslationContainer; //导入依赖的package包/类
@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;
}
sender.getServer().getNameBans().remove(args[0]);
Command.broadcastCommandMessage(sender, new TranslationContainer("%commands.unban.success", args[0]));
return true;
}
示例15: execute
import cn.nukkit.lang.TranslationContainer; //导入依赖的package包/类
@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;
}
String value = args[0];
if (Pattern.matches("^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$", value)) {
sender.getServer().getIPBans().remove(value);
Command.broadcastCommandMessage(sender, new TranslationContainer("commands.unbanip.success", value));
} else {
sender.sendMessage(new TranslationContainer("commands.unbanip.invalid"));
}
return true;
}