Maven repo for SpongeCommon

Hey guys,
today I tried to use the org.spongepowered.common.world.DimensionManager (Dimension Manager).
Problem is, that it seems like the package common is not included, so I can’t use the DimensionManager class.

I added SpongeAPI like this:

<repositories>
        <repository>
            <id>sponge-maven-repo</id>
            <name>Sponge maven repo</name>
            <url>http://repo.spongepowered.org/maven</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.spongepowered</groupId>
            <artifactId>spongeapi</artifactId>
            <version>2.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>ninja.leaping.configurate</groupId>
            <artifactId>configurate-yaml</artifactId>
            <version>2.0</version>
            <!-- Update this with the most recent version -->
        </dependency>
    </dependencies>

How can I add SpongeCommon (maven)?
Greets

You are still using Sponge 2.1. You should change for that.

    <dependencies>
        <dependency>
            <groupId>org.spongepowered</groupId>
            <artifactId>spongeapi</artifactId>
            <version>3.0.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
1 Like

What do you need to use DimensionManager for? That’s implementation code that plugins shouldn’t use unless there’s a legitimate use-case.

However, you should not depend on SpongeCommon, instead use SpongeForge or SpongeVanilla if you want to tie your plugin to a specific implementation.

Just curious, why do you suggest depending on a specific implementation rather then supporting both by depending on SpongeCommon? Or is it not possible to support both in this manner?

SpongeCommon is really just a source-set component of both implementations, it’s not a separate dependency and should not be seen as such. If you only use org.spongepowered.common in your usage of SpongeForge/Vanilla then yes it will work on both but again this is all very implementation specific and I don’t recommend using.

I was looking at the code of ProjectWorlds. To register a new (sponge) config (convert bukkit worlds to sponge worlds with /load), i need the dimension manager.
This is the code, where I need to use the manager. (code by @TrenTech - ProjectWorlds)

public void createNewConfig(String dimType) throws IOException{
		int dimId = DimensionManager.getNextFreeDimId();
		DimensionManager.registerDimension(dimId, 0);

		CompoundTag compoundTag = new CompoundTag("SpongeData", null);	
		
		compoundTag.put(new IntegerTag("dimensionId", dimId));
		compoundTag.put(new LongTag("uuid_least", -6732046318667659594L));
		compoundTag.put(new LongTag("uuid_most", 9143053678590905554L));
		compoundTag.put(new StringTag("dimensionType", dimType));

		CompoundTag compoundPlayerId = new CompoundTag("", null);
		
		compoundPlayerId.put(new LongTag("uuid_least", -7628444587550319768L));
		compoundPlayerId.put(new LongTag("uuid_most", 4244735002832685980L));

		List<NBTTag> listPlayerId = new ArrayList<>();
		listPlayerId.add(compoundPlayerId);
		
		compoundTag.put(new ListTag("PlayerIdTable", listPlayerId));

		CompoundTag compoundRoot = new CompoundTag("", null);

		compoundRoot.put(compoundTag);

		List<NBTTag> list = new ArrayList<>();
		
		list.add(compoundRoot);

		XNBT.saveTags(list, dataFile);
		
		this.compoundTag = compoundTag;
		
		WorldData worldData = new WorldData(worldName);
		
		if(!worldData.exists()){
			return;
		}
		
		if(!worldData.isCorrectLevelName()){
			worldData.setLevelName();
		}
	}

That code is outdated. You do not need to create data files to import bukkit worlds.

Hmm, strange thing… I cloned your git repo, so do you use this code in your plugin (now) or not? :smiley:
Greets

No. That was used as a workaround while some issues were being worked out in Sponge. It’s no longer needed.

1 Like

Sponge has its own worldmigrator now :wink:


I’d still try to depend on SpongeAPI only, not the implementation…

I think all the migrator does is move bukkit worlds to Sponges respected locations unless things have changed since I last looked. WorldProperties still needs to be created.

1 Like