Basically, I'm trying to let the console run a command that players can already run. I have it set up so players can run commands but I want to set up commands blocks that can run a command. Hope someone can help me since I'm fairly new
@360_ If this is a command from a plugin you are creating, post the code. If the command is from another plugin, and the command does not currently support commandblocks/console, there is no way to add support for them. In this case, ask the creator of the plugin to add support.
@Zombie_Striker Code: package me.SkyLine.core; import net.minecraft.server.v1_12_R1.EnumParticle; import net.minecraft.server.v1_12_R1.PacketPlayOutWorldParticles; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; import org.bukkit.entity.Player; public class staffchat implements CommandExecutor { public boolean onCommand(CommandSender sender, Command cmd, String lable, String[] args) { Player player = (Player)sender; if ((sender instanceof Player)) { if(sender.hasPermission("skyline.cp")){ StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i < args.length; i++) { strBuilder.append(args[i]); } if(player.hasPermission("skyline.owner")){ Bukkit.broadcast("§8(§3StaffChannel§8) §3"+ "§8(§cLeader§8)§b " + player.getName() + "§8:§7 " + String.join(" ", args), "skyline.cp"); }else if(player.hasPermission("skyline.admin")){ Bukkit.broadcast("§8(§3StaffChannel§8) §3"+ "§8(§6Admin§8)§b " + player.getName() + "§8:§7 " + String.join(" ", args), "skyline.cp"); }else if(player.hasPermission("skyline.cm")){ Bukkit.broadcast("§8(§3StaffChannel§8) §3"+ "§8(§3Cast Member§8)§b " + player.getName() + "§8:§7 " + String.join(" ", args), "skyline.cp"); }else if(player.hasPermission("skyline.cp")) { Bukkit.broadcast("§8(§3StaffChannel§8) §3" + "§8(§bCollage Program§8)§b " + player.getName() + "§8:§7 " + String.join(" ", args), "skyline.cp"); } } } else { sender.sendMessage("HEY! Only players can run this"); } return true; } } sorry for the long delay but here it is
Remove these lines because: They are never needed elsewhere in the code. getName() should work for all types of sends, so you can delete these lines and replace all other instances of "player." with "sender.". If it is not a player, this will throw an error because you are casting it to a player before you even know if it is a player (That is the whole point of an instanceof check) The entire purpose of these lines is so the console cannot use it.