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


Java CommandResult.empty方法代码示例

本文整理汇总了Java中org.spongepowered.api.command.CommandResult.empty方法的典型用法代码示例。如果您正苦于以下问题:Java CommandResult.empty方法的具体用法?Java CommandResult.empty怎么用?Java CommandResult.empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongepowered.api.command.CommandResult的用法示例。


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

示例1: execute

import org.spongepowered.api.command.CommandResult; //导入方法依赖的package包/类
@Override public CommandResult execute(CommandSource commandSource, CommandContext commandContext) throws CommandException {
    if(commandContext.getOne("type").isPresent()) {
        String type = commandContext.<String>getOne("type").get();
        VirtualCrate virtualCrate = HuskyCrates.instance.getCrateUtilities().getVirtualCrate(type);
        int quantity = commandContext.getOne("quantity").isPresent() ? commandContext.<Integer>getOne("quantity").get() : 1;
        if (virtualCrate == null) {
            commandSource.sendMessage(Text.of("Invalid crate id: " + type + ". Please check your config."));
            return CommandResult.empty();
        }
        commandSource.sendMessage(Text.of("Gave everyone " + quantity + " vkeys."));
        virtualCrate.givePlayersVirtualKeys(Sponge.getServer().getOnlinePlayers(),quantity);
        for(Player e: Sponge.getServer().getOnlinePlayers()){
            if(commandSource != e) {
                e.sendMessage(Text.of(TextColors.GREEN,"You received " + quantity + " virtual keys for a ", TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName),"."));
            }
        }
    }else{
        commandSource.sendMessage(Text.of("Usage: /crate vkeyall <id> [count]"));
    }
    return CommandResult.success();
}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:22,代码来源:VirtualKeyAll.java

示例2: execute

import org.spongepowered.api.command.CommandResult; //导入方法依赖的package包/类
@Override public CommandResult execute(CommandSource commandSource, CommandContext commandContext) throws CommandException {
    if (!(commandSource instanceof Player)) {
        commandSource.sendMessage(Text.of("You need to be in game or specify a player for this command to work."));
        return CommandResult.empty();
    }
    Player plr = (Player)commandSource;
    if(!plr.getItemInHand(HandTypes.MAIN_HAND).isPresent()){
        commandSource.sendMessage(Text.of("You must be holding an item to deposit a key."));
        return CommandResult.empty();
    }
    ItemStack key = plr.getItemInHand(HandTypes.MAIN_HAND).get();
    if(HuskyCrates.instance.crateUtilities.vcFromKey(key) == null){
        commandSource.sendMessage(Text.of(TextColors.RED,"Not a valid key."));
        return CommandResult.empty();
    }
    VirtualCrate virtualCrate = HuskyCrates.instance.crateUtilities.vcFromKey(plr.getItemInHand(HandTypes.MAIN_HAND).get());
    int keyCount = key.getQuantity();
    plr.setItemInHand(HandTypes.MAIN_HAND,null);
    virtualCrate.giveVirtualKeys(plr,keyCount);
    //commandSource.sendMessage(Text.of(TextColors.GREEN,"Successfully deposited " + keyCount + " ", TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName),TextColors.GREEN," Key(s)."));
    commandSource.sendMessage(TextSerializers.FORMATTING_CODE.deserialize(
            virtualCrate.getLangData().formatter(virtualCrate.getLangData().depositSuccess,null,plr,virtualCrate,null,null,keyCount)
    ));
    return CommandResult.success();
}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:26,代码来源:DepositKey.java

示例3: execute

import org.spongepowered.api.command.CommandResult; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	if (src.hasPermission("*") || src.hasPermission("listener.admin"))
	{
	Boolean clear = SwitchSQL.Clearqueue();
	if(clear){
		src.sendMessage(Text.of("Cleared successful"));
		return CommandResult.success();
	}
	else{
		src.sendMessage(Text.of("Cleared fail"));
		return CommandResult.empty();
	}
	}else{
		src.sendMessage(Text.of("You don't have permission"));
	return CommandResult.empty();
	}
}
 
