Hello all, I was wondering if someone can push me in the direction of making a plugin that opens a web page to a certain link. Thanks in advance Rege
@SkyGlue And do what with it? Do you just need to view the source from within the plugin? Do you want it to open clientside?
@SkyGlue Asuming you mean get the source code (because i cant thing of something you can do with it server-side), Get the url, open the stream, put it on a BufferedReader or whatever you prefer, read from that, while reading you can append the Strings read to a StringBuilder to have the entire source later.. This can be resource leaky if not handled properly or the remote page/file is massive.
@SkyGlue It'll only open the webpage on the computer that the server is running on if you open it from the plugin. Are you talking about using clickable text that opens a website from MC? You can send a player JSON that'll do that.
Yea. I know, but with the events, how would you do that? Like with a onClick event and such? And how would you differ the actions, like Action.OPEN_URL, or Action.PERFORM_COMMAND? You know what I mean.
@SkyGlue i didnt want to do this but here we go... you can check this video First thing i must say that you shouldnt watch his videos because it would be a bad influence to you but if you are really looking for it go ahead =)
I tried video but this is what I got: Main Class Code: package me.SkyGlue.Wiki; import org.bukkit.plugin.java.JavaPlugin; public class Wiki extends JavaPlugin{ public void registerCommand() { getCommand("wiki").setExecutor(new Wiki()); } } My command file. Code: package me.SkyGlue.Wiki; import org.bukkit.command.CommandSender; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; import net.minecraft.server.v1_8_R3.CommandExecute; import net.minecraft.server.v1_8_R3.IChatBaseComponent.ChatSerializer; import net.minecraft.server.v1_8_R3.PacketPlayOutChat; import net.minecraft.server.v1_8_R3.PlayerConnection; public class Command extends CommandExecute { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (!(sender instanceof Player)) { sender.sendMessage("You are not a player!"); return false; } Player player = (Player) sender; PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection; PacketPlayOutChat packet = new PacketPlayOutChat(ChatSerializer.a( "[\"\",{\"text\":\"Click me to check out the wiki!\",\"color\":\"green\",\"bold\":true,\"clickEvent\":{\"action\":\"open_url\",\"value\":\"http://pixelmonmod.com/wiki/index.php?title=Welcome_to_the_Pixelmon_Wiki\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Click me!\",\"color\":\"light_purple\"}]}}}]")); connection.sendPacket(packet); return true; } } Plugin.YML Code: name: PixelmonWiki main: me.SkyGlue.Wiki.Wiki version: 1.0 commands: wiki: description: Opens thePixelmon wiki page! So When I export it, I get no errors but when I get ingame and do /wiki nothing happens. Any Suggestions?
@SkyGlue like @bwfcwalshy sad you need to change the yml file and probably when yuo run the plugin the console says plugin.yml invalid.
@bwfcwalshy @Gonmarte I still get this error in the console Code: Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token found character '\t(TAB)' that cannot start any token. (Do not use \t(TAB) for indentation) in 'reader', line 5, column 1: wiki: ^ at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:420) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:226) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingValue.produce(ParserImpl.java:586) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:143) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:132) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:229) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:155) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.composer.Composer.composeDocument(Composer.java:122) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:105) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:120) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:450) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.Yaml.load(Yaml.java:381) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.bukkit.plugin.PluginDescriptionFile.<init>(PluginDescriptionFile.java:232) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:159) ~[spigot.jar:git-Spigot-044d928-e8c6403] ... 5 more I know it says that I shouldn't use tabs but I didn't and it didn't work!
@timtower I did that. Let me show you my code again. Main class called "Wiki" Code: package me.SkyGlue.Wiki; import org.bukkit.plugin.java.JavaPlugin; public class Wiki extends JavaPlugin{ public void registerCommand() { getCommand("wiki").setExecutor(new Wiki()); } } Class called "Command" Code: package me.SkyGlue.Wiki; import org.bukkit.command.CommandSender; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; import net.minecraft.server.v1_8_R3.CommandExecute; import net.minecraft.server.v1_8_R3.IChatBaseComponent.ChatSerializer; import net.minecraft.server.v1_8_R3.PacketPlayOutChat; import net.minecraft.server.v1_8_R3.PlayerConnection; public class Command extends CommandExecute { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (!(sender instanceof Player)) { sender.sendMessage("You are not a player!"); return false; } Player player = (Player) sender; PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection; PacketPlayOutChat packet = new PacketPlayOutChat(ChatSerializer.a( "[\"\",{\"text\":\"Click me to check out the wiki!\",\"color\":\"green\",\"bold\":true,\"clickEvent\":{\"action\":\"open_url\",\"value\":\"http://pixelmonmod.com/wiki/index.php?title=Welcome_to_the_Pixelmon_Wiki\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Click me!\",\"color\":\"light_purple\"}]}}}]")); connection.sendPacket(packet); return true; } } Plugin.yml Code: name: PixelmonWiki main: me.SkyGlue.Wiki.Wiki version: 1.0 commands: wiki: description: Sends the user to the Pixelmon Wiki! pls help
This is the error I get; Code: org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:164) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [spigot.jar:git-Spigot-044d928-e8c6403] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:291) [spigot.jar:git-Spigot-044d928-e8c6403] at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:198) [spigot.jar:git-Spigot-044d928-e8c6403] at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:528) [spigot.jar:git-Spigot-044d928-e8c6403] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_60] Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token found character '\t(TAB)' that cannot start any token. (Do not use \t(TAB) for indentation) in 'reader', line 5, column 1: wiki: ^ at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:420) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:226) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingValue.produce(ParserImpl.java:586) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:143) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:132) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:229) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:155) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.composer.Composer.composeDocument(Composer.java:122) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:105) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:120) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:450) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.yaml.snakeyaml.Yaml.load(Yaml.java:381) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.bukkit.plugin.PluginDescriptionFile.<init>(PluginDescriptionFile.java:232) ~[spigot.jar:git-Spigot-044d928-e8c6403] at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:159) ~[spigot.jar:git-Spigot-044d928-e8c6403] ... 5 more
Code: name: PixelmonWiki version: 1.0 main: me.SkyGlue.Wiki.Wiki commands: wiki: description: Sends the user to the pixelmon wiki! It should work. Are you compiling it to the right place? Are you reloading your server (If so don't, use /restart) go back through and make sure there are no tabs. Rewrite the config if you have to Just Do It