Skip to content

Commit 28480a0

Browse files
author
games647
committed
Add floodgate service to Bungee
1 parent a3bf875 commit 28480a0

File tree

9 files changed

+30
-11
lines changed

9 files changed

+30
-11
lines changed

bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.bukkit.entity.Player;
5454
import org.bukkit.plugin.PluginManager;
5555
import org.bukkit.plugin.java.JavaPlugin;
56+
import org.geysermc.floodgate.api.FloodgateApi;
5657
import org.slf4j.Logger;
5758

5859
/**
@@ -146,7 +147,7 @@ public void onEnable() {
146147

147148
private boolean initializeFloodgate() {
148149
if (getServer().getPluginManager().getPlugin("Floodgate") != null) {
149-
floodgateService = new FloodgateService(core);
150+
floodgateService = new FloodgateService(FloodgateApi.getInstance(), core);
150151
}
151152

152153
// Check Floodgate config values

bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class NameCheckTask extends JoinManagement<Player, CommandSender, Protoco
5454

5555
public NameCheckTask(FastLoginBukkit plugin, Random random, Player player, PacketEvent packetEvent,
5656
String username, PublicKey publicKey) {
57-
super(plugin.getCore(), plugin.getCore().getAuthPluginHook(), plugin.getCore().getFloodgateService());
57+
super(plugin.getCore(), plugin.getCore().getAuthPluginHook(), plugin.getFloodgateService());
5858

5959
this.plugin = plugin;
6060
this.packetEvent = packetEvent;

bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolSupportListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class ProtocolSupportListener extends JoinManagement<Player, CommandSende
5353
private final RateLimiter rateLimiter;
5454

5555
public ProtocolSupportListener(FastLoginBukkit plugin, RateLimiter rateLimiter) {
56-
super(plugin.getCore(), plugin.getCore().getAuthPluginHook());
56+
super(plugin.getCore(), plugin.getCore().getAuthPluginHook(), plugin.getFloodgateService());
5757

5858
this.plugin = plugin;
5959
this.rateLimiter = rateLimiter;

bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.github.games647.fastlogin.core.AsyncScheduler;
3434
import com.github.games647.fastlogin.core.CommonUtil;
3535
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
36+
import com.github.games647.fastlogin.core.hooks.FloodgateService;
3637
import com.github.games647.fastlogin.core.message.ChangePremiumMessage;
3738
import com.github.games647.fastlogin.core.message.ChannelMessage;
3839
import com.github.games647.fastlogin.core.message.NamespaceKey;
@@ -59,6 +60,7 @@
5960
import net.md_5.bungee.api.plugin.PluginManager;
6061
import net.md_5.bungee.api.scheduler.GroupedThreadFactory;
6162

63+
import org.geysermc.floodgate.api.FloodgateApi;
6264
import org.slf4j.Logger;
6365

6466
/**
@@ -70,6 +72,7 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
7072

7173
private FastLoginCore<ProxiedPlayer, CommandSender, FastLoginBungee> core;
7274
private AsyncScheduler scheduler;
75+
private FloodgateService floodgateService;
7376
private Logger logger;
7477

7578
@Override
@@ -83,6 +86,10 @@ public void onEnable() {
8386
return;
8487
}
8588

89+
if (isPluginInstalled("Floodgate")) {
90+
floodgateService = new FloodgateService(FloodgateApi.getInstance(), core);
91+
}
92+
8693
//events
8794
PluginManager pluginManager = getProxy().getPluginManager();
8895

@@ -185,4 +192,9 @@ public AsyncScheduler getScheduler() {
185192
public boolean isPluginInstalled(String name) {
186193
return getProxy().getPluginManager().getPlugin(name) != null;
187194
}
195+
196+
@Override
197+
public FloodgateService getFloodgateService() {
198+
return floodgateService;
199+
}
188200
}

bungee/src/main/java/com/github/games647/fastlogin/bungee/task/AsyncPremiumCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class AsyncPremiumCheck extends JoinManagement<ProxiedPlayer, CommandSend
4949

5050
public AsyncPremiumCheck(FastLoginBungee plugin, PreLoginEvent preLoginEvent, PendingConnection connection,
5151
String username) {
52-
super(plugin.getCore(), plugin.getCore().getAuthPluginHook());
52+
super(plugin.getCore(), plugin.getCore().getAuthPluginHook(), plugin.getFloodgateService());
5353

5454
this.plugin = plugin;
5555
this.preLoginEvent = preLoginEvent;

core/src/main/java/com/github/games647/fastlogin/core/hooks/FloodgateService.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@
4141

4242
public class FloodgateService {
4343

44+
private final FloodgateApi floodgate;
4445
private final FastLoginCore<?, ?, ?> core;
4546

46-
public FloodgateService(FastLoginCore<?, ?, ?> core) {
47+
public FloodgateService(FloodgateApi floodgate, FastLoginCore<?, ?, ?> core) {
48+
this.floodgate = floodgate;
4749
this.core = core;
4850
}
4951

@@ -84,10 +86,11 @@ public boolean isUsernameForbidden(StoredProfile profile) {
8486
* @param username the name of the player
8587
* @param source an instance of LoginSource
8688
*/
87-
public void checkFloodgateNameConflict(String username, LoginSource source, FloodgatePlayer floodgatePlayer) {
89+
public void checkNameConflict(String username, LoginSource source) {
8890
String allowConflict = core.getConfig().get("allowFloodgateNameConflict").toString().toLowerCase();
8991

9092
// check if the Bedrock player is linked to a Java account
93+
FloodgatePlayer floodgatePlayer = getFloodgatePlayer(username);
9194
boolean isLinked = floodgatePlayer.getLinkedPlayer() != null;
9295

9396
if ("false".equals(allowConflict)
@@ -151,6 +154,5 @@ public boolean isFloodgatePlayer(UUID uuid) {
151154

152155
public boolean isFloodgateConnection(String username) {
153156
return getFloodgatePlayer(username) != null;
154-
155157
}
156158
}

core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636

3737
import net.md_5.bungee.config.Configuration;
3838

39-
import org.geysermc.floodgate.api.player.FloodgatePlayer;
40-
4139
public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
4240

4341
protected final FastLoginCore<P, C, ?> core;
@@ -60,7 +58,7 @@ public void onLogin(String username, S source) {
6058
//check if the player is connecting through Floodgate
6159
if (floodgateService != null) {
6260
if (floodgateService.isFloodgateConnection(username)) {
63-
floodgateService.checkFloodgateNameConflict(username, source, floodgatePlayer);
61+
floodgateService.checkNameConflict(username, source);
6462
// skip flow for any floodgate player
6563
return;
6664
}

velocity/src/main/java/com/github/games647/fastlogin/velocity/FastLoginVelocity.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
package com.github.games647.fastlogin.velocity;
2727

2828
import com.github.games647.fastlogin.core.AsyncScheduler;
29+
import com.github.games647.fastlogin.core.hooks.FloodgateService;
2930
import com.github.games647.fastlogin.core.message.ChangePremiumMessage;
3031
import com.github.games647.fastlogin.core.message.ChannelMessage;
3132
import com.github.games647.fastlogin.core.message.SuccessMessage;
@@ -138,6 +139,11 @@ public boolean isPluginInstalled(String name) {
138139
return server.getPluginManager().isLoaded(name);
139140
}
140141

142+
@Override
143+
public FloodgateService getFloodgateService() {
144+
return null;
145+
}
146+
141147
public FastLoginCore<Player, CommandSource, FastLoginVelocity> getCore() {
142148
return core;
143149
}

velocity/src/main/java/com/github/games647/fastlogin/velocity/task/AsyncPremiumCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class AsyncPremiumCheck extends JoinManagement<Player, CommandSource, Vel
5050
private final InboundConnection connection;
5151

5252
public AsyncPremiumCheck(FastLoginVelocity plugin, InboundConnection connection, String username, Continuation continuation, PreLoginEvent preLoginEvent) {
53-
super(plugin.getCore(), plugin.getCore().getAuthPluginHook());
53+
super(plugin.getCore(), plugin.getCore().getAuthPluginHook(), plugin.getFloodgateService());
5454
this.plugin = plugin;
5555
this.connection = connection;
5656
this.username = username;

0 commit comments

Comments
 (0)