本文整理汇总了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();
}
示例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();
}
示例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();
}
}
示例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();
}
示例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();
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}