Swf Map Loader

Load Dofus 1.29 maps from SWF file.

License

License

GroupId

GroupId

fr.arakne
ArtifactId

ArtifactId

swf-map-loader
Last Version

Last Version

0.1-alpha
Release Date

Release Date

Type

Type

jar
Description

Description

Swf Map Loader
Load Dofus 1.29 maps from SWF file.
Project URL

Project URL

https://github.com/Arakne/SwfMapLoader
Source Code Management

Source Code Management

http://github.com/Arakne/SwfMapLoader/tree/master

Download swf-map-loader

How to add to project

<!-- https://jarcasting.com/artifacts/fr.arakne/swf-map-loader/ -->
<dependency>
    <groupId>fr.arakne</groupId>
    <artifactId>swf-map-loader</artifactId>
    <version>0.1-alpha</version>
</dependency>
// https://jarcasting.com/artifacts/fr.arakne/swf-map-loader/
implementation 'fr.arakne:swf-map-loader:0.1-alpha'
// https://jarcasting.com/artifacts/fr.arakne/swf-map-loader/
implementation ("fr.arakne:swf-map-loader:0.1-alpha")
'fr.arakne:swf-map-loader:jar:0.1-alpha'
<dependency org="fr.arakne" name="swf-map-loader" rev="0.1-alpha">
  <artifact name="swf-map-loader" type="jar" />
</dependency>
@Grapes(
@Grab(group='fr.arakne', module='swf-map-loader', version='0.1-alpha')
)
libraryDependencies += "fr.arakne" % "swf-map-loader" % "0.1-alpha"
[fr.arakne/swf-map-loader "0.1-alpha"]

Dependencies

compile (4)

Group / Artifact Type Version
fr.arakne : arakne-map jar [0.2-alpha,)
org.apache.commons : commons-lang3 jar [3.9,)
org.xerial : sqlite-jdbc jar [3.28.0,)
com.jpexs » ffdec-lib jar 11.3.0

test (4)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.5.2
org.junit.jupiter : junit-jupiter-engine jar 5.5.2
org.mockito : mockito-core jar 3.0.0
io.github.artsok : rerunner-jupiter jar 2.1.3

Project Modules

There are no modules declared in this project.

Swf Map Loader

Build Status Scrutinizer Code Quality Code Coverage javadoc Maven Central

Load and parse Dofus 1.29 maps from swf file and CDN.

Installation

For installing using maven, add this dependency into the pom.xml :

<dependency>
    <groupId>fr.arakne</groupId>
    <artifactId>swf-map-loader</artifactId>
    <version>0.1-alpha</version>
</dependency>

Usage

Create your Map class

Create your map and cell classes. The map should inherit SimpleMap, which provide simple adapter for SwfMapStructure. More details about maps implementation here.

// The SimpleMap parameter should be the cell implementation
public class MyMap extends SimpleMap<MyCell> {
    public MyMap(SwfMapStructure structure, CellData[] cells, MapFactory<MyCell, MyMap> mapFactory) {
        super(structure, cells, mapFactory);
    }

    // Add methods here.
    // structure and cells attributes are accessible here (with protected access)
}

// The AbstractCellDataAdapter should be the map implementation
public class MyCell extends AbstractCellDataAdapter<MyMap> {
    public MyCell(MyMap map, CellData data, int id) {
        super(map, data, id);
    }

    // Implements other methods here...
}

After that, you can create your factory for instantiate those classes :

class MyMapFactory implements MapFactory<MyCell, MyMap> {
    @Override
    public MyMap createMap(SwfMapStructure structure, CellData[] cells) {
        return new MyMap(structure, cells, this);
    }

    @Override
    public MyCell createCell(MyCustomMap map, int id, CellData cell) {
        return new MyCell(map, cell, id);
    }
}

Configure the loader

Once map and cell classes implemented, you can configure the MapLoader. For this purpose, you can use MapLoaderConfigurator :

// Create the configurator. Note: parameters must match with map and cell implementations
MapLoaderConfigurator<MyCell, MyMap> configurator = new MapLoaderConfigurator<>();

configurator
    .factory(new MyMapFactory()) // Configure the factory : link the custom map implementation to the loader
    .baseUrl("http://my-server.com/dofus/maps") // Define the CDN URL. SWF files must be located at the given path
    .cacheFile("./map-cache.sqlite") // Enable SQLite cache system : maps will be parsed once, and will be retrieved from the cache for further access.
;

// Create the map loader
MapLoader<MyCell, MyMap> loader = configurator.create();

Load maps

Final step : you can load the map !

// Handler for the GDM packet
class LoadMapPacketHandler {
    private MapLoader<MyCell, MyMap> loader;
    // ...

    public void handlePacket(String data) {
        String[] parts = data.split("\\|");

        // Load the map
        client.setCurrentMap(
            loader.load(Integer.parseInt(parts[0]), parts[1], parts[2])
        );
    }
}

You can also directly load a SWF file :

File swfFile = new File("...");
String mapKey = xxx;

// Convert File to URL, and loads it
MyMap map = loader.load(swfFile.toURI().toURL(), mapKey);

Licence

This project is licensed under the LGPLv3 licence. See COPYING and COPYING.LESSER files for details.

It also links FFDec Library which is licensed with GNU LGPL v3, for parsing SWF files. See lib/ffdec for more details.

fr.arakne
Open source Dofus 1.29 platform

Versions

Version
0.1-alpha