Sending console command?

Discussion in 'Plugin Development' started by firecombat4, Mar 25, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    firecombat4

    Just wondering how i would send a console command, and also how to send a global message but with colours (not /broadcast)
    Thank you!
     
  2. Offline

    CorrieKay

    Im not sure what you mean by sending a console command, Just type it in and go :p

    as for sending a message with colors, you should be able to add ChatColor to a broadcast.

    However, if you dont want to send a broadcast that logs in the server log, you can always either
    1) send a message to a specific permission, just remember to add ChatColor, or
    2) grab a list of players and send them all messages:
    Code:java
    1. for(Player player : plugin.getServer().getOnlinePlayers()){
    2. player.sendMessage(ChatColor.RED+"This message is red!");
    3. }
     
    firecombat4 likes this.
  3. Offline

    colony88

    Or
    Code:java
    1. Bukkit.getServer().broadcastMessage(ChatColor.RED + "Your message here is displayed without [Server]");

    EDIT: Sorry CorrieKay, I didn't see that you already said "broadcast" :p
     
    firecombat4 likes this.
  4. Offline

    Lolmewn

    ConsoleCommand:
    Code:
    Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "someCommand");
     
    firecombat4 likes this.
  5. Offline

    colony88

    I was just going to say that :D
     
    firecombat4 likes this.
  6. Offline

    Lolmewn

    Ninja'd :D
     
    colony88 likes this.
  7. Offline

    firecombat4

    Sorry for the simple question, but thanks a lot ! :)
     
  8. Offline

    odogollie

    When I use,
    Code:
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "eco take " + player + " " + getConfig().getString(item));
    I get this error,
    Code:
    [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'stock' in plugin Stock v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:42)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:168)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:492)
        at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:878)
        at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:825)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:807)
        at net.minecraft.server.Packet3Chat.handle(Packet3Chat.java:44)
        at net.minecraft.server.NetworkManager.b(NetworkManager.java:276)
        at net.minecraft.server.NetServerHandler.d(NetServerHandler.java:109)
        at net.minecraft.server.ServerConnection.b(SourceFile:35)
        at net.minecraft.server.DedicatedServerConnection.b(SourceFile:30)
        at net.minecraft.server.MinecraftServer.q(MinecraftServer.java:581)
        at net.minecraft.server.DedicatedServer.q(DedicatedServer.java:212)
        at net.minecraft.server.MinecraftServer.p(MinecraftServer.java:474)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:406)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:539)
    Caused by: java.lang.ArrayIndexOutOfBoundsException: 3
        at co.stock.Stock.onCommand(Stock.java:48)
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:40)
        ... 15 more
    Whats going wrong?
     
Thread Status:
Not open for further replies.

Share This Page