Creating commands.
This commit is contained in:
Navoei
2022-07-03 13:20:36 -05:00
parent 9d1bbd4ac2
commit 108008331f
4 changed files with 48 additions and 6 deletions

View File

@@ -6,6 +6,7 @@ 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 {
@@ -13,17 +14,25 @@ public final class CustomDiscs extends JavaPlugin {
public static final Logger LOGGER = LogManager.getLogger(PLUGIN_ID);
@Nullable
private ExampleVoicechatPlugin voicechatPlugin;
private PlayMusic voicechatPlugin;
@Override
public void onEnable() {
BukkitVoicechatService service = getServer().getServicesManager().load(BukkitVoicechatService.class);
if (!new File(this.getDataFolder(), "config.yml").exists()) {
this.getConfig().options().copyDefaults(true);
}
this.saveConfig();
if (service != null) {
voicechatPlugin = new ExampleVoicechatPlugin();
voicechatPlugin = new PlayMusic();
service.registerPlugin(voicechatPlugin);
LOGGER.info("Successfully registered example plugin");
LOGGER.info("Successfully registered CustomDiscs plugin");
} else {
LOGGER.info("Failed to register example plugin");
LOGGER.info("Failed to register CustomDiscs plugin");
}
}
@@ -31,7 +40,7 @@ public final class CustomDiscs extends JavaPlugin {
public void onDisable() {
if (voicechatPlugin != null) {
getServer().getServicesManager().unregister(voicechatPlugin);
LOGGER.info("Successfully unregistered example plugin");
LOGGER.info("Successfully unregistered CustomDiscs plugin");
}
}
}

View File

@@ -4,7 +4,7 @@ import de.maxhenkel.voicechat.api.VoicechatApi;
import de.maxhenkel.voicechat.api.VoicechatPlugin;
import de.maxhenkel.voicechat.api.events.EventRegistration;
public class ExampleVoicechatPlugin implements VoicechatPlugin {
public class PlayMusic implements VoicechatPlugin {
/**
* @return the unique ID for this voice chat plugin

View File

@@ -0,0 +1,31 @@
package na.Navoei.customdiscsplugin.command;
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 {
@Override
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!");
return true;
}
Player p = (Player) sender;
if (command.getName().equalsIgnoreCase("customdisc")) {
if (args.length == 2) {
} else {
sender.sendMessage("§cIncorrect arguments! ( /customdiscs <filename> [customname] )");
}
}
return false;
}
}

View File

@@ -0,0 +1,2 @@
#Volume of the music playing from a juke box as a percentage.
DiscVolume: 100