2019-12-01 21:16:52 +00:00
|
|
|
/*
|
2020-04-15 19:39:21 +00:00
|
|
|
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
2019-12-01 21:16:52 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* @author GeyserMC
|
|
|
|
* @link https://github.com/GeyserMC/Geyser
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.geysermc.platform.standalone;
|
|
|
|
|
2019-12-21 17:53:19 +00:00
|
|
|
import org.geysermc.common.PlatformType;
|
2020-04-29 20:01:53 +00:00
|
|
|
import org.geysermc.connector.GeyserConfiguration;
|
|
|
|
import org.geysermc.connector.bootstrap.GeyserBootstrap;
|
2019-12-01 21:16:52 +00:00
|
|
|
import org.geysermc.connector.GeyserConnector;
|
2020-04-19 23:08:14 +00:00
|
|
|
import org.geysermc.connector.command.CommandManager;
|
2019-12-01 21:16:52 +00:00
|
|
|
import org.geysermc.connector.utils.FileUtils;
|
2020-04-19 23:08:14 +00:00
|
|
|
import org.geysermc.platform.standalone.command.GeyserCommandManager;
|
2019-12-01 21:16:52 +00:00
|
|
|
|
2020-04-20 01:56:03 +00:00
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
2020-04-29 20:01:53 +00:00
|
|
|
public class GeyserStandaloneBootstrap implements GeyserBootstrap {
|
2020-04-19 23:08:14 +00:00
|
|
|
|
|
|
|
private GeyserCommandManager geyserCommandManager;
|
2019-12-01 21:16:52 +00:00
|
|
|
private GeyserConfiguration geyserConfig;
|
2020-04-29 20:01:53 +00:00
|
|
|
private GeyserStandaloneLogger geyserLogger;
|
2019-12-01 21:16:52 +00:00
|
|
|
|
2020-03-17 16:43:09 +00:00
|
|
|
private GeyserConnector connector;
|
|
|
|
|
2019-12-01 21:16:52 +00:00
|
|
|
public static void main(String[] args) {
|
2020-04-29 20:01:53 +00:00
|
|
|
new GeyserStandaloneBootstrap().onEnable();
|
2019-12-01 21:16:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEnable() {
|
2020-04-29 20:01:53 +00:00
|
|
|
geyserLogger = new GeyserStandaloneLogger();
|
2020-04-19 23:08:14 +00:00
|
|
|
|
2020-03-25 05:55:09 +00:00
|
|
|
LoopbackUtil.checkLoopback(geyserLogger);
|
2020-03-24 07:56:04 +00:00
|
|
|
|
2019-12-01 21:16:52 +00:00
|
|
|
try {
|
|
|
|
File configFile = FileUtils.fileOrCopiedFromResource("config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
|
2020-04-29 20:01:53 +00:00
|
|
|
geyserConfig = FileUtils.loadConfig(configFile, GeyserStandaloneConfiguration.class);
|
2019-12-01 21:16:52 +00:00
|
|
|
} catch (IOException ex) {
|
2019-12-01 22:52:07 +00:00
|
|
|
geyserLogger.severe("Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!", ex);
|
2019-12-01 21:16:52 +00:00
|
|
|
System.exit(0);
|
|
|
|
}
|
2020-05-21 03:43:22 +00:00
|
|
|
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
|
2019-12-01 21:16:52 +00:00
|
|
|
|
2020-03-17 16:43:09 +00:00
|
|
|
connector = GeyserConnector.start(PlatformType.STANDALONE, this);
|
2020-04-19 23:08:14 +00:00
|
|
|
geyserCommandManager = new GeyserCommandManager(connector);
|
2020-04-20 01:56:03 +00:00
|
|
|
geyserLogger.start();
|
2019-12-01 21:16:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDisable() {
|
2020-03-17 16:43:09 +00:00
|
|
|
connector.shutdown();
|
2019-12-01 21:16:52 +00:00
|
|
|
System.exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public GeyserConfiguration getGeyserConfig() {
|
|
|
|
return geyserConfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-04-29 20:01:53 +00:00
|
|
|
public GeyserStandaloneLogger getGeyserLogger() {
|
2019-12-01 21:16:52 +00:00
|
|
|
return geyserLogger;
|
|
|
|
}
|
2020-04-19 23:08:14 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public CommandManager getGeyserCommandManager() {
|
|
|
|
return geyserCommandManager;
|
|
|
|
}
|
2019-12-01 21:16:52 +00:00
|
|
|
}
|