Search in sources :

Example 6 with MarketSignData

use of org.cubeengine.module.signmarket.data.MarketSignData in project modules-extra by CubeEngine.

the class EditModeCommand method demand.

@Command(desc = "Changes the demand of a sign")
public void demand(Player context, Integer demand) {
    MarketSignData data = manager.getCurrentData(context);
    if (data == null) {
        i18n.send(context, NEGATIVE, "No active sign!");
        return;
    }
    if (data.getSignType() == null) {
        data.setSignType(SignType.SELL);
    } else if (data.getSignType() == SignType.BUY) {
        i18n.send(context, NEGATIVE, "Buy signs cannot have a demand!");
        return;
    }
    data.setDemand(demand);
    Location<World> loc = manager.updateData(data, context);
    manager.executeShowInfo(data, context, loc);
}
Also used : MarketSignData(org.cubeengine.module.signmarket.data.MarketSignData) IMarketSignData(org.cubeengine.module.signmarket.data.IMarketSignData) ImmutableMarketSignData(org.cubeengine.module.signmarket.data.ImmutableMarketSignData) World(org.spongepowered.api.world.World) Command(org.cubeengine.butler.parametric.Command) ConversationCommand(org.cubeengine.libcube.service.command.conversation.ConversationCommand)

Example 7 with MarketSignData

use of org.cubeengine.module.signmarket.data.MarketSignData in project modules-extra by CubeEngine.

the class EditModeCommand method amount.

@Command(desc = "Sets the amount")
public void amount(Player context, Integer amount) {
    if (amount < 0) {
        i18n.send(context, NEGATIVE, "Negative amounts could be unfair! Just sayin'");
        return;
    }
    MarketSignData data = manager.getCurrentData(context);
    if (data == null) {
        i18n.send(context, NEGATIVE, "No active sign!");
        return;
    }
    data.setAmount(amount);
    Location<World> loc = manager.updateData(data, context);
    manager.executeShowInfo(data, context, loc);
}
Also used : MarketSignData(org.cubeengine.module.signmarket.data.MarketSignData) IMarketSignData(org.cubeengine.module.signmarket.data.IMarketSignData) ImmutableMarketSignData(org.cubeengine.module.signmarket.data.ImmutableMarketSignData) World(org.spongepowered.api.world.World) Command(org.cubeengine.butler.parametric.Command) ConversationCommand(org.cubeengine.libcube.service.command.conversation.ConversationCommand)

Example 8 with MarketSignData

use of org.cubeengine.module.signmarket.data.MarketSignData in project modules-extra by CubeEngine.

the class EditModeCommand method buy.

@Command(desc = "Changes the sign to a buy-sign")
public void buy(Player context) {
    // TODO perms for sell/Buy maybe?
    MarketSignData data = manager.getCurrentData(context);
    if (data == null) {
        i18n.send(context, NEGATIVE, "No active sign!");
        return;
    }
    data.setSignType(SignType.BUY);
    Location<World> loc = manager.updateData(data, context);
    manager.executeShowInfo(data, context, loc);
}
Also used : MarketSignData(org.cubeengine.module.signmarket.data.MarketSignData) IMarketSignData(org.cubeengine.module.signmarket.data.IMarketSignData) ImmutableMarketSignData(org.cubeengine.module.signmarket.data.ImmutableMarketSignData) World(org.spongepowered.api.world.World) Command(org.cubeengine.butler.parametric.Command) ConversationCommand(org.cubeengine.libcube.service.command.conversation.ConversationCommand)

Example 9 with MarketSignData

use of org.cubeengine.module.signmarket.data.MarketSignData in project modules-extra by CubeEngine.

the class EditModeCommand method item.

@Command(desc = "Sets the item")
public void item(Player context, ItemStack item) {
    MarketSignData data = manager.getCurrentData(context);
    if (data == null) {
        i18n.send(context, NEGATIVE, "No active sign!");
        return;
    }
    if (!data.isAdminOwner() && data.getStock() != 0) {
        i18n.send(context, NEGATIVE, "You have to take all items out of the market-sign to be able to change the item in it!");
        return;
    }
    data.setItem(item, false);
    Location<World> loc = manager.updateData(data, context);
    manager.executeShowInfo(data, context, loc);
}
Also used : MarketSignData(org.cubeengine.module.signmarket.data.MarketSignData) IMarketSignData(org.cubeengine.module.signmarket.data.IMarketSignData) ImmutableMarketSignData(org.cubeengine.module.signmarket.data.ImmutableMarketSignData) World(org.spongepowered.api.world.World) Command(org.cubeengine.butler.parametric.Command) ConversationCommand(org.cubeengine.libcube.service.command.conversation.ConversationCommand)

Example 10 with MarketSignData

use of org.cubeengine.module.signmarket.data.MarketSignData in project modules-extra by CubeEngine.

the class MarketSignListener method onSignPlace.

@Listener(order = Order.POST)
public void onSignPlace(ChangeBlockEvent.Place event, @First Player player) {
    if (event.getTransactions().size() > 1 || !module.getEditModeCommand().hasUser(player)) {
        return;
    }
    for (Transaction<BlockSnapshot> trans : event.getTransactions()) {
        BlockType type = trans.getFinal().getState().getType();
        if (// placed sign
        type == BlockTypes.STANDING_SIGN || type == BlockTypes.WALL_SIGN) {
            if (!player.hasPermission(module.perms().EDIT_USE.getId())) {
                event.setCancelled(true);
                i18n.send(player, NEGATIVE, "You are not allowed to create market signs!");
                return;
            }
            MarketSignData data = new MarketSignData();
            data.setID(UUID.randomUUID());
            data.setOwner(player.getUniqueId());
            Location<World> loc = trans.getFinal().getLocation().get();
            loc.offer(data);
            manager.setSign(loc, player);
            Sponge.getCauseStackManager().pushCause(player);
            player.closeInventory();
        }
    }
}
Also used : BlockType(org.spongepowered.api.block.BlockType) BlockSnapshot(org.spongepowered.api.block.BlockSnapshot) MarketSignData(org.cubeengine.module.signmarket.data.MarketSignData) ImmutableMarketSignData(org.cubeengine.module.signmarket.data.ImmutableMarketSignData) World(org.spongepowered.api.world.World) Listener(org.spongepowered.api.event.Listener)

Aggregations

ImmutableMarketSignData (org.cubeengine.module.signmarket.data.ImmutableMarketSignData)20 MarketSignData (org.cubeengine.module.signmarket.data.MarketSignData)20 World (org.spongepowered.api.world.World)19 IMarketSignData (org.cubeengine.module.signmarket.data.IMarketSignData)18 Command (org.cubeengine.butler.parametric.Command)14 ConversationCommand (org.cubeengine.libcube.service.command.conversation.ConversationCommand)14 PermissionDeniedException (org.cubeengine.libcube.service.command.exception.PermissionDeniedException)5 BlockType (org.spongepowered.api.block.BlockType)2 Listener (org.spongepowered.api.event.Listener)2 Restricted (org.cubeengine.butler.filter.Restricted)1 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)1 SignData (org.spongepowered.api.data.manipulator.mutable.tileentity.SignData)1 InteractBlockEvent (org.spongepowered.api.event.block.InteractBlockEvent)1 Primary (org.spongepowered.api.event.block.InteractBlockEvent.Primary)1 Text (org.spongepowered.api.text.Text)1 TextColor (org.spongepowered.api.text.format.TextColor)1