Create stub GeyserService

The FloodgateService and GeyserService classes are not merged,
because Geyser can work without Floodgate.
Added Geyser as 'softdepends' in plugin.yml and bungee.yml
to make it load before FastLogin.
Also made Floodgate a soft dependency in bungee.yml.
This commit is contained in:
Smart123s
2021-10-23 10:09:04 +02:00
committed by games647
parent 5612ca744b
commit 3ee6cb2ada
10 changed files with 136 additions and 0 deletions

View File

@ -209,6 +209,14 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Bedrock player bridge, used for low level checks -->
<dependency>
<groupId>org.geysermc</groupId>
<artifactId>connector</artifactId>
<version>1.4.3-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--Login Plugins--> <!--Login Plugins-->
<dependency> <dependency>
<groupId>fr.xephi</groupId> <groupId>fr.xephi</groupId>

View File

@ -36,6 +36,7 @@ import com.github.games647.fastlogin.bukkit.task.DelayedAuthHook;
import com.github.games647.fastlogin.core.CommonUtil; import com.github.games647.fastlogin.core.CommonUtil;
import com.github.games647.fastlogin.core.PremiumStatus; import com.github.games647.fastlogin.core.PremiumStatus;
import com.github.games647.fastlogin.core.hooks.FloodgateService; import com.github.games647.fastlogin.core.hooks.FloodgateService;
import com.github.games647.fastlogin.core.hooks.GeyserService;
import com.github.games647.fastlogin.core.shared.FastLoginCore; import com.github.games647.fastlogin.core.shared.FastLoginCore;
import com.github.games647.fastlogin.core.shared.PlatformPlugin; import com.github.games647.fastlogin.core.shared.PlatformPlugin;
@ -53,6 +54,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.floodgate.api.FloodgateApi; import org.geysermc.floodgate.api.FloodgateApi;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -71,6 +73,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
private final BukkitScheduler scheduler; private final BukkitScheduler scheduler;
private FastLoginCore<Player, CommandSender, FastLoginBukkit> core; private FastLoginCore<Player, CommandSender, FastLoginBukkit> core;
private FloodgateService floodgateService; private FloodgateService floodgateService;
private GeyserService geyserService;
private PremiumPlaceholder premiumPlaceholder; private PremiumPlaceholder premiumPlaceholder;
@ -146,6 +149,10 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
} }
private boolean initializeFloodgate() { private boolean initializeFloodgate() {
if (getServer().getPluginManager().getPlugin("Geyser-Spigot") != null) {
geyserService = new GeyserService(GeyserConnector.getInstance(), core);
}
if (getServer().getPluginManager().getPlugin("floodgate") != null) { if (getServer().getPluginManager().getPlugin("floodgate") != null) {
floodgateService = new FloodgateService(FloodgateApi.getInstance(), core); floodgateService = new FloodgateService(FloodgateApi.getInstance(), core);
@ -281,6 +288,11 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
return floodgateService; return floodgateService;
} }
@Override
public GeyserService getGeyserService() {
return geyserService;
}
/** /**
* Send warning messages to log if incompatible plugins are used * Send warning messages to log if incompatible plugins are used
*/ */

View File

@ -20,6 +20,8 @@ softdepend:
- ProtocolLib - ProtocolLib
# Premium variable # Premium variable
- PlaceholderAPI - PlaceholderAPI
# Bedrock Player Bridge
- Geyser-Spigot
- floodgate - floodgate
# Auth plugins # Auth plugins
- AuthMe - AuthMe

View File

@ -141,6 +141,14 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Bedrock player bridge, used for low level checks -->
<dependency>
<groupId>org.geysermc</groupId>
<artifactId>connector</artifactId>
<version>1.4.3-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--Login plugin--> <!--Login plugin-->
<dependency> <dependency>
<groupId>me.vik1395</groupId> <groupId>me.vik1395</groupId>

View File

@ -34,6 +34,7 @@ import com.github.games647.fastlogin.core.AsyncScheduler;
import com.github.games647.fastlogin.core.CommonUtil; import com.github.games647.fastlogin.core.CommonUtil;
import com.github.games647.fastlogin.core.hooks.AuthPlugin; import com.github.games647.fastlogin.core.hooks.AuthPlugin;
import com.github.games647.fastlogin.core.hooks.FloodgateService; import com.github.games647.fastlogin.core.hooks.FloodgateService;
import com.github.games647.fastlogin.core.hooks.GeyserService;
import com.github.games647.fastlogin.core.message.ChangePremiumMessage; import com.github.games647.fastlogin.core.message.ChangePremiumMessage;
import com.github.games647.fastlogin.core.message.ChannelMessage; import com.github.games647.fastlogin.core.message.ChannelMessage;
import com.github.games647.fastlogin.core.message.NamespaceKey; import com.github.games647.fastlogin.core.message.NamespaceKey;
@ -60,6 +61,7 @@ import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.api.plugin.PluginManager; import net.md_5.bungee.api.plugin.PluginManager;
import net.md_5.bungee.api.scheduler.GroupedThreadFactory; import net.md_5.bungee.api.scheduler.GroupedThreadFactory;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.floodgate.api.FloodgateApi; import org.geysermc.floodgate.api.FloodgateApi;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -73,6 +75,7 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
private FastLoginCore<ProxiedPlayer, CommandSender, FastLoginBungee> core; private FastLoginCore<ProxiedPlayer, CommandSender, FastLoginBungee> core;
private AsyncScheduler scheduler; private AsyncScheduler scheduler;
private FloodgateService floodgateService; private FloodgateService floodgateService;
private GeyserService geyserService;
private Logger logger; private Logger logger;
@Override @Override
@ -90,6 +93,10 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
floodgateService = new FloodgateService(FloodgateApi.getInstance(), core); floodgateService = new FloodgateService(FloodgateApi.getInstance(), core);
} }
if (isPluginInstalled("Geyser-BungeeCord")) {
geyserService = new GeyserService(GeyserConnector.getInstance(), core);
}
//events //events
PluginManager pluginManager = getProxy().getPluginManager(); PluginManager pluginManager = getProxy().getPluginManager();
@ -197,4 +204,9 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
public FloodgateService getFloodgateService() { public FloodgateService getFloodgateService() {
return floodgateService; return floodgateService;
} }
@Override
public GeyserService getGeyserService() {
return geyserService;
}
} }

View File

@ -13,6 +13,9 @@ softDepends:
- BungeeAuth - BungeeAuth
- BungeeCordAuthenticatorBungee - BungeeCordAuthenticatorBungee
- SodionAuth - SodionAuth
# Bedrock Player Bridge
- Geyser-BungeeCord
- floodgate
description: | description: |
${project.description} ${project.description}

View File

@ -98,6 +98,14 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Bedrock player bridge -->
<dependency>
<groupId>org.geysermc</groupId>
<artifactId>connector</artifactId>
<version>1.4.3-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--Common component for contacting the Mojang API--> <!--Common component for contacting the Mojang API-->
<dependency> <dependency>
<groupId>com.github.games647</groupId> <groupId>com.github.games647</groupId>

View File

@ -0,0 +1,74 @@
/*
* SPDX-License-Identifier: MIT
*
* The MIT License (MIT)
*
* Copyright (c) 2015-2021 <Your name and contributors>
*
* 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.
*/
package com.github.games647.fastlogin.core.hooks;
import java.util.UUID;
import com.github.games647.fastlogin.core.shared.FastLoginCore;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.session.GeyserSession;
public class GeyserService {
private final GeyserConnector geyser;
private final FastLoginCore<?, ?, ?> core;
public GeyserService(GeyserConnector geyser, FastLoginCore<?, ?, ?> core) {
this.geyser = geyser;
this.core = core;
}
/**
* The Geyser API does not support querying players by name, so this function
* iterates over every online Geyser Player and checks if the requested
* username can be found
*
* @param username the name of the player
* @return GeyserSession if found, null otherwise
*/
public GeyserSession getGeyserPlayer(String username) {
for (GeyserSession gSess : geyser.getSessionManager().getSessions().values()) {
if (gSess.getName().equals(username)) {
return gSess;
}
}
return null;
}
public GeyserSession getGeyserPlayer(UUID uuid) {
return geyser.getPlayerByUuid(uuid);
}
public boolean isGeyserPlayer(UUID uuid) {
return getGeyserPlayer(uuid) != null;
}
public boolean isGeyserConnection(String username) {
return getGeyserPlayer(username) != null;
}
}

View File

@ -27,6 +27,7 @@ package com.github.games647.fastlogin.core.shared;
import com.github.games647.fastlogin.core.AsyncScheduler; import com.github.games647.fastlogin.core.AsyncScheduler;
import com.github.games647.fastlogin.core.hooks.FloodgateService; import com.github.games647.fastlogin.core.hooks.FloodgateService;
import com.github.games647.fastlogin.core.hooks.GeyserService;
import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.nio.file.Path; import java.nio.file.Path;
@ -56,6 +57,8 @@ public interface PlatformPlugin<C> {
FloodgateService getFloodgateService(); FloodgateService getFloodgateService();
GeyserService getGeyserService();
default ThreadFactory getThreadFactory() { default ThreadFactory getThreadFactory() {
return new ThreadFactoryBuilder() return new ThreadFactoryBuilder()
.setNameFormat(getName() + " Pool Thread #%1$d") .setNameFormat(getName() + " Pool Thread #%1$d")

View File

@ -27,6 +27,7 @@ package com.github.games647.fastlogin.velocity;
import com.github.games647.fastlogin.core.AsyncScheduler; import com.github.games647.fastlogin.core.AsyncScheduler;
import com.github.games647.fastlogin.core.hooks.FloodgateService; import com.github.games647.fastlogin.core.hooks.FloodgateService;
import com.github.games647.fastlogin.core.hooks.GeyserService;
import com.github.games647.fastlogin.core.message.ChangePremiumMessage; import com.github.games647.fastlogin.core.message.ChangePremiumMessage;
import com.github.games647.fastlogin.core.message.ChannelMessage; import com.github.games647.fastlogin.core.message.ChannelMessage;
import com.github.games647.fastlogin.core.message.SuccessMessage; import com.github.games647.fastlogin.core.message.SuccessMessage;
@ -144,6 +145,11 @@ public class FastLoginVelocity implements PlatformPlugin<CommandSource> {
return null; return null;
} }
@Override
public GeyserService getGeyserService() {
return null;
}
public FastLoginCore<Player, CommandSource, FastLoginVelocity> getCore() { public FastLoginCore<Player, CommandSource, FastLoginVelocity> getCore() {
return core; return core;
} }