Skip to content

Commit ccdc455

Browse files
author
games647
committed
Clarify naming and structure
1 parent 4e1f5e9 commit ccdc455

File tree

10 files changed

+21
-25
lines changed

10 files changed

+21
-25
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import com.github.games647.fastlogin.bukkit.command.CrackedCommand;
2929
import com.github.games647.fastlogin.bukkit.command.PremiumCommand;
3030
import com.github.games647.fastlogin.bukkit.listener.ConnectionListener;
31-
import com.github.games647.fastlogin.bukkit.listener.PaperPreLoginListener;
31+
import com.github.games647.fastlogin.bukkit.listener.PaperCacheListener;
3232
import com.github.games647.fastlogin.bukkit.listener.protocollib.ProtocolLibListener;
3333
import com.github.games647.fastlogin.bukkit.listener.protocollib.SkinApplyListener;
3434
import com.github.games647.fastlogin.bukkit.listener.protocolsupport.ProtocolSupportListener;
@@ -131,7 +131,7 @@ public void onEnable() {
131131

132132
//if server is using paper - we need to add one more listener to correct the usercache usage
133133
if (PaperLib.isPaper()) {
134-
pluginManager.registerEvents(new PaperPreLoginListener(this), this);
134+
pluginManager.registerEvents(new PaperCacheListener(this), this);
135135
}
136136

137137
//register commands using a unique name

bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/PaperPreLoginListener.java renamed to bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/PaperCacheListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
3636
import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result;
3737

38-
public class PaperPreLoginListener implements Listener {
38+
public class PaperCacheListener implements Listener {
3939

4040
private final FastLoginBukkit plugin;
4141

42-
public PaperPreLoginListener(final FastLoginBukkit plugin) {
42+
public PaperCacheListener(final FastLoginBukkit plugin) {
4343
this.plugin = plugin;
4444
}
4545

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ public class NameCheckTask extends JoinManagement<Player, CommandSender, Protoco
5252
private final Player player;
5353
private final String username;
5454

55-
56-
public NameCheckTask(FastLoginBukkit plugin, PacketEvent packetEvent, Random random,
57-
Player player, String username, PublicKey publicKey) {
55+
public NameCheckTask(FastLoginBukkit plugin, Random random, Player player, PacketEvent packetEvent,
56+
String username, PublicKey publicKey) {
5857
super(plugin.getCore(), plugin.getCore().getAuthPluginHook());
5958

6059
this.plugin = plugin;
@@ -68,7 +67,7 @@ public NameCheckTask(FastLoginBukkit plugin, PacketEvent packetEvent, Random ran
6867
@Override
6968
public void run() {
7069
try {
71-
super.onLogin(username, new ProtocolLibLoginSource(packetEvent, player, random, publicKey));
70+
super.onLogin(username, new ProtocolLibLoginSource(player, random, publicKey));
7271
} finally {
7372
ProtocolLibrary.getProtocolManager().getAsynchronousManager().signalPacketTransmission(packetEvent);
7473
}
@@ -87,7 +86,7 @@ public FastLoginPreLoginEvent callFastLoginPreLoginEvent(String username, Protoc
8786
public void requestPremiumLogin(ProtocolLibLoginSource source, StoredProfile profile
8887
, String username, boolean registered) {
8988
try {
90-
source.setOnlineMode();
89+
source.enableOnlinemode();
9190
} catch (Exception ex) {
9291
plugin.getLog().error("Cannot send encryption packet. Falling back to cracked login for: {}", profile, ex);
9392
return;

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public ProtocolLibListener(FastLoginBukkit plugin, RateLimiter rateLimiter) {
6464
}
6565

6666
public static void register(FastLoginBukkit plugin, RateLimiter rateLimiter) {
67-
//they will be created with a static builder, because otherwise it will throw a NoClassDefFoundError
67+
// they will be created with a static builder, because otherwise it will throw a NoClassDefFoundError
68+
// TODO: make synchronous processing, but do web or database requests async
6869
ProtocolLibrary.getProtocolManager()
6970
.getAsynchronousManager()
7071
.registerAsyncHandler(new ProtocolLibListener(plugin, rateLimiter))
@@ -74,7 +75,7 @@ public static void register(FastLoginBukkit plugin, RateLimiter rateLimiter) {
7475
@Override
7576
public void onPacketReceiving(PacketEvent packetEvent) {
7677
if (packetEvent.isCancelled()
77-
|| plugin.getCore().getAuthPluginHook()== null
78+
|| plugin.getCore().getAuthPluginHook() == null
7879
|| !plugin.isServerFullyStarted()) {
7980
return;
8081
}
@@ -120,7 +121,7 @@ private void onLogin(PacketEvent packetEvent, Player player) {
120121
plugin.getLog().trace("GameProfile {} with {} connecting", sessionKey, username);
121122

122123
packetEvent.getAsyncMarker().incrementProcessingDelay();
123-
Runnable nameCheckTask = new NameCheckTask(plugin, packetEvent, random, player, username, keyPair.getPublic());
124+
Runnable nameCheckTask = new NameCheckTask(plugin, random, player, packetEvent, username, keyPair.getPublic());
124125
plugin.getScheduler().runAsync(nameCheckTask);
125126
}
126127
}

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import com.comphenix.protocol.ProtocolLibrary;
2929
import com.comphenix.protocol.ProtocolManager;
3030
import com.comphenix.protocol.events.PacketContainer;
31-
import com.comphenix.protocol.events.PacketEvent;
3231
import com.comphenix.protocol.reflect.StructureModifier;
3332
import com.comphenix.protocol.wrappers.WrappedChatComponent;
3433
import com.github.games647.fastlogin.core.shared.LoginSource;
@@ -46,7 +45,6 @@
4645

4746
class ProtocolLibLoginSource implements LoginSource {
4847

49-
private final PacketEvent packetEvent;
5048
private final Player player;
5149

5250
private final Random random;
@@ -55,15 +53,14 @@ class ProtocolLibLoginSource implements LoginSource {
5553
private final String serverId = "";
5654
private byte[] verifyToken;
5755

58-
public ProtocolLibLoginSource(PacketEvent packetEvent, Player player, Random random, PublicKey publicKey) {
59-
this.packetEvent = packetEvent;
56+
public ProtocolLibLoginSource(Player player, Random random, PublicKey publicKey) {
6057
this.player = player;
6158
this.random = random;
6259
this.publicKey = publicKey;
6360
}
6461

6562
@Override
66-
public void setOnlineMode() throws Exception {
63+
public void enableOnlinemode() throws Exception {
6764
verifyToken = EncryptionUtil.generateVerifyToken(random);
6865

6966
/*
@@ -109,7 +106,7 @@ public void kick(String message) throws InvocationTargetException {
109106

110107
@Override
111108
public InetSocketAddress getAddress() {
112-
return packetEvent.getPlayer().getAddress();
109+
return player.getAddress();
113110
}
114111

115112
public String getServerId() {
@@ -123,8 +120,7 @@ public byte[] getVerifyToken() {
123120
@Override
124121
public String toString() {
125122
return this.getClass().getSimpleName() + '{' +
126-
"packetEvent=" + packetEvent +
127-
", player=" + player +
123+
"player=" + player +
128124
", random=" + random +
129125
", serverId='" + serverId + '\'' +
130126
", verifyToken=" + Arrays.toString(verifyToken) +

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public ProtocolLoginSource(PlayerLoginStartEvent loginStartEvent) {
4040
}
4141

4242
@Override
43-
public void setOnlineMode() {
43+
public void enableOnlinemode() {
4444
loginStartEvent.setOnlineMode(true);
4545
}
4646

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
@@ -112,7 +112,7 @@ public FastLoginPreLoginEvent callFastLoginPreLoginEvent(String username, Protoc
112112
@Override
113113
public void requestPremiumLogin(ProtocolLoginSource source, StoredProfile profile, String username
114114
, boolean registered) {
115-
source.setOnlineMode();
115+
source.enableOnlinemode();
116116

117117
String ip = source.getAddress().getAddress().getHostAddress();
118118
plugin.getCore().getPendingLogin().put(ip + username, new Object());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public BungeeLoginSource(PendingConnection connection, PreLoginEvent preLoginEve
4646
}
4747

4848
@Override
49-
public void setOnlineMode() {
49+
public void enableOnlinemode() {
5050
connection.setOnlineMode(true);
5151
}
5252

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
@@ -78,7 +78,7 @@ public FastLoginPreLoginEvent callFastLoginPreLoginEvent(String username, Bungee
7878
@Override
7979
public void requestPremiumLogin(BungeeLoginSource source, StoredProfile profile,
8080
String username, boolean registered) {
81-
source.setOnlineMode();
81+
source.enableOnlinemode();
8282
plugin.getSession().put(source.getConnection(), new BungeeLoginSession(username, registered, profile));
8383

8484
String ip = source.getAddress().getAddress().getHostAddress();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
public interface LoginSource {
3131

32-
void setOnlineMode() throws Exception;
32+
void enableOnlinemode() throws Exception;
3333

3434
void kick(String message) throws Exception;
3535

0 commit comments

Comments
 (0)