RuneHive-Game
Loading...
Searching...
No Matches
RuneHive.java
Go to the documentation of this file.
1package com.runehive;
2
3import com.runehive.content.WellOfGoodwill;
4import com.runehive.content.bloodmoney.BloodChestEvent;
5import com.runehive.content.clanchannel.ClanRepository;
6import com.runehive.content.itemaction.ItemActionRepository;
7import com.runehive.content.lms.LMSGameEvent;
8import com.runehive.content.lms.loadouts.LMSLoadoutManager;
9import com.runehive.content.lms.lobby.LMSLobbyEvent;
10import com.runehive.content.mysterybox.MysteryBox;
11import com.runehive.content.preloads.PreloadRepository;
12import com.runehive.content.shootingstar.ShootingStar;
13import com.runehive.content.skill.SkillRepository;
14import com.runehive.content.tradingpost.TradingPost;
15import com.runehive.content.triviabot.TriviaBot;
16import com.runehive.content.wintertodt.Wintertodt;
17import com.runehive.fs.cache.FileSystem;
18import com.runehive.fs.cache.decoder.*;
19import com.runehive.game.engine.GameEngine;
20import com.runehive.game.plugin.PluginManager;
21import com.runehive.game.service.*;
22import com.runehive.game.task.impl.ClanUpdateEvent;
23import com.runehive.game.task.impl.DoubleExperienceEvent;
24import com.runehive.game.task.impl.MessageEvent;
25import com.runehive.game.task.impl.PlayerSaveEvent;
26import com.runehive.game.world.World;
27import com.runehive.game.world.WorldType;
28import com.runehive.game.world.cronjobs.Jobs;
29import com.runehive.game.world.entity.combat.attack.listener.CombatListenerManager;
30import com.runehive.game.world.entity.combat.strategy.npc.boss.skotizo.SkotizoEvent;
31import com.runehive.game.world.entity.mob.npc.definition.NpcDefinition;
32import com.runehive.game.world.entity.mob.player.BannedPlayers;
33import com.runehive.game.world.entity.mob.player.IPBannedPlayers;
34import com.runehive.game.world.entity.mob.player.IPMutedPlayers;
35import com.runehive.game.world.entity.mob.player.profile.ProfileRepository;
36import com.runehive.game.world.items.ItemDefinition;
37import com.runehive.io.PacketListenerLoader;
38import com.runehive.net.LoginExecutorService;
39import com.runehive.util.GameSaver;
40import com.runehive.util.Stopwatch;
41import com.runehive.util.parser.impl.*;
42import dev.advo.fs.FileServer;
43import org.apache.logging.log4j.LogManager;
44import org.apache.logging.log4j.Logger;
45import org.jire.runehiveps.OldToNew;
46import org.jire.runehiveps.objectexamines.ObjectExamines;
47import org.joda.time.DateTime;
48import org.joda.time.DateTimeZone;
49import plugin.click.item.ClueScrollPlugin;
50
51import java.io.IOException;
52import java.util.concurrent.TimeUnit;
53import java.util.concurrent.atomic.AtomicBoolean;
54
55public final class RuneHive {
56
57 private static final Logger logger = LogManager.getLogger(RuneHive.class);
58
59 public static final AtomicBoolean serverStarted = new AtomicBoolean(false);
60 public static final Stopwatch UPTIME = Stopwatch.start();
61
62 // services
63 private static final StartupService startupService = new StartupService();
64 private static final GameEngine gameService = new GameEngine();
65 private static final NetworkService networkService = new NetworkService();
66
67 private static final RuneHive INSTANCE = new RuneHive();
68
70
71 private RuneHive() {
72 loginExecutorService = new LoginExecutorService(Runtime.getRuntime().availableProcessors());
73 }
74
76 OldToNew.load();
77 try {
78 //object/region decoding must be done before parallel.
80 final FileSystem fs = FileSystem.create("data/cache");
82 new MapDefinitionDecoder(fs).run();
83 new RegionDecoder(fs).run();
86 } catch (IOException e) {
87 e.printStackTrace();
88 }
91 ObjectExamines.loadObjectExamines();
94 new NpcSpawnParser().run();
95 new NpcDropParser().run();
96 new NpcForceChatParser().run();
97 new StoreParser().run();
98 new GlobalObjectParser().run();
99 // ShootingStar.init(); // Disabled - causes deadlock
101 }
102
103 /**
104 * Called after the sequential startup tasks, use this for faster startup.
105 * Try not to use this method for tasks that rely on other tasks you'll run into
106 * issues.
107 */
109 startupService.submit(new PacketSizeParser());
112// startupService.submit(PersonalStoreSaver::loadPayments);
114 // startupService.submit(GlobalRecords::load);
118 startupService.submit(ClueScrollPlugin::declare);
125 startupService.shutdown();
126 }
127
128 /**
129 * Called when the game engine is running and all the startup tasks have finished loading
130 */
131 private void onStart() {
132 if (WellOfGoodwill.isActive()) {
134 }
135
140// World.schedule(new BotStartupEvent());
142 // World.schedule(new LMSLobbyEvent()); // Disabled - causes deadlock
143 // World.schedule(new LMSGameEvent()); // Disabled - related to LMS
144 logger.info("Events have been scheduled");
145 }
146
147 public void start() throws Exception {
149 ForumService.start(); // used to check users logging in with website credentials
150
152 PostgreService.start(); // used to start the postgres connection pool
153 WebsitePlayerCountService.getInstance().startAsync(); // used to display player count on website
154 }
155 }
156
157 new FileServer().start();
158
159 logger.info("RuneHive is running (client version " + Config.CLIENT_VERSION + ")");
160 logger.info(String.format("Game Engine=%s", Config.PARALLEL_GAME_ENGINE ? "Parallel" : "Sequential"));
163
164 startupService.awaitUntilFinished(5, TimeUnit.MINUTES);
165 logger.info("Startup service finished");
166
168
169 PluginManager.load("plugin");
170
171 gameService.startAsync().awaitRunning();
172 logger.info("Game service started");
173
174 onStart();
175
176 Jobs.load();
177
181
183 }
184
185 public static void main(String[] args) {
186 Runtime.getRuntime().addShutdownHook(new Thread(() -> {
187 logger.info("shutting down server, initializing shutdown hook");
188 World.save();
189 com.runehive.content.ai.LazyAIManager.shutdown();
190 }));
191
192 try {
193 INSTANCE.start();
194 } catch (Throwable t) {
195 logger.error("A problem has been encountered while starting the server.", t);
196 }
197
198 }
199
200 public static RuneHive getInstance() {
201 return INSTANCE;
202 }
203
204 public static DateTime currentDateTime() {
205 return new DateTime(timeZone());
206 }
207
208 public static DateTimeZone timeZone() {
209 return DateTimeZone.UTC;
210 }
211
213 return this.loginExecutorService;
214 }
215}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final boolean FORUM_INTEGRATION
If forum integration is true, users can only login if they enter the same username and password that'...
Definition Config.java:117
static final boolean PARALLEL_GAME_ENGINE
This will use the parallel game game.
Definition Config.java:108
static final int CLIENT_VERSION
Definition Config.java:135
static final int SERVER_PORT
The server port.
Definition Config.java:154
static WorldType WORLD_TYPE
Definition Config.java:103
void processSequentialStartupTasks()
Definition RuneHive.java:75
void processParallelStartupTasks()
Called after the sequential startup tasks, use this for faster startup.
static final AtomicBoolean serverStarted
Definition RuneHive.java:59
static DateTime currentDateTime()
static final Stopwatch UPTIME
Definition RuneHive.java:60
static RuneHive getInstance()
static final RuneHive INSTANCE
Definition RuneHive.java:67
LoginExecutorService getLoginExecutorService()
static DateTimeZone timeZone()
static void main(String[] args)
void onStart()
Called when the game engine is running and all the startup tasks have finished loading.
static final StartupService startupService
Definition RuneHive.java:63
static final NetworkService networkService
Definition RuneHive.java:65
final LoginExecutorService loginExecutorService
Definition RuneHive.java:69
static final Logger logger
Definition RuneHive.java:57
static final GameEngine gameService
Definition RuneHive.java:64
Handles contribution towards the well of goodwill.
static void loadChannels()
Loads all clans and puts them into the map.
static void declare()
Declares all the item actions.
static void load()
Handles loading the mystery boxes.
static void declare()
Declares all the preloads into the list on startup.
static void load()
Loads all the skilling data.
static void loadAllListings()
static void loadItemHistory()
static void loadRecentItemHistory()
static void declare()
Declares the TriviaBot data.
Represents a file system of Caches and Archives.
static final int CONFIG_ARCHIVE
Represents the id of the configurations archive.
static FileSystem create(String directory)
Constructs and initializes a FileSystem from the specified directory.
static void unpackConfig(final Archive archive)
A class which parses static object definitions, which include tool.mapviewer tiles and landscapes.
This class handles how plugins are loaded/unloaded and accessed.
static void load(final String pkg)
The bootstrap that will prepare the game and net.
An ExecutorService that waits for all its events to finish executing.
An randomevent which handles updating clan chats.
An randomevent which starts double experience for 1 hour.
Sends game messages to all the online players.
Represents the game world.
Definition World.java:46
static void schedule(Task task)
Submits a new event.
Definition World.java:247
static void save()
Saves all the game data.
Definition World.java:97
Represents all of an in-game Item's attributes.
The class that loads all packet listeners.
static Stopwatch start()
The class that loads all global object on startup.
Parses through the npc spawn file and creates Npcs on startup.
Parses through the npc spawn file and creates Npcs on startup.
Parses through the packet sizes file and associates their opcode with a size.
Parses throug the shops files and creates in-game shop object for the game on startup.
The OS Royale world types.
Definition WorldType.java:8