Removed obsolete quest global data.
This commit is contained in:
@@ -64,10 +64,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Couldn't restore global variables.");
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
compareAndSetChanges(true, false);
|
||||
}
|
||||
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + getSet().size() + " variables.");
|
||||
return true;
|
||||
}
|
||||
@@ -75,12 +72,6 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
@Override
|
||||
public boolean storeMe()
|
||||
{
|
||||
// No changes, nothing to store.
|
||||
if (!hasChanges())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement del = con.createStatement();
|
||||
PreparedStatement st = con.prepareStatement(INSERT_QUERY))
|
||||
@@ -102,10 +93,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Couldn't save global variables to database.", e);
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
compareAndSetChanges(true, false);
|
||||
}
|
||||
|
||||
LOGGER.info(getClass().getSimpleName() + ": Stored " + getSet().size() + " variables.");
|
||||
return true;
|
||||
}
|
||||
|
@@ -1121,102 +1121,6 @@ public class Quest extends ManagedScript
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert (or Update) in the database variables that need to stay persistant for this quest after a reboot. This function is for storage of values that do not related to a specific player but are global for all characters. For example, if we need to disable a quest-gatekeeper until a certain
|
||||
* time (as is done with some grand-boss gatekeepers), we can save that time in the DB.
|
||||
* @param var : String designating the name of the variable for the quest
|
||||
* @param value : String designating the value of the variable for the quest
|
||||
*/
|
||||
public void saveGlobalQuestVar(String var, String value)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
PreparedStatement statement;
|
||||
statement = con.prepareStatement("REPLACE INTO quest_global_data (quest_name,var,value) VALUES (?,?,?)");
|
||||
statement.setString(1, getName());
|
||||
statement.setString(2, var);
|
||||
statement.setString(3, value);
|
||||
statement.executeUpdate();
|
||||
statement.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning("could not insert global quest variable: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from the database a previously saved variable for this quest. Due to performance considerations, this function should best be used only when the quest is first loaded. Subclasses of this class can define structures into which these loaded values can be saved. However, on-demand usage of
|
||||
* this function throughout the script is not prohibited, only not recommended. Values read from this function were entered by calls to "saveGlobalQuestVar"
|
||||
* @param var : String designating the name of the variable for the quest
|
||||
* @return String : String representing the loaded value for the passed var, or an empty string if the var was invalid
|
||||
*/
|
||||
public String loadGlobalQuestVar(String var)
|
||||
{
|
||||
String result = "";
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
PreparedStatement statement;
|
||||
statement = con.prepareStatement("SELECT value FROM quest_global_data WHERE quest_name = ? AND var = ?");
|
||||
statement.setString(1, getName());
|
||||
statement.setString(2, var);
|
||||
final ResultSet rs = statement.executeQuery();
|
||||
|
||||
if (rs.first())
|
||||
{
|
||||
result = rs.getString(1);
|
||||
}
|
||||
|
||||
rs.close();
|
||||
statement.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning("could not load global quest variable: " + e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permanently delete from the database a global quest variable that was previously saved for this quest.
|
||||
* @param var : String designating the name of the variable for the quest
|
||||
*/
|
||||
public void deleteGlobalQuestVar(String var)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
PreparedStatement statement;
|
||||
statement = con.prepareStatement("DELETE FROM quest_global_data WHERE quest_name = ? AND var = ?");
|
||||
statement.setString(1, getName());
|
||||
statement.setString(2, var);
|
||||
statement.executeUpdate();
|
||||
statement.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning("could not delete global quest variable: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Permanently delete from the database all global quest variables that was previously saved for this quest.
|
||||
*/
|
||||
public void deleteAllGlobalQuestVars()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
PreparedStatement statement;
|
||||
statement = con.prepareStatement("DELETE FROM quest_global_data WHERE quest_name = ?");
|
||||
statement.setString(1, getName());
|
||||
statement.executeUpdate();
|
||||
statement.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning("could not delete global quest variables: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert in the database the quest for the player.
|
||||
* @param qs : QuestState pointing out the state of the quest
|
||||
|
Reference in New Issue
Block a user