当前位置: 首页>>代码示例>>Java>>正文


Java ParameterPermission类代码示例

本文整理汇总了Java中org.cubeengine.libcube.service.command.annotation.ParameterPermission的典型用法代码示例。如果您正苦于以下问题:Java ParameterPermission类的具体用法?Java ParameterPermission怎么用?Java ParameterPermission使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ParameterPermission类属于org.cubeengine.libcube.service.command.annotation包,在下文中一共展示了ParameterPermission类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clearinventory

import org.cubeengine.libcube.service.command.annotation.ParameterPermission; //导入依赖的package包/类
@Command(alias = {"ci", "clear"}, desc = "Clears the inventory")
public void clearinventory(CommandSource context, @Default User player,
                           @Flag(longName = "removeArmor", name = "ra") boolean removeArmor,
                           @ParameterPermission(value = "quiet", desc = "Prevents the other player being notified when his inventory got cleared")
                                @Flag boolean quiet,
                           @Flag boolean force)
{
    //sender.sendTranslated(NEGATIVE, "That awkward moment when you realize you do not have an inventory!");
    boolean self = context.getIdentifier().equals(player.getIdentifier());
    if (!self)
    {
        if (!context.hasPermission(COMMAND_CLEARINVENTORY_OTHER.getId()))
        {
            throw new PermissionDeniedException(COMMAND_CLEARINVENTORY_OTHER);
        }
        if (player.hasPermission(COMMAND_CLEARINVENTORY_PREVENT.getId())
            && !(force && context.hasPermission(COMMAND_CLEARINVENTORY_FORCE.getId())))
        {
            i18n.send(context, NEGATIVE, "You are not allowed to clear the inventory of {user}", player);
            return;
        }
    }
    player.getInventory().query(QueryOperationTypes.INVENTORY_TYPE.of(InventoryRow.class)).clear();
    if (removeArmor)
    {
        player.getInventory().query(QueryOperationTypes.INVENTORY_TYPE.of(EquipmentInventory.class)).clear();
    }
    if (self)
    {
        i18n.send(context, POSITIVE, "Your inventory has been cleared!");
        return;
    }
    if (player.isOnline() && player.hasPermission(COMMAND_CLEARINVENTORY_NOTIFY.getId()) && !quiet)
    {
        i18n.send(player.getPlayer().get(), NEUTRAL, "Your inventory has been cleared by {sender}!", context);
    }
    i18n.send(context, POSITIVE, "The inventory of {user} has been cleared!", player);
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:39,代码来源:ClearInventoryCommand.java

示例2: open

import org.cubeengine.libcube.service.command.annotation.ParameterPermission; //导入依赖的package包/类
@Alias(value = "openbp")
@Command(desc = "opens a backpack")
@Restricted(value = Player.class, msg = "You cannot open a inventory in console!")
public void open(Player ctx, @Complete(BackpackCompleter.class) @Optional String name, @Default User player,
                 @ParameterPermission(value = "other-context", desc = "Allows using the open command in another context")
                 @Flag boolean outOfContext)
{
    if (name == null)
    {
        name = player.getName();
    }
    if (ctx != player && !ctx.hasPermission(module.perms().COMMAND_OPEN_OTHER_PLAYER.getId()))
    {
        i18n.send(ctx, NEGATIVE, "You are not allowed to open the backpacks of other users!");
        return;
    }
    manager.openBackpack(ctx, player, outOfContext, name) ;
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:19,代码来源:BackpackCommands.java

示例3: remove

import org.cubeengine.libcube.service.command.annotation.ParameterPermission; //导入依赖的package包/类
@Command(desc = "Remove a world", alias = "delete")
public void remove(CommandSource context, WorldProperties world, @Flag @ParameterPermission(value = "remove-worldfolder", desc = "Allows deleting the world folder") boolean folder, @Flag boolean unload)
{
    Optional<World> loadedWorld = Sponge.getServer().getWorld(world.getUniqueId());
    if (loadedWorld.isPresent())
    {
        if (!unload)
        {
            i18n.send(context, NEGATIVE, "You have to unload the world first!");
            return;
        }
        if (!Sponge.getServer().unloadWorld(loadedWorld.get()))
        {
            i18n.send(context, NEGATIVE, "Could not unload {world}", world);
            return;
        }
    }

    if (folder)
    {
        i18n.send(context, POSITIVE, "Deleting the world {world} from disk...", world);
        Sponge.getServer().deleteWorld(world).
            thenAccept(b -> i18n.send(context, POSITIVE, "Finished deleting the world {world} from disk", world));
        return;
    }
    world.setEnabled(false);
    i18n.send(context, POSITIVE, "The world {world} is now disabled and will not load by itself.", world);
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:29,代码来源:WorldsCommands.java

示例4: giveall

import org.cubeengine.libcube.service.command.annotation.ParameterPermission; //导入依赖的package包/类
@Command(desc = "Gives a kit to every online player")
public void giveall(CommandSource context, Kit kit, @ParameterPermission @Flag boolean force)
{
    boolean gaveKit = false;
    int kitNotReceived = 0;
    for (Player receiver : Sponge.getServer().getOnlinePlayers())
    {
        try
        {
            if (kit.give(context, receiver, force))
            {
                if (receiver.equals(context))
                {
                    i18n.send(context, POSITIVE, "Received the {name#kit} kit!", kit.getKitName());
                }
                else
                {
                    i18n.send(context, POSITIVE, "You gave {user} the {name#kit} kit!", receiver, kit.getKitName());
                    i18n.send(receiver, POSITIVE, "Received the {name#kit} kit. Enjoy.", kit.getKitName());
                }
                gaveKit = true;
            }
        }
        catch (Exception ex)
        {
            kitNotReceived++;
        }
    }
    if (!gaveKit)
    {
        i18n.send(context, NEGATIVE, "No one received the kit!");
    }
    else if (kitNotReceived > 0)
    {
        i18n.sendN(context, NEGATIVE, kitNotReceived,
                "{amount} players did not receive a kit!",
                "One player did not receive a kit!",
                kitNotReceived);
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:41,代码来源:KitCommand.java

示例5: give

import org.cubeengine.libcube.service.command.annotation.ParameterPermission; //导入依赖的package包/类
@Command(desc = "Gives a set of items.")
public void give(CommandSource context, Kit kit, @Default Player player, @ParameterPermission @Flag boolean force)
{
    boolean other = !context.getIdentifier().equals(player.getIdentifier());
    if (other && !context.hasPermission(module.perms().GIVE_OTHER.getId()))
    {
        i18n.send(context, NEGATIVE, "You are not allowed to give kits to other players!");
        return;
    }
    if (kit.give(context, player, force))
    {
        if (other)
        {
            i18n.send(context, POSITIVE, "You gave {user} the {name#kit} kit!", player, kit.getKitName());
            if (kit.getCustomMessage().isEmpty())
            {
                i18n.send(player, POSITIVE, "Received the {name#kit} kit. Enjoy.", kit.getKitName());
                return;
            }
            player.sendMessage(FORMATTING_CODE.deserialize(kit.getCustomMessage()));
            return;
        }
        if (kit.getCustomMessage().isEmpty())
        {
            i18n.send(context, POSITIVE, "Received the {name#kit} kit. Enjoy.", kit.getKitName());
            return;
        }
        context.sendMessage(FORMATTING_CODE.deserialize(kit.getCustomMessage()));
        return;
    }
    if (other)
    {
        i18n.send(context, NEUTRAL, "{user} has not enough space in your inventory for this kit!",
                            player);
        return;
    }
    i18n.send(context, NEUTRAL, "You don't have enough space in your inventory for this kit!");
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:39,代码来源:KitCommand.java

示例6: roleSpawn

import org.cubeengine.libcube.service.command.annotation.ParameterPermission; //导入依赖的package包/类
@Command(desc = "Teleports a player to the configured rolespawn")
public void roleSpawn(CommandSource ctx, @Default Player player, @Default Context context,
                  @Named({"role", "r"}) @Default @Parser(SubjectParser.class) Subject role,
                  @ParameterPermission @Flag boolean force)
{
    java.util.Optional<String> spawnString = role.getOption(toSet(context), ROLESPAWN);
    String name = role.getIdentifier();
    if (pm.getGroupSubjects() == role.getContainingCollection())
    {
        name = Sponge.getServiceManager().provideUnchecked(UserStorageService.class).get(UUID.fromString(name)).get().getName();
    }

    if (!spawnString.isPresent())
    {
        i18n.send(ctx, NEGATIVE, "No rolespawn set for {name} in {ctx}", name, context);
        return;
    }

    Transform<World> spawnPoint = getSpawnLocation(spawnString.get());
    if (!player.isOnline()) // TODO tp users
    {
        i18n.send(ctx, NEGATIVE, "You cannot teleport an offline player to spawn!");
        return;
    }
    if (!this.tpTo(player, spawnPoint, force))
    {
        i18n.send(ctx, NEGATIVE, "Teleport failed!");
        return;
    }
    if (!ctx.equals(player))
    {
        i18n.send(ctx, POSITIVE, "Teleported {user} to the spawn of the role {name#role} in {ctx}", player, name, context);
    }
    else if (pm.getGroupSubjects() == role.getContainingCollection())
    {
        i18n.send(ctx, POSITIVE, "You are now standing at your role's spawn in {ctx}!", context);
    }
    else
    {
        i18n.send(ctx, POSITIVE, "You are now standing at the spawn of {name#role} in {ctx}!", name, context);
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:43,代码来源:SpawnCommands.java


注:本文中的org.cubeengine.libcube.service.command.annotation.ParameterPermission类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。