mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-09-12 06:08:07 +02:00
Use towns list in Towny worlds/* files to get valid towns (old towns
still in towns/* directory)
This commit is contained in:
parent
c65b17d80b
commit
625b62fa36
@ -39,19 +39,30 @@ public class TownyConfigHandler {
|
|||||||
*/
|
*/
|
||||||
public Map<String, Object> getRegionData(String wname) {
|
public Map<String, Object> getRegionData(String wname) {
|
||||||
Map<String, Object> rslt = new HashMap<String, Object>();
|
Map<String, Object> rslt = new HashMap<String, Object>();
|
||||||
/* List towns directory - process all towns there */
|
Properties p = new Properties();
|
||||||
File towndir = new File("plugins/Towny/data/towns");
|
FileInputStream fis = null;
|
||||||
File[] towns = towndir.listFiles(new FilenameFilter() {
|
/* Read world data for this world */
|
||||||
@Override
|
try {
|
||||||
public boolean accept(File dir, String name) {
|
fis = new FileInputStream("plugins/Towny/data/worlds/" + wname + ".txt"); /* Open and load file */
|
||||||
return name.endsWith(".txt");
|
p.load(fis);
|
||||||
|
} catch (IOException iox) {
|
||||||
|
Log.severe("Error loading Towny world file " + wname + ".txt");
|
||||||
|
} finally {
|
||||||
|
if(fis != null) {
|
||||||
|
try { fis.close(); } catch (IOException iox) {}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
for(File town : towns) {
|
/* Get towns list for our world */
|
||||||
Map<?,?> td = processTown(town, wname);
|
String t = p.getProperty("towns", "");
|
||||||
|
String towns[] = t.split(","); /* Split on commas */
|
||||||
|
/* List towns directory - process all towns there */
|
||||||
|
for(String town : towns) {
|
||||||
|
town = town.trim();
|
||||||
|
if(town.length() == 0) continue;
|
||||||
|
File tfile = new File("plugins/Towny/data/towns/" + town + ".txt");
|
||||||
|
Map<?,?> td = processTown(tfile, wname);
|
||||||
if(td != null) {
|
if(td != null) {
|
||||||
String fn = town.getName();
|
rslt.put(town, td);
|
||||||
rslt.put(fn.substring(0, fn.lastIndexOf('.')), td);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rslt;
|
return rslt;
|
||||||
|
Loading…
Reference in New Issue
Block a user