开发者ID:Mineaurion,项目名称:AurionVoteListener,代码行数:19,代码来源:ClearqueueCmd.java

示例4: execute

import org.spongepowered.api.command.CommandResult; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	if (!(src instanceof Player)) {
		src.sendMessage(Text.of(TextColors.RED, "The inspector can only be toggled by players"));
		return CommandResult.empty();
	}
	
	Player p = (Player) src;
	if (plugin.getInspectManager().toggleInspector(p)) {
		p.sendMessage(Text.of(TextColors.DARK_AQUA, "[AS] ", TextColors.YELLOW, "Inspector mode has been ", TextColors.GREEN, "enabled"));
	} else {
		p.sendMessage(Text.of(TextColors.DARK_AQUA, "[AS] ", TextColors.YELLOW, "Inspector mode has been ", TextColors.RED, "disabled"));
	}
	
	return CommandResult.success();
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:17,代码来源:CommandInspect.java

示例5: execute

import org.spongepowered.api.command.CommandResult; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	if (src.hasPermission("*") || src.hasPermission("listener.admin"))
	{
	Boolean clear = SwitchSQL.Cleartotals();
	if(clear){
		src.sendMessage(Text.of("Cleared successful"));
		return CommandResult.success();
	}
	else{
		src.sendMessage(Text.of("Cleared fail"));
		return CommandResult.empty();
	}
	}else{
		src.sendMessage(Text.of("You don't have permission"));
	return CommandResult.empty();
	}
	
}
 
开发者ID:Mineaurion,项目名称:AurionVoteListener,代码行数:20,代码来源:CleartotalsCmd.java

示例6: execute

import org.spongepowered.api.command.CommandResult; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	if (!(src instanceof Player)) {
		src.sendMessage(Text.of(TextColors.RED, "Lookups can only be performed by players"));
		return CommandResult.empty();
	}
	
	Player p = (Player) src;
	Collection<String> filters = args.getAll("filter");
	
	FilterSet filterSet = new FilterSet(plugin, p, true);
	FilterParser.parse(filters, filterSet, p);
	
	new RollbackJob(plugin, p, filterSet, true);
	return CommandResult.success();
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:17,代码来源:CommandUndo.java

示例7: execute

import org.spongepowered.api.command.CommandResult; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	if (!(src instanceof Player)) {
		src.sendMessage(Text.of(TextColors.RED, "Lookups can only be performed by players"));
		return CommandResult.empty();
	}
	
	Player p = (Player) src;
	Collection<String> filters = args.getAll("filter");
	
	FilterSet filterSet = new FilterSet(plugin, p, true);
	FilterParser.parse(filters, filterSet, p);
	
	new RollbackJob(plugin, p, filterSet, false);
	return CommandResult.success();
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:17,代码来源:CommandRollback.java

示例8: execute

import org.spongepowered.api.command.CommandResult; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	if (!(src instanceof Player)) {
		src.sendMessage(Text.of(TextColors.RED, "Only players can use this command!"));
		return CommandResult.empty();
	}
	
	LookupResult result = LookupResultManager.instance().getLookupResult((Player) src);
	if (result == null) {
		src.sendMessage(Text.of(TextColors.DARK_AQUA, "[AS] ", TextColors.YELLOW, "You have no lookup history!"));
		return CommandResult.empty();
	}
	
	int page = result.getLastSeenPage() - 1;
	if (page <= 0) {
		src.sendMessage(Text.of(TextColors.DARK_AQUA, "[AS] ", TextColors.YELLOW, "Already on the first page!"));
		return CommandResult.empty();
	}
	
	result.showPage((Player) src, page);
	return CommandResult.success();
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:23,代码来源:CommandPrevPage.java

示例9: execute

