What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Sgather Profile to GB2 Converter

CptJesus

Member
Joined
Jan 4, 2011
Messages
49
Reaction score
3
This is NOT a plugin per-se, its actually a Java program. I wrote it because I felt that many of the SGather profiles are superior to what we have here, so this is a quick and easy way to convert it. Only the waypoints are converted, not the Blackspots or the Town Waypoints, because GB2 uses a different format. I'm releasing the source, so if you're paranoid, just compile it yourself. If I'm breaking the rules for some reason, let me know.

Code:
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.swing.JFileChooser;


public class Main {
	public static void main(String[] args) throws FileNotFoundException{
		ConverterClass c = new ConverterClass();
	}
	
	static class ConverterClass{
		public ConverterClass() throws FileNotFoundException{
				try {
					doStuff();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		
		private static void doStuff() throws IOException{
			String x;
			String y;
			String z;
			boolean cont = true;
			Pattern p = Pattern.compile(">(.*)<");
			final JFileChooser fc = new JFileChooser();
			fc.setCurrentDirectory(new File(new File(".").getAbsolutePath()));
			fc.showOpenDialog(fc);
			
			File f = new File(fc.getSelectedFile().getName().substring(0, fc.getSelectedFile().getName().length() - 4) + " - Converted.xml");
			FileWriter fw = new FileWriter(f);
			PrintWriter pw = new PrintWriter(fw);
			
			Scanner s = new Scanner(fc.getSelectedFile());
			
			//Write the Header for the HB Profile
			pw.print("<HBProfile>\n\t<Name></Name>\n\t<MinDurability>0.4</MinDurability>\n\t<MinFreeBagSlots>1</MinFreeBagSlots>\n\n" +
					"\t<MinLevel>1</MinLevel>\n\t<MaxLevel>86</MaxLevel>\n\t<Factions>99999</Factions>\n\n\t<MailGrey>False</MailGrey>\n\t<MailWhite>" +
					"True</MailWhite>\n\t<MailGreen>True</MailGreen>\n\t<MailBlue>True</MailBlue>\n\t<MailPurple>True</MailPurple>\n\n\t<SellGrey>True</SellGrey>\n\t" +
					"<SellWhite>True</SellWhite>\n\t<SellGreen>False</SellGreen>\n\t<SellBlue>False</SellBlue>\n\t<SellPurple>False</SellPurple>\n\n\t<Hotspots>");
			
			//Write the hotspots
			while (s.hasNext()){
				String line = s.nextLine();
				if (line.contains("<Position>") && cont){
					line = s.nextLine();
					Matcher m = p.matcher(line);
					m.find();
					x = m.group(1);
					
					line = s.nextLine();
					m = p.matcher(line);
					m.find();
					y = m.group(1);
					
					line = s.nextLine();
					m = p.matcher(line);
					m.find();
					z = m.group(1);
					
					pw.print("\n\t\t<Hotspot X=\"" + x +"\" Y=\"" + y + "\" Z=\"" + z + "\" />");
				}
				
				if (line.contains("/Waypoints")){
					cont = false;					
				}
			}
			
			//Write the footer and close
			pw.print("\n\t</Hotspots>\n</HBProfile>");
			pw.close();
		}
	}
}

Download Link
 
Thank's, but i hope you didnt steal the source code from Mmowned and post it as your own work.
 
That was me on mmowned...the names are even the same >.>

ahh cool, i just saw a quick glimpse of it yestaday and didnt have the time to see who posted it today, i appoligise anyway's :)
 
Back
Top