本文整理匯總了Java中org.spongepowered.api.command.CommandResult.success方法的典型用法代碼示例。如果您正苦於以下問題:Java CommandResult.success方法的具體用法?Java CommandResult.success怎麽用?Java CommandResult.success使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.spongepowered.api.command.CommandResult
的用法示例。
在下文中一共展示了CommandResult.success方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: execute
import org.spongepowered.api.command.CommandResult; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
final Optional<User> optionalUser = args.getOne("player");
if (!optionalUser.isPresent()) {
throw new CommandException(Text.of(TextColors.RED, "You must specify an existing user."));
}
final Optional<InetAddress> optionalIP = args.getOne("ip");
if (!optionalIP.isPresent()) {
throw new CommandException(Text.of(TextColors.RED, "You must specify a proper IP address."));
}
final User user = optionalUser.get();
final InetAddress ip = optionalIP.get();
Sponge.getScheduler().createAsyncExecutor(IPLog.getPlugin()).execute(() -> IPLog.getPlugin().getStorage().purgeConnection(ip, user.getUniqueId()));
src.sendMessage(Text.of(TextColors.YELLOW, "You have successfully removed the specified connection from the database."));
return CommandResult.success();
}
示例2: execute
import org.spongepowered.api.command.CommandResult; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource source, CommandContext context) throws CommandException {
//https://docs.spongepowered.org/stable/zh-CN/plugin/commands/arguments.html?highlight=commandcontext
if (context.hasAny("arg")) {
String[] args = context.<String>getOne("arg").get().split(" ");
for (CommandHandler handler : this.handlerList) {
if (args[0].equalsIgnoreCase(handler.getName()) && handler.hasPermission(source)) {
if (!handler.hasPermission(source)) {//如果命令已禁用後台執行並且執行者是後台
if (source instanceof Player) {
source.sendMessage(TextUtil.of("§c你沒有執行該命令的權限."));
} else {
source.sendMessage(TextUtil.of("§c後台無法執行該命令."));
}
} else {//否則
handler.execute(source, args.length == 1 ? new String[0] : Util.subArray(args, 1, args.length - 1));
return CommandResult.success();
}
}
}
}
source.sendMessage(TextUtil.of("§2輸入/" + McrmbPluginInfo.config.command + " help §2來查看幫助"));
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"))
{
List<String> player = SwitchSQL.QueuePlayer();
for(int i = 0; i < player.size(); i++)
{
String username = player.get(i);
List<String> service = SwitchSQL.QueueReward(username);
for(int x = 0; x < service.size(); x++)
{
RewardsTask.Notonline(username, service.get(x));
SwitchSQL.removeQueue(username, service.get(x));
}
}
}
return CommandResult.success();
}
示例4: 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();
}
示例5: 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);
p.sendMessage(Text.of(TextColors.BLUE, "Querying database, please wait..."));
Sponge.getScheduler().createAsyncExecutor(plugin).execute(() -> {
LookupResult lookup;
Connection c = plugin.getDatabase().getConnection();
try {
int worldId = Database.worldCache.getDataId(c, p.getWorld().getUniqueId().toString());
ResultSet r = c.createStatement().executeQuery(QueryHelper.getLookupQuery(filterSet, p, worldId));
if (filterSet.getLookupType() == LookupType.ITEM_LOOKUP)
lookup = new ContainerLookupResult(r);
else
lookup = new BlockLookupResult(r);
LookupResultManager.instance().setLookupResult(p, lookup);
r.close();
c.close();
} catch (SQLException e) {
e.printStackTrace();
p.sendMessage(Text.of(TextColors.DARK_AQUA, "[AC] ", TextColors.RED, "A database error has occurred! Contact your server administrator!"));
return;
}
lookup.showPage(p, 1);
});
return CommandResult.success();
}
示例6: execute
import org.spongepowered.api.command.CommandResult; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource source, CommandContext context) throws CommandException
{
List<Faction> factionsList = new ArrayList<>(FactionLogic.getFactions());
List<Text> helpList = new ArrayList<>();
int index = 0;
factionsList.sort((o1, o2) -> o2.Power.compareTo(o1.Power));
//This should show only top 10 factions on the server.
for(Faction faction: factionsList)
{
if(faction.Name.equalsIgnoreCase("safezone") || faction.Name.equalsIgnoreCase("warzone")) continue;
if(index == 11) break;
index++;
String tag = "";
if(faction.Tag != null && !faction.Tag.equals("")) tag = "[" + faction.Tag + "] ";
Text factionHelp = Text.builder()
.append(Text.builder()
.append(Text.of(TextColors.AQUA, index + ". " + tag + faction.Name + " (" + faction.Power + "/" + PowerService.getFactionMaxPower(faction) + ")"))
.build())
.build();
helpList.add(factionHelp);
}
PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get();
PaginationList.Builder paginationBuilder = paginationService.builder().title(Text.of(TextColors.GREEN, "Factions List")).padding(Text.of("-")).contents(helpList);
paginationBuilder.sendTo(source);
return CommandResult.success();
}
示例7: execute
import org.spongepowered.api.command.CommandResult; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource source, CommandContext context) throws CommandException
{
if(source instanceof Player)
{
Player player = (Player)source;
if(EagleFactions.AutoMapList.contains(player.getUniqueId().toString()))
{
EagleFactions.AutoMapList.remove(player.getUniqueId().toString());
player.sendMessage(Text.of(PluginInfo.PluginPrefix, TextColors.GOLD, "AutoMap", TextColors.WHITE, " has been turned ", TextColors.GOLD, "off"));
return CommandResult.success();
}
else
{
EagleFactions.AutoMapList.add(player.getUniqueId().toString());
player.sendMessage(Text.of(PluginInfo.PluginPrefix, TextColors.GOLD, "AutoMap", TextColors.WHITE, " has been turned ", TextColors.GOLD, "on"));
return CommandResult.success();
}
}
else
{
source.sendMessage(Text.of(PluginInfo.ErrorPrefix, TextColors.RED, "Only in-game players can use this command!"));
}
return CommandResult.success();
}
示例8: execute
import org.spongepowered.api.command.CommandResult; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource source, CommandContext context) throws CommandException
{
Optional<Player> optionalSelectedPlayer = context.<Player>getOne("player");
Optional<String> optionalPower = context.<String>getOne("power");
if (optionalSelectedPlayer.isPresent() && optionalPower.isPresent())
{
if (source instanceof Player)
{
Player player = (Player) source;
if (EagleFactions.AdminList.contains(player.getUniqueId().toString()))
{
BigDecimal newPower = new BigDecimal(optionalPower.get());
PowerService.setPower(optionalSelectedPlayer.get().getUniqueId(), newPower);
player.sendMessage(Text.of(PluginInfo.PluginPrefix, TextColors.GREEN, "Player's power has been changed!"));
return CommandResult.success();
}
else
{
player.sendMessage(Text.of(PluginInfo.ErrorPrefix, TextColors.RED, "You need to toggle faction admin mode to do this!"));
}
}
else
{
source.sendMessage(Text.of(PluginInfo.ErrorPrefix, TextColors.RED, "Only in-game players can use this command!"));
}
}
else
{
source.sendMessage(Text.of(PluginInfo.ErrorPrefix, TextColors.RED, "Wrong command arguments!"));
source.sendMessage(Text.of(TextColors.RED, "Usage: /f setpower <player> <power>"));
}
return CommandResult.success();
}
示例9: execute
import org.spongepowered.api.command.CommandResult; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource source, CommandContext context) throws CommandException
{
source.sendMessage (Text.of (TextColors.AQUA, PluginInfo.Name, TextColors.WHITE, " - Version ", PluginInfo.Version));
return CommandResult.success ();
}
示例10: execute
import org.spongepowered.api.command.CommandResult; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
final Optional<User> optionalUser = args.getOne("player");
if (!optionalUser.isPresent()) {
throw new CommandException(Text.of(TextColors.RED, "You must specify an existing user."));
}
final Optional<InetAddress> optionalIP = args.getOne("ip");
if (!optionalIP.isPresent()) {
throw new CommandException(Text.of(TextColors.RED, "You must specify a proper IP address."));
}
final User user = optionalUser.get();
final InetAddress ip = optionalIP.get();
if (IPLog.getPlugin().getStorage().isPresent(ip, user.getUniqueId())) {
throw new CommandException(Text.of(TextColors.RED, "This connection already exists in the database."));
}
Sponge.getScheduler().createAsyncExecutor(IPLog.getPlugin()).execute(() -> IPLog.getPlugin().getStorage().addConnection(ip, user.getUniqueId(), LocalDateTime.now()));
src.sendMessage(Text.of(TextColors.YELLOW, "You have successfully added the specified connection to the database."));
return CommandResult.success();
}
示例11: execute
import org.spongepowered.api.command.CommandResult; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
boolean hasAnyPermission = false;
Text text = Text.of(TextColors.DARK_AQUA, "[AS] ", TextColors.YELLOW, "Available commands: ");
if (src.hasPermission(Permissions.LOOKUP.get())) {
hasAnyPermission = true;
text = Text.of(text, Text.NEW_LINE, CommandInspect.getHelpEntry(), Text.NEW_LINE, CommandLookup.getHelpEntry());
}
if (src.hasPermission(Permissions.FILTER.get())) {
hasAnyPermission = true;
text = Text.of(text, Text.NEW_LINE, CommandFilter.getHelpEntry());
}
if (src.hasPermission(Permissions.LOOKUP.get())) {
text = Text.of(text, Text.NEW_LINE, CommandPage.getHelpEntry(), Text.NEW_LINE, CommandNextPage.getHelpEntry(), Text.NEW_LINE,
CommandPrevPage.getHelpEntry());
}
if (src.hasPermission(Permissions.PURGE.get())) {
hasAnyPermission = true;
text = Text.of(text, Text.NEW_LINE, CommandPurge.getHelpEntry());
}
if (hasAnyPermission) {
text = Text.of(text, Text.NEW_LINE, getHelpEntry());
} else {
text = Text.of(TextColors.DARK_AQUA, "[AS] ", TextColors.YELLOW, "AdamantineShield v",
Sponge.getPluginManager().getPlugin("adamantineshield").get().getVersion().get());
}
src.sendMessage(text);
return CommandResult.success();
}
示例12: execute
import org.spongepowered.api.command.CommandResult; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource source, CommandContext context) throws CommandException
{
if(source instanceof Player)
{
Player player = (Player)source;
String playerFactionName = FactionLogic.getFactionName(player.getUniqueId());
if(playerFactionName != null)
{
if(!FactionLogic.getLeader(playerFactionName).equals(player.getUniqueId().toString()))
{
FactionLogic.leaveFaction(player.getUniqueId(), playerFactionName);
//TODO: Add listener that will inform players in a faction that someone has left their faction.
player.sendMessage(Text.of(PluginInfo.PluginPrefix,TextColors.GREEN,"You left faction ", TextColors.GOLD, playerFactionName));
if(EagleFactions.AutoClaimList.contains(player.getUniqueId().toString())) EagleFactions.AutoClaimList.remove(player.getUniqueId().toString());
CommandResult.success();
}
else
{
source.sendMessage(Text.of(PluginInfo.ErrorPrefix, TextColors.RED, "You can't leave your faction because you are its leader! Disband your faction or set someone as leader."));
}
}
else
{
source.sendMessage(Text.of(PluginInfo.ErrorPrefix, TextColors.RED, "You are not in a faction!"));
}
}
else
{
source.sendMessage (Text.of (PluginInfo.ErrorPrefix, TextColors.RED, "Only in-game players can use this command!"));
}
return CommandResult.success();
}
示例13: execute
import org.spongepowered.api.command.CommandResult; //導入方法依賴的package包/類
@SuppressWarnings("static-access")
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
AurionsVoteListener plugin = new AurionsVoteListener();
for(int i = 0; i<plugin.votetopheader.size();i++){
src.sendMessage(plugin.formatmessage(plugin.votetopheader.get(i),"",src.getName()));
}
SwitchSQL.VoteTop(src);
return CommandResult.success();
}
示例14: execute
import org.spongepowered.api.command.CommandResult; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource source, CommandContext context) throws CommandException
{
if(source instanceof Player)
{
Player player = (Player)source;
String playerFactionName = FactionLogic.getFactionName(player.getUniqueId());
if(playerFactionName != null)
{
if(FactionLogic.getHome(playerFactionName) != null)
{
//TODO: Wait 5-10 seconds before teleporting.
World world = player.getWorld();
if(FactionLogic.isHomeInWorld(world.getUniqueId(), playerFactionName))
{
Vector3i home = FactionLogic.getHome(playerFactionName);
player.setLocation(player.getLocation().setBlockPosition(home));
source.sendMessage(Text.of(PluginInfo.PluginPrefix, "You were teleported to faction's home"));
}
else
{
source.sendMessage(Text.of(PluginInfo.ErrorPrefix, "Faction's home is not in this world."));
}
}
else
{
source.sendMessage(Text.of(PluginInfo.ErrorPrefix, TextColors.RED, "Faction's home is not set!"));
}
}
else
{
source.sendMessage(Text.of(PluginInfo.ErrorPrefix, TextColors.RED, "You must be in a faction in order to use this command!"));
}
}
else
{
source.sendMessage(Text.of(PluginInfo.ErrorPrefix, TextColors.RED, "Only in-game players can use this command!"));
}
return CommandResult.success();
}
示例15: execute
import org.spongepowered.api.command.CommandResult; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
getPaginationList().sendTo(src);
return CommandResult.success();
}