mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-22 17:17:37 +00:00
Few changes to toggleable listener system
This commit is contained in:
parent
d55886dcbd
commit
117852e6d0
@ -3,7 +3,7 @@ package dev.plex.handlers;
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.plex.PlexBase;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.listener.annotation.Toggled;
|
||||
import dev.plex.listener.annotation.Toggleable;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@ -21,10 +21,10 @@ public class ListenerHandler extends PlexBase
|
||||
{
|
||||
try
|
||||
{
|
||||
Toggled annotation = clazz.getDeclaredAnnotation(Toggled.class);
|
||||
Toggleable annotation = clazz.getDeclaredAnnotation(Toggleable.class);
|
||||
if (annotation != null)
|
||||
{
|
||||
if (plugin.config.getBoolean("chat.enabled") && annotation.enabled())
|
||||
if (plugin.config.get(annotation.value()) != null && plugin.config.getBoolean(annotation.value()))
|
||||
{
|
||||
listeners.add(clazz.getConstructor().newInstance());
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
package dev.plex.listener.annotation;
|
||||
|
||||
public @interface Toggleable
|
||||
{
|
||||
String value();
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package dev.plex.listener.annotation;
|
||||
|
||||
public @interface Toggled
|
||||
{
|
||||
boolean enabled() default false;
|
||||
}
|
@ -2,7 +2,7 @@ package dev.plex.listener.impl;
|
||||
|
||||
import dev.plex.cache.PlayerCache;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.listener.annotation.Toggled;
|
||||
import dev.plex.listener.annotation.Toggleable;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import io.papermc.paper.chat.ChatRenderer;
|
||||
@ -15,7 +15,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Toggled(enabled = true)
|
||||
@Toggleable("chat.enabled")
|
||||
public class ChatListener extends PlexListener
|
||||
{
|
||||
private final PlexChatRenderer renderer = new PlexChatRenderer();
|
||||
|
Loading…
Reference in New Issue
Block a user