mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Don't make a new File every time.
This commit is contained in:
parent
182b01ac2f
commit
e1f6366a00
@ -21,6 +21,7 @@ import com.gmail.nossr50.util.player.UserManager;
|
|||||||
public final class PartyManager {
|
public final class PartyManager {
|
||||||
private static String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
|
private static String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
|
||||||
private static List<Party> parties = new ArrayList<Party>();
|
private static List<Party> parties = new ArrayList<Party>();
|
||||||
|
private static File partyFile = new File(partiesFilePath);
|
||||||
|
|
||||||
private PartyManager() {}
|
private PartyManager() {}
|
||||||
|
|
||||||
@ -439,13 +440,11 @@ public final class PartyManager {
|
|||||||
* Load party file.
|
* Load party file.
|
||||||
*/
|
*/
|
||||||
public static void loadParties() {
|
public static void loadParties() {
|
||||||
File file = new File(partiesFilePath);
|
if (!partyFile.exists()) {
|
||||||
|
|
||||||
if (!file.exists()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
YamlConfiguration partiesFile = YamlConfiguration.loadConfiguration(file);
|
YamlConfiguration partiesFile = YamlConfiguration.loadConfiguration(partyFile);
|
||||||
|
|
||||||
for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) {
|
for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) {
|
||||||
Party party = new Party();
|
Party party = new Party();
|
||||||
@ -472,10 +471,8 @@ public final class PartyManager {
|
|||||||
* Save party file.
|
* Save party file.
|
||||||
*/
|
*/
|
||||||
public static void saveParties() {
|
public static void saveParties() {
|
||||||
File file = new File(partiesFilePath);
|
if (partyFile.exists()) {
|
||||||
|
partyFile.delete();
|
||||||
if (file.exists()) {
|
|
||||||
file.delete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
YamlConfiguration partiesFile = new YamlConfiguration();
|
YamlConfiguration partiesFile = new YamlConfiguration();
|
||||||
@ -501,7 +498,7 @@ public final class PartyManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
partiesFile.save(new File(partiesFilePath));
|
partiesFile.save(partyFile);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Loading…
Reference in New Issue
Block a user