Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main.commands;
- import java.util.Random;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.command.ConsoleCommandSender;
- import org.bukkit.craftbukkit.Main;
- import org.bukkit.entity.Player;
- import org.bukkit.event.Listener;
- import org.bukkit.plugin.Plugin;
- import org.bukkit.plugin.java.JavaPlugin;
- import net.minecraft.server.v1_11_R1.CommandExecute;
- public class CommandCustomSound extends CommandExecute implements Listener, CommandExecutor {
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- if (cmd.getName().equalsIgnoreCase("csound")) {
- if(sender.isOp()) {
- if (args.length == 2) {
- String player = args[0];
- int method = Integer.parseInt(args[1]);
- ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
- Plugin plugin = JavaPlugin.getPlugin(Main.class);
- Bukkit.getScheduler().runTaskLater(plugin, () -> {
- String command = "playsound mvendor.vendor1 master " + player + " ~ ~ ~ 100 1 1";
- Bukkit.dispatchCommand(console, command);
- }, 8);
- if (method == 1)
- {
- Random rand = new Random();
- int randomNum = rand.nextInt((3 - 1) + 1) + 1;
- System.out.println("Music Random Number: " + randomNum);
- switch (randomNum) {
- case 1:
- String command = "playsound mvendor.vendor1 master " + player + " ~ ~ ~ 100 1 1";
- Bukkit.dispatchCommand(console, command);
- return true;
- case 2:
- String command2 = "playsound mvendor.vendor2 master " + player + " ~ ~ ~ 100 1 1";
- Bukkit.dispatchCommand(console, command2);
- return true;
- case 3:
- String command3 = "playsound mvendor.vendor3 master " + player + " ~ ~ ~ 100 1 1";
- Bukkit.dispatchCommand(console, command3);
- return true;
- }
- }else {
- sender.sendMessage(ChatColor.RED + "Wrong Method!");
- return true;
- }
- } else {
- sender.sendMessage(ChatColor.RED + "Not enough arguments!");
- return true;
- }
- }else {
- sender.sendMessage(ChatColor.RED + "You are not OP!");
- return true;
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement