RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
WebsitePlayerCountService.java
1package com.osroyale.game.service;
2
3import com.google.common.util.concurrent.AbstractScheduledService;
4import com.osroyale.Config;
5import com.osroyale.game.world.World;
6import org.apache.logging.log4j.LogManager;
7import org.apache.logging.log4j.Logger;
8
9import java.io.IOException;
10import java.io.InputStream;
11import java.net.URL;
12import java.util.concurrent.TimeUnit;
13
36
37public final class WebsitePlayerCountService extends AbstractScheduledService {
38
39 private static final Logger logger = LogManager.getLogger(WebsitePlayerCountService.class);
40
41 private static final WebsitePlayerCountService INSTANCE = new WebsitePlayerCountService();
42
43 public static WebsitePlayerCountService getInstance() {
44 return INSTANCE;
45 }
46
47 @Override
48 protected void runOneIteration() throws Exception {
49 try {
50 final int count = World.getPlayerCount();
51 InputStream is = new URL(String.format("%s/player_count.php?key=9A@2U0764JqB&amount=%d", Config.WEBSITE_URL, count)).openStream();
52 is.close();
53 } catch (IOException ex) {
54 logger.error("Error writing player count on website.", ex);
55 }
56 }
57
58 @Override
59 protected Scheduler scheduler() {
60 return Scheduler.newFixedRateSchedule(10, 30, TimeUnit.SECONDS);
61 }
62
63}