mirror of
https://github.com/SPAWNRYS-ban/FUCK-CustomDiscs.git
synced 2025-12-16 08:19:37 +05:00
File Checks
When inserted into jukebox, the plugin will check if a file exists.
This commit is contained in:
65
src/main/java/me/Navoei/customdiscsplugin/CustomDiscs.java
Normal file
65
src/main/java/me/Navoei/customdiscsplugin/CustomDiscs.java
Normal file
@@ -0,0 +1,65 @@
|
||||
package me.Navoei.customdiscsplugin;
|
||||
|
||||
import de.maxhenkel.voicechat.api.BukkitVoicechatService;
|
||||
import me.Navoei.customdiscsplugin.command.CustomDisc;
|
||||
import me.Navoei.customdiscsplugin.event.JukeBox;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
|
||||
public final class CustomDiscs extends JavaPlugin {
|
||||
|
||||
public static final String PLUGIN_ID = "CustomDiscs";
|
||||
public static final Logger LOGGER = LogManager.getLogger(PLUGIN_ID);
|
||||
static CustomDiscs instance;
|
||||
|
||||
@Nullable
|
||||
private VoicePlugin voicechatPlugin;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
CustomDiscs.instance = this;
|
||||
|
||||
BukkitVoicechatService service = getServer().getServicesManager().load(BukkitVoicechatService.class);
|
||||
|
||||
CustomDisc command = new CustomDisc();
|
||||
|
||||
if (!new File(this.getDataFolder(), "config.yml").exists()) {
|
||||
this.getConfig().options().copyDefaults(true);
|
||||
}
|
||||
this.saveConfig();
|
||||
|
||||
File musicData = new File(this.getDataFolder() + "\\musicdata\\");
|
||||
if (!(musicData.exists())) {
|
||||
musicData.mkdirs();
|
||||
}
|
||||
|
||||
if (service != null) {
|
||||
voicechatPlugin = new VoicePlugin();
|
||||
service.registerPlugin(voicechatPlugin);
|
||||
LOGGER.info("Successfully registered CustomDiscs plugin");
|
||||
} else {
|
||||
LOGGER.info("Failed to register CustomDiscs plugin");
|
||||
}
|
||||
|
||||
getServer().getPluginManager().registerEvents(new JukeBox(), this);
|
||||
getCommand("customdisc").setExecutor(command);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (voicechatPlugin != null) {
|
||||
getServer().getServicesManager().unregister(voicechatPlugin);
|
||||
LOGGER.info("Successfully unregistered CustomDiscs plugin");
|
||||
}
|
||||
}
|
||||
|
||||
public static CustomDiscs getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user