Attempting to port a plugin

Good evening forum!

I’m working on porting Laborus to API 7.1
As someone who has never coded in his life… man is it rough :slight_smile:

I’ve figured out (i think) a few issues, deprecated code that a simple copy paste job seemed to fix (namedCause)

However… i cannot for the life of me figure out this line here:
extent.spawnEntity(itemEntity, Cause.builder().owner(player).build());

IntelliJ says “Cannot resolve method '”

I’m hoping someone could perhaps explain what this was changed to between API 7 and 7.1.0-Snapshot.

7.1.0 there no breaking changes api 7 just another it just 7.1.0 brings add a few things to 7.1.0
however the import for player nothing nothing wrong with it if your building against sponge
you shouldn’t use deprecated code even if it does the same thing, it just that it very well could break the plugin

Silly question;
How do i tell if i am building against API 7.1 when using IntelliJ?

Check the build.gradle in there should be dependencies that what your looking at for what api your using

It was 7.0.0-SNAPSHOT, i changed it to 7.1.0-SNAPSHOT

threw all sorts of errors;

See pastebin above

May i ask?
what plugin are you trying to make or port over? and what pastebin ? lol

Sorry on the Pastebin… that was to my buddy on discord; thought it was here too lol

I can silence the “Error:(11, 41) java: cannot find symbol
symbol: class NamedCause
location: package org.spongepowered.api.event.cause
Error:(28, 42) java: cannot find symbol
symbol: variable NamedCause
location: class de.lergin.laborus.job.bonus.EconomyJobBonus”

errors by changing
import org.spongepowered.api.event.cause.NamedCause;
import org.spongepowered.api.event.cause.EventContext;

and changing
NamedCause.Source to

But i am just ripping someone elses code who fixed a plugin that had economy issues; of which this error is related.

okay well first thing first Cause and context method been completely change you can read all about it here
i can’t help with much so little information
changing method like that wont help at all

While i read this and try to make sense of it… here is what i changed:

private final Cause cause = Cause.of(NamedCause.source(Sponge.getPluginManager().fromInstance(Laborus.instance())));

to private final Cause cause = Cause.of(EventContext.empty(),(Sponge.getPluginManager().fromInstance(Laborus.instance())));

that silences errors. not that i know if it works

That should work fine if not, here what you can try

private final Cause cause = Cause.of(EventContext.empty(), Laborus.instance());

i do not know if this work because i dont know what plugin or what is it your doing xD

Laborus; GitHub - Lergin/Laborus: a customisable sponge job plugin

It’s a jobs plugin.

If my above or your above worked… I am now battling this:

public void applyBonus(JobItem item, Player player, Object i2) {
    Extent extent = player.getLocation().getExtent();
    Entity itemEntity = extent.createEntity(EntityTypes.EXPERIENCE_ORB, player.getLocation().getPosition());

    itemEntity.offer(Keys.CONTAINED_EXPERIENCE, new Random().nextInt(maxEp - minEp) + minEp);

    extent.spawnEntity(itemEntity, Cause.builder().owner(player).build());

.owner is the problem here.

I’m guessing EventContext.builder() is what should replace Cause.builder but i still have the issue with .owner

saying “Cannot resolve method owner”

i THINK it is supposed to give XP to the player instead of dropping it

Since Extent is grabbing the player then you really don’t need


you can actually do this


it should just spawn the entity items just find from the player location or whatever it is.
it should work fine but you want to setup a test server and fully test it out just to make sure, when writing something in java coding you always want test out your code to make sure that it works fine.

I think the original auther was giving custom XP not found in the game; Would that impact the code at all?

Nah should work fine.

Think the same will work for this?

public void applyBonus(JobItem item, Player player, Object i2) {
BonusHelper.dropItem(player.getLocation(), itemStack, Cause.builder().owner(player).build());

I think that should work by talking about the cause

I’m sorry; I’m afraid i don’t follow…
do you mean taking out the cause?

I’m heading to bed and i appreciate all your help! i’ll post back tomorrow afterwork when i continue to debug :slight_smile:



There shouldn’t be any API methods that take a Cause except for the Economy API. If you need to get a Cause, you should get it from Sponge.getCauseStackManager().getCurrentCause().