2019-07-08 17:55:14 +00:00
|
|
|
/*
|
2021-01-01 15:10:36 +00:00
|
|
|
* Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
|
2019-07-08 17:55:14 +00:00
|
|
|
*
|
2019-07-11 21:30:35 +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:
|
2019-07-08 17:55:14 +00:00
|
|
|
*
|
2019-07-11 21:30:35 +00:00
|
|
|
* 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.
|
2019-07-08 17:55:14 +00:00
|
|
|
*
|
|
|
|
* @author GeyserMC
|
|
|
|
* @link https://github.com/GeyserMC/Geyser
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.geysermc.connector;
|
|
|
|
|
2019-07-08 23:35:32 +00:00
|
|
|
import com.nukkitx.protocol.bedrock.BedrockServer;
|
2020-11-14 23:49:56 +00:00
|
|
|
import org.geysermc.common.PlatformType;
|
2019-10-16 18:55:05 +00:00
|
|
|
import org.geysermc.connector.network.session.GeyserSession;
|
2021-11-20 21:34:30 +00:00
|
|
|
import org.geysermc.geyser.GeyserImpl;
|
2021-11-21 18:36:42 +00:00
|
|
|
import org.geysermc.api.Geyser;
|
2019-07-08 17:55:14 +00:00
|
|
|
|
2021-11-12 16:25:15 +00:00
|
|
|
import java.util.UUID;
|
2019-07-08 17:55:14 +00:00
|
|
|
|
2021-11-20 21:34:30 +00:00
|
|
|
/**
|
|
|
|
* Deprecated, please use {@link Geyser} or {@link GeyserImpl}.
|
|
|
|
*
|
|
|
|
* @deprecated legacy code
|
|
|
|
*/
|
|
|
|
@Deprecated
|
2019-12-21 17:35:48 +00:00
|
|
|
public class GeyserConnector {
|
2021-11-20 21:34:30 +00:00
|
|
|
public static final String NAME = GeyserImpl.NAME;
|
|
|
|
public static final String GIT_VERSION = GeyserImpl.GIT_VERSION; // A fallback for running in IDEs
|
|
|
|
public static final String VERSION = GeyserImpl.VERSION; // A fallback for running in IDEs
|
2021-05-23 19:55:01 +00:00
|
|
|
|
2021-11-20 21:34:30 +00:00
|
|
|
public static final String OAUTH_CLIENT_ID = GeyserImpl.OAUTH_CLIENT_ID;
|
2021-06-05 00:02:10 +00:00
|
|
|
|
2021-11-20 21:34:30 +00:00
|
|
|
private static final GeyserConnector INSTANCE = new GeyserConnector();
|
2019-08-09 21:09:47 +00:00
|
|
|
|
2021-11-20 21:34:30 +00:00
|
|
|
public static GeyserConnector getInstance() {
|
|
|
|
return INSTANCE;
|
2019-07-08 17:55:14 +00:00
|
|
|
}
|
|
|
|
|
2021-11-20 21:34:30 +00:00
|
|
|
public BedrockServer getBedrockServer() {
|
|
|
|
return GeyserImpl.getInstance().getBedrockServer();
|
2019-07-08 17:55:14 +00:00
|
|
|
}
|
2019-08-06 01:59:54 +00:00
|
|
|
|
2021-11-20 21:34:30 +00:00
|
|
|
public boolean isShuttingDown() {
|
|
|
|
return GeyserImpl.getInstance().isShuttingDown();
|
2020-12-17 16:58:49 +00:00
|
|
|
}
|
|
|
|
|
2021-11-20 21:34:30 +00:00
|
|
|
public PlatformType getPlatformType() {
|
|
|
|
return GeyserImpl.getInstance().getPlatformType();
|
2020-12-17 16:58:49 +00:00
|
|
|
}
|
|
|
|
|
2021-11-20 21:34:30 +00:00
|
|
|
public void shutdown() {
|
|
|
|
GeyserImpl.getInstance().shutdown();
|
2020-03-17 16:43:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void reload() {
|
2021-11-20 21:34:30 +00:00
|
|
|
GeyserImpl.getInstance().reload();
|
2020-04-29 20:01:53 +00:00
|
|
|
}
|
|
|
|
|
2021-11-20 21:34:30 +00:00
|
|
|
public GeyserSession getPlayerByXuid(String xuid) {
|
2021-11-22 21:32:17 +00:00
|
|
|
org.geysermc.geyser.session.GeyserSession session = GeyserImpl.getInstance().connectionByXuid(xuid);
|
|
|
|
if (session != null) {
|
|
|
|
return new GeyserSession(session);
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
2020-04-19 23:08:14 +00:00
|
|
|
}
|
|
|
|
|
2021-11-20 21:34:30 +00:00
|
|
|
public GeyserSession getPlayerByUuid(UUID uuid) {
|
2021-11-22 21:32:17 +00:00
|
|
|
org.geysermc.geyser.session.GeyserSession session = GeyserImpl.getInstance().connectionByUuid(uuid);
|
|
|
|
if (session != null) {
|
|
|
|
return new GeyserSession(session);
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
2021-05-25 23:55:58 +00:00
|
|
|
}
|
|
|
|
|
2021-06-15 16:48:45 +00:00
|
|
|
public boolean isProductionEnvironment() {
|
2021-11-21 18:36:42 +00:00
|
|
|
return GeyserImpl.getInstance().productionEnvironment();
|
2019-12-21 17:35:48 +00:00
|
|
|
}
|
2019-07-08 17:55:14 +00:00
|
|
|
}
|