Help with this plugin I'm making teleportation

Discussion in 'Plugin Development' started by CheifKeef, Jun 9, 2014.

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

    CheifKeef

    I am brand new to coding plugins and this is my 1st plugin I'm making what do i do after this I'm stuck and have no leads

    http://pastebin.com/Q0rZXnRC
     
  2. Offline

    Etched

    You need to actually put parameters for .teleport();. It takes a location, sooo:
    Code:java
    1. Location l = *whatever sort of location you want*;
    2.  
    3. //Or
    4.  
    5. [Another player].getLocation();
     
  3. Offline

    CheifKeef

    Can you show me what that would look like with the code I already wrote
     
  4. Offline

    Etched

    Code:java
    1.  
    2.  
    3. package me.Yongblood11.SimpleCommands;
    4.  
    5. import java.util.logging.Logger;
    6.  
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.plugin.PluginDescriptionFile;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12.  
    13. public class SimpleCommands extends JavaPlugin{
    14. public static Logger logger = Logger.getLogger("Minecraft");
    15. public static SimpleCommands plugin;
    16.  
    17. @Override
    18. public void onDisable() {
    19. PluginDescriptionFile pdfFile = this.getDescription();
    20. this.logger.info(pdfFile.getName() + "Has been disabled");
    21. }
    22.  
    23. @Override
    24. public void onEnable() {
    25. PluginDescriptionFile pdfFile = this.getDescription();
    26. this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " has been enabled!");
    27. }
    28.  
    29. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    30. Player player = (Player) sender;
    31. if(commandLabel.equalsIgnoreCase("tp")){
    32. //Added code here
    33. player.teleport([Another Player].getLocation());
    34. }
    35. }
    36.  
    37.  
    38.  
    39. }
    40.  
    41.  

    Or
    Code:java
    1.  
    2.  
    3. package me.Yongblood11.SimpleCommands;
    4.  
    5. import java.util.logging.Logger;
    6.  
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.plugin.PluginDescriptionFile;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12.  
    13. public class SimpleCommands extends JavaPlugin{
    14. public static Logger logger = Logger.getLogger("Minecraft");
    15. public static SimpleCommands plugin;
    16.  
    17. @Override
    18. public void onDisable() {
    19. PluginDescriptionFile pdfFile = this.getDescription();
    20. this.logger.info(pdfFile.getName() + "Has been disabled");
    21. }
    22.  
    23. @Override
    24. public void onEnable() {
    25. PluginDescriptionFile pdfFile = this.getDescription();
    26. this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " has been enabled!");
    27. }
    28.  
    29. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    30. Player player = (Player) sender;
    31. if(commandLabel.equalsIgnoreCase("tp")){
    32. Location l = *whatever*
    33. player.teleport(loc);
    34. }
    35. }
    36.  
    37.  
    38.  
    39. }
    40.  
    41.  
     
  5. Offline

    jimuskin

    Lol ^.^
    Code:
    Location l = *whatever*
    player.teleport(loc);
    Would be player.teleport(l);
     
  6. Offline

    spy_1134

    In order to teleport you need to have an instance of the Location class to teleport the player to.

    You can create one like this: (replace x, y, and z with the coordinates)
    Code:java
    1. Location loc = new Location(player.getWorld(), x, y, z);


    Alternatively you can get another player's location with:
    Code:java
    1. otherPlayer.getLocation();


    So, to teleport to another player you would do this:
    Code:java
    1. player.teleport(otherPlayer.getLocation());
     
Thread Status:
Not open for further replies.

Share This Page