Hi there, I am trying to create a simple plugin that returns a lot of information on a certain player selected. I currently have two classes (as I don't have much done yet). I want to call the method "getlocation" from my PlayerLocation class. Although, I don't know how I would go about doing this, any tips? Here is my main class Code: package com.github.walk2222; import org.bukkit.ChatColor; import org.bukkit.entity.*; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.plugin.java.JavaPlugin; public final class Main extends JavaPlugin { //Enabling plugin message @Override public void onEnable(){ getLogger().info("[Player info] has been enabled"); } //Player info command public boolean onCommand(CommandSender sender, Command cmd, String label, String [] args){ if(cmd.getName().equalsIgnoreCase("playerinfo")){ Player target = sender.getServer().getPlayer(args[0]); //Call getlocation method here! } return false; } //Disabling plugin message @Override public void onDisable(){ getLogger().info("[PlayerInfo] has been disabled"); } } And here is my PlayerLocation class Code: package com.github.walk2222; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PlayerLocation { @SuppressWarnings("null") public static boolean getlocation(Player playerloc) { int px = (int) playerloc.getLocation().getX(); int py = (int) playerloc.getLocation().getY(); int pz = (int) playerloc.getLocation().getZ(); CommandSender player = null; player.sendMessage(ChatColor.AQUA + "X: "+px+" Y: "+py+" Z: "+pz); return false; } }
PlayerLocation.getLocation(target) Make it also take an argument of CommandSender so that it isn't null.
Instead of CommandSender player, use what CubixCoders posted above so it looks like this: Code: sender.sendMessage("Your message here");
I'm sorry I'm a major newbie at this. Could someone change some things in the code I provided so it is correct? Thanks for all your help so far by the way
Code:java public static void getlocation(Player playerloc, CommandSender player) { int px = (int) playerloc.getLocation().getX(); int py = (int) playerloc.getLocation().getY(); int pz = (int) playerloc.getLocation().getZ(); player.sendMessage(ChatColor.AQUA + "X: "+px+" Y: "+py+" Z: "+pz); } public boolean onCommand(CommandSender sender, Command cmd, String label, String [] args){ if(cmd.getName().equalsIgnoreCase("playerinfo")){ Player target = sender.getServer().getPlayer(args[0]); PlayerLocation.getLocation(target, sender); } return false; } Please don't just copy and paste and actually attempt to understand what is going on.