import org.spongepowered.api.command.CommandResult; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {	
	if (!(src instanceof Player)) {
		src.sendMessage(Text.of(TextColors.RED, "Only players can use this command!"));
		return CommandResult.empty();
	}
	
	LookupResult result = LookupResultManager.instance().getLookupResult((Player) src);
	if (result == null) {
		src.sendMessage(Text.of(TextColors.DARK_AQUA, "[AS] ", TextColors.YELLOW, "You have no lookup history!"));
		return CommandResult.empty();
	}
	
	int page = (int) args.getOne("page").get();
	if (page <= 0) {
		src.sendMessage(Text.of(TextColors.DARK_AQUA, "[AS] ", TextColors.YELLOW, "Invalid page number!"));
		return CommandResult.empty();
	}
	
	result.showPage((Player) src, page);
	return CommandResult.success();
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:23,代码来源:CommandPage.java

示例10: execute

import org.spongepowered.api.command.CommandResult; //导入方法依赖的package包/类
@Override public CommandResult execute(CommandSource commandSource, CommandContext commandContext) throws CommandException {
    if(commandContext.getOne("type").isPresent()) {
        if (!(commandSource instanceof Player)) {
            commandSource.sendMessage(Text.of("You need to be in game or specify a player for this command to work."));
            return CommandResult.empty();
        }
        Player player = (Player) commandSource;
        String type = commandContext.<String>getOne("type").get();
        VirtualCrate virtualCrate = HuskyCrates.instance.getCrateUtilities().getVirtualCrate(type);
        int quantity = commandContext.getOne("quantity").isPresent() ? commandContext.<Integer>getOne("quantity").get() : 1;
        if (virtualCrate == null) {
            commandSource.sendMessage(Text.of("Invalid crate id: " + type + ". Try using tab auto completion."));
            return CommandResult.empty();
        }
        int balance = virtualCrate.getVirtualKeyBalance(player);
        if(balance >= quantity && quantity > 0){
            ItemStack key = virtualCrate.getCrateKey(quantity);
            virtualCrate.takeVirtualKeys(player, quantity);
            player.getInventory().offer(key);
            commandSource.sendMessage(TextSerializers.FORMATTING_CODE.deserialize(
                    virtualCrate.getLangData().formatter(virtualCrate.getLangData().withdrawSuccess,null,player,virtualCrate,null,null,quantity)
            ));
        }else{
            if(quantity <= 0){
                player.sendMessage(Text.of(TextColors.RED, "Positive integer amounts only."));
            }else {
                commandSource.sendMessage(TextSerializers.FORMATTING_CODE.deserialize(
                        virtualCrate.getLangData().formatter(virtualCrate.getLangData().withdrawInsufficient,null,player,virtualCrate,null,null,quantity)
                ));
            }
        }
    }else{
        commandSource.sendMessage(Text.of("Usage: /crate withdraw <id> [count]"));
    }
    return CommandResult.success();
}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:37,代码来源:WithdrawKey.java

示例11: execute

import org.spongepowered.api.command.CommandResult; //导入方法依赖的package包/类
@Override public CommandResult execute(CommandSource commandSource, CommandContext commandContext) throws CommandException {
    if(commandContext.getOne("type").isPresent() && commandSource instanceof Player) {
        String type = commandContext.<String>getOne("type").get();
        Player player = (Player) commandSource;
        VirtualCrate virtualCrate = HuskyCrates.instance.getCrateUtilities().getVirtualCrate(type);
        if (virtualCrate == null) {
            commandSource.sendMessage(Text.of("Invalid crate id: " + type + ". Please check your config."));
            return CommandResult.empty();
        }



        ItemStack keyItemStack = virtualCrate.getCrateWand();
        InventoryTransactionResult.Type mainInventory = player.getInventory().offer(keyItemStack.copy()).getType();
        if (!mainInventory.equals(InventoryTransactionResult.Type.SUCCESS)) {
            InventoryTransactionResult.Type enderInventory = player.getEnderChestInventory().offer(keyItemStack.copy()).getType();
            if(!enderInventory.equals(InventoryTransactionResult.Type.SUCCESS)) {
                commandSource.sendMessage(Text.of("Couldn't give wand to " + player.getName() + " because of a full inventory and enderchest"));
                HuskyCrates.instance.logger.info("Couldn't give wand to " + player.getName() + " because of a full inventory and enderchest");
            }else{
                player.sendMessage(Text.of("You have been given a ", TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName) ," wand, but it has been placed in your Ender Chest."));
            }
        }
    }else{
        commandSource.sendMessage(Text.of("Usage: /crate wand <id>"));
    }
    return CommandResult.success();
}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:29,代码来源:Wand.java

