Lucas C. Lucas C. - 1 year ago 128
Java Question

Minecraft Spigot Plugin coding, having issue with Player.sendMessage

I am getting the following error on Eclipse Java Mars while coding a simple Minecraft 1.10 test plugin: "Cannot make a static reference to the non-static method sendMessage(String) from the type CommandSender." This is in a separate class just for commands, aside from the main class. Here is the entire class:

package io.github.ultraMLGcode.TestPlugin;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class TestPluginCommandExecutor implements CommandExecutor {

public TestPlugin plugin;

public TestPluginCommandExecutor(TestPlugin instance) {
plugin = instance;

public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("basic") && sender instanceof Player) { //If the player typed /basic then do the following...

if (sender instanceof Player) {
Player player = (Player) sender;
//do something
Player.sendMessage("Hello, it is a nice day, isn't it?");
} else {
sender.sendMessage("You must be a player!");

return true;
return false;


Answer Source

I don't know about the minecraft api, but i think this can helps:

Change this line:

Player.sendMessage("Hello, it is a nice day, isn't it?");

to this line

player.sendMessage("Hello, it is a nice day, isn't it?");

I think "sendMessage" is a non static method.

I hope it helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download