mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-23 02:42:31 +00:00
Fixed NPE when database was not initialized
This commit is contained in:
parent
198f83c738
commit
dcd50bad33
@ -42,7 +42,6 @@ public class ShopChest extends JavaPlugin {
|
|||||||
private String latestVersion = "";
|
private String latestVersion = "";
|
||||||
private String downloadLink = "";
|
private String downloadLink = "";
|
||||||
private ShopUtils shopUtils;
|
private ShopUtils shopUtils;
|
||||||
private File debugLogFile;
|
|
||||||
private FileWriter fw;
|
private FileWriter fw;
|
||||||
private WorldGuardPlugin worldGuard;
|
private WorldGuardPlugin worldGuard;
|
||||||
|
|
||||||
@ -73,7 +72,7 @@ public class ShopChest extends JavaPlugin {
|
|||||||
config = new Config(this);
|
config = new Config(this);
|
||||||
|
|
||||||
if (config.enable_debug_log) {
|
if (config.enable_debug_log) {
|
||||||
debugLogFile = new File(getDataFolder(), "debug.txt");
|
File debugLogFile = new File(getDataFolder(), "debug.txt");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!debugLogFile.exists()) {
|
if (!debugLogFile.exists()) {
|
||||||
@ -308,6 +307,7 @@ public class ShopChest extends JavaPlugin {
|
|||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
debug("Disabling ShopChest...");
|
debug("Disabling ShopChest...");
|
||||||
|
|
||||||
|
if (database != null) {
|
||||||
int highestId = database.getHighestID();
|
int highestId = database.getHighestID();
|
||||||
|
|
||||||
for (int i = 1; i <= highestId; i++) {
|
for (int i = 1; i <= highestId; i++) {
|
||||||
@ -320,6 +320,7 @@ public class ShopChest extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
database.disconnect();
|
database.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
if (fw != null && config.enable_debug_log) {
|
if (fw != null && config.enable_debug_log) {
|
||||||
try {
|
try {
|
||||||
@ -336,7 +337,7 @@ public class ShopChest extends JavaPlugin {
|
|||||||
* @param message Message to print
|
* @param message Message to print
|
||||||
*/
|
*/
|
||||||
public void debug(String message) {
|
public void debug(String message) {
|
||||||
if (config.enable_debug_log) {
|
if (config.enable_debug_log && fw != null) {
|
||||||
try {
|
try {
|
||||||
Calendar c = Calendar.getInstance();
|
Calendar c = Calendar.getInstance();
|
||||||
String timestamp = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(c.getTime());
|
String timestamp = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(c.getTime());
|
||||||
@ -354,7 +355,7 @@ public class ShopChest extends JavaPlugin {
|
|||||||
* @param throwable {@link Throwable} whose stacktrace will be printed
|
* @param throwable {@link Throwable} whose stacktrace will be printed
|
||||||
*/
|
*/
|
||||||
public void debug(Throwable throwable) {
|
public void debug(Throwable throwable) {
|
||||||
if (config.enable_debug_log) {
|
if (config.enable_debug_log && fw != null) {
|
||||||
PrintWriter pw = new PrintWriter(fw);
|
PrintWriter pw = new PrintWriter(fw);
|
||||||
throwable.printStackTrace(pw);
|
throwable.printStackTrace(pw);
|
||||||
pw.flush();
|
pw.flush();
|
||||||
|
Loading…
Reference in New Issue
Block a user