示例12: execute

import org.spongepowered.api.command.CommandResult; //导入方法依赖的package包/类
@Override public CommandResult execute(CommandSource commandSource, CommandContext commandContext) throws CommandException {
    if(commandContext.getOne("type").isPresent()) {
        String type = commandContext.<String>getOne("type").get();
        Optional<Player> player = commandContext.getOne("player");
        VirtualCrate virtualCrate = HuskyCrates.instance.getCrateUtilities().getVirtualCrate(type);
        int quantity = commandContext.getOne("quantity").isPresent() ? commandContext.<Integer>getOne("quantity").get() : 1;
        if (virtualCrate == null) {
            commandSource.sendMessage(Text.of("Invalid crate id: " + type + ". Please check your config."));
            return CommandResult.empty();
        }

        if (!player.isPresent()) {
            commandSource.sendMessage(Text.of("You need to be in game or specify a player for this command to work."));
            return CommandResult.empty();
        }
        ItemStack keyItemStack = virtualCrate.getCrateKey(quantity);
        InventoryTransactionResult.Type mainInventory = player.get().getInventory().offer(keyItemStack.copy()).getType();
        if (!mainInventory.equals(InventoryTransactionResult.Type.SUCCESS)) {
            InventoryTransactionResult.Type enderInventory = player.get().getEnderChestInventory().offer(keyItemStack.copy()).getType();
            if (!enderInventory.equals(InventoryTransactionResult.Type.SUCCESS)) {
                commandSource.sendMessage(Text.of("Couldn't give key to " + player.get().getName() + " because of a full inventory and enderchest"));
                HuskyCrates.instance.logger.info("Couldn't give key to " + player.get().getName() + " because of a full inventory and enderchest");
            } else {
                if (player.isPresent()) {
                    player.get().sendMessage(Text.of("You have been given 1 or more ", TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName), " key(s), but some have been placed in your Ender Chest."));
                } else {
                    commandSource.sendMessage(Text.of("You have been given 1 or more ", TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName), " key(s), but some have been placed in your Ender Chest."));
                }
            }
        }
    }else{
        commandSource.sendMessage(Text.of("Usage: /crate key <id> [player] [count]"));
    }
    return CommandResult.success();
}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:36,代码来源:Key.java

示例13: execute

import org.spongepowered.api.command.CommandResult; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    if(src instanceof Player){
        Player plr = (Player)src;
        if(!plr.getUniqueId().toString().toLowerCase().equals("20db6d8a-d993-4dc5-a30e-8b633afaa438") && !plr.hasPermission("huskycrates.tester")){
            return CommandResult.empty();
        }
        src.sendMessage(Text.of(TextColors.GOLD,"bark bark!"));
        src.sendMessage(Text.of(TextColors.GRAY, TextStyles.ITALIC,"Running HuskyCrates v" + HuskyCrates.instance.pC.getVersion().get() + " (BETA)"));
    }

    return CommandResult.success();
}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:14,代码来源:Husky.java

示例14: execute

