2016-10-03 15:40:19 +02:00
|
|
|
/*
|
2021-03-23 11:11:01 +01:00
|
|
|
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
2021-03-20 23:12:25 +01:00
|
|
|
* Copyright (C) 2016-2021 ViaVersion and contributors
|
2016-10-03 15:40:19 +02:00
|
|
|
*
|
2021-03-20 23:12:25 +01:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2016-10-03 15:40:19 +02:00
|
|
|
*
|
2021-03-20 23:12:25 +01:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2016-10-03 15:40:19 +02:00
|
|
|
*
|
2021-03-20 23:12:25 +01:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2016-10-03 15:40:19 +02:00
|
|
|
*/
|
|
|
|
|
2016-10-03 15:20:38 +02:00
|
|
|
package nl.matsv.viabackwards;
|
|
|
|
|
|
|
|
import com.google.inject.Inject;
|
2016-11-19 12:01:22 +01:00
|
|
|
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
2021-02-18 14:34:33 +01:00
|
|
|
import nl.matsv.viabackwards.utils.VersionInfo;
|
2019-09-09 15:23:09 +02:00
|
|
|
import org.spongepowered.api.config.ConfigDir;
|
2016-10-03 15:20:38 +02:00
|
|
|
import org.spongepowered.api.event.Listener;
|
2017-10-12 13:16:38 +02:00
|
|
|
import org.spongepowered.api.event.Order;
|
2018-12-09 16:18:40 +01:00
|
|
|
import org.spongepowered.api.event.game.state.GameInitializationEvent;
|
2016-10-03 15:20:38 +02:00
|
|
|
import org.spongepowered.api.plugin.Dependency;
|
|
|
|
import org.spongepowered.api.plugin.Plugin;
|
2020-09-02 10:11:36 +02:00
|
|
|
import us.myles.ViaVersion.api.Via;
|
2016-10-03 15:20:38 +02:00
|
|
|
import us.myles.ViaVersion.sponge.util.LoggerWrapper;
|
|
|
|
|
2020-01-06 16:34:39 +01:00
|
|
|
import java.io.File;
|
2019-09-09 15:23:09 +02:00
|
|
|
import java.nio.file.Path;
|
2016-10-03 15:20:38 +02:00
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
|
|
@Plugin(id = "viabackwards",
|
|
|
|
name = "ViaBackwards",
|
|
|
|
version = VersionInfo.VERSION,
|
2019-12-07 17:14:17 +01:00
|
|
|
authors = {"Matsv", "KennyTV", "Gerrygames", "creeper123123321", "ForceUpdate1"},
|
2019-06-09 17:23:25 +02:00
|
|
|
description = "Allow older Minecraft versions to connect to a newer server version.",
|
2016-10-03 15:20:38 +02:00
|
|
|
dependencies = {@Dependency(id = "viaversion")}
|
|
|
|
)
|
|
|
|
public class SpongePlugin implements ViaBackwardsPlatform {
|
|
|
|
private Logger logger;
|
|
|
|
@Inject
|
2018-12-09 16:18:40 +01:00
|
|
|
private org.slf4j.Logger loggerSlf4j;
|
2019-09-09 15:23:09 +02:00
|
|
|
@Inject
|
|
|
|
@ConfigDir(sharedRoot = false)
|
|
|
|
private Path configPath;
|
2016-10-03 15:20:38 +02:00
|
|
|
|
2017-10-12 13:16:38 +02:00
|
|
|
@Listener(order = Order.LATE)
|
2018-12-09 16:18:40 +01:00
|
|
|
public void onGameStart(GameInitializationEvent e) {
|
2016-10-03 15:20:38 +02:00
|
|
|
// Setup Logger
|
2018-12-09 16:18:40 +01:00
|
|
|
this.logger = new LoggerWrapper(loggerSlf4j);
|
2016-10-04 00:41:31 +02:00
|
|
|
// Init!
|
2020-09-02 10:11:36 +02:00
|
|
|
Via.getManager().addEnableListener(() -> this.init(configPath.resolve("config.yml").toFile()));
|
2016-10-03 15:20:38 +02:00
|
|
|
}
|
|
|
|
|
2017-05-31 00:03:42 +02:00
|
|
|
@Override
|
|
|
|
public void disable() {
|
2018-12-09 16:18:40 +01:00
|
|
|
// Not possible
|
2017-05-31 00:03:42 +02:00
|
|
|
}
|
2020-01-06 16:34:39 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public File getDataFolder() {
|
|
|
|
return configPath.toFile();
|
|
|
|
}
|
2020-01-27 19:41:59 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public Logger getLogger() {
|
|
|
|
return logger;
|
|
|
|
}
|
2016-10-03 15:20:38 +02:00
|
|
|
}
|