Update D4J and fix LuckPerms support
This commit is contained in:
parent
a9c71a3384
commit
4ecd32f0ad
4 changed files with 28 additions and 28 deletions
4
pom.xml
4
pom.xml
|
@ -180,7 +180,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.discord4j</groupId>
|
<groupId>com.discord4j</groupId>
|
||||||
<artifactId>discord4j-core</artifactId>
|
<artifactId>discord4j-core</artifactId>
|
||||||
<version>3.0.13</version>
|
<version>3.0.14</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-jdk14 -->
|
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-jdk14 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -233,7 +233,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.lucko</groupId>
|
<groupId>com.github.lucko</groupId>
|
||||||
<artifactId>LuckPerms</artifactId>
|
<artifactId>LuckPerms</artifactId>
|
||||||
<version>v4.4</version>
|
<version>master-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -36,7 +36,6 @@ import lombok.val;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
@ -129,7 +128,7 @@ public class DiscordPlugin extends ButtonPlugin {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val cb = new DiscordClientBuilder(token);
|
val cb = DiscordClientBuilder.create(token);
|
||||||
cb.setInitialPresence(Presence.doNotDisturb(Activity.playing("booting")));
|
cb.setInitialPresence(Presence.doNotDisturb(Activity.playing("booting")));
|
||||||
cb.setStoreService(new JdkStoreService()); //The default doesn't work for some reason - it's waaay faster now
|
cb.setStoreService(new JdkStoreService()); //The default doesn't work for some reason - it's waaay faster now
|
||||||
dc = cb.build();
|
dc = cb.build();
|
||||||
|
|
|
@ -147,6 +147,7 @@ public class MinecraftChatModule extends Component<DiscordPlugin> {
|
||||||
TBMCCoreAPI.SendException("Failed to init LuckPerms injector", e);
|
TBMCCoreAPI.SendException("Failed to init LuckPerms injector", e);
|
||||||
} catch (NoClassDefFoundError e) {
|
} catch (NoClassDefFoundError e) {
|
||||||
getPlugin().getLogger().info("No LuckPerms, not injecting");
|
getPlugin().getLogger().info("No LuckPerms, not injecting");
|
||||||
|
//e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ import buttondevteam.discordplugin.mcchat.MCChatUtils;
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitBootstrap;
|
import me.lucko.luckperms.bukkit.LPBukkitBootstrap;
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
import me.lucko.luckperms.bukkit.inject.dummy.DummyPermissibleBase;
|
import me.lucko.luckperms.bukkit.inject.permissible.DummyPermissibleBase;
|
||||||
import me.lucko.luckperms.bukkit.inject.permissible.LPPermissible;
|
import me.lucko.luckperms.bukkit.inject.permissible.LuckPermsPermissible;
|
||||||
import me.lucko.luckperms.bukkit.listeners.BukkitConnectionListener;
|
import me.lucko.luckperms.bukkit.listeners.BukkitConnectionListener;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
|
@ -31,16 +31,16 @@ import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
public final class LPInjector implements Listener { //Disable login event for LuckPerms
|
public final class LPInjector implements Listener { //Disable login event for LuckPerms
|
||||||
private LPBukkitPlugin plugin;
|
private final LPBukkitPlugin plugin;
|
||||||
private BukkitConnectionListener connectionListener;
|
private final BukkitConnectionListener connectionListener;
|
||||||
private Set<UUID> deniedLogin;
|
private final Set<UUID> deniedLogin;
|
||||||
private Field detectedCraftBukkitOfflineMode;
|
private final Field detectedCraftBukkitOfflineMode;
|
||||||
private Method printCraftBukkitOfflineModeError;
|
private final Method printCraftBukkitOfflineModeError;
|
||||||
private Field PERMISSIBLE_BASE_ATTACHMENTS_FIELD;
|
private final Field PERMISSIBLE_BASE_ATTACHMENTS_FIELD;
|
||||||
private Method convertAndAddAttachments;
|
private final Method convertAndAddAttachments;
|
||||||
private Method getActive;
|
private final Method getActive;
|
||||||
private Method setOldPermissible;
|
private final Method setOldPermissible;
|
||||||
private Method getOldPermissible;
|
private final Method getOldPermissible;
|
||||||
|
|
||||||
public LPInjector(MainPlugin mp) throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException {
|
public LPInjector(MainPlugin mp) throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException {
|
||||||
LPBukkitBootstrap bs = (LPBukkitBootstrap) Bukkit.getPluginManager().getPlugin("LuckPerms");
|
LPBukkitBootstrap bs = (LPBukkitBootstrap) Bukkit.getPluginManager().getPlugin("LuckPerms");
|
||||||
|
@ -68,13 +68,13 @@ public final class LPInjector implements Listener { //Disable login event for Lu
|
||||||
PERMISSIBLE_BASE_ATTACHMENTS_FIELD = PermissibleBase.class.getDeclaredField("attachments");
|
PERMISSIBLE_BASE_ATTACHMENTS_FIELD = PermissibleBase.class.getDeclaredField("attachments");
|
||||||
PERMISSIBLE_BASE_ATTACHMENTS_FIELD.setAccessible(true);
|
PERMISSIBLE_BASE_ATTACHMENTS_FIELD.setAccessible(true);
|
||||||
|
|
||||||
convertAndAddAttachments = LPPermissible.class.getDeclaredMethod("convertAndAddAttachments", Collection.class);
|
convertAndAddAttachments = LuckPermsPermissible.class.getDeclaredMethod("convertAndAddAttachments", Collection.class);
|
||||||
convertAndAddAttachments.setAccessible(true);
|
convertAndAddAttachments.setAccessible(true);
|
||||||
getActive = LPPermissible.class.getDeclaredMethod("getActive");
|
getActive = LuckPermsPermissible.class.getDeclaredMethod("getActive");
|
||||||
getActive.setAccessible(true);
|
getActive.setAccessible(true);
|
||||||
setOldPermissible = LPPermissible.class.getDeclaredMethod("setOldPermissible", PermissibleBase.class);
|
setOldPermissible = LuckPermsPermissible.class.getDeclaredMethod("setOldPermissible", PermissibleBase.class);
|
||||||
setOldPermissible.setAccessible(true);
|
setOldPermissible.setAccessible(true);
|
||||||
getOldPermissible = LPPermissible.class.getDeclaredMethod("getOldPermissible");
|
getOldPermissible = LuckPermsPermissible.class.getDeclaredMethod("getOldPermissible");
|
||||||
getOldPermissible.setAccessible(true);
|
getOldPermissible.setAccessible(true);
|
||||||
|
|
||||||
TBMCCoreAPI.RegisterEventsForExceptions(this, mp);
|
TBMCCoreAPI.RegisterEventsForExceptions(this, mp);
|
||||||
|
@ -92,9 +92,9 @@ public final class LPInjector implements Listener { //Disable login event for Lu
|
||||||
|
|
||||||
final DiscordConnectedPlayer player = (DiscordConnectedPlayer) e.getPlayer();
|
final DiscordConnectedPlayer player = (DiscordConnectedPlayer) e.getPlayer();
|
||||||
|
|
||||||
if (plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
|
/*if (plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
|
||||||
plugin.getLogger().info("Processing login for " + player.getUniqueId() + " - " + player.getName());
|
plugin.getLogger().info("Processing login for " + player.getUniqueId() + " - " + player.getName());
|
||||||
}
|
}*/
|
||||||
|
|
||||||
final User user = plugin.getUserManager().getIfLoaded(player.getUniqueId());
|
final User user = plugin.getUserManager().getIfLoaded(player.getUniqueId());
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ public final class LPInjector implements Listener { //Disable login event for Lu
|
||||||
PermissibleBase oldPermissible = player.getPerm();
|
PermissibleBase oldPermissible = player.getPerm();
|
||||||
|
|
||||||
// Make a new permissible for the user
|
// Make a new permissible for the user
|
||||||
LPPermissible lpPermissible = new LPPermissible(player, user, plugin);
|
LuckPermsPermissible lpPermissible = new LuckPermsPermissible(player, user, plugin);
|
||||||
|
|
||||||
// Inject into the player
|
// Inject into the player
|
||||||
inject(player, lpPermissible, oldPermissible);
|
inject(player, lpPermissible, oldPermissible);
|
||||||
|
@ -149,7 +149,7 @@ public final class LPInjector implements Listener { //Disable login event for Lu
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.refreshAutoOp(player, true);
|
//this.plugin.getContextManager().signalContextUpdate(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait until the last priority to unload, so plugins can still perform permission checks on this event
|
// Wait until the last priority to unload, so plugins can still perform permission checks on this event
|
||||||
|
@ -183,10 +183,10 @@ public final class LPInjector implements Listener { //Disable login event for Lu
|
||||||
}
|
}
|
||||||
|
|
||||||
//me.lucko.luckperms.bukkit.inject.permissible.PermissibleInjector
|
//me.lucko.luckperms.bukkit.inject.permissible.PermissibleInjector
|
||||||
private void inject(DiscordConnectedPlayer player, LPPermissible newPermissible, PermissibleBase oldPermissible) throws IllegalAccessException, InvocationTargetException {
|
private void inject(DiscordConnectedPlayer player, LuckPermsPermissible newPermissible, PermissibleBase oldPermissible) throws IllegalAccessException, InvocationTargetException {
|
||||||
|
|
||||||
// seems we have already injected into this player.
|
// seems we have already injected into this player.
|
||||||
if (oldPermissible instanceof LPPermissible) {
|
if (oldPermissible instanceof LuckPermsPermissible) {
|
||||||
throw new IllegalStateException("LPPermissible already injected into player " + player.toString());
|
throw new IllegalStateException("LPPermissible already injected into player " + player.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,8 +213,8 @@ public final class LPInjector implements Listener { //Disable login event for Lu
|
||||||
PermissibleBase permissible = player.getPerm();
|
PermissibleBase permissible = player.getPerm();
|
||||||
|
|
||||||
// only uninject if the permissible was a luckperms one.
|
// only uninject if the permissible was a luckperms one.
|
||||||
if (permissible instanceof LPPermissible) {
|
if (permissible instanceof LuckPermsPermissible) {
|
||||||
LPPermissible lpPermissible = ((LPPermissible) permissible);
|
LuckPermsPermissible lpPermissible = ((LuckPermsPermissible) permissible);
|
||||||
|
|
||||||
// clear all permissions
|
// clear all permissions
|
||||||
lpPermissible.clearPermissions();
|
lpPermissible.clearPermissions();
|
||||||
|
|
Loading…
Reference in a new issue