mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2024-12-27 17:28:23 +01:00
Handle integrations loading later better
This commit is contained in:
parent
2cbb2ede2f
commit
56c1baa830
@ -240,6 +240,7 @@ public class BukkitDiscordSRV extends AbstractDiscordSRV<DiscordSRVBukkitBootstr
|
|||||||
protected void disable() {
|
protected void disable() {
|
||||||
super.disable();
|
super.disable();
|
||||||
|
|
||||||
|
pluginManager.disable();
|
||||||
audiences.close();
|
audiences.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,26 +69,9 @@ public class DiscordSRVBukkitBootstrap extends BukkitBootstrap implements IBoots
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
lifecycleManager.loadAndEnable(() -> this.discordSRV = new BukkitDiscordSRV(this));
|
lifecycleManager.loadAndEnable(() -> this.discordSRV = new BukkitDiscordSRV(this));
|
||||||
|
if (discordSRV == null) return;
|
||||||
|
|
||||||
boolean isFolia = false;
|
discordSRV.scheduler().runOnMainThreadLaterInTicks(() -> discordSRV.invokeServerStarted(), 1);
|
||||||
try {
|
|
||||||
Class.forName("io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler");
|
|
||||||
isFolia = true;
|
|
||||||
} catch (ClassNotFoundException ignored) {}
|
|
||||||
|
|
||||||
if (isFolia) {
|
|
||||||
if (discordSRV != null) {
|
|
||||||
discordSRV.invokeServerStarted();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run a task on the main thread 1 tick later, so essentially when the server has finished booting
|
|
||||||
getPlugin().getServer().getScheduler().runTaskLater(getPlugin(), () -> {
|
|
||||||
if (discordSRV != null) {
|
|
||||||
discordSRV.invokeServerStarted();
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -60,7 +60,7 @@ public class EssentialsXIntegration
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getIntegrationName() {
|
public @NotNull String getIntegrationId() {
|
||||||
return "Essentials";
|
return "Essentials";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ public class EssentialsXIntegration
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getOwnerName() {
|
public @NotNull String getOwnerName() {
|
||||||
return getIntegrationName();
|
return getIntegrationId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -50,7 +50,7 @@ public class PlaceholderAPIIntegration extends PluginIntegration<BukkitDiscordSR
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getIntegrationName() {
|
public @NotNull String getIntegrationId() {
|
||||||
return "PlaceholderAPI";
|
return "PlaceholderAPI";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class VaultIntegration extends PluginIntegration<BukkitDiscordSRV> implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getIntegrationName() {
|
public @NotNull String getIntegrationId() {
|
||||||
return "Vault";
|
return "Vault";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class ChattyChatIntegration extends PluginIntegration<BukkitDiscordSRV> i
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getIntegrationName() {
|
public @NotNull String getIntegrationId() {
|
||||||
return "Chatty";
|
return "Chatty";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ public class ChattyChatIntegration extends PluginIntegration<BukkitDiscordSRV> i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getOwnerName() {
|
public @NotNull String getOwnerName() {
|
||||||
return getIntegrationName();
|
return getIntegrationId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,7 +35,7 @@ public class GriefPreventionChatIntegration extends PluginIntegration<BukkitDisc
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getIntegrationName() {
|
public @NotNull String getIntegrationId() {
|
||||||
return "GriefPrevention";
|
return "GriefPrevention";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +52,8 @@ public class GriefPreventionChatIntegration extends PluginIntegration<BukkitDisc
|
|||||||
|
|
||||||
@Subscribe(priority = EventPriority.EARLY)
|
@Subscribe(priority = EventPriority.EARLY)
|
||||||
public void onGameChatMessageReceive(GameChatMessageReceiveEvent event) {
|
public void onGameChatMessageReceive(GameChatMessageReceiveEvent event) {
|
||||||
GriefPrevention griefPrevention = (GriefPrevention) discordSRV.server().getPluginManager().getPlugin(getIntegrationName());
|
GriefPrevention griefPrevention = (GriefPrevention) discordSRV.server().getPluginManager().getPlugin(
|
||||||
|
getIntegrationId());
|
||||||
if (griefPrevention == null) {
|
if (griefPrevention == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ public class LunaChatIntegration extends PluginIntegration<BukkitDiscordSRV> imp
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getIntegrationName() {
|
public @NotNull String getIntegrationId() {
|
||||||
return "LunaChat";
|
return "LunaChat";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ public class LunaChatIntegration extends PluginIntegration<BukkitDiscordSRV> imp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getOwnerName() {
|
public @NotNull String getOwnerName() {
|
||||||
return getIntegrationName();
|
return getIntegrationId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,7 +55,7 @@ public class McMMOChatIntegration extends PluginIntegration<BukkitDiscordSRV> im
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getIntegrationName() {
|
public @NotNull String getIntegrationId() {
|
||||||
return "mcMMO";
|
return "mcMMO";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ public class McMMOChatIntegration extends PluginIntegration<BukkitDiscordSRV> im
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getOwnerName() {
|
public @NotNull String getOwnerName() {
|
||||||
return getIntegrationName();
|
return getIntegrationId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,7 +51,7 @@ public class TownyChatIntegration extends PluginIntegration<BukkitDiscordSRV> im
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getIntegrationName() {
|
public @NotNull String getIntegrationId() {
|
||||||
return "TownyChat";
|
return "TownyChat";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ public class TownyChatIntegration extends PluginIntegration<BukkitDiscordSRV> im
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getOwnerName() {
|
public @NotNull String getOwnerName() {
|
||||||
return getIntegrationName();
|
return getIntegrationId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,7 +54,7 @@ public class VentureChatIntegration extends PluginIntegration<BukkitDiscordSRV>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getIntegrationName() {
|
public @NotNull String getIntegrationId() {
|
||||||
return "VentureChat";
|
return "VentureChat";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ public class VentureChatIntegration extends PluginIntegration<BukkitDiscordSRV>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getOwnerName() {
|
public @NotNull String getOwnerName() {
|
||||||
return getIntegrationName();
|
return getIntegrationId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,6 +26,7 @@ import org.bukkit.OfflinePlayer;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
@ -53,6 +54,11 @@ public class BukkitPlayerProvider extends ServerPlayerProvider<BukkitPlayer, Buk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unsubscribe() {
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||||
if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
|
if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
|
||||||
|
@ -21,18 +21,29 @@ package com.discordsrv.bukkit.plugin;
|
|||||||
import com.discordsrv.bukkit.BukkitDiscordSRV;
|
import com.discordsrv.bukkit.BukkitDiscordSRV;
|
||||||
import com.discordsrv.common.abstraction.plugin.Plugin;
|
import com.discordsrv.common.abstraction.plugin.Plugin;
|
||||||
import com.discordsrv.common.abstraction.plugin.PluginManager;
|
import com.discordsrv.common.abstraction.plugin.PluginManager;
|
||||||
|
import com.discordsrv.common.events.integration.IntegrationLifecycleEvent;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.server.PluginDisableEvent;
|
||||||
|
import org.bukkit.event.server.PluginEnableEvent;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class BukkitPluginManager implements PluginManager {
|
public class BukkitPluginManager implements PluginManager, Listener {
|
||||||
|
|
||||||
private final BukkitDiscordSRV discordSRV;
|
private final BukkitDiscordSRV discordSRV;
|
||||||
|
|
||||||
public BukkitPluginManager(BukkitDiscordSRV discordSRV) {
|
public BukkitPluginManager(BukkitDiscordSRV discordSRV) {
|
||||||
this.discordSRV = discordSRV;
|
this.discordSRV = discordSRV;
|
||||||
|
discordSRV.server().getPluginManager().registerEvents(this, discordSRV.plugin());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disable() {
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -49,4 +60,20 @@ public class BukkitPluginManager implements PluginManager {
|
|||||||
})
|
})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPluginEnable(PluginEnableEvent event) {
|
||||||
|
discordSRV.eventBus().publish(new IntegrationLifecycleEvent(
|
||||||
|
event.getPlugin().getName(),
|
||||||
|
IntegrationLifecycleEvent.Type.ENABLE
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPluginDisable(PluginDisableEvent event) {
|
||||||
|
discordSRV.eventBus().publish(new IntegrationLifecycleEvent(
|
||||||
|
event.getPlugin().getName(),
|
||||||
|
IntegrationLifecycleEvent.Type.DISABLE
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,11 @@ public class BungeePlayerProvider extends AbstractPlayerProvider<BungeePlayer, B
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unsubscribe() {
|
||||||
|
discordSRV.proxy().getPluginManager().unregisterListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = Byte.MIN_VALUE) // Runs first
|
@EventHandler(priority = Byte.MIN_VALUE) // Runs first
|
||||||
public void onPostLogin(PostLoginEvent event) {
|
public void onPostLogin(PostLoginEvent event) {
|
||||||
addPlayer(event.getPlayer(), false);
|
addPlayer(event.getPlayer(), false);
|
||||||
|
@ -713,6 +713,10 @@ public abstract class AbstractDiscordSRV<
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.status.set(Status.SHUTTING_DOWN);
|
this.status.set(Status.SHUTTING_DOWN);
|
||||||
|
|
||||||
|
// Unregister PlayerProvider listeners
|
||||||
|
playerProvider().unsubscribe();
|
||||||
|
|
||||||
eventBus().publish(new DiscordSRVShuttingDownEvent());
|
eventBus().publish(new DiscordSRVShuttingDownEvent());
|
||||||
eventBus().shutdown();
|
eventBus().shutdown();
|
||||||
try {
|
try {
|
||||||
|
@ -63,6 +63,7 @@ public abstract class AbstractPlayerProvider<T extends IPlayer, DT extends Disco
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract void subscribe();
|
public abstract void subscribe();
|
||||||
|
public abstract void unsubscribe();
|
||||||
|
|
||||||
protected void addPlayer(UUID uuid, T player, boolean initial) {
|
protected void addPlayer(UUID uuid, T player, boolean initial) {
|
||||||
this.players.put(uuid, player);
|
this.players.put(uuid, player);
|
||||||
|
@ -33,7 +33,9 @@ import com.discordsrv.common.core.logging.Logger;
|
|||||||
import com.discordsrv.common.core.logging.NamedLogger;
|
import com.discordsrv.common.core.logging.NamedLogger;
|
||||||
import com.discordsrv.common.core.module.type.AbstractModule;
|
import com.discordsrv.common.core.module.type.AbstractModule;
|
||||||
import com.discordsrv.common.core.module.type.ModuleDelegate;
|
import com.discordsrv.common.core.module.type.ModuleDelegate;
|
||||||
|
import com.discordsrv.common.core.module.type.PluginIntegration;
|
||||||
import com.discordsrv.common.discord.connection.jda.JDAConnectionManager;
|
import com.discordsrv.common.discord.connection.jda.JDAConnectionManager;
|
||||||
|
import com.discordsrv.common.events.integration.IntegrationLifecycleEvent;
|
||||||
import com.discordsrv.common.feature.debug.DebugGenerateEvent;
|
import com.discordsrv.common.feature.debug.DebugGenerateEvent;
|
||||||
import com.discordsrv.common.feature.debug.file.TextDebugFile;
|
import com.discordsrv.common.feature.debug.file.TextDebugFile;
|
||||||
import com.discordsrv.common.util.function.CheckedFunction;
|
import com.discordsrv.common.util.function.CheckedFunction;
|
||||||
@ -211,6 +213,18 @@ public class ModuleManager {
|
|||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onIntegrationLifecycle(IntegrationLifecycleEvent event) {
|
||||||
|
String integrationIdentifier = event.integrationIdentifier();
|
||||||
|
for (Module module : modules) {
|
||||||
|
AbstractModule<?> abstractModule = getAbstract(module);
|
||||||
|
if (abstractModule instanceof PluginIntegration
|
||||||
|
&& ((PluginIntegration<?>) abstractModule).getIntegrationId().equals(integrationIdentifier)) {
|
||||||
|
enableOrDisableAsNeeded(abstractModule, discordSRV.isReady(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<DiscordSRVApi.ReloadResult> reload() {
|
public List<DiscordSRVApi.ReloadResult> reload() {
|
||||||
return reloadAndEnableModules(true);
|
return reloadAndEnableModules(true);
|
||||||
}
|
}
|
||||||
@ -240,7 +254,7 @@ public class ModuleManager {
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DiscordSRVApi.ReloadResult> enableOrDisableAsNeeded(AbstractModule<?> module, boolean isReady, boolean reload) {
|
private List<DiscordSRVApi.ReloadResult> enableOrDisableAsNeeded(AbstractModule<?> module, boolean isReady, boolean mayReload) {
|
||||||
boolean canBeEnabled = isReady || module.canEnableBeforeReady();
|
boolean canBeEnabled = isReady || module.canEnableBeforeReady();
|
||||||
if (!canBeEnabled) {
|
if (!canBeEnabled) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
@ -278,7 +292,7 @@ public class ModuleManager {
|
|||||||
List<DiscordSRVApi.ReloadResult> results = enable(module);
|
List<DiscordSRVApi.ReloadResult> results = enable(module);
|
||||||
if (results != null) {
|
if (results != null) {
|
||||||
reloadResults.addAll(results);
|
reloadResults.addAll(results);
|
||||||
} else if (reload) {
|
} else if (mayReload) {
|
||||||
reloadResults.addAll(reload(module));
|
reloadResults.addAll(reload(module));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,16 +38,16 @@ public abstract class PluginIntegration<DT extends DiscordSRV> extends AbstractM
|
|||||||
* @return the id (when available) or name of the plugin or mod
|
* @return the id (when available) or name of the plugin or mod
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public abstract String getIntegrationName();
|
public abstract String getIntegrationId();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@MustBeInvokedByOverriders
|
@MustBeInvokedByOverriders
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
String integrationName = getIntegrationName();
|
String integrationId = getIntegrationId();
|
||||||
if (discordSRV.config().integrations.disabledIntegrations.contains(integrationName)) {
|
if (discordSRV.config().integrations.disabledIntegrations.contains(integrationId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!discordSRV.pluginManager().isPluginEnabled(integrationName)) {
|
if (!discordSRV.pluginManager().isPluginEnabled(integrationId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return super.isEnabled();
|
return super.isEnabled();
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of DiscordSRV, licensed under the GPLv3 License
|
||||||
|
* Copyright (c) 2016-2024 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.discordsrv.common.events.integration;
|
||||||
|
|
||||||
|
import com.discordsrv.api.events.Event;
|
||||||
|
|
||||||
|
public class IntegrationLifecycleEvent implements Event {
|
||||||
|
|
||||||
|
private final String integrationIdentifier;
|
||||||
|
private final Type type;
|
||||||
|
|
||||||
|
public IntegrationLifecycleEvent(String integrationIdentifier, Type type) {
|
||||||
|
this.integrationIdentifier = integrationIdentifier;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String integrationIdentifier() {
|
||||||
|
return integrationIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Type {
|
||||||
|
ENABLE,
|
||||||
|
DISABLE,
|
||||||
|
RELOAD
|
||||||
|
}
|
||||||
|
}
|
@ -66,7 +66,7 @@ public class LuckPermsIntegration extends PluginIntegration<DiscordSRV> implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getIntegrationName() {
|
public @NotNull String getIntegrationId() {
|
||||||
return "LuckPerms";
|
return "LuckPerms";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,6 +185,11 @@ public class MockDiscordSRV extends AbstractDiscordSRV<IBootstrap, MainConfig, C
|
|||||||
public void subscribe() {
|
public void subscribe() {
|
||||||
playerProviderSubscribed = true;
|
playerProviderSubscribed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unsubscribe() {
|
||||||
|
playerProviderSubscribed = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,11 @@ public class VelocityPlayerProvider extends AbstractPlayerProvider<VelocityPlaye
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unsubscribe() {
|
||||||
|
discordSRV.proxy().getEventManager().unregisterListener(discordSRV.plugin(), this);
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe(order = PostOrder.FIRST)
|
@Subscribe(order = PostOrder.FIRST)
|
||||||
public void onPostLogin(PostLoginEvent event) {
|
public void onPostLogin(PostLoginEvent event) {
|
||||||
addPlayer(event.getPlayer(), false);
|
addPlayer(event.getPlayer(), false);
|
||||||
|
@ -24,6 +24,7 @@ import com.discordsrv.velocity.VelocityDiscordSRV;
|
|||||||
import com.velocitypowered.api.plugin.PluginDescription;
|
import com.velocitypowered.api.plugin.PluginDescription;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class VelocityPluginManager implements PluginManager {
|
public class VelocityPluginManager implements PluginManager {
|
||||||
@ -35,8 +36,8 @@ public class VelocityPluginManager implements PluginManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPluginEnabled(String pluginName) {
|
public boolean isPluginEnabled(String pluginIdentifier) {
|
||||||
return discordSRV.proxy().getPluginManager().isLoaded(pluginName);
|
return discordSRV.proxy().getPluginManager().isLoaded(pluginIdentifier.toLowerCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user