listen to sponge refresh event

This commit is contained in:
Draycia committed 2021-12-01 13:12:08 -08:00
1 parent 0f5956149f
commit 96e9f394c9
3 files changed
+50 -2

No files matched your search

@@ -30,7 +30,6 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.DefaultQualifier;
// TODO: listen to sponge reload stuff
@DefaultQualifier(NonNull.class)
public class ReloadCommand {
@@ -42,6 +42,7 @@ import net.draycia.carbon.common.util.PlayerUtils;
import net.draycia.carbon.sponge.listeners.SpongeChatListener;
import net.draycia.carbon.sponge.listeners.SpongePlayerDeathListener;
import net.draycia.carbon.sponge.listeners.SpongePlayerJoinListener;
import net.draycia.carbon.sponge.listeners.SpongeReloadListener;
import net.kyori.adventure.text.Component;
import net.kyori.moonshine.message.IMessageRenderer;
import org.apache.logging.log4j.Logger;
@@ -63,7 +64,7 @@ import org.spongepowered.plugin.builtin.jvm.Plugin;
public final class CarbonChatSponge implements CarbonChat {
private static final Set<Class<?>> LISTENER_CLASSES = Set.of(SpongeChatListener.class,
SpongePlayerDeathListener.class, SpongePlayerJoinListener.class);
SpongePlayerDeathListener.class, SpongePlayerJoinListener.class, SpongeReloadListener.class);
private static final int BSTATS_PLUGIN_ID = 11279;
@@ -0,0 +1,48 @@
/*
* CarbonChat
*
* Copyright (c) 2021 Josua Parks (Vicarious)
* 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 net.draycia.carbon.sponge.listeners;
import com.google.inject.Inject;
import net.draycia.carbon.common.channels.CarbonChannelRegistry;
import net.draycia.carbon.common.config.ConfigFactory;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.lifecycle.RefreshGameEvent;
public class SpongeReloadListener {
final ConfigFactory configFactory;
final CarbonChannelRegistry channelRegistry;
@Inject
public SpongeReloadListener(
final ConfigFactory configFactory,
final CarbonChannelRegistry channelRegistry
) {
this.configFactory = configFactory;
this.channelRegistry = channelRegistry;
}
@Listener
public void onReload(final RefreshGameEvent event) {
this.channelRegistry.reloadRegisteredConfigChannels();
this.configFactory.reloadPrimaryConfig();
}
}