Search in sources :

Example 11 with MarketSignData

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

the class EditModeCommand method copy.

@Restricted(Player.class)
@Command(desc = "Copies the settings from the previous sign")
public void copy(Player context) {
    ImmutableMarketSignData data = manager.getPreviousData(context);
    if (data == null) {
        i18n.send(context, NEGATIVE, "No previous market sign");
        return;
    }
    if (data.getOwner().equals(IMarketSignData.ADMIN_SIGN)) {
        if (!context.hasPermission(module.perms().EDIT_ADMIN.getId())) {
            throw new PermissionDeniedException(module.perms().EDIT_ADMIN);
        }
    } else {
        if (!context.hasPermission(module.perms().EDIT_USE.getId())) {
            throw new PermissionDeniedException(module.perms().EDIT_USE);
        }
    }
    MarketSignData copy = data.asMutable();
    if (!copy.isAdminOwner()) {
        copy.setStock(0);
    }
    Location<World> loc = manager.updateData(copy, context);
    manager.executeShowInfo(copy, context, loc);
}
Also used : ImmutableMarketSignData(org.cubeengine.module.signmarket.data.ImmutableMarketSignData) MarketSignData(org.cubeengine.module.signmarket.data.MarketSignData) IMarketSignData(org.cubeengine.module.signmarket.data.IMarketSignData) ImmutableMarketSignData(org.cubeengine.module.signmarket.data.ImmutableMarketSignData) PermissionDeniedException(org.cubeengine.libcube.service.command.exception.PermissionDeniedException) World(org.spongepowered.api.world.World) Restricted(org.cubeengine.butler.filter.Restricted) Command(org.cubeengine.butler.parametric.Command) ConversationCommand(org.cubeengine.libcube.service.command.conversation.ConversationCommand)

Example 12 with MarketSignData

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

the class EditModeCommand method setstock.

@Command(desc = "Sets the signs stock")
public void setstock(Player context, Integer amount) {
    MarketSignData data = manager.getCurrentData(context);
    if (data == null) {
        i18n.send(context, NEGATIVE, "No active sign!");
        return;
    }
    if (data.getStock() == null) {
        i18n.send(context, NEGATIVE, "This sign has no stock! Use \"stock\" first to enable it!");
        return;
    }
    data.setStock(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 13 with MarketSignData

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

the class EditModeCommand method player.

@Command(desc = "Changes the sign to an player-sign")
public void player(Player context) {
    if (!context.hasPermission(module.perms().EDIT_PLAYER_SELF.getId())) {
        throw new PermissionDeniedException(module.perms().EDIT_PLAYER_SELF);
    }
    MarketSignData data = manager.getCurrentData(context);
    if (data == null) {
        i18n.send(context, NEGATIVE, "No active sign!");
        return;
    }
    if (data.isAdminOwner()) {
        data.setSize(6);
    }
    data.setOwner(context.getUniqueId());
    data.setStock(0);
    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) PermissionDeniedException(org.cubeengine.libcube.service.command.exception.PermissionDeniedException) World(org.spongepowered.api.world.World) Command(org.cubeengine.butler.parametric.Command) ConversationCommand(org.cubeengine.libcube.service.command.conversation.ConversationCommand)

Example 14 with MarketSignData

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

the class EditModeCommand method sell.

@Command(desc = "Changes the sign to a sell-sign")
public void sell(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.SELL);
    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 15 with MarketSignData

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

the class EditModeCommand method owner.

@Command(desc = "Changes the signs owner")
public void owner(Player context, User owner) {
    if (!context.equals(owner)) {
        if (!context.hasPermission(module.perms().EDIT_PLAYER_OTHER.getId())) {
            throw new PermissionDeniedException(module.perms().EDIT_PLAYER_OTHER);
        }
    } else {
        if (!context.hasPermission(module.perms().EDIT_PLAYER_SELF.getId())) {
            throw new PermissionDeniedException(module.perms().EDIT_PLAYER_SELF);
        }
    }
    MarketSignData data = manager.getCurrentData(context);
    if (data == null) {
        i18n.send(context, NEGATIVE, "No active sign!");
        return;
    }
    data.setOwner(owner.getUniqueId());
    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) PermissionDeniedException(org.cubeengine.libcube.service.command.exception.PermissionDeniedException) World(org.spongepowered.api.world.World) Command(org.cubeengine.butler.parametric.Command) ConversationCommand(org.cubeengine.libcube.service.command.conversation.ConversationCommand)

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