mirror of
https://github.com/SPAWNRYS-ban/FUCK-CustomDiscs.git
synced 2026-01-28 13:59:38 +05:00
Command creation
Created the command so I can get it's arguments.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 <filename> [customname] )");
|
||||
p.sendMessage(ChatColor.RED + "Incorrect arguments! ( /customdisc <filename> [customname] )");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user