Fixed where the default gate is saved to.

This commit is contained in:
Drakia 2011-02-12 20:30:52 -08:00
parent fe1c136e63
commit 13dbf6e8f1
3 changed files with 9 additions and 7 deletions

2
README
View File

@ -73,6 +73,8 @@ Configuration
============= =============
Changes Changes
============= =============
[Version 0.07]
- Fixed where the default gate is saved to.
[Version 0.06] [Version 0.06]
- Forgot to make gates load from new location, oops - Forgot to make gates load from new location, oops
[Version 0.05] [Version 0.05]

View File

@ -87,11 +87,11 @@ public class Gate {
this.controls = controlList.toArray(this.controls); this.controls = controlList.toArray(this.controls);
} }
public void save() { public void save(String gateFolder) {
HashMap<Integer, Character> reverse = new HashMap<Integer, Character>(); HashMap<Integer, Character> reverse = new HashMap<Integer, Character>();
try { try {
BufferedWriter bw = new BufferedWriter(new FileWriter("stargates/" + filename)); BufferedWriter bw = new BufferedWriter(new FileWriter(gateFolder + filename));
writeConfig(bw, "portal-open", portalBlockOpen); writeConfig(bw, "portal-open", portalBlockOpen);
writeConfig(bw, "portal-closed", portalBlockClosed); writeConfig(bw, "portal-closed", portalBlockClosed);
@ -313,7 +313,7 @@ public class Gate {
Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Gates must have exactly 2 control points."); Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Gates must have exactly 2 control points.");
return null; return null;
} else { } else {
gate.save(); // Updates format for version changes gate.save(file.getParent() + File.separator); // Updates format for version changes
return gate; return gate;
} }
} }
@ -342,7 +342,7 @@ public class Gate {
if (files.length == 0) { if (files.length == 0) {
dir.mkdir(); dir.mkdir();
populateDefaults(dir); populateDefaults(gateFolder);
} else { } else {
for (File file : files) { for (File file : files) {
Gate gate = loadGate(file); Gate gate = loadGate(file);
@ -351,7 +351,7 @@ public class Gate {
} }
} }
public static void populateDefaults(File dir) { public static void populateDefaults(String gateFolder) {
Integer[][] layout = new Integer[][] { Integer[][] layout = new Integer[][] {
{ANYTHING, Portal.OBSIDIAN, Portal.OBSIDIAN, ANYTHING}, {ANYTHING, Portal.OBSIDIAN, Portal.OBSIDIAN, ANYTHING},
{Portal.OBSIDIAN, ENTRANCE, ENTRANCE, Portal.OBSIDIAN}, {Portal.OBSIDIAN, ENTRANCE, ENTRANCE, Portal.OBSIDIAN},
@ -364,7 +364,7 @@ public class Gate {
types.put('-', Portal.OBSIDIAN); types.put('-', Portal.OBSIDIAN);
Gate gate = new Gate("nethergate.gate", layout, types); Gate gate = new Gate("nethergate.gate", layout, types);
gate.save(); gate.save(gateFolder);
registerGate(gate); registerGate(gate);
} }

View File

@ -1,6 +1,6 @@
name: Stargate name: Stargate
main: net.TheDgtl.Stargate.Stargate main: net.TheDgtl.Stargate.Stargate
version: 0.06 version: 0.07
description: Stargate mod for Bukkit description: Stargate mod for Bukkit
author: Drakia author: Drakia
website: http://www.thedgtl.net website: http://www.thedgtl.net