use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class PlayerData method readExistingData.
private void readExistingData(Statement statement, UUID uuid, ResultSet resultSet) throws Exception {
playerDataHashMap.put(uuid, this);
currency = resultSet.getDouble("Currency");
guildPrestigeLevel = resultSet.getInt("GuildPrestigeLevel");
maxGuildLevel = resultSet.getInt("GuildMaxLevel");
activeGuildLevel = resultSet.getInt("GuildActiveLevel");
score = resultSet.getInt("Score");
kills = resultSet.getInt("Kills");
highestLevelKilled = resultSet.getInt("HighestLevelKilled");
deaths = resultSet.getInt("Deaths");
questsCompleted = resultSet.getInt("QuestsCompleted");
backTeleportLocation = ConfigurationLocation.serialize(resultSet.getString("BackTeleportLocation"));
if (resultSet.getBytes("QuestStatus") != null) {
try {
quests = (List<Quest>) ObjectSerializer.fromString(new String(resultSet.getBytes("QuestStatus"), "UTF-8"));
// Serializes ItemStack which require specific handling, necessary recovering the rewards
for (Quest quest : quests) if (quest instanceof CustomQuest)
((CustomQuest) quest).applyTemporaryPermissions(Bukkit.getPlayer(uuid));
} catch (Exception ex) {
new WarningMessage("Failed to serialize quest data for player " + Bukkit.getPlayer(uuid) + " ! This player's quest data will be wiped to prevent future errors.");
try {
resetQuests(uuid);
} catch (Exception ex2) {
new WarningMessage("Failed to reset quest data! Ironic.");
ex2.printStackTrace();
}
}
}
if (resultSet.getBytes("PlayerQuestCooldowns") != null) {
try {
playerQuestCooldowns = (PlayerQuestCooldowns) ObjectSerializer.fromString(new String(resultSet.getBytes("PlayerQuestCooldowns"), "UTF-8"));
playerQuestCooldowns.startCooldowns(uuid);
} catch (Exception exception) {
new WarningMessage("Failed to get player quest cooldowns! ! This player's quest cooldowns will be wiped to prevent future errors.");
try {
resetPlayerQuestCooldowns(uuid);
} catch (Exception ex2) {
new WarningMessage("Failed to reset quest cooldowns! Ironic.");
ex2.printStackTrace();
}
}
}
new InfoMessage("User " + uuid + " data successfully read!");
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class PlayerData method getDatabaseString.
private static String getDatabaseString(UUID uuid, String value) {
try {
Statement statement = getConnection().createStatement();
ResultSet resultSet = statement.executeQuery("SELECT * FROM " + PLAYER_DATA_TABLE_NAME + " WHERE PlayerUUID = '" + uuid.toString() + "';");
String reply = resultSet.getString(value);
resultSet.close();
statement.close();
return reply;
} catch (Exception e) {
new WarningMessage("Failed to get string value from database!");
e.printStackTrace();
return null;
}
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class GenerateDatabase method addColumn.
private static void addColumn(String columnName, ColumnValues type) {
try {
Statement statement = PlayerData.getConnection().createStatement();
String sql = "ALTER TABLE " + PlayerData.getPLAYER_DATA_TABLE_NAME() + " ADD " + columnName + " " + type.toString();
statement.executeUpdate(sql);
statement.close();
} catch (Exception ex) {
new WarningMessage("Failed to insert new column " + columnName);
ex.printStackTrace();
}
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class ConfigurationExporter method overwriteSHA1.
public static void overwriteSHA1(CommandSender commandSender) {
File serverProperties = null;
try {
serverProperties = new File(Paths.get(MetadataHandler.PLUGIN.getDataFolder().getParentFile().getCanonicalFile().getParentFile().toString() + File.separatorChar + "server.properties").toString());
if (!serverProperties.exists()) {
commandSender.sendMessage("[EliteMobs] Could not find server.properties file correctly! You will have to set the SHA-1 value manually!");
return;
}
} catch (Exception exception) {
new WarningMessage("[EliteMobs] Could not find server.properties file correctly! You will have to set the SHA-1 value manually.");
exception.printStackTrace();
return;
}
String sha1 = generateResourcePackSHA1(commandSender);
if (sha1 == null)
return;
try {
FileInputStream in = new FileInputStream(serverProperties);
Properties props = new Properties();
props.load(in);
in.close();
FileOutputStream out = new FileOutputStream(serverProperties);
props.setProperty("resource-pack-sha1", sha1);
props.store(out, null);
out.close();
} catch (Exception ex) {
commandSender.sendMessage("[EliteMobs] Failed to save SHA1 value " + sha1 + " ! You will have to do this manually.");
}
commandSender.sendMessage(ChatColor.GREEN + "[EliteMobs] Successfully set the value resource-pack-sha1=" + sha1 + " in server.properties!");
commandSender.sendMessage(ChatColor.RED + "[EliteMobs] Don't forget to update the downloadable resource pack at your online location of choice!" + " If you don't update the version people download things won't work correctly!");
commandSender.sendMessage(ChatColor.GREEN + "[EliteMobs] The server.properties modification will work starting with the next restart!");
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class ConfigurationExporter method copyDirectory.
private static void copyDirectory(File directoryToClone, Path targetPath) {
for (File file : directoryToClone.listFiles()) try {
new InfoMessage("Adding " + file.getCanonicalPath());
copyFile(file, targetPath);
} catch (Exception exception) {
new WarningMessage("Failed to move directories for " + file.getName() + "! Tell the dev!");
exception.printStackTrace();
}
}
Aggregations