mirror of https://github.com/PikaMug/Quests.git
New quest IDs use leading zeros
This commit is contained in:
parent
45a64a05ed
commit
5805b47e88
|
@ -562,7 +562,7 @@ public class BukkitQuestsPlugin extends JavaPlugin implements Quests {
|
||||||
* @param fileName Name of file to attempt move
|
* @param fileName Name of file to attempt move
|
||||||
*/
|
*/
|
||||||
private void moveStorageResource(String fileName) {
|
private void moveStorageResource(String fileName) {
|
||||||
File storageFile = new File(getDataFolder(), fileName);
|
final File storageFile = new File(getDataFolder(), fileName);
|
||||||
if (!storageFile.isFile()) {
|
if (!storageFile.isFile()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -575,9 +575,9 @@ public class BukkitQuestsPlugin extends JavaPlugin implements Quests {
|
||||||
+ outDir.canWrite() + ")");
|
+ outDir.canWrite() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean q = storageFile.renameTo(outFile);
|
final boolean moved = storageFile.renameTo(outFile);
|
||||||
if (!q) {
|
if (!moved) {
|
||||||
getLogger().severe("Unable to move " + fileName + " file. Check folder permissions and restart.");
|
getLogger().severe("Unable to move " + fileName + " file. Check folder permissions and restart server.");
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -866,15 +867,17 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||||
ConfigurationSection newSection = null;
|
ConfigurationSection newSection = null;
|
||||||
if (context.getSessionData(Key.Q_ID) == null) {
|
if (context.getSessionData(Key.Q_ID) == null) {
|
||||||
// Creating
|
// Creating
|
||||||
int customNum = 1;
|
int num = 1;
|
||||||
|
final int padding = 6;
|
||||||
|
final String customNum = String.format(Locale.US, "%0" + padding + "d", num);
|
||||||
while (true) {
|
while (true) {
|
||||||
if (questSection.contains("custom" + customNum)) {
|
if (questSection.contains(customNum)) {
|
||||||
customNum++;
|
num++;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newSection = questSection.createSection("custom" + customNum);
|
newSection = questSection.createSection(customNum);
|
||||||
} else {
|
} else {
|
||||||
// Editing
|
// Editing
|
||||||
final String qid = (String)context.getSessionData(Key.Q_ID);
|
final String qid = (String)context.getSessionData(Key.Q_ID);
|
||||||
|
|
Loading…
Reference in New Issue