|
|
@ -15,17 +15,13 @@ import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
public class StatusProvider { |
|
|
|
|
|
|
|
private static final String SERVER_URL = "85.214.148.23"; |
|
|
|
private static final String statusChannelId = "889880296168755231"; |
|
|
|
private static final String messageId = "889887149850251304"; |
|
|
|
|
|
|
|
private static final ScheduledExecutorService statusScheduler = Executors.newScheduledThreadPool(1); |
|
|
|
|
|
|
|
private static int lastPlayersOnline = -1; |
|
|
|
|
|
|
|
|
|
|
|
public static void provide(int secondsPerTime, Guild guild){ |
|
|
|
TextChannel statusChannel = guild.getTextChannelById(statusChannelId); |
|
|
|
TextChannel statusChannel = guild.getTextChannelById(Resources.getStatus_channel()); |
|
|
|
statusScheduler.scheduleAtFixedRate(() -> { |
|
|
|
try { |
|
|
|
updateStatusMessage(statusChannel); |
|
|
@ -43,7 +39,7 @@ public class StatusProvider { |
|
|
|
EmbedBuilder eb = new EmbedBuilder(); |
|
|
|
eb.setTitle("Status"); |
|
|
|
eb.addField("Minecraft-Server, Spieler online: ", Integer.toString(lastPlayersOnline), false); |
|
|
|
statusChannel.editMessageById(messageId, eb.build()).queue(); |
|
|
|
statusChannel.editMessageById(Resources.getStatus_message(), eb.build()).queue(); |
|
|
|
} |
|
|
|
|
|
|
|
private static int getPlayersOnline() throws IOException { |
|
|
@ -52,13 +48,13 @@ public class StatusProvider { |
|
|
|
DataInputStream in = null; |
|
|
|
|
|
|
|
try { |
|
|
|
socket = new Socket(SERVER_URL, 25565); |
|
|
|
socket = new Socket(Resources.getMc_server(), 25565); |
|
|
|
out = new DataOutputStream(socket.getOutputStream()); |
|
|
|
in = new DataInputStream(socket.getInputStream()); |
|
|
|
} catch (UnknownHostException e) { |
|
|
|
System.err.println("Don't know about host: " + SERVER_URL); |
|
|
|
System.err.println("Don't know about host: " + Resources.getMc_server()); |
|
|
|
} catch (IOException e) { |
|
|
|
System.err.println("Couldn't get I/O for " + "the connection to:" + SERVER_URL); |
|
|
|
System.err.println("Couldn't get I/O for " + "the connection to:" + Resources.getMc_server()); |
|
|
|
} |
|
|
|
|
|
|
|
out.write(0xFE); |
|
|
|