hey guys, how i can import a Player, like args[0] to a void? Code: public void run() { // how to define player ? this.player.kickPlayer(); }
You can't import something to "void". It tells you that there is no return value. If you want to have some arguments in the method you could do with: public void run( Player player )
i know the problem your having and what you need to do is make your Player import a final like Code: final Player player = (Player) sender;
hm i got errors when i make (Player player)... Code: plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { this.player.kickPlayer(); } }, 80L);
Why are you placing that code within an delayed task? You also failed to register the player within the brackets.
yeah thats what i ask, how to register the player in this void. i want a 4 sec delayed kick... like /kick2 <Player>
dont work without this... i fixed it a other way, i made a seperate command to it, bcause "Bukkit.dispatchCommand(Bukkit.getConsoleSender()" is workin in that void thanks for the help!
No it won't work! Code:java public class MyClass { public Player player; // Here is no final "needed" ... public void myMethod() { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Overridepublic void run() {player.kickPlayer(); // You cannot work with "this" here to make a reference to MyClass!!!!! You only will get methods from Runnable and Object!}}, 80L); } } You should learn inheritance and visibility of classes and its fields and methods
im trying to tell you to do this. Code: final Player player = (Player) sender; plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { player.kickPlayer("test"); } }, 80L);