Fix LPInjector and player data stuff

This commit is contained in:
Norbi Peti 2020-10-25 21:49:09 +01:00
parent 40fe1093e0
commit fdcab1acb2
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
3 changed files with 10 additions and 6 deletions

View file

@ -206,8 +206,8 @@
<version>1.0.0.M3</version>
</dependency> -->
<dependency>
<groupId>com.github.lucko</groupId>
<artifactId>LuckPerms</artifactId>
<groupId>com.github.lucko.LuckPerms</groupId>
<artifactId>bukkit</artifactId>
<version>master-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

View file

@ -16,7 +16,7 @@ public class DiscordPlayer extends ChromaGamerBase {
public String getDiscordID() {
if (did == null)
did = plugindata.getString(getFolder() + "_id");
did = getFileName();
return did;
}

View file

@ -13,6 +13,7 @@ import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.locale.Message;
import me.lucko.luckperms.common.locale.TranslationManager;
import me.lucko.luckperms.common.model.User;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
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.
// Care should be taken at this stage to ensure that async tasks which manipulate bukkit data check that the player is still online.
try {
// get the existing PermissibleBase held by the player
PermissibleBase oldPermissible = player.getPerm();
// Make a new permissible for the user
LuckPermsPermissible lpPermissible = new LuckPermsPermissible(player, user, this.plugin);
// Inject into the player
inject(player, lpPermissible);
inject(player, lpPermissible, oldPermissible);
} catch (Throwable t) {
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();
handleDisconnect(player.getUniqueId());
connectionListener.handleDisconnect(player.getUniqueId());
// perform unhooking from bukkit objects 1 tick later.
// this allows plugins listening after us on MONITOR to still have intact permissions data
this.plugin.getBootstrap().getServer().getScheduler().runTaskLater(this.plugin.getBootstrap(), () -> {
// Remove the custom permissible
try {
uninject(player, true);
uninject(player);
} catch (Exception ex) {
ex.printStackTrace();
}