cn.nukkit.plugin.PluginDescription Java Examples
The following examples show how to use
cn.nukkit.plugin.PluginDescription.
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: QueryRegenerateEvent.java From Jupiter with GNU General Public License v3.0 | 4 votes |
public byte[] getLongQuery() { ByteBuffer query = ByteBuffer.allocate(65536); String plist = this.server_engine; if (this.plugins.length > 0 && this.listPlugins) { plist += ":"; for (Plugin p : this.plugins) { PluginDescription d = p.getDescription(); plist += " " + d.getName().replace(";", "").replace(":", "").replace(" ", "_") + " " + d.getVersion().replace(";", "").replace(":", "").replace(" ", "_") + ";"; } plist = plist.substring(0, plist.length() - 2); } query.put("splitnum".getBytes()); query.put((byte) 0x00); query.put((byte) 128); query.put((byte) 0x00); LinkedHashMap<String, String> KVdata = new LinkedHashMap<>(); KVdata.put("hostname", this.serverName); KVdata.put("gametype", this.gameType); KVdata.put("game_id", GAME_ID); KVdata.put("version", this.version); KVdata.put("server_engine", this.server_engine); KVdata.put("plugins", plist); KVdata.put("map", this.map); KVdata.put("numplayers", String.valueOf(this.numPlayers)); KVdata.put("maxplayers", String.valueOf(this.maxPlayers)); KVdata.put("whitelist", this.whitelist); KVdata.put("hostip", this.ip); KVdata.put("hostport", String.valueOf(this.port)); for (Map.Entry<String, String> entry : KVdata.entrySet()) { query.put(entry.getKey().getBytes(StandardCharsets.UTF_8)); query.put((byte) 0x00); query.put(entry.getValue().getBytes(StandardCharsets.UTF_8)); query.put((byte) 0x00); } query.put(new byte[]{0x00, 0x01}).put("player_".getBytes()).put(new byte[]{0x00, 0x00}); for (Player player : this.players) { query.put(player.getName().getBytes(StandardCharsets.UTF_8)); query.put((byte) 0x00); } query.put((byte) 0x00); return Arrays.copyOf(query.array(), query.position()); }
Example #2
Source File: VersionCommand.java From Jupiter with GNU General Public License v3.0 | 4 votes |
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!this.testPermission(sender)) { return true; } if (args.length == 0) { sender.sendMessage(sender.getServer().getLanguage().translateString("nukkit.server.info.extended", new String[]{ sender.getServer().getName(), sender.getServer().getNukkitVersion(), sender.getServer().getCodename(), sender.getServer().getApiVersion(), sender.getServer().getVersion(), String.valueOf(ProtocolInfo.CURRENT_PROTOCOL) }) + "使用しているJupiterのバージョンは" + sender.getServer().getJupiterVersion() + "です。"); } else { String pluginName = ""; for (String arg : args) pluginName += arg + " "; pluginName = pluginName.trim(); final boolean[] found = {false}; final Plugin[] exactPlugin = {sender.getServer().getPluginManager().getPlugin(pluginName)}; if (exactPlugin[0] == null) { pluginName = pluginName.toLowerCase(); final String finalPluginName = pluginName; sender.getServer().getPluginManager().getPlugins().forEach((s, p) -> { if (s.toLowerCase().contains(finalPluginName)) { exactPlugin[0] = p; found[0] = true; } }); } else { found[0] = true; } if (found[0]) { PluginDescription desc = exactPlugin[0].getDescription(); sender.sendMessage(TextFormat.DARK_GREEN + desc.getName() + TextFormat.WHITE + " version " + TextFormat.DARK_GREEN + desc.getVersion()); if (desc.getDescription() != null) { sender.sendMessage(desc.getDescription()); } if (desc.getWebsite() != null) { sender.sendMessage("Website: " + desc.getWebsite()); } List<String> authors = desc.getAuthors(); final String[] authorsString = {""}; authors.forEach((s) -> authorsString[0] += s); if (authors.size() == 1) { sender.sendMessage("Author: " + authorsString[0]); } else if (authors.size() >= 2) { sender.sendMessage("Authors: " + authorsString[0]); } } else { sender.sendMessage(new TranslationContainer("nukkit.command.version.noSuchPlugin")); } } return true; }
Example #3
Source File: QueryRegenerateEvent.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public byte[] getLongQuery(byte[] buffer) { if (buffer == null) buffer = new byte[Character.MAX_VALUE]; FastByteArrayOutputStream query = new FastByteArrayOutputStream(buffer); try { String plist = this.server_engine; if (this.plugins.length > 0 && this.listPlugins) { plist += ":"; for (Plugin p : this.plugins) { PluginDescription d = p.getDescription(); plist += " " + d.getName().replace(";", "").replace(":", "").replace(" ", "_") + " " + d.getVersion().replace(";", "").replace(":", "").replace(" ", "_") + ";"; } plist = plist.substring(0, plist.length() - 2); } query.write("splitnum".getBytes()); query.write((byte) 0x00); query.write((byte) 128); query.write((byte) 0x00); LinkedHashMap<String, String> KVdata = new LinkedHashMap<>(); KVdata.put("hostname", this.serverName); KVdata.put("gametype", this.gameType); KVdata.put("game_id", GAME_ID); KVdata.put("version", this.version); KVdata.put("server_engine", this.server_engine); KVdata.put("plugins", plist); KVdata.put("map", this.map); KVdata.put("numplayers", String.valueOf(this.numPlayers)); KVdata.put("maxplayers", String.valueOf(this.maxPlayers)); KVdata.put("whitelist", this.whitelist); KVdata.put("hostip", this.ip); KVdata.put("hostport", String.valueOf(this.port)); for (Map.Entry<String, String> entry : KVdata.entrySet()) { query.write(entry.getKey().getBytes(StandardCharsets.UTF_8)); query.write((byte) 0x00); query.write(entry.getValue().getBytes(StandardCharsets.UTF_8)); query.write((byte) 0x00); } query.write(new byte[]{0x00, 0x01}); query.write("player_".getBytes()); query.write(new byte[]{0x00, 0x00}); for (Player player : this.players) { query.write(player.getName().getBytes(StandardCharsets.UTF_8)); query.write((byte) 0x00); } query.write((byte) 0x00); } catch (IOException e) { e.printStackTrace(); } return query.toByteArray(); }
Example #4
Source File: VersionCommand.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!this.testPermission(sender)) { return true; } if (args.length == 0) { sender.sendMessage(new TranslationContainer("nukkit.server.info.extended", sender.getServer().getName(), sender.getServer().getNukkitVersion(), sender.getServer().getCodename(), sender.getServer().getApiVersion(), sender.getServer().getVersion(), String.valueOf(ProtocolInfo.CURRENT_PROTOCOL))); } else { String pluginName = ""; for (String arg : args) pluginName += arg + " "; pluginName = pluginName.trim(); final boolean[] found = {false}; final Plugin[] exactPlugin = {sender.getServer().getPluginManager().getPlugin(pluginName)}; if (exactPlugin[0] == null) { pluginName = pluginName.toLowerCase(); final String finalPluginName = pluginName; sender.getServer().getPluginManager().getPlugins().forEach((s, p) -> { if (s.toLowerCase().contains(finalPluginName)) { exactPlugin[0] = p; found[0] = true; } }); } else { found[0] = true; } if (found[0]) { PluginDescription desc = exactPlugin[0].getDescription(); sender.sendMessage(TextFormat.DARK_GREEN + desc.getName() + TextFormat.WHITE + " version " + TextFormat.DARK_GREEN + desc.getVersion()); if (desc.getDescription() != null) { sender.sendMessage(desc.getDescription()); } if (desc.getWebsite() != null) { sender.sendMessage("Website: " + desc.getWebsite()); } List<String> authors = desc.getAuthors(); final String[] authorsString = {""}; authors.forEach((s) -> authorsString[0] += s); if (authors.size() == 1) { sender.sendMessage("Author: " + authorsString[0]); } else if (authors.size() >= 2) { sender.sendMessage("Authors: " + authorsString[0]); } } else { sender.sendMessage(new TranslationContainer("nukkit.command.version.noSuchPlugin")); } } return true; }
Example #5
Source File: DebugPasteCommand.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!this.testPermission(sender)) { return true; } Server server = Server.getInstance(); server.getScheduler().scheduleAsyncTask(new AsyncTask() { @Override public void onRun() { try { new StatusCommand("status").execute(server.getConsoleSender(), "status", new String[]{}); String dataPath = server.getDataPath(); String nukkitYML = HastebinUtility.upload(new File(dataPath, "nukkit.yml")); String serverProperties = HastebinUtility.upload(new File(dataPath, "server.properties")); String latestLog = HastebinUtility.upload(new File(dataPath, "/logs/server.log")); String threadDump = HastebinUtility.upload(Utils.getAllThreadDumps()); StringBuilder b = new StringBuilder(); b.append("# Files\n"); b.append("links.nukkit_yml: ").append(nukkitYML).append('\n'); b.append("links.server_properties: ").append(serverProperties).append('\n'); b.append("links.server_log: ").append(latestLog).append('\n'); b.append("links.thread_dump: ").append(threadDump).append('\n'); b.append("\n# Server Information\n"); b.append("version.api: ").append(server.getApiVersion()).append('\n'); b.append("version.nukkit: ").append(server.getNukkitVersion()).append('\n'); b.append("version.minecraft: ").append(server.getVersion()).append('\n'); b.append("version.protocol: ").append(ProtocolInfo.CURRENT_PROTOCOL).append('\n'); b.append("plugins:"); for (Plugin plugin : server.getPluginManager().getPlugins().values()) { boolean enabled = plugin.isEnabled(); String name = plugin.getName(); PluginDescription desc = plugin.getDescription(); String version = desc.getVersion(); b.append("\n ") .append(name) .append(":\n ") .append("version: '") .append(version) .append('\'') .append("\n enabled: ") .append(enabled); } b.append("\n\n# Java Details\n"); Runtime runtime = Runtime.getRuntime(); b.append("memory.free: ").append(runtime.freeMemory()).append('\n'); b.append("memory.max: ").append(runtime.maxMemory()).append('\n'); b.append("cpu.runtime: ").append(ManagementFactory.getRuntimeMXBean().getUptime()).append('\n'); b.append("cpu.processors: ").append(runtime.availableProcessors()).append('\n'); b.append("java.specification.version: '").append(System.getProperty("java.specification.version")).append("'\n"); b.append("java.vendor: '").append(System.getProperty("java.vendor")).append("'\n"); b.append("java.version: '").append(System.getProperty("java.version")).append("'\n"); b.append("os.arch: '").append(System.getProperty("os.arch")).append("'\n"); b.append("os.name: '").append(System.getProperty("os.name")).append("'\n"); b.append("os.version: '").append(System.getProperty("os.version")).append("'\n\n"); b.append("\n# Create a ticket: https://github.com/NukkitX/Nukkit/issues/new"); String link = HastebinUtility.upload(b.toString()); sender.sendMessage(link); } catch (IOException e) { MainLogger.getLogger().logException(e); } } }); return true; }
Example #6
Source File: PlanNukkitMocker.java From Plan with GNU Lesser General Public License v3.0 | 4 votes |
PlanNukkitMocker withPluginDescription() { PluginDescription description = Mockito.mock(PluginDescription.class); doReturn("1.0.0").when(description).getVersion(); doReturn(description).when(planMock).getDescription(); return this; }
Example #7
Source File: QueryRegenerateEvent.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public byte[] getLongQuery(byte[] buffer) { if (buffer == null) buffer = new byte[Character.MAX_VALUE]; FastByteArrayOutputStream query = new FastByteArrayOutputStream(buffer); try { String plist = this.server_engine; if (this.plugins.length > 0 && this.listPlugins) { plist += ":"; for (Plugin p : this.plugins) { PluginDescription d = p.getDescription(); plist += " " + d.getName().replace(";", "").replace(":", "").replace(" ", "_") + " " + d.getVersion().replace(";", "").replace(":", "").replace(" ", "_") + ";"; } plist = plist.substring(0, plist.length() - 2); } query.write("splitnum".getBytes()); query.write((byte) 0x00); query.write((byte) 128); query.write((byte) 0x00); LinkedHashMap<String, String> KVdata = new LinkedHashMap<>(); KVdata.put("hostname", this.serverName); KVdata.put("gametype", this.gameType); KVdata.put("game_id", GAME_ID); KVdata.put("version", this.version); KVdata.put("server_engine", this.server_engine); KVdata.put("plugins", plist); KVdata.put("map", this.map); KVdata.put("numplayers", String.valueOf(this.numPlayers)); KVdata.put("maxplayers", String.valueOf(this.maxPlayers)); KVdata.put("whitelist", this.whitelist); KVdata.put("hostip", this.ip); KVdata.put("hostport", String.valueOf(this.port)); for (Map.Entry<String, String> entry : KVdata.entrySet()) { query.write(entry.getKey().getBytes(StandardCharsets.UTF_8)); query.write((byte) 0x00); query.write(entry.getValue().getBytes(StandardCharsets.UTF_8)); query.write((byte) 0x00); } query.write(new byte[]{0x00, 0x01}); query.write("player_".getBytes()); query.write(new byte[]{0x00, 0x00}); for (Player player : this.players) { query.write(player.getName().getBytes(StandardCharsets.UTF_8)); query.write((byte) 0x00); } query.write((byte) 0x00); } catch (IOException e) { e.printStackTrace(); } return query.toByteArray(); }
Example #8
Source File: VersionCommand.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!this.testPermission(sender)) { return true; } if (args.length == 0) { sender.sendMessage(new TranslationContainer("nukkit.server.info.extended", new String[]{ sender.getServer().getName(), sender.getServer().getNukkitVersion(), sender.getServer().getCodename(), sender.getServer().getApiVersion(), sender.getServer().getVersion(), String.valueOf(ProtocolInfo.CURRENT_PROTOCOL) })); } else { String pluginName = ""; for (String arg : args) pluginName += arg + " "; pluginName = pluginName.trim(); final boolean[] found = {false}; final Plugin[] exactPlugin = {sender.getServer().getPluginManager().getPlugin(pluginName)}; if (exactPlugin[0] == null) { pluginName = pluginName.toLowerCase(); final String finalPluginName = pluginName; sender.getServer().getPluginManager().getPlugins().forEach((s, p) -> { if (s.toLowerCase().contains(finalPluginName)) { exactPlugin[0] = p; found[0] = true; } }); } else { found[0] = true; } if (found[0]) { PluginDescription desc = exactPlugin[0].getDescription(); sender.sendMessage(TextFormat.DARK_GREEN + desc.getName() + TextFormat.WHITE + " version " + TextFormat.DARK_GREEN + desc.getVersion()); if (desc.getDescription() != null) { sender.sendMessage(desc.getDescription()); } if (desc.getWebsite() != null) { sender.sendMessage("Website: " + desc.getWebsite()); } List<String> authors = desc.getAuthors(); final String[] authorsString = {""}; authors.forEach((s) -> authorsString[0] += s); if (authors.size() == 1) { sender.sendMessage("Author: " + authorsString[0]); } else if (authors.size() >= 2) { sender.sendMessage("Authors: " + authorsString[0]); } } else { sender.sendMessage(new TranslationContainer("nukkit.command.version.noSuchPlugin")); } } return true; }
Example #9
Source File: DebugPasteCommand.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!this.testPermission(sender)) { return true; } Server server = Server.getInstance(); server.getScheduler().scheduleAsyncTask(new AsyncTask() { @Override public void onRun() { try { new StatusCommand("status").execute(server.getConsoleSender(), "status", new String[]{}); String dataPath = server.getDataPath(); String nukkitYML = HastebinUtility.upload(new File(dataPath, "nukkit.yml")); String serverProperties = HastebinUtility.upload(new File(dataPath, "server.properties")); String latestLog = HastebinUtility.upload(new File(dataPath, "server.log")); String threadDump = HastebinUtility.upload(Utils.getAllThreadDumps()); StringBuilder b = new StringBuilder(); b.append("# Files\n"); b.append("links.nukkit_yml: ").append(nukkitYML).append('\n'); b.append("links.server_properties: ").append(serverProperties).append('\n'); b.append("links.server_log: ").append(latestLog).append('\n'); b.append("links.thread_dump: ").append(threadDump).append('\n'); b.append("\n# Server Information\n"); b.append("version.api: ").append(server.getApiVersion()).append('\n'); b.append("version.nukkit: ").append(server.getNukkitVersion()).append('\n'); b.append("version.minecraft: ").append(server.getVersion()).append('\n'); b.append("version.protocol: ").append(ProtocolInfo.CURRENT_PROTOCOL).append('\n'); b.append("plugins:"); for (Plugin plugin : server.getPluginManager().getPlugins().values()) { boolean enabled = plugin.isEnabled(); String name = plugin.getName(); PluginDescription desc = plugin.getDescription(); String version = desc.getVersion(); b.append("\n ") .append(name) .append(":\n ") .append("version: '") .append(version) .append('\'') .append("\n enabled: ") .append(enabled); } b.append("\n\n# Java Details\n"); Runtime runtime = Runtime.getRuntime(); b.append("memory.free: ").append(runtime.freeMemory()).append('\n'); b.append("memory.max: ").append(runtime.maxMemory()).append('\n'); b.append("cpu.runtime: ").append(ManagementFactory.getRuntimeMXBean().getUptime()).append('\n'); b.append("cpu.processors: ").append(runtime.availableProcessors()).append('\n'); b.append("java.specification.version: '").append(System.getProperty("java.specification.version")).append("'\n"); b.append("java.vendor: '").append(System.getProperty("java.vendor")).append("'\n"); b.append("java.version: '").append(System.getProperty("java.version")).append("'\n"); b.append("os.arch: '").append(System.getProperty("os.arch")).append("'\n"); b.append("os.name: '").append(System.getProperty("os.name")).append("'\n"); b.append("os.version: '").append(System.getProperty("os.version")).append("'\n\n"); b.append("\n# Create a ticket: https://github.com/NukkitX/Nukkit/issues/new"); String link = HastebinUtility.upload(b.toString()); sender.sendMessage(link); } catch (IOException e) { MainLogger.getLogger().logException(e); } } }); return true; }