Ok well here is my problem. I have made the basics to this plugin i am fiddling around with, for my first project. And i have ran into this problem. So i have 3 classes BlastPick.java, BlastPickPlayerListener.java, BlastPickBlockListener. and in my PlayeListener i have 2 methods onPlayerCommand and onLength. Code: public int onLength(PlayerChatEvent event) { String s; int Length = 0; String[] split = event.getMessage().split(" "); if ((split[0].equalsIgnoreCase("/BlastLength"))) { s = split[1]; Length = Integer.parseInt(s.trim()); } return Length; } Code: public void onPlayerCommand(PlayerChatEvent event) { //Make the message a string. String[] split = event.getMessage().split(" "); //Get the player that talked. Player player = event.getPlayer(); //If the first part of the string is /BlastPick or /b then do this. if ((split[0].equalsIgnoreCase("/BlastBox"))) { //Run the method toggleVision for player plugin.toggleVision(player); event.setCancelled(true); } } How would i get the return value of my onLength method into my blocklistener class.
If you need to do such a thing why not have BlastPick supersede the other two classes and define onLength() there? The simple solution here is to make onLength() static and call BlastPickPlayerListener.onLength(param); Code: public static int onLength(PlayerChatEvent event) { //do stuff } }
I agree, make it static if its a method that doesn't need an instance of a class to use. Even better, separate out 'helper' methods like that into a utilities class that is static and just access the methods from there.