Asyc logging because it's better.
This commit is contained in:
@@ -30,7 +30,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
public class PlayerVaults extends JavaPlugin {
|
public class PlayerVaults extends JavaPlugin {
|
||||||
|
|
||||||
public static PlayerVaults PLUGIN;
|
public static PlayerVaults PLUGIN;
|
||||||
public static Logger log;
|
public static Logger LOG;
|
||||||
public static boolean UPDATE = false;
|
public static boolean UPDATE = false;
|
||||||
public static String NEWVERSION = "";
|
public static String NEWVERSION = "";
|
||||||
public static String LINK = "";
|
public static String LINK = "";
|
||||||
@@ -53,7 +53,7 @@ public class PlayerVaults extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
loadLang();
|
loadLang();
|
||||||
log = getServer().getLogger();
|
LOG = getServer().getLogger();
|
||||||
getServer().getPluginManager().registerEvents(listener = new Listeners(this), this);
|
getServer().getPluginManager().registerEvents(listener = new Listeners(this), this);
|
||||||
loadConfig();
|
loadConfig();
|
||||||
loadSigns();
|
loadSigns();
|
||||||
@@ -98,14 +98,21 @@ public class PlayerVaults extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
public void checkUpdate() {
|
public void checkUpdate() {
|
||||||
if (getConfig().getBoolean("check-update")) {
|
if (getConfig().getBoolean("check-update")) {
|
||||||
Updater.UpdateType updateType = (getConfig().getBoolean("download-update") ? UpdateType.DEFAULT : UpdateType.NO_DOWNLOAD);
|
final PlayerVaults plugin = this;
|
||||||
Updater updater = new Updater(this, 50123, this.getFile(), updateType, false);
|
final File file = this.getFile();
|
||||||
UPDATE = updater.getResult() == Updater.UpdateResult.UPDATE_AVAILABLE;
|
final Updater.UpdateType updateType = (getConfig().getBoolean("download-update") ? UpdateType.DEFAULT : UpdateType.NO_DOWNLOAD);
|
||||||
NEWVERSION = updater.getLatestName();
|
getServer().getScheduler().runTaskAsynchronously(this, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Updater updater = new Updater(plugin, 50123, file, updateType, false);
|
||||||
|
PlayerVaults.UPDATE = updater.getResult() == Updater.UpdateResult.UPDATE_AVAILABLE;
|
||||||
|
PlayerVaults.NEWVERSION = updater.getLatestName();
|
||||||
if (updater.getResult() == Updater.UpdateResult.SUCCESS) {
|
if (updater.getResult() == Updater.UpdateResult.SUCCESS) {
|
||||||
getLogger().info("Successfully updated Playervaults for next restart!");
|
getLogger().info("Successfully updated Playervaults for next restart!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,8 +154,8 @@ public class PlayerVaults extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
signs.createNewFile();
|
signs.createNewFile();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.severe("PlayerVaults has encountered a fatal error trying to load the signs file.");
|
LOG.severe("PlayerVaults has encountered a fatal error trying to load the signs file.");
|
||||||
log.severe("Please report this error to drtshock and gomeow.");
|
LOG.severe("Please report this error to drtshock and gomeow.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,8 +179,8 @@ public class PlayerVaults extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
PlayerVaults.SIGNS.save(PlayerVaults.SIGNS_FILE);
|
PlayerVaults.SIGNS.save(PlayerVaults.SIGNS_FILE);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.severe("PlayerVaults has encountered an error trying to save the signs file.");
|
LOG.severe("PlayerVaults has encountered an error trying to save the signs file.");
|
||||||
log.severe("Please report this error to drtshock and gomeow.");
|
LOG.severe("Please report this error to drtshock and gomeow.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -242,8 +249,8 @@ public class PlayerVaults extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace(); // So they notice
|
e.printStackTrace(); // So they notice
|
||||||
log.severe("[PlayerVaults] Couldn't create language file.");
|
LOG.severe("[PlayerVaults] Couldn't create language file.");
|
||||||
log.severe("[PlayerVaults] This is a fatal error. Now disabling");
|
LOG.severe("[PlayerVaults] This is a fatal error. Now disabling");
|
||||||
this.setEnabled(false); // Without it loaded, we can't send them messages
|
this.setEnabled(false); // Without it loaded, we can't send them messages
|
||||||
} finally {
|
} finally {
|
||||||
if (defLangStream != null) {
|
if (defLangStream != null) {
|
||||||
@@ -275,8 +282,8 @@ public class PlayerVaults extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
conf.save(getLangFile());
|
conf.save(getLangFile());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.log(Level.WARNING, "PlayerVaults: Failed to save lang.yml.");
|
LOG.log(Level.WARNING, "PlayerVaults: Failed to save lang.yml.");
|
||||||
log.log(Level.WARNING, "PlayerVaults: Report this stack trace to drtshock and gomeow.");
|
LOG.log(Level.WARNING, "PlayerVaults: Report this stack trace to drtshock and gomeow.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.drtshock.playervaults.commands;
|
package com.drtshock.playervaults.commands;
|
||||||
|
|
||||||
import com.drtshock.playervaults.PlayerVaults;
|
import com.drtshock.playervaults.PlayerVaults;
|
||||||
|
import static com.drtshock.playervaults.PlayerVaults.LOG;
|
||||||
import com.drtshock.playervaults.util.EconomyOperations;
|
import com.drtshock.playervaults.util.EconomyOperations;
|
||||||
import com.drtshock.playervaults.util.Lang;
|
import com.drtshock.playervaults.util.Lang;
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ public class VaultOperations {
|
|||||||
}
|
}
|
||||||
if (checkPerms(player, number)) {
|
if (checkPerms(player, number)) {
|
||||||
if (EconomyOperations.payToOpen(player, number)) {
|
if (EconomyOperations.payToOpen(player, number)) {
|
||||||
PlayerVaults.log.info(String.valueOf(player.hasPermission("playervaults.small")));
|
PlayerVaults.LOG.info(String.valueOf(player.hasPermission("playervaults.small")));
|
||||||
Inventory inv = PlayerVaults.VM.loadVault(player.getName(), number);
|
Inventory inv = PlayerVaults.VM.loadVault(player.getName(), number);
|
||||||
player.openInventory(inv);
|
player.openInventory(inv);
|
||||||
player.sendMessage(Lang.TITLE.toString() + Lang.OPEN_VAULT.toString().replace("%v", arg));
|
player.sendMessage(Lang.TITLE.toString() + Lang.OPEN_VAULT.toString().replace("%v", arg));
|
||||||
|
|||||||
@@ -69,6 +69,10 @@ public class Updater {
|
|||||||
private String updateFolder = YamlConfiguration.loadConfiguration(new File("bukkit.yml")).getString("settings.update-folder"); // The folder that downloads will be placed in
|
private String updateFolder = YamlConfiguration.loadConfiguration(new File("bukkit.yml")).getString("settings.update-folder"); // The folder that downloads will be placed in
|
||||||
private Updater.UpdateResult result = Updater.UpdateResult.SUCCESS; // Used for determining the outcome of the update process
|
private Updater.UpdateResult result = Updater.UpdateResult.SUCCESS; // Used for determining the outcome of the update process
|
||||||
|
|
||||||
|
public Updater(Runnable aThis, int i, File file, UpdateType updateType, boolean b) {
|
||||||
|
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gives the dev the result of the update process. Can be obtained by called getResult().
|
* Gives the dev the result of the update process. Can be obtained by called getResult().
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user