Skip to content

Commit

Permalink
fixed #8
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonidius20 committed Aug 18, 2020
1 parent 2bcebc8 commit 3b08518
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/ua/leonidius/trdinterface/sell/Sell.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ public static void sellItem(Player player, String id, int amount) {

double price = Trading.sellCfg.getDouble(id.replace(":", "-"));

double cost = price*amount;
double cost = price * amount;

if (!player.getInventory().contains(item)) {
player.showFormWindow(new SellFailScreen());
return;
}

player.getInventory().removeItem(item);
EconomyAPI.getInstance().addMoney(player, cost);
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/ua/leonidius/trdinterface/sell/SellFailScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package ua.leonidius.trdinterface.sell;

import cn.nukkit.event.player.PlayerFormRespondedEvent;
import cn.nukkit.form.element.ElementButton;
import cn.nukkit.form.window.FormWindowSimple;
import ua.leonidius.trdinterface.Message;
import ua.leonidius.trdinterface.screens.Screen;

public class SellFailScreen extends FormWindowSimple implements Screen {

public SellFailScreen() {
super(Message.WDW_FAIL_TITLE.getText(), Message.WDW_SELL_NOTHING.getText());
addButton(new ElementButton(Message.BTN_BACK.getText()));
}

public void onResponse(PlayerFormRespondedEvent event) {
event.getPlayer().showFormWindow(new SellItemSelectorScreen(event.getPlayer().getInventory()));
}
}

0 comments on commit 3b08518

Please sign in to comment.