Skip to content

Commit

Permalink
3.31 - TokenManager extra offline mode support
Browse files Browse the repository at this point in the history
  • Loading branch information
Trophonix committed May 19, 2019
1 parent 92ddf84 commit 85a28fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.trophonix</groupId>
<artifactId>TradePlus</artifactId>
<version>3.30</version>
<version>3.31</version>

<properties>
<res>${project.basedir}/res/</res>
Expand Down Expand Up @@ -119,7 +119,7 @@
<dependency>
<groupId>com.github.Realizedd</groupId>
<artifactId>TokenManager</artifactId>
<version>c0acc20b16</version>
<version>3.2.2</version>
<scope>system</scope>
<systemPath>${res}/TokenManager.jar</systemPath>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,33 @@
import com.trophonix.tradeplus.trade.Trade;
import com.trophonix.tradeplus.util.ItemFactory;
import me.realized.tokenmanager.TokenManagerPlugin;
import me.realized.tokenmanager.api.TokenManager;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

public class TokenManagerExtra extends Extra {


private TokenManager api;

public TokenManagerExtra(Player player1, Player player2, TradePlus pl, Trade trade) {
super("tokenmanager", player1, player2, pl, trade);
api = (TokenManager)pl.getServer().getPluginManager().getPlugin("TokenManager");
}

@Override
public double getMax(Player player) {
return TokenManagerPlugin.getInstance().getTokens(player).orElse(0);
return api.getTokens(player).orElse(0);
}

@Override
public void onTradeEnd() {
if (value1 > 0) {
TokenManagerPlugin.getInstance().removeTokens(player1.getUniqueId().toString(), (long)value1);
TokenManagerPlugin.getInstance().addTokens(player2.getUniqueId().toString(), (long)value1);
api.setTokens(player1, api.getTokens(player1).orElse((long)value1) - (long)value1);
api.setTokens(player2, api.getTokens(player2).orElse(0L) + (long)value1);
}
if (value2 > 0) {
TokenManagerPlugin.getInstance().removeTokens(player2.getUniqueId().toString(), (long)value2);
TokenManagerPlugin.getInstance().addTokens(player1.getUniqueId().toString(), (long)value2);
api.setTokens(player2, api.getTokens(player2).orElse((long)value2) - (long)value2);
api.setTokens(player1, api.getTokens(player1).orElse(0L) + (long)value2);
}
}

Expand Down

0 comments on commit 85a28fb

Please sign in to comment.