Search in sources :

Example 21 with Command

use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.

the class EditModeCommand method price.

@Command(desc = "Sets the price")
public void price(Player context, Double price) {
    if (price < 0) {
        i18n.send(context, NEGATIVE, "A negative price!? Are you serious?");
        return;
    }
    MarketSignData data = manager.getCurrentData(context);
    if (data == null) {
        i18n.send(context, NEGATIVE, "No active sign!");
        return;
    }
    data.setPrice(price);
    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 22 with Command

use of org.cubeengine.butler.parametric.Command 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 23 with Command

use of org.cubeengine.butler.parametric.Command 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 24 with Command

use of org.cubeengine.butler.parametric.Command 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 25 with Command

use of org.cubeengine.butler.parametric.Command 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)

Aggregations

Command (org.cubeengine.butler.parametric.Command)46 World (org.spongepowered.api.world.World)18 ContainerCommand (org.cubeengine.libcube.service.command.ContainerCommand)14 ConversationCommand (org.cubeengine.libcube.service.command.conversation.ConversationCommand)14 IMarketSignData (org.cubeengine.module.signmarket.data.IMarketSignData)14 ImmutableMarketSignData (org.cubeengine.module.signmarket.data.ImmutableMarketSignData)14 MarketSignData (org.cubeengine.module.signmarket.data.MarketSignData)14 Player (org.spongepowered.api.entity.living.player.Player)11 Alias (org.cubeengine.butler.alias.Alias)10 Restricted (org.cubeengine.butler.filter.Restricted)9 PermissionDeniedException (org.cubeengine.libcube.service.command.exception.PermissionDeniedException)5 ItemStack (org.spongepowered.api.item.inventory.ItemStack)5 Language (de.cubeisland.engine.i18n.language.Language)4 Inventory (org.spongepowered.api.item.inventory.Inventory)4 BlockRayHit (org.spongepowered.api.util.blockray.BlockRayHit)4 ArrayList (java.util.ArrayList)3 Locale (java.util.Locale)3 Text (org.spongepowered.api.text.Text)3 Vector3d (com.flowpowered.math.vector.Vector3d)2 IOException (java.io.IOException)2