mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-22 02:25:42 +01:00
Fix duplicate actions.yml section if legacy one is present. Bump version
This commit is contained in:
parent
501b2b3fb4
commit
946779b17e
2
dist/pom.xml
vendored
2
dist/pom.xml
vendored
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>me.blackvein.quests</groupId>
|
||||
<artifactId>quests-parent</artifactId>
|
||||
<version>3.7.1</version>
|
||||
<version>3.7.2</version>
|
||||
</parent>
|
||||
<artifactId>quests-dist</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>me.blackvein.quests</groupId>
|
||||
<artifactId>quests-parent</artifactId>
|
||||
<version>3.7.1</version>
|
||||
<version>3.7.2</version>
|
||||
</parent>
|
||||
<artifactId>quests-main</artifactId>
|
||||
|
||||
|
@ -473,7 +473,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
@Override
|
||||
public void run() {
|
||||
loadQuests();
|
||||
loadEvents();
|
||||
loadActions();
|
||||
getLogger().log(Level.INFO, "Loaded " + quests.size() + " Quest(s)"
|
||||
+ ", " + events.size() + " Event(s)"
|
||||
+ ", " + Lang.size() + " Phrase(s)");
|
||||
@ -489,6 +489,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
}, 5L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load player and NPC GUI data from file
|
||||
*/
|
||||
public void loadData() {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
File dataFile = new File(this.getDataFolder(), "data.yml");
|
||||
@ -503,7 +506,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
questNpcGuis.addAll(ids);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load modules from file
|
||||
*/
|
||||
public void loadModules() {
|
||||
File f = new File(this.getDataFolder(), "modules");
|
||||
if (f.exists() && f.isDirectory()) {
|
||||
@ -1252,7 +1258,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
|
||||
loadQuests();
|
||||
loadData();
|
||||
loadEvents();
|
||||
loadActions();
|
||||
// Reload config from disc in-case a setting was changed
|
||||
reloadConfig();
|
||||
settings.init();
|
||||
@ -1325,6 +1331,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
return qs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load quests from file
|
||||
*/
|
||||
public void loadQuests() {
|
||||
boolean failedToLoad;
|
||||
boolean needsSaving = false;
|
||||
@ -2714,26 +2723,45 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
}
|
||||
throw new StageFailedException();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load actions from file
|
||||
*
|
||||
* @deprecated Use loadActions()
|
||||
*/
|
||||
public void loadEvents() {
|
||||
loadActions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load actions from file
|
||||
*/
|
||||
public void loadActions() {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
File legacyFile = new File(this.getDataFolder(), "events.yml");
|
||||
File actionsFile = new File(this.getDataFolder(), "actions.yml");
|
||||
if (legacyFile.exists()) {
|
||||
getLogger().log(Level.INFO, "Renaming legacy \"events.yml\" to \"actions.yml\"");
|
||||
// Using isFile() because exists() and renameTo() can return false positives
|
||||
if (legacyFile.isFile()) {
|
||||
getLogger().log(Level.INFO, "Renaming legacy events.yml to actions.yml ...");
|
||||
try {
|
||||
if (legacyFile.renameTo(actionsFile)) {
|
||||
getLogger().log(Level.INFO, "Success! Deleting legacy \"events.yml\" ... done!");
|
||||
legacyFile.renameTo(actionsFile);
|
||||
if (actionsFile.isFile()) {
|
||||
getLogger().log(Level.INFO, "Success! Deleting legacy events.yml ...");
|
||||
legacyFile.delete();
|
||||
getLogger().log(Level.INFO, "Done!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
getLogger().log(Level.WARNING, "Unable to rename \"events.yml\" to \"actions.yml\"");
|
||||
getLogger().log(Level.WARNING, "Unable to rename events.yml to actions.yml");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (actionsFile.length() != 0) {
|
||||
try {
|
||||
config.load(actionsFile);
|
||||
if (actionsFile.isFile()) {
|
||||
config.load(actionsFile);
|
||||
} else {
|
||||
config.load(legacyFile);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidConfigurationException e) {
|
||||
@ -3209,14 +3237,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
* @deprecated Use getAction()
|
||||
*/
|
||||
public Action getEvent(String name) {
|
||||
for (Action e : events) {
|
||||
if (e.getName().equalsIgnoreCase(name)){
|
||||
return e;
|
||||
} else if (e.getName().toLowerCase().startsWith(name.toLowerCase())) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return getAction(name);
|
||||
}
|
||||
|
||||
public Location getNPCLocation(int id) {
|
||||
|
@ -401,13 +401,13 @@ public class Action {
|
||||
}
|
||||
File legacy = new File(plugin.getDataFolder(), "events.yml");
|
||||
File actions = new File(plugin.getDataFolder(), "actions.yml");
|
||||
if (legacy.exists()) {
|
||||
plugin.getLogger().info("Renaming legacy \"events.yml\" to \"actions.yml\" before loading data for " + name);
|
||||
legacy.renameTo(actions);
|
||||
}
|
||||
FileConfiguration data = new YamlConfiguration();
|
||||
try {
|
||||
data.load(actions);
|
||||
if (actions.isFile()) {
|
||||
data.load(actions);
|
||||
} else {
|
||||
data.load(legacy);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidConfigurationException e) {
|
||||
|
@ -905,13 +905,19 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorReadingFile"));
|
||||
return;
|
||||
}
|
||||
String key = "actions";
|
||||
ConfigurationSection sec = data.getConfigurationSection(key);
|
||||
if (sec == null) {
|
||||
key = "events";
|
||||
sec = data.getConfigurationSection(key);
|
||||
}
|
||||
if (((String) context.getSessionData(CK.E_OLD_EVENT)).isEmpty() == false) {
|
||||
data.set("events." + (String) context.getSessionData(CK.E_OLD_EVENT), null);
|
||||
data.set(key + "." + (String) context.getSessionData(CK.E_OLD_EVENT), null);
|
||||
LinkedList<Action> temp = plugin.getEvents();
|
||||
temp.remove(plugin.getAction((String) context.getSessionData(CK.E_OLD_EVENT)));
|
||||
plugin.setEvents(temp);
|
||||
}
|
||||
ConfigurationSection section = data.createSection("actions." + (String) context.getSessionData(CK.E_NAME));
|
||||
ConfigurationSection section = data.createSection(key + "." + (String) context.getSessionData(CK.E_NAME));
|
||||
names.remove((String) context.getSessionData(CK.E_NAME));
|
||||
if (context.getSessionData(CK.E_MESSAGE) != null) {
|
||||
section.set("message", getCString(context, CK.E_MESSAGE));
|
||||
|
4
pom.xml
4
pom.xml
@ -6,12 +6,12 @@
|
||||
<groupId>me.blackvein.quests</groupId>
|
||||
|
||||
<artifactId>quests-parent</artifactId>
|
||||
<version>3.7.1</version>
|
||||
<version>3.7.2</version>
|
||||
<name>quests</name>
|
||||
<url>https://github.com/PikaMug/Quests/</url>
|
||||
|
||||
<properties>
|
||||
<revision>3.7.1</revision>
|
||||
<revision>3.7.2</revision>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>me.blackvein.quests</groupId>
|
||||
<artifactId>quests-parent</artifactId>
|
||||
<version>3.7.1</version>
|
||||
<version>3.7.2</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>me.blackvein.quests</groupId>
|
||||
<artifactId>quests-parent</artifactId>
|
||||
<version>3.7.1</version>
|
||||
<version>3.7.2</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>me.blackvein.quests</groupId>
|
||||
<artifactId>quests-parent</artifactId>
|
||||
<version>3.7.1</version>
|
||||
<version>3.7.2</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
Loading…
Reference in New Issue
Block a user