Files
VoiceChatInteraction/src/main/java/de/winniepat/voiceChatInteraction/VoiceChatInteraction.java
T
2026-06-25 15:16:43 +02:00

57 lines
2.3 KiB
Java

package de.winniepat.voiceChatInteraction;
import de.maxhenkel.voicechat.api.BukkitVoicechatService;import de.winniepat.voiceChatInteraction.config.ServerConfig;
import org.bukkit.GameEvent;import org.bukkit.Server;import org.bukkit.configuration.file.FileConfiguration;import org.bukkit.plugin.java.JavaPlugin;
import javax.annotation.Nullable;import java.util.logging.LogManager;
import java.util.logging.Logger;
public final class VoiceChatInteraction extends JavaPlugin {
public static final String PLUGIN_ID = "voicechat_interaction";
public static final Logger LOGGER = LogManager.getLogManager().getLogger(PLUGIN_ID);
public static ServerConfig SERVER_CONFIG;
public static Server SERVER;
public static GameEvent VOICE_GAME_EVENT;
public static VoiceChatInteraction INSTANCE;
@Nullable
public static VoiceChatInteractionPlugin voicechatPlugin;
@Override
public void onEnable() {
SERVER = getServer();
VOICE_GAME_EVENT = GameEvent.PRIME_FUSE;
INSTANCE = this;
FileConfiguration config = this.getConfig();
config.addDefault("group_interaction", false);
config.addDefault("whisper_interaction", false);
config.addDefault("sneak_interaction", false);
config.addDefault("minimum_activation_threshold", -50);
config.addDefault("default_interaction_toggle", true);
config.options().copyDefaults(true);
saveConfig();
SERVER_CONFIG = new ServerConfig(config);
BukkitVoicechatService service = getServer().getServicesManager().load(BukkitVoicechatService.class);
if (service != null) {
voicechatPlugin = new VoiceChatInteractionPlugin();
service.registerPlugin(voicechatPlugin);
getLogger().info("Successfully registered voicechat_interaction plugin");
} else {
getLogger().info("Failed to register voicechat_interaction plugin");
}
this.getCommand("voicechat_interaction").setExecutor(new VoiceChatInteractionCommand());
}
@Override
public void onDisable() {
if (voicechatPlugin != null) {
getServer().getServicesManager().unregister(voicechatPlugin);
getLogger().info("Successfully unregistered voicechat_interaction plugin");
}
}
}