This is a simple plugin when you type /l it prints your X Y and Z cords but the outtput of it is Your X Coordinates: (Then it prints the X cord.) Your Y Coordinates: (Then it prints the X cord.) Your Z Coordinates: (Then it prints the X cord.) Here's the coding. Code: package me.colby.Basic; import java.util.logging.Logger; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; public class Basic extends JavaPlugin { public static final Logger log = Logger.getLogger("Minecraft"); public static Basic plugin; private Listener playerListener; Plugin BasicPlayerListener(Basic instance) { return plugin = instance; } public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){ if(sender instanceof Player == cmd.getName().equalsIgnoreCase("L")){ // If the player typed /l then do the following... Player player = (Player)sender; Location playerLoc = player.getLocation(); player.sendMessage(ChatColor.RED + "Your X Coordinates : " + playerLoc.getX()); player.sendMessage(ChatColor.RED + "Your Y Coordinates : " + playerLoc.getY()); player.sendMessage(ChatColor.RED + "Your Z Coordinates : " + playerLoc.getZ()); return true; } return false; } @Override public void onDisable(){ } @Override public void onEnable(){ PluginManager pm = this.getServer().getPluginManager(); log.info("Plugin enabled"); pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, this.playerListener, Event.Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Event.Priority.Normal, this); PluginDescriptionFile pdfFile = this.getDescription(); System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + "is enabled!" ); } Plugin instance; } Btw, does anyone know where I can learn to make Spout Plugins?
if(sender instanceof Player == cmd.getName().equalsIgnoreCase("L")){ to if(sender instanceof Player && cmd.getName().equalsIgnoreCase("L")) {
change: if(sender instanceof Player == cmd.getName().equalsIgnoreCase("L")){ to: if(sender instanceof Player && cmd.getName().equalsIgnoreCase("L")) {
Lol, duh sorry. I thought you were saying something else. Now what does this little change do? Didn't work. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
I know this works... Code: if(sender instanceof Player) { if (commandLabel.equalsIgnoreCase("L")) { Player player = (Player) sender; Location Loc = player.getLocation(); player.sendMessage(ChatColor.RED + "Your X Coordinates : " + Loc.getX()); player.sendMessage(ChatColor.RED + "Your Y Coordinates : " + Loc.getY()); player.sendMessage(ChatColor.RED + "Your Z Coordinates : " + Loc.getZ()); return true; } }
Okay, your not understanding what i'm saying. Yes, it "works" but how I want it to. With that code it only prints out the X cord on all 3 lines. Anyone else know whats wrong? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
No, this is what it prints out. For example let's say the X cord is 102 the Z is 527 and the Y 63, when I type /l the console feedback would be. Your X Coordinates: 102 Your Y Coordinates: 102 Your Z Coordinates: 102 See it prints the X coordinate on all 3 lines.