Why is this not working the error: Code: [17:31:54] [Server thread/WARN]: java.io.IOException: Server returned HTTP response code: 403 for URL: http://minecraft-api.com/v1/get/?server=mc.ender.lt [17:31:54] [Server thread/WARN]: at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) [17:31:54] [Server thread/WARN]: at java.net.URL.openStream(Unknown Source) [17:31:54] [Server thread/WARN]: at pingserver.main.pingServer(main.java:43) [17:31:54] [Server thread/WARN]: at pingserver.main.lol(main.java:27) [17:31:54] [Server thread/WARN]: at pingserver.main.onCommand(main.java:61) [17:31:54] [Server thread/WARN]: at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) [17:31:54] [Server thread/WARN]: at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:180) [17:31:54] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchCommand(CraftServer.java:728) [17:31:54] [Server thread/WARN]: at net.minecraft.server.v1_7_R3.PlayerConnection.handleCommand(PlayerConnection.java:985) [17:31:54] [Server thread/WARN]: at net.minecraft.server.v1_7_R3.PlayerConnection.a(PlayerConnection.java:830) [17:31:54] [Server thread/WARN]: at net.minecraft.server.v1_7_R3.PacketPlayInChat.a(PacketPlayInChat.java:28) [17:31:54] [Server thread/WARN]: at net.minecraft.server.v1_7_R3.PacketPlayInChat.handle(PacketPlayInChat.java:65) [17:31:54] [Server thread/WARN]: at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:180) [17:31:54] [Server thread/WARN]: at net.minecraft.server.v1_7_R3.ServerConnection.c(ServerConnection.java:81) [17:31:54] [Server thread/WARN]: at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:713) [17:31:54] [Server thread/WARN]: at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:283) [17:31:54] [Server thread/WARN]: at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:576) [17:31:54] [Server thread/WARN]: at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:482) [17:31:54] [Server thread/WARN]: at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) and the code: Code:java package pingserver; import com.google.gson.Gson;import com.google.gson.internal.LinkedTreeMap;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.net.MalformedURLException;import java.net.URL;import java.util.HashMap; import org.bukkit.command.Command;import org.bukkit.command.CommandSender;import org.bukkit.entity.Player;import org.bukkit.event.Listener;import org.bukkit.plugin.java.JavaPlugin; public class main extends JavaPlugin implements Listener { public void onEnable() {getServer().getPluginManager().registerEvents(this, this);} @SuppressWarnings("rawtypes")public static void lol(Player player){HashMap JSON = pingServer("mc.ender.lt"); if (JSON == null || JSON.get("error") != null) {player.sendMessage("The server is offline :(");} else {LinkedTreeMap players = (LinkedTreeMap) JSON.get("players");player.sendMessage("There are " + players.get("online") + " out of " + players.get("max") + " online!");player.sendMessage("MoTD is (" + JSON.get("motd") + ")");}} @SuppressWarnings("rawtypes")public static HashMap pingServer(String server){try {URL url = new URL("[url]http://minecraft-api.com/v1/get/?server=[/url]" + server);try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()))) {String data = reader.readLine(); Gson gson = new Gson();return gson.fromJson(data, HashMap.class);}} catch (MalformedURLException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}return null;} public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){Player player = (Player) sender; if(label.equalsIgnoreCase("ping-that")) {lol(player);} return false;} }
Smerfa Oh the tag is from these forums when i pasted the code its there for some reason but in my code theres is no [.url] tag and with https there is the same error. Can someone help me? bump EDIT by Moderator: merged posts, please use the edit button instead of double posting.
This code is from website http://minecraft-api.com/getting-started So can anyone help? EDIT by Moderator: merged posts, please use the edit button instead of double posting.