Fix LPInjector and player data stuff
This commit is contained in:
parent
40fe1093e0
commit
fdcab1acb2
3 changed files with 10 additions and 6 deletions
4
pom.xml
4
pom.xml
|
@ -206,8 +206,8 @@
|
||||||
<version>1.0.0.M3</version>
|
<version>1.0.0.M3</version>
|
||||||
</dependency> -->
|
</dependency> -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.lucko</groupId>
|
<groupId>com.github.lucko.LuckPerms</groupId>
|
||||||
<artifactId>LuckPerms</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>master-SNAPSHOT</version>
|
<version>master-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class DiscordPlayer extends ChromaGamerBase {
|
||||||
|
|
||||||
public String getDiscordID() {
|
public String getDiscordID() {
|
||||||
if (did == null)
|
if (did == null)
|
||||||
did = plugindata.getString(getFolder() + "_id");
|
did = getFileName();
|
||||||
return did;
|
return did;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.locale.Message;
|
import me.lucko.luckperms.common.locale.Message;
|
||||||
import me.lucko.luckperms.common.locale.TranslationManager;
|
import me.lucko.luckperms.common.locale.TranslationManager;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -136,11 +137,14 @@ public final class LPInjector implements Listener { //Disable login event for Lu
|
||||||
// User instance is there, now we can inject our custom Permissible into the player.
|
// User instance is there, now we can inject our custom Permissible into the player.
|
||||||
// Care should be taken at this stage to ensure that async tasks which manipulate bukkit data check that the player is still online.
|
// Care should be taken at this stage to ensure that async tasks which manipulate bukkit data check that the player is still online.
|
||||||
try {
|
try {
|
||||||
|
// get the existing PermissibleBase held by the player
|
||||||
|
PermissibleBase oldPermissible = player.getPerm();
|
||||||
|
|
||||||
// Make a new permissible for the user
|
// Make a new permissible for the user
|
||||||
LuckPermsPermissible lpPermissible = new LuckPermsPermissible(player, user, this.plugin);
|
LuckPermsPermissible lpPermissible = new LuckPermsPermissible(player, user, this.plugin);
|
||||||
|
|
||||||
// Inject into the player
|
// Inject into the player
|
||||||
inject(player, lpPermissible);
|
inject(player, lpPermissible, oldPermissible);
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
plugin.getLogger().warn("Exception thrown when setting up permissions for " +
|
plugin.getLogger().warn("Exception thrown when setting up permissions for " +
|
||||||
|
@ -163,14 +167,14 @@ public final class LPInjector implements Listener { //Disable login event for Lu
|
||||||
|
|
||||||
final DiscordConnectedPlayer player = (DiscordConnectedPlayer) e.getPlayer();
|
final DiscordConnectedPlayer player = (DiscordConnectedPlayer) e.getPlayer();
|
||||||
|
|
||||||
handleDisconnect(player.getUniqueId());
|
connectionListener.handleDisconnect(player.getUniqueId());
|
||||||
|
|
||||||
// perform unhooking from bukkit objects 1 tick later.
|
// perform unhooking from bukkit objects 1 tick later.
|
||||||
// this allows plugins listening after us on MONITOR to still have intact permissions data
|
// this allows plugins listening after us on MONITOR to still have intact permissions data
|
||||||
this.plugin.getBootstrap().getServer().getScheduler().runTaskLater(this.plugin.getBootstrap(), () -> {
|
this.plugin.getBootstrap().getServer().getScheduler().runTaskLater(this.plugin.getBootstrap(), () -> {
|
||||||
// Remove the custom permissible
|
// Remove the custom permissible
|
||||||
try {
|
try {
|
||||||
uninject(player, true);
|
uninject(player);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue