Search in sources :

Example 16 with Command

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

the class RulebookCommands method modify.

@Alias(value = "modifyrules")
@Command(desc = "modified the rulebook of the declared language with the book in hand")
public void modify(Player context, String language) {
    ItemStack item = context.getItemInHand(MAIN_HAND).orElse(null);
    if (item != null && !(item.getItem() == WRITABLE_BOOK || item.getItem() == WRITTEN_BOOK)) {
        i18n.send(context, NEGATIVE, "I would try it with a book as item in hand");
        return;
    }
    Language lang = this.rulebookManager.getLanguage(language);
    if (lang == null) {
        i18n.send(context, NEGATIVE, "More than one or no language is matched with {input}", language);
        return;
    }
    Locale locale = lang.getLocale();
    if (!this.rulebookManager.contains(locale)) {
        i18n.send(context, NEGATIVE, "You can't modify a non-existent book.");
        return;
    }
    try {
        this.rulebookManager.removeBook(locale);
        this.rulebookManager.addBook(item, locale);
        i18n.send(context, POSITIVE, "The rulebook {name} was succesful modified.", locale.getDisplayLanguage(context.getLocale()));
    } catch (IOException ex) {
        throw new IllegalStateException(ex);
    }
}
Also used : Locale(java.util.Locale) Language(de.cubeisland.engine.i18n.language.Language) IOException(java.io.IOException) ItemStack(org.spongepowered.api.item.inventory.ItemStack) ContainerCommand(org.cubeengine.libcube.service.command.ContainerCommand) Command(org.cubeengine.butler.parametric.Command) Alias(org.cubeengine.butler.alias.Alias)

Example 17 with Command

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

the class RulebookCommands method add.

@Alias(value = "addrules")
@Command(desc = "adds the book in hand as rulebook of the declared language")
public void add(Player context, String language) {
    ItemStack item = context.getItemInHand(MAIN_HAND).orElse(null);
    if (item != null && !(item.getItem() == WRITABLE_BOOK || item.getItem() == WRITTEN_BOOK)) {
        i18n.send(context, NEGATIVE, "I would try it with a book as item in hand");
        return;
    }
    Language lang = this.rulebookManager.getLanguage(language);
    if (lang == null) {
        i18n.send(context, NEGATIVE, "More than one or no language is matched with {input}", language);
        return;
    }
    Locale locale = lang.getLocale();
    if (this.rulebookManager.contains(locale)) {
        i18n.send(context, NEUTRAL, "There is already a book in that language.");
        return;
    }
    this.rulebookManager.addBook(item, locale);
    i18n.send(context, POSITIVE, "Rulebook for the language {input} was added succesfully", lang.getLocale().getDisplayLanguage(context.getLocale()));
}
Also used : Locale(java.util.Locale) Language(de.cubeisland.engine.i18n.language.Language) ItemStack(org.spongepowered.api.item.inventory.ItemStack) ContainerCommand(org.cubeengine.libcube.service.command.ContainerCommand) Command(org.cubeengine.butler.parametric.Command) Alias(org.cubeengine.butler.alias.Alias)

Example 18 with Command

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

the class RulebookCommands method remove.

@Alias(value = "removerules")
@Command(desc = "removes the declared language and languagefiles!")
public void remove(CommandSource context, String language) {
    Language lang = this.rulebookManager.getLanguage(language);
    if (lang == null) {
        i18n.send(context, NEGATIVE, "More than one or no language is matched with {input}", language);
        return;
    }
    if (!this.rulebookManager.contains(lang.getLocale())) {
        i18n.send(context, POSITIVE, "The languagefile of {input} doesn't exist at the moment", lang.getLocale().getDisplayLanguage(context.getLocale()));
        return;
    }
    try {
        this.rulebookManager.removeBook(lang.getLocale());
        i18n.send(context, POSITIVE, "The languagefiles of {input} was deleted", lang.getLocale().getDisplayLanguage(context.getLocale()));
    } catch (IOException ex) {
        throw new IllegalStateException(ex);
    }
}
Also used : Language(de.cubeisland.engine.i18n.language.Language) IOException(java.io.IOException) ContainerCommand(org.cubeengine.libcube.service.command.ContainerCommand) Command(org.cubeengine.butler.parametric.Command) Alias(org.cubeengine.butler.alias.Alias)

Example 19 with Command

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

the class IgnoreCommands method unignore.

@Command(desc = "Stops ignoring all messages from a player")
@Restricted(value = Player.class, msg = "Congratulations! You are now looking at this text!")
public void unignore(Player context, List<User> players) {
    List<String> added = new ArrayList<>();
    for (User user : players) {
        if (!this.removeIgnore(context, user)) {
            i18n.send(context, NEGATIVE, "You haven't ignored {user}!", user);
        } else {
            added.add(user.getName());
        }
    }
    if (added.isEmpty()) {
        return;
    }
    i18n.send(context, POSITIVE, "You removed {user#list} from your ignore list!", StringUtils.implode(ChatFormat.WHITE + ", " + ChatFormat.DARK_GREEN, added));
}
Also used : User(org.spongepowered.api.entity.living.player.User) ArrayList(java.util.ArrayList) Command(org.cubeengine.butler.parametric.Command) Restricted(org.cubeengine.butler.filter.Restricted)

Example 20 with Command

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

the class EditModeCommand method stock.

@Command(desc = "Changes whether the sign has stock")
public void stock(Player context) {
    MarketSignData data = manager.getCurrentData(context);
    if (data == null) {
        i18n.send(context, NEGATIVE, "No active sign!");
        return;
    }
    if (!data.isAdminOwner()) {
        i18n.send(context, NEGATIVE, "Player signs cannot have no stock!");
        return;
    }
    if (data.getStock() == null) {
        data.setStock(0);
    } else {
        data.setStock(null);
    }
    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