Skip to content

Commit 5a314e7

Browse files
author
HackusatePvP
committed
Added a reload function for RenJava.
1 parent c6c4074 commit 5a314e7

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/main/java/me/piitex/renjava/RenJava.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,29 @@ protected void init() {
109109
this.registerData(PLAYER);
110110
this.registerData(TRACKS);
111111
new RenLoader(this);
112-
ADDONLOADER = new AddonLoader();
112+
}
113+
114+
public void reload(boolean resetGraphics) {
115+
// Reloads the game. Do not call unless you know what you are doing.
116+
PLAYER = null;
117+
TRACKS = null;
118+
EVENTHANDLER.getRegisteredListeners().clear();
119+
registeredCharacters.clear();
120+
registeredData.clear();
121+
ADDONLOADER.disable();
122+
ADDONLOADER = null;
123+
124+
gameWindow.clear();
125+
gameWindow.render();
126+
127+
// Re-initialize.
128+
init();
129+
130+
if (resetGraphics) {
131+
gameWindow.getStage().setOnHiding(null);
132+
gameWindow.getStage().hide();
133+
new GuiLoader(gameWindow.getStage(), this, hostServices);
134+
}
113135
}
114136

115137
public String getName() {

0 commit comments

Comments
 (0)