Skip to content

Commit bfeb340

Browse files
committed
Remove usage of PlayerLoginEvent
1 parent 9affef2 commit bfeb340

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

build.gradle.kts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ repositories {
1717
}
1818

1919
dependencies {
20-
compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT")
21-
compileOnlyApi("net.luckperms:api:5.4")
20+
compileOnly("io.papermc.paper:paper-api:1.21.9-R0.1-SNAPSHOT")
21+
compileOnlyApi("net.luckperms:api:5.5")
2222

2323
implementation("org.bstats:bstats-bukkit:3.1.0")
2424
}
@@ -40,18 +40,18 @@ publishing {
4040

4141
bukkit {
4242
main = "$group.cloudchat.CloudChatMain"
43-
apiVersion = "1.20"
43+
apiVersion = "1.21.7"
4444
authors = listOf("booky10")
4545
depend = listOf("LuckPerms")
4646
}
4747

4848
tasks {
4949
runServer {
50-
minecraftVersion("1.21.1")
50+
minecraftVersion("1.21.9")
5151

5252
downloadPlugins {
5353
// bukkit plugin is not available on modrinth/hangar/github/etc.
54-
url("https://download.luckperms.net/1556/bukkit/loader/LuckPerms-Bukkit-5.4.141.jar")
54+
url("https://download.luckperms.net/1602/bukkit/loader/LuckPerms-Bukkit-5.5.15.jar")
5555
}
5656
}
5757

@@ -104,7 +104,7 @@ publishMods {
104104

105105
projectId = "JIftXlPn"
106106
minecraftVersionRange {
107-
start = "1.20.6"
107+
start = "1.21.7"
108108
end = "latest"
109109
}
110110

src/main/java/dev/booky/cloudchat/JoinQuitListener.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package dev.booky.cloudchat;
22
// Created by booky10 in CloudChat (05:26 08.05.22)
33

4+
import com.destroystokyo.paper.profile.PlayerProfile;
5+
import io.papermc.paper.connection.PlayerConfigurationConnection;
6+
import io.papermc.paper.event.connection.PlayerConnectionValidateLoginEvent;
47
import org.bukkit.event.EventHandler;
58
import org.bukkit.event.EventPriority;
69
import org.bukkit.event.Listener;
7-
import org.bukkit.event.player.PlayerLoginEvent;
810
import org.bukkit.event.player.PlayerQuitEvent;
911

1012
class JoinQuitListener implements Listener {
@@ -16,10 +18,15 @@ public JoinQuitListener(CloudChatApi api) {
1618
}
1719

1820
@EventHandler(priority = EventPriority.MONITOR)
19-
public void onLogin(PlayerLoginEvent event) {
20-
if (event.getResult() == PlayerLoginEvent.Result.ALLOWED) {
21-
this.api.createTeam(event.getPlayer());
21+
public void onLogin(PlayerConnectionValidateLoginEvent event) {
22+
if (event.getKickMessage() != null) {
23+
return; // player will be kicked, don't create team
2224
}
25+
if (!(event.getConnection() instanceof PlayerConfigurationConnection connection)) {
26+
return; // player isn't exiting configuration phase, skip
27+
}
28+
PlayerProfile profile = connection.getProfile();
29+
this.api.createTeam(profile.getId(), profile.getName());
2330
}
2431

2532
@EventHandler(priority = EventPriority.MONITOR)

0 commit comments

Comments
 (0)