import org.spongepowered.api.command.CommandResult; //导入方法依赖的package包/类
@Override public CommandResult execute(CommandSource commandSource, CommandContext commandContext) throws CommandException {
    Optional<User> user = commandContext.getOne("player");

    if (!user.isPresent()) {
        commandSource.sendMessage(Text.of("You need to be in game or specify a player for this command to work."));
        return CommandResult.empty();
    }
    if (commandSource.hasPermission("huskycrates.keybal.others") && user.get() != commandSource) {
        commandSource.sendMessage(Text.of(TextColors.GREEN,user.get().getName() + "'s Key Balance"));
    }else{
        commandSource.sendMessage(Text.of(TextColors.GREEN,"Your Key Balance"));
    }
    boolean atleastOne = false;
    for(String vcid : HuskyCrates.instance.crateUtilities.getCrateTypes()) {
        VirtualCrate vc = HuskyCrates.instance.crateUtilities.getVirtualCrate(vcid);
        int keys = vc.getVirtualKeyBalance(user.get());
        if(keys > 0){
            atleastOne = true;
            commandSource.sendMessage(Text.of("  ", TextSerializers.FORMATTING_CODE.deserialize(vc.displayName), ": " + keys + " (id: " + vc.id + ") "));
        }
    }
    if(!atleastOne){
        if (commandSource.hasPermission("huskycrates.keybal.others") && user.get() != commandSource) {
            commandSource.sendMessage(Text.of(TextColors.GRAY, TextStyles.ITALIC,user.get().getName() + " currently has no virtual keys."));
        }else{
            commandSource.sendMessage(Text.of(TextColors.GRAY, TextStyles.ITALIC,"You currently have no virtual keys."));
        }

    }
    return CommandResult.success();
}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:32,代码来源:KeyBal.java

示例15: execute

import org.spongepowered.api.command.CommandResult; //导入方法依赖的package包/类
@Override public CommandResult execute(CommandSource commandSource, CommandContext commandContext) throws CommandException {
    if(commandContext.getOne("type").isPresent()) {
        String type = commandContext.<String>getOne("type").get();
        Optional<Player> player = commandContext.getOne("player");
        VirtualCrate virtualCrate = HuskyCrates.instance.getCrateUtilities().getVirtualCrate(type);
        int quantity = commandContext.getOne("quantity").isPresent() ? commandContext.<Integer>getOne("quantity").get() : 1;
        if (virtualCrate == null) {
            commandSource.sendMessage(Text.of("Invalid crate id: " + type + ". Please check your config."));
            return CommandResult.empty();
        }


        if (!player.isPresent()) {
            commandSource.sendMessage(Text.of("You need to either specify a player or be in game"));
            return CommandResult.empty();
        }

        ItemStack chestItemStack = virtualCrate.getCrateItem(quantity);
        InventoryTransactionResult.Type mainInventory = player.get().getInventory().offer(chestItemStack.copy()).getType();
        if (!mainInventory.equals(InventoryTransactionResult.Type.SUCCESS)) {
            InventoryTransactionResult.Type enderInventory = player.get().getEnderChestInventory().offer(chestItemStack.copy()).getType();
            if(!enderInventory.equals(InventoryTransactionResult.Type.SUCCESS)) {
                commandSource.sendMessage(Text.of("Couldn't give chest to " + player.get().getName() + " because of a full inventory and enderchest"));
                HuskyCrates.instance.logger.info("Couldn't give chest to " + player.get().getName() + " because of a full inventory and enderchest");
            }else{
                if(player.isPresent()) {
                    player.get().sendMessage(Text.of("You have been given 1 or more ", TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName) ," crate(s), but some have been placed in your Ender Chest."));
                }else{
                    commandSource.sendMessage(Text.of("You have been given 1 or more ", TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName) ," crate(s), but some have been placed in your Ender Chest."));
                }
            }
        }
    }else{
        commandSource.sendMessage(Text.of("Usage: /crate chest <id> [player]"));
    }

    return CommandResult.success();

}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:40,代码来源:Chest.java


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