Hello, it's possible to create a player variable, example : String myPlayerVar; myPlayerVar = myFunction(); Thanks for your help. Cordially, Metra
You need to learn more java. Regardless, here are some answers to different questions that you are asking Ways to get the Player object In a command: Code:java if (sender instanceof Player) {Player player = (Player) sender;} From a player driven event: Code:java Player player = event.getPlayer(); From a string: Code:java Bukkit.getServer().getPlayer(playerName); How to return a value from a method So, this is basic Java, and doesn't require Bukkit. Lets take this scenario: Theres a class, named Human. The constructor is: Code:java private String name; public Human(String name) {this.name = name;} You need a way to get the human's name from another class, since it is private. The method to get the players name would look something like this: Code:java public String getName() {return name;} Key points: We replace void with the type of object we would like to return. At the end of the method we must return a value. Now, what if we sometimes don't want to return a value? In this method, if a random number is greater than 5 we will return null (Which you should already know about) Code:java public String getName() {if (new Random().nextInt(10) > 5) {return null;}return name;} Thats about it! Hope it helped
i think his not asking for a name of the player...if it was, even a noob can figure that out instead he said Variable..not name more def: my theory is he is trying to get a string of a specific player using his own function but he doesnt know how to do that...simple as making a function called public String hisFunction(Player playerName){ }