Fix the error when either of the command handlers are null, fixes #40
These errors only happen when the plugin didn't load successfully, you'll need to check further up in the console/server log to see what actually caused this error.
This commit is contained in:
		| @@ -11,6 +11,7 @@ import com.graywolf336.jail.beans.Jail; | ||||
| import com.graywolf336.jail.beans.Prisoner; | ||||
| import com.graywolf336.jail.command.CommandHandler; | ||||
| import com.graywolf336.jail.command.JailHandler; | ||||
| import com.graywolf336.jail.enums.Lang; | ||||
| import com.graywolf336.jail.enums.Settings; | ||||
| import com.graywolf336.jail.legacy.LegacyManager; | ||||
| import com.graywolf336.jail.listeners.BlockListener; | ||||
| @@ -171,11 +172,16 @@ public class JailMain extends JavaPlugin { | ||||
|      * Send the command off to the CommandHandler class, that way this main class doesn't get clogged up. | ||||
|      */ | ||||
|     public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) { | ||||
|         if(commandLabel.equalsIgnoreCase("jail") || commandLabel.equalsIgnoreCase("j")) { | ||||
|             jh.parseCommand(jm, sender, args); | ||||
|         }else { | ||||
|             cmdHand.handleCommand(jm, sender, command.getName().toLowerCase(), args); | ||||
|         } | ||||
|     	if(jh == null || cmdHand == null) { | ||||
|     		sender.sendMessage(Lang.PLUGINNOTLOADED.get()); | ||||
|     		getServer().getConsoleSender().sendMessage(Lang.PLUGINNOTLOADED.get()); | ||||
|     	}else { | ||||
|             if(commandLabel.equalsIgnoreCase("jail") || commandLabel.equalsIgnoreCase("j")) { | ||||
|             	jh.parseCommand(jm, sender, args); | ||||
|             }else { | ||||
|                 cmdHand.handleCommand(jm, sender, command.getName().toLowerCase(), args); | ||||
|             } | ||||
|     	} | ||||
|  | ||||
|         return true;//Always return true here, that way we can handle the help and command usage ourself. | ||||
|     } | ||||
|   | ||||
| @@ -163,6 +163,8 @@ public enum Lang { | ||||
|     PLAYERNOTONLINE("general"), | ||||
|     /** The message sent to the sender when the plugin data has been reloaded. */ | ||||
|     PLUGINRELOADED("general"), | ||||
|     /** The message sent to the sender of a command when the plugin didn't start correct. */ | ||||
|     PLUGINNOTLOADED("general"), | ||||
|     /** The message sent whenever the prisoners are cleared from jail(s). */ | ||||
|     PRISONERSCLEARED("general"), | ||||
|     /** The format we should use when entering a record into flatfile or showing it. */ | ||||
|   | ||||
| @@ -32,6 +32,7 @@ language: | ||||
|     numberformatincorrect: '&cNumber format is incorrect.' | ||||
|     playercontextrequired: '&cA player context is required for this.' | ||||
|     playernotonline: '&cThat player is not online!' | ||||
|     pluginnotloaded: '&cThe plugin did not load correctly, tell the administrator to check the console for errors.' | ||||
|     pluginreloaded: '&9Jail data successfully reloaded.' | ||||
|     prisonerscleared: '&cAll the prisoners from %0% have been cleared.' | ||||
|     recordentry: '&7[%0%]: &9%1% &fjailed by &9%2% &ffor &9%3% &fminutes with a reason of &9%4%&f. [%5%]' | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 graywolf336
					graywolf336