Please tell me what i'm doing wrong

Discussion in 'Plugin Development' started by nanerz_123, Mar 3, 2014.

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

    nanerz_123

    I am trying to make a basic plugin for my server, I am new to java, and plugins. Even when I type /plugins, it doesn't show up. This is it, thank you!
    -----------------------------------------------------------------------------------------------------------------------

    package me.nanerz_123;

    import org.bukkit.Bukkit;

    import org.bukkit.Location;

    import org.bukkit.command.Command;

    import org.bukkit.command.CommandSender;

    import org.bukkit.entity.HumanEntity;

    import org.bukkit.entity.Player;

    import org.bukkit.event.Listener;

    import org.bukkit.inventory.PlayerInventory;

    /* This gives the player a whole list of info! */


    publicclass MyFirstPlugin implements Listener {


    publicvoid onEnable() {






    }





    publicvoid onDisable() {




    }



    publicboolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

    // Uses equalsIgnoreCase() over equals() to accept "pinfo" or "pInFo"

    if (cmd.getName().equalsIgnoreCase("pinfo")) {

    // Make sure that the player specified exactly one argument (the name of the player to pinfo).

    if (args.length != 1) {

    // When onCommand() returns false, the help message associated with that command is displayed.

    returnfalse;


    }



    // Make sure the sender is a player.

    if (!(sender instanceof Player)) {

    sender.sendMessage("Only players can see other players info ingame");

    returntrue;


    }



    // Get the player who you should get the info about. Remember that indecies start with 0, not 1.


    Player target = Bukkit.getServer().getPlayer(args[0]);



    // Make sure the player is online.

    if (target == null) {

    sender.sendMessage(args[0] + " is not currently online.");

    returntrue;


    }



    // The thing that you make happen, in this case send the sender the player's info. Use target for the argument for example target.setFireTicks(1000);


    Location playerspawnloc = ((Player) sender).getBedSpawnLocation();



    Location playersloc = ((Player) sender).getLocation();



    PlayerInventory playersinvent = ((HumanEntity) sender).getInventory();





    sender.sendMessage("Your spawn X Coordinates : " + playerspawnloc.getX());


    sender.sendMessage("Your spawn Y Coordinates : " + playerspawnloc.getY());


    sender.sendMessage("Your spawn Z Coordinates : " + playerspawnloc.getZ());


    sender.sendMessage("Your x cord is : " + playersloc.getX());


    sender.sendMessage("Your y cord is : " + playersloc.getY());


    sender.sendMessage("Your z cord is : " + playersloc.getZ());


    sender.sendMessage("Your world is : " + playersloc.getWorld());


    sender.sendMessage("Your direction is : " + playersloc.getDirection());


    sender.sendMessage("The chunk you are in is : " + playersloc.getChunk());


    sender.sendMessage("Your Pitch is : " + playersloc.getPitch());


    sender.sendMessage("You have this helment : " + playersinvent.getHelmet());


    sender.sendMessage("You have this chestplate : " + playersinvent.getChestplate());


    sender.sendMessage("You have these leggings : " + playersinvent.getLeggings());


    sender.sendMessage("You have these boots : " + playersinvent.getBoots());

    returntrue;


    }

    returnfalse;


    }



    }
     
  2. Offline

    Mmarz11

    nanerz_123 You are implementing Listener when you should be extending JavaPlugin.

    Code:
    package me.nanerz_123;
     
    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.HumanEntity;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.PlayerInventory;
    import org.bukkit.plugin.java.JavaPlugin;
     
    /* This gives the player a whole list of info! */
     
    public class MyFirstPlugin extends JavaPlugin {
     
    public void onEnable() {
     
    }
     
    public void onDisable() {
     
    }
     
    public boolean onCommand(CommandSender sender, Command cmd, String label,
    String[] args) {
     
    // Uses equalsIgnoreCase() over equals() to accept "pinfo" or "pInFo"
     
    if (cmd.getName().equalsIgnoreCase("pinfo")) {
     
    // Make sure that the player specified exactly one argument (the
    // name of the player to pinfo).
     
    if (args.length != 1) {
     
    // When onCommand() returns false, the help message associated
    // with that command is displayed.
     
    return false;
     
    }
     
    // Make sure the sender is a player.
     
    if (!(sender instanceof Player)) {
     
    sender.sendMessage("Only players can see other players info ingame");
     
    return true;
     
    }
     
    // Get the player who you should get the info about. Remember that
    // indecies start with 0, not 1.
     
    Player target = Bukkit.getServer().getPlayer(args[0]);
     
    // Make sure the player is online.
     
    if (target == null) {
     
    sender.sendMessage(args[0] + " is not currently online.");
     
    return true;
     
    }
     
    // The thing that you make happen, in this case send the sender the
    // player's info. Use target for the argument for example
    // target.setFireTicks(1000);
     
    Location playerspawnloc = ((Player) sender).getBedSpawnLocation();
     
    Location playersloc = ((Player) sender).getLocation();
     
    PlayerInventory playersinvent = ((HumanEntity) sender)
    .getInventory();
     
    sender.sendMessage("Your spawn X Coordinates : "
    + playerspawnloc.getX());
     
    sender.sendMessage("Your spawn Y Coordinates : "
    + playerspawnloc.getY());
     
    sender.sendMessage("Your spawn Z Coordinates : "
    + playerspawnloc.getZ());
     
    sender.sendMessage("Your x cord is : " + playersloc.getX());
     
    sender.sendMessage("Your y cord is : " + playersloc.getY());
     
    sender.sendMessage("Your z cord is : " + playersloc.getZ());
     
    sender.sendMessage("Your world is : " + playersloc.getWorld());
     
    sender.sendMessage("Your direction is : "
    + playersloc.getDirection());
     
    sender.sendMessage("The chunk you are in is : "
    + playersloc.getChunk());
     
    sender.sendMessage("Your Pitch is : " + playersloc.getPitch());
     
    sender.sendMessage("You have this helment : "
    + playersinvent.getHelmet());
     
    sender.sendMessage("You have this chestplate : "
    + playersinvent.getChestplate());
     
    sender.sendMessage("You have these leggings : "
    + playersinvent.getLeggings());
     
    sender.sendMessage("You have these boots : "
    + playersinvent.getBoots());
     
    return true;
     
    }
     
    return false;
     
    }
     
    }
     
  3. Offline

    nanerz_123

Thread Status:
Not open for further replies.

Share This Page