Recover from broken yaml

This commit is contained in:
md_5 2013-08-09 17:23:16 +10:00
parent 332033bb02
commit b68b6a76c7

View File

@ -14,6 +14,7 @@ import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.error.YAMLException;
public class YamlReconnectHandler extends AbstractReconnectManager public class YamlReconnectHandler extends AbstractReconnectManager
{ {
@ -34,6 +35,10 @@ public class YamlReconnectHandler extends AbstractReconnectManager
{ {
data = yaml.loadAs( rd, Map.class ); data = yaml.loadAs( rd, Map.class );
} }
} catch ( YAMLException ex )
{
file.renameTo( new File( "locations.yml.old" ) );
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Could not load reconnect locations, resetting them" );
} catch ( IOException ex ) } catch ( IOException ex )
{ {
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Could not load reconnect locations", ex ); ProxyServer.getInstance().getLogger().log( Level.WARNING, "Could not load reconnect locations", ex );