mirror of
https://github.com/SPAWNRYS-ban/FUCK-CustomDiscs.git
synced 2025-12-10 13:30:24 +05:00
Commands
Creating commands.
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
2
src/main/resources/config.yml
Normal file
2
src/main/resources/config.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
#Volume of the music playing from a juke box as a percentage.
|
||||
DiscVolume: 100
|
||||
Reference in New Issue
Block a user