diff --git a/src/main/java/na/Navoei/customdiscsplugin/CustomDiscs.java b/src/main/java/na/Navoei/customdiscsplugin/CustomDiscs.java index 7ef2589..b793acf 100644 --- a/src/main/java/na/Navoei/customdiscsplugin/CustomDiscs.java +++ b/src/main/java/na/Navoei/customdiscsplugin/CustomDiscs.java @@ -1,6 +1,7 @@ package na.Navoei.customdiscsplugin; import de.maxhenkel.voicechat.api.BukkitVoicechatService; +import na.Navoei.customdiscsplugin.command.CustomDisc; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.bukkit.plugin.java.JavaPlugin; @@ -10,7 +11,7 @@ import java.io.File; public final class CustomDiscs extends JavaPlugin { - public static final String PLUGIN_ID = "example_plugin"; + public static final String PLUGIN_ID = "CustomDiscs"; public static final Logger LOGGER = LogManager.getLogger(PLUGIN_ID); @Nullable @@ -20,12 +21,17 @@ public final class CustomDiscs extends JavaPlugin { public void onEnable() { 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 PlayMusic(); @@ -34,6 +40,9 @@ public final class CustomDiscs extends JavaPlugin { } else { LOGGER.info("Failed to register CustomDiscs plugin"); } + + getCommand("customdisc").setExecutor(command); + } @Override diff --git a/src/main/java/na/Navoei/customdiscsplugin/command/CustomDisc.java b/src/main/java/na/Navoei/customdiscsplugin/command/CustomDisc.java index c652abc..446a090 100644 --- a/src/main/java/na/Navoei/customdiscsplugin/command/CustomDisc.java +++ b/src/main/java/na/Navoei/customdiscsplugin/command/CustomDisc.java @@ -1,9 +1,12 @@ package na.Navoei.customdiscsplugin.command; +import +import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; + import org.jetbrains.annotations.NotNull; public class CustomDisc implements CommandExecutor { @@ -12,17 +15,22 @@ public class CustomDisc implements CommandExecutor { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { - sender.sendMessage("§cOnly players can use this command!"); + sender.sendMessage(ChatColor.RED + "Only players can use this command!"); return true; } Player p = (Player) sender; + // /customdisc wewontbealone "We wont be alone" if (command.getName().equalsIgnoreCase("customdisc")) { if (args.length == 2) { + + + p.sendMessage("Your filename is:" + args[0]); + p.sendMessage("Your custom name is " + args[1]); } else { - sender.sendMessage("§cIncorrect arguments! ( /customdiscs [customname] )"); + p.sendMessage(ChatColor.RED + "Incorrect arguments! ( /customdisc [customname] )"); } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index fa0e4e4..72cdfef 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,8 +1,13 @@ name: CustomDiscs version: ${version} -main: CustomDiscs +main: na.Navoei.customdiscsplugin.CustomDiscs api-version: ${bukkit_api_version} prefix: CustomDiscs authors: [ "Navoei" ] description: A plugin which used the Simple Voice Chat API to add custom music discs. -depend: [ voicechat ] \ No newline at end of file +depend: [ voicechat ] + +commands: + customdisc: + description: Create a custom disc! + aliases: cd \ No newline at end of file