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

View File

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

View File

@ -141,6 +141,14 @@
<scope>provided</scope>
</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-->
<dependency>
<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.hooks.AuthPlugin;
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.ChannelMessage;
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.scheduler.GroupedThreadFactory;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.floodgate.api.FloodgateApi;
import org.slf4j.Logger;
@ -73,6 +75,7 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
private FastLoginCore<ProxiedPlayer, CommandSender, FastLoginBungee> core;
private AsyncScheduler scheduler;
private FloodgateService floodgateService;
private GeyserService geyserService;
private Logger logger;
@Override
@ -90,6 +93,10 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
floodgateService = new FloodgateService(FloodgateApi.getInstance(), core);
}
if (isPluginInstalled("Geyser-BungeeCord")) {
geyserService = new GeyserService(GeyserConnector.getInstance(), core);
}
//events
PluginManager pluginManager = getProxy().getPluginManager();
@ -197,4 +204,9 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
public FloodgateService getFloodgateService() {
return floodgateService;
}
@Override
public GeyserService getGeyserService() {
return geyserService;
}
}

View File

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

View File

@ -98,6 +98,14 @@
<scope>provided</scope>
</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-->
<dependency>
<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.hooks.FloodgateService;
import com.github.games647.fastlogin.core.hooks.GeyserService;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.nio.file.Path;
@ -56,6 +57,8 @@ public interface PlatformPlugin<C> {
FloodgateService getFloodgateService();
GeyserService getGeyserService();
default ThreadFactory getThreadFactory() {
return new ThreadFactoryBuilder()
.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.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.ChannelMessage;
import com.github.games647.fastlogin.core.message.SuccessMessage;
@ -144,6 +145,11 @@ public class FastLoginVelocity implements PlatformPlugin<CommandSource> {
return null;
}
@Override
public GeyserService getGeyserService() {
return null;
}
public FastLoginCore<Player, CommandSource, FastLoginVelocity> getCore() {
return core;
}