Plugin help.

Discussion in 'Bukkit Help' started by nanerz_123, Mar 5, 2014.

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

    nanerz_123

    Code:
    name: MyFirstPlugin
    main: me.nanerz_123
    version: 1.5.2
    commands:
      pinfo:
          description: Tells info about you.
          usage: /<pinfo>
    Code:java
    1. package me.nanerz_123;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.Location;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.HumanEntity;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.inventory.PlayerInventory;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11.  
    12. /* This gives the player a whole list of info! */
    13.  
    14. public class MyFirstPlugin extends JavaPlugin {
    15.  
    16. public void onEnable() {
    17.  
    18. }
    19.  
    20. public void onDisable() {
    21.  
    22. }
    23.  
    24. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    25.  
    26. // Uses equalsIgnoreCase() over equals() to accept "pinfo" or "pInFo"
    27.  
    28. if (cmd.getName().equalsIgnoreCase("pinfo")) {
    29.  
    30. // Make sure that the player specified exactly one argument (the
    31. // name of the player to pinfo).
    32.  
    33. if (args.length != 1) {
    34.  
    35. // When onCommand() returns false, the help message associated
    36. // with that command is displayed.
    37.  
    38. return false;
    39.  
    40. }
    41.  
    42. // Make sure the sender is a player.
    43.  
    44. if (!(sender instanceof Player)) {
    45.  
    46. sender.sendMessage("Only players can see other players info ingame");
    47.  
    48. return true;
    49.  
    50. }
    51.  
    52. // Get the player who you should get the info about. Remember that
    53. // indecies start with 0, not 1.
    54.  
    55. Player target = Bukkit.getServer().getPlayer(args[0]);
    56.  
    57. // Make sure the player is online.
    58.  
    59. if (target == null) {
    60.  
    61. sender.sendMessage(args[0] + " is not currently online.");
    62.  
    63. return true;
    64.  
    65. }
    66.  
    67. // The thing that you make happen, in this case send the sender the
    68. // player's info. Use target for the argument for example
    69. // target.setFireTicks(1000);
    70.  
    71. Location playerspawnloc = ((Player) sender).getBedSpawnLocation();
    72.  
    73. Location playersloc = ((Player) sender).getLocation();
    74.  
    75. PlayerInventory playersinvent = ((HumanEntity) sender).getInventory();
    76.  
    77. sender.sendMessage("Your spawn X Coordinates : " + playerspawnloc.getX());
    78.  
    79. sender.sendMessage("Your spawn Y Coordinates : " + playerspawnloc.getY());
    80.  
    81. sender.sendMessage("Your spawn Z Coordinates : " + playerspawnloc.getZ());
    82.  
    83. sender.sendMessage("Your x cord is : " + playersloc.getX());
    84.  
    85. sender.sendMessage("Your y cord is : " + playersloc.getY());
    86.  
    87. sender.sendMessage("Your z cord is : " + playersloc.getZ());
    88.  
    89. sender.sendMessage("Your world is : " + playersloc.getWorld());
    90.  
    91. sender.sendMessage("Your direction is : "
    92. + playersloc.getDirection());
    93.  
    94. sender.sendMessage("The chunk you are in is : " + playersloc.getChunk());
    95.  
    96. sender.sendMessage("Your Pitch is : " + playersloc.getPitch());
    97.  
    98. sender.sendMessage("You have this helment : " + playersinvent.getHelmet());
    99.  
    100. sender.sendMessage("You have this chestplate : " + playersinvent.getChestplate());
    101.  
    102. sender.sendMessage("You have these leggings : " + playersinvent.getLeggings());
    103.  
    104. sender.sendMessage("You have these boots : " + playersinvent.getBoots());
    105.  
    106. return true;
    107.  
    108. }
    109.  
    110. return false;
    111.  
    112. }
    113.  
    114. }

    (1.5.2 server and craftbukkit) Can someone please help me, I made this plugin, however it wont work, nor show up if I do /plugins. Thanks in advance! :D
     
  2. Offline

    TomYaMee

    Wrong section. This should be in the "Plugin Development" section
     
  3. Offline

    Necrodoom

Thread Status:
Not open for further replies.

Share This Page