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


Java Flag类代码示例

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


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

示例1: tpall

import org.cubeengine.butler.parametric.Flag; //导入依赖的package包/类
@Command(desc = "Teleports everyone directly to a player.")
public void tpall(CommandSource context, Player player, @Flag boolean force)
{
    force = force && context.hasPermission(module.perms().COMMAND_TPALL_FORCE.getId());
    if (!force && player.hasPermission(module.perms().TELEPORT_PREVENT_TPTO.getId()))
    {
        i18n.send(context, NEGATIVE, "You are not allowed to teleport to {user}!", player);
        return;
    }
    ArrayList<String> noTp = new ArrayList<>();
    for (Player p : Sponge.getServer().getOnlinePlayers())
    {
        if (!force && p.hasPermission(module.perms().TELEPORT_PREVENT_TP.getId()))
        {
            noTp.add(p.getName());
            continue;
        }
        Location target = player.getLocation();
        p.getPlayer().get().setLocation(target);
    }
    bc.broadcastTranslated(POSITIVE, "Teleporting everyone to {user}", player);
    if (!noTp.isEmpty())
    {
        i18n.send(context, NEUTRAL, "The following players were not teleported: \n{user#list}", StringUtils.implode(WHITE + "," + DARK_GREEN, noTp));
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:27,代码来源:TeleportCommands.java

示例2: tphere

import org.cubeengine.butler.parametric.Flag; //导入依赖的package包/类
@Command(desc = "Teleport a player directly to you.")
@Restricted(value = Player.class, msg = "{text:Pro Tip}: Teleport does not work IRL!")
public void tphere(Player context, Player player, @Flag boolean force)
{
    force = force && context.hasPermission(module.perms().COMMAND_TPHERE_FORCE.getId());
    if ( context.equals(player))
    {
        i18n.send(context, NEUTRAL, "You found yourself!");
        return;
    }
    if (!force && player.hasPermission(module.perms().TELEPORT_PREVENT_TP.getId()))
    {
        i18n.send(context, NEGATIVE, "You are not allowed to teleport {user}!", player);
        return;
    }

    player.setLocation(context.getLocation());
    i18n.send(context, POSITIVE, "You teleported {user} to you!", player);
    i18n.send(player, POSITIVE, "You were teleported to {sender}", context);
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:21,代码来源:TeleportCommands.java

示例3: tphereall

import org.cubeengine.butler.parametric.Flag; //导入依赖的package包/类
@Command(desc = "Teleport every player directly to you.")
@Restricted(value = Player.class, msg = "{text:Pro Tip}: Teleport does not work IRL!")
public void tphereall(Player context, @Flag boolean force)
{
    force = force && context.hasPermission(module.perms().COMMAND_TPHEREALL_FORCE.getId());
    ArrayList<String> noTp = new ArrayList<>();
    Location<World> target = context.getLocation();
    for (Player p : Sponge.getServer().getOnlinePlayers())
    {
        if (!force && p.hasPermission(module.perms().TELEPORT_PREVENT_TP.getId()))
        {
            noTp.add(p.getName());
            continue;
        }
        p.getPlayer().get().setLocation(target);
    }
    i18n.send(context, POSITIVE, "You teleported everyone to you!");
    bc.broadcastTranslated(POSITIVE, "Teleporting everyone to {sender}", context);
    if (!noTp.isEmpty())
    {
        i18n.send(context, NEUTRAL, "The following players were not teleported: \n{user#list}", StringUtils.implode(
            WHITE + "," + DARK_GREEN, noTp));
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:25,代码来源:TeleportCommands.java

示例4: tppos

import org.cubeengine.butler.parametric.Flag; //导入依赖的package包/类
@Command(desc = "Direct teleport to a coordinate.")
public void tppos(CommandSource context, Integer x, Integer y, Integer z, // TODO optional y coord
                  @Default @Named({"world", "w"}) World world,
                  @Default @Named({"player", "p"}) Player player,
                  @Flag boolean unsafe)
{
    Location<World> loc = new Location<>(world, x, y, z).add(0.5, 0, 0.5);
    unsafe = unsafe && context.hasPermission(module.perms().COMMAND_TPPOS_UNSAFE.getId());
    if (unsafe)
    {
        player.setLocation(loc);
    }
    else if (!player.setLocationSafely(loc))
    {
        i18n.send(context, NEGATIVE, "Unsafe Target!");
        return;
    }
    i18n.send(context, POSITIVE, "Teleported to {vector:x\\=:y\\=:z\\=} in {world}!", new Vector3i(x, y, z), world);
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:20,代码来源:TeleportCommands.java

示例5: spawn

import org.cubeengine.butler.parametric.Flag; //导入依赖的package包/类
@Command(desc = "Teleports a player to spawn")
public void spawn(CommandSource context, @Default Player player, @Optional World world, @Flag boolean force)
{
    // TODO if OptionSubjects available => per role spawn?

    world = world == null ? module.getConfig().getMainWorld() : world;
    if (world == null)
    {
        world = player.getWorld();
    }
    force = force && context.hasPermission(module.perms().CMD_SPAWN_FORCE.getId()) || context.equals( player);
    if (!force && player.hasPermission(module.perms().CMD_SPAWN_PREVENT.getId()))
    {
        i18n.send(context, NEGATIVE, "You are not allowed to spawn {user}!", player);
        return;
    }
    final Location<World> spawnLocation = world.getSpawnLocation().add(0.5, 0, 0.5);
    Vector3d rotation = player.getRotation();
    player.setLocation(spawnLocation);
    player.setRotation(rotation);
    i18n.send(context, POSITIVE, "You are now standing at the spawn in {world}!", world);
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:23,代码来源:SpawnCommands.java

示例6: create

import org.cubeengine.butler.parametric.Flag; //导入依赖的package包/类
@Command(desc = "Creates a new bank")
public void create(CommandSource context, String name,
                   @Flag(longName = "hidden", name = "h") boolean hidden,
                   @Flag(longName = "invite", name = "i") boolean invite)
{
    if (service.hasAccount(name))
    {
        i18n.send(context, NEGATIVE, "There is already a bank names {input#bank}!", name);
        return;
    }
    BaseAccount.Virtual bank = service.getOrCreateAccount(name).map(BaseAccount.Virtual.class::cast).get();
    bank.setHidden(hidden);
    bank.setInvite(invite);
    i18n.send(context, POSITIVE, "Created new Bank {account}!", bank);
    if (context instanceof User)
    {
        access(context, ((User) context), AccessLevel.MANAGE, bank);

    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:21,代码来源:BankManageCommand.java

示例7: clearinventory

import org.cubeengine.butler.parametric.Flag; //导入依赖的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

示例8: load

import org.cubeengine.butler.parametric.Flag; //导入依赖的package包/类
@Command(desc = "Loads a world")
public void load(CommandSource context, WorldProperties world, @Flag boolean enable)
{
    Optional<World> w = Sponge.getServer().getWorld(world.getUniqueId());
    if (w.isPresent())
    {
        i18n.send(context, POSITIVE, "The world {world} is already loaded!", w.get());
        return;
    }

    if (enable)
    {
        world.setEnabled(true);
    }
    i18n.send(context, NEGATIVE, "Loading...", world);
    // TODO async me?
    Optional<World> loaded = Sponge.getServer().loadWorld(world);
    if (!loaded.isPresent())
    {
        i18n.send(context, NEGATIVE, "Could not load {name#world}", world);
        return;
    }
    i18n.send(context, POSITIVE, "World {world} loaded!", loaded.get());
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:25,代码来源:WorldsCommands.java

示例9: listPermission

import org.cubeengine.butler.parametric.Flag; //导入依赖的package包/类
@Alias(value = "listRPerm")
@Command(alias = "listPerm", desc = "Lists all permissions of given role [in context]")
public void listPermission(CommandSource ctx, FileSubject role, @Flag boolean all, @Named("in") @Default Context context)
{
    i18n.send(ctx, NEUTRAL, "Permission list for {role}", role);
    Set<Context> contextSet = toSet(context);
    if (all)
    {
        listPermission(ctx, true, contextSet, RolesUtil.fillPermissions(role, contextSet, new TreeMap<>(), service));
    }
    else if (contextSet.isEmpty())
    {
        role.getSubjectData().getAllPermissions().forEach((key, value) -> listPermission(ctx, false, key, value));
    }
    else
    {
        listPermission(ctx, false, contextSet, new TreeMap<>(role.getSubjectData().getPermissions(contextSet)));
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:20,代码来源:RoleInformationCommands.java

示例10: listOption

import org.cubeengine.butler.parametric.Flag; //导入依赖的package包/类
@Alias(value = {"listROption", "listRData"})
@Command(alias = "listData", desc = "Lists all options of given role [in context]")
public void listOption(CommandSource ctx, FileSubject role, @Flag boolean all, @Named("in") @Default Context context)
{
    i18n.send(ctx, NEUTRAL, "Options list for {role}", role);
    Set<Context> contextSet = toSet(context);
    if (all)
    {
        listOption(ctx, true, contextSet, RolesUtil.fillOptions(role, contextSet, new HashMap<>(), service));
    }
    else if (contextSet.isEmpty())
    {
        role.getSubjectData().getAllOptions().forEach((key, value) -> listOption(ctx, false, key, value));
    }
    else
    {
        listOption(ctx, false, contextSet, role.getSubjectData().getOptions(contextSet));
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:20,代码来源:RoleInformationCommands.java

示例11: modify

import org.cubeengine.butler.parametric.Flag; //导入依赖的package包/类
@Alias(value = "cmodify")
@Command(desc = "adds or removes player from the accesslist")
@Restricted(value = Player.class, msg = "This command can only be used in game")
public void modify(Player context, List<PlayerAccess> players, @Flag boolean global, @Flag boolean persist)
{
    if (persist)
    {
        this.persist(context);
    }

    if (global)
    {
        this.manager.setGlobalAccess(context, players);
    }
    else
    {
        this.manager.commandListener.submitLockAction(context, (lock, loc, entity) -> lock.modifyLock(context, players));
        i18n.send(context, POSITIVE, "Right click a protection to modify it!");
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:21,代码来源:LockerCommands.java

示例12: give

import org.cubeengine.butler.parametric.Flag; //导入依赖的package包/类
@Alias(value = "cgive")
@Command(desc = "gives a protection to someone else")
@Restricted(value = Player.class, msg = "This command can only be used in game")
public void give(Player context, User player, @Flag boolean persist)
{
    if (persist)
    {
        this.persist(context);
    }
    this.manager.commandListener.submitLockAction(context, (lock, loc, entity) -> {
        if (lock.isOwner(context) || player.hasPermission(module.perms().CMD_GIVE_OTHER.getId()))
        {
            lock.setOwner(player);
            i18n.send(context, NEUTRAL, "{user} is now the owner of this protection.", player);
            return;
        }
        i18n.send(context, NEGATIVE, "This is not your protection!");
    });
    i18n.send(context, POSITIVE, "Right click a protection to give it to {user}!", player);
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:21,代码来源:LockerCommands.java

示例13: clear

import org.cubeengine.butler.parametric.Flag; //导入依赖的package包/类
@Alias(value = "ptc")
@Command(desc = "Removes all commands from your powertool")
@Restricted(value = Player.class, msg = "No more power for you!")
public void clear(Player context, @Flag boolean all)
{
    if (all)
    {
        for (Inventory slot : context.getInventory().slots())
        {
            if (slot.peek().isPresent())
            {
                slot.set(this.setPowerTool(slot.peek().get(), null));
            }
        }
        i18n.send(context, POSITIVE, "Removed all commands bound to items in your inventory!");
        return;
    }
    if (!context.getItemInHand(HandTypes.MAIN_HAND).isPresent())
    {
        i18n.send(context, NEUTRAL, "You are not holding any item in your hand.");
        return;
    }
    context.setItemInHand(HandTypes.MAIN_HAND, this.setPowerTool(context.getItemInHand(HandTypes.MAIN_HAND).get(), null));
    i18n.send(context, POSITIVE, "Removed all commands bound to the item in your hand!");
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:26,代码来源:PowertoolCommand.java

示例14: add

import org.cubeengine.butler.parametric.Flag; //导入依赖的package包/类
@Alias(value = "pta")
@Command(desc = "Adds a command to your powertool")
@Restricted(value = Player.class, msg = "You already have enough power!")
public void add(Player context, @Greed(INFINITE) String commandString, @Flag boolean replace)
{
    if (!context.getItemInHand(HandTypes.MAIN_HAND).isPresent())
    {
        i18n.send(context, NEUTRAL, "You do not have an item in your hand to bind the command to!");
        return;
    }
    List<String> powerTools;
    if (replace)
    {
        powerTools = new ArrayList<>(1);
    }
    else
    {
        powerTools = new ArrayList<>(this.getPowerTools(context.getItemInHand(HandTypes.MAIN_HAND).get()));
    }
    powerTools.add(commandString);
    context.setItemInHand(HandTypes.MAIN_HAND, this.setPowerTool(context.getItemInHand(HandTypes.MAIN_HAND).get(), powerTools));
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:23,代码来源:PowertoolCommand.java

示例15: open

import org.cubeengine.butler.parametric.Flag; //导入依赖的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


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