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


Java ConsoleSource类代码示例

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


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

示例1: callback

import org.spongepowered.api.command.source.ConsoleSource; //导入依赖的package包/类
protected ClickAction.ExecuteCallback callback(Chunk chunk) {
    return TextActions.executeCallback((commandSource -> {
        if (commandSource instanceof ConsoleSource) {
            commandSource.sendMessage(Text.of(TextColors.RED + "Silly console, you can't teleport."));
            return;
        }
        Player player = (Player) commandSource;
        Location<World> a = new Location<>(chunk.getWorld(), chunk.getPosition());
        Location<World> b = new Location<>(a.getExtent(), a.getX() * 16, a.getExtent().getBlockMax().getY(), a.getZ() * 16);
        Optional<BlockRayHit<World>> c = BlockRay.from(b).stopFilter(BlockRay.onlyAirFilter()).to(a.getPosition().sub(b.getX(), 1, b.getZ()))
                .end();

        if (c.isPresent()) {
            BlockRayHit<World> d = c.get();
            player.setLocation(d.getLocation());
        } else {
            commandSource.sendMessage(Text.of("Could not send you to: " + a.getX() + "," + a.getZ()));
        }
    }));
}
 
开发者ID:Time6628,项目名称:CatClearLag,代码行数:21,代码来源:LaggyChunksCommand.java

示例2: sendMessage

import org.spongepowered.api.command.source.ConsoleSource; //导入依赖的package包/类
/** Send a message from a channel as console.
 * @param sender {@code ConsoleSource} - Console sender.
 * @param message {@code Text} - Message to send.
 * @param direct {@code boolean} - Send message direct to players on channel.
 */
public void sendMessage(ConsoleSource sender, Text message, boolean direct){
	if (direct){			
		for (Player p:Sponge.getServer().getOnlinePlayers()){
			UCChannel chp = UChat.get().getPlayerChannel(p);
			if (UChat.get().getPerms().channelReadPerm(p, this) && !this.isIgnoring(p.getName()) && (!this.neeFocus() || chp.equals(this))){
				UChat.get().getLogger().timings(timingType.START, "UCChannel#sendMessage()|Direct Message");
				p.sendMessage(message);					
			}
		}
		sender.sendMessage(message);
	} else {
		UChat.get().getLogger().timings(timingType.START, "UCChannel#sendMessage()|Fire MessageChannelEvent");
		UCMessages.sendFancyMessage(new String[0], message, this, sender, null);
	}
}
 
开发者ID:FabioZumbi12,项目名称:UltimateChat,代码行数:21,代码来源:UCChannel.java

示例3: sendPreTell

import org.spongepowered.api.command.source.ConsoleSource; //导入依赖的package包/类
private void sendPreTell(CommandSource sender, CommandSource receiver, Text msg){		
	CommandSource src = sender;
	if (sender instanceof ConsoleSource){
		src = receiver;
	}

	UChat.get().getLogger().timings(UCLogger.timingType.START, "UCListener#sendPreTell()|Fire AsyncPlayerChatEvent");

	MessageChannelEvent.Chat event = SpongeEventFactory.createMessageChannelEventChat(
			UChat.get().getVHelper().getCause(src), 
			src.getMessageChannel(), 
			Optional.of(src.getMessageChannel()), 				    							
			new MessageEvent.MessageFormatter(Text.builder("<" + src.getName() + "> ")
					.onShiftClick(TextActions.insertText(src.getName()))
					.onClick(TextActions.suggestCommand("/msg " + src.getName()))
					.build(), msg),
			msg,  
			false);
	Sponge.getEventManager().post(event);
}
 
开发者ID:FabioZumbi12,项目名称:UltimateChat,代码行数:21,代码来源:UCCommands.java

示例4: displayCurrentProject

import org.spongepowered.api.command.source.ConsoleSource; //导入依赖的package包/类
@CustomCommand(command = "ms")
public void displayCurrentProject(CommandSource source, Map<String, Object> values) {
    if(!(source instanceof ConsoleSource))
        return;

    if(Main.getInstance().getCurrentProject() == null) {
        Main.getInstance().getLogger().info("There is no project loaded.");
        return;
    }

    PluginInfo pluginInfo = Main.getInstance().getCurrentProject().getPluginInfo();

    Main.getInstance().getLogger().info("Current project");
    Main.getInstance().getLogger().info("- Name: "+pluginInfo.getName());
    Main.getInstance().getLogger().info("- Id: "+pluginInfo.getId());
    Main.getInstance().getLogger().info("- Version: "+pluginInfo.getVersion());
    Main.getInstance().getLogger().info("- Description: "+pluginInfo.getDescription());
    Main.getInstance().getLogger().info("- Url: "+pluginInfo.getUrl());
    Main.getInstance().getLogger().info("- Authors: "+pluginInfo.getAuthors());
    Main.getInstance().getLogger().info("- Dependencies: "+pluginInfo.getDependencies());
}
 
开发者ID:djxy,项目名称:MultiScripts,代码行数:22,代码来源:ProjectCommands.java

示例5: reloadProject

import org.spongepowered.api.command.source.ConsoleSource; //导入依赖的package包/类
@CustomCommand(command = "ms reload")
public void reloadProject(CommandSource source, Map<String, Object> values){
    if(!(source instanceof ConsoleSource))
        return;

    if(Main.getInstance().getCurrentProject() == null) {
        Main.getInstance().getLogger().info("There is no project loaded.");
        return;
    }

    try {
        ProjectPlugin.getInstance().loadProject();
        Main.getInstance().getLogger().info(Main.getInstance().getCurrentProject().getPluginInfo().getName()+" reloaded.");
    } catch (ScriptException | IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:djxy,项目名称:MultiScripts,代码行数:18,代码来源:ProjectCommands.java

示例6: execute

import org.spongepowered.api.command.source.ConsoleSource; //导入依赖的package包/类
@Override
public CompletableFuture<Boolean> execute(final CommandSource source, final List<String> args) throws CommandException {
	if (args.size() == 1) {
		String message = EEMsg.replaceMessage(this.plugin.getChat(), source, args.get(0));
		
		// La source est un joueur
		if (source instanceof EPlayer) {
			return this.commandReply(source, ((EPlayer) source).getReplyTo(), message);
		// La source est une console
		} else if (source instanceof ConsoleSource) {
			return this.commandReply(source, this.plugin.getEssentials().getConsole().getReplyTo(), message);
		} else {
			EAMessages.COMMAND_ERROR_FOR_PLAYER.sender()
				.prefix(EEMessages.PREFIX)
				.sendTo(source);
		}
		
	} else {
		source.sendMessage(this.help(source));
	}
	return CompletableFuture.completedFuture(false);
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:23,代码来源:EEReply.java

示例7: onStarted

import org.spongepowered.api.command.source.ConsoleSource; //导入依赖的package包/类
@Listener
public void onStarted(GameStartedServerEvent event) {
    if (!PluginInfo.isIsLoaded()) {
        ConsoleSource source = Sponge.getServer().getConsole();

        Lists.newArrayList(
                Text.of(TextColors.RED, "----------------------------------"),
                Text.of(TextColors.RED, "- NUCLEUS MIXINS WERE NOT LOADED -"),
                Text.of(TextColors.RED, "----------------------------------"),
                Text.of(TextColors.RED, " "),
                Text.of(TextColors.RED, "The Nucleus Mixins are not being applied, and so /invsee and pregen enhancements will not work."),
                Text.of(TextColors.RED, "This is usually because you have not put Nucleus Mixins in your ", TextColors.YELLOW, "mods", TextColors.RED,
                        " directory. Nucleus Mixins is a MOD and **must** go in the mods folder."),
                Text.of(TextColors.RED, "Please put the mixins in ", TextColors.YELLOW, "/mods ", TextColors.RED, " - not ", TextColors.YELLOW,
                        "/plugins", TextColors.RED, " or any other directory - and restart your server.")).forEach(source::sendMessage);
    }
}
 
开发者ID:NucleusPowered,项目名称:NucleusMixins,代码行数:18,代码来源:NucleusMixinSpongePlugin.java

示例8: execute

import org.spongepowered.api.command.source.ConsoleSource; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException
{
	if (src instanceof Player)
	{
		Player player = (Player) src;
		player.getWorld().getProperties().setSpawnPosition(player.getLocation().getBlockPosition());
		src.sendMessage(Text.of(TextColors.GREEN, "Success: ", TextColors.YELLOW, "World spawn set."));
	}
	else if (src instanceof ConsoleSource || src instanceof CommandBlockSource)
	{
		src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Must be an in-game player to use /world setspawn!"));
	}

	return CommandResult.success();
}
 
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:17,代码来源:WorldsBase.java

示例9: onCommandSent

import org.spongepowered.api.command.source.ConsoleSource; //导入依赖的package包/类
@Listener
public void onCommandSent(SendCommandEvent event, @Root CommandSource src)
{
	if (src instanceof Player && Utils.isPlayerCommandLoggingEnabled())
	{
		EssentialCmds.getEssentialCmds().getLogger().info("[" + src.getName() + "]" + " executed command " + event.getCommand() + " " + event.getArguments());
	}
	else if (src instanceof ConsoleSource && Utils.isConsoleCommandLoggingEnabled())
	{
		EssentialCmds.getEssentialCmds().getLogger().info("[" + src.getName() + "]" + " executed command " + event.getCommand() + " " + event.getArguments());
	}
	else if (src instanceof CommandBlockSource && Utils.isCommandBlockCommandLoggingEnabled())
	{
		EssentialCmds.getEssentialCmds().getLogger().info("[" + src.getName() + "]" + " executed command " + event.getCommand() + " " + event.getArguments());
	}
	else if (Utils.isOtherCommandLoggingEnabled())
	{
		EssentialCmds.getEssentialCmds().getLogger().info("[" + src.getName() + "]" + " executed command " + event.getCommand() + " " + event.getArguments());
	}
}
 
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:21,代码来源:CommandSentListener.java

示例10: process

import org.spongepowered.api.command.source.ConsoleSource; //导入依赖的package包/类
@Override
public CommandResult process(CommandSource source, String arguments) throws CommandException {
    if (!testPermission(source)) {
        throw new CommandPermissionException(Text.of(TextColors.RED, "[Hammer] You do not have permission to do that."));
    }

    try {
        List<String> a = Arrays.asList(arguments.split(" "));
        if (source instanceof Player) {
            core.executeCommand(new SpongeWrappedPlayer((Player)source), a);
        } else if (source instanceof ConsoleSource) {
            core.executeCommand(new SpongeWrappedConsole((ConsoleSource)source), a);
        }

        return CommandResult.success();
    } catch (HammerException e) {
        e.printStackTrace();
        throw new CommandException(error, e);
    }

}
 
开发者ID:dualspiral,项目名称:Hammer,代码行数:22,代码来源:SpongeCommand.java

示例11: isOPOrConsole

import org.spongepowered.api.command.source.ConsoleSource; //导入依赖的package包/类
/**
 * Returns true if the CommandSource is an Operator or of a ConsoleSource.
 * 
 * @param cs
 *            The CommandSource.
 * @return True if instaceof Player and is OP OR is instanceof
 *         ConsoleSource.
 */
public boolean isOPOrConsole(CommandSource cs) {
	if (cs instanceof Player) {
		if (isOP(((Player) cs).getUniqueId().toString())) {
			return true;
		} else {
			cs.sendMessage(Text.of(TextColors.RED, "This command requires operator privilages."));
			return false;
		}

	} else if (cs instanceof ConsoleSource) {
		return true;
	} else {
		return false;
	}
}
 
开发者ID:Volition21,项目名称:BlockTrackR,代码行数:24,代码来源:BTRPermissionTools.java

示例12: isAuthed

import org.spongepowered.api.command.source.ConsoleSource; //导入依赖的package包/类
/**
 * Takes a CommandSource and returns true if it's a player and is authorized
 * (or an operator), or if it's a ConsoleSource.
 * 
 * Will also inform the CommandSource if they are not authorized.
 * 
 * @param cs
 *            The CommandSource
 * @return True if the source is a player and is authorized or is a
 *         ConsoleSource.
 */
public boolean isAuthed(CommandSource cs) {
	if (cs instanceof Player) {
		if (isAuthed(((Player) cs).getUniqueId().toString())) {
			return true;
		} else {
			cs.sendMessage(Text.of(TextColors.RED, "You are not an authorized user."));
			return false;
		}

	} else if (cs instanceof ConsoleSource) {
		return true;
	} else {
		return false;
	}
}
 
开发者ID:Volition21,项目名称:BlockTrackR,代码行数:27,代码来源:BTRPermissionTools.java

示例13: execute

import org.spongepowered.api.command.source.ConsoleSource; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {

    // Make sure source can receive messages back.
    if (!(src instanceof Player || src instanceof ConsoleSource)) return CommandResult.empty();

    String action = "";
    String option = args.getOne("option").orElse("help").toString().toLowerCase();
    String value = "";

    if (args.getOne("value").isPresent()) {
        action = "set";
        value = args.getOne("value").orElse("help").toString();

        // Add remaining text to value.
        if (args.getOne("remaining").isPresent()) {
            value += " " + args.getOne("remaining").toString(); // TODO: This doesn't actually work.
        }
    }else{
        action = "get";
    }

    return doCommand(src, action, option, value) ? CommandResult.success() : CommandResult.empty();
}
 
开发者ID:yariplus,项目名称:minecraft-nodebb-integration,代码行数:25,代码来源:CommandNodeBBSponge.java

示例14: apply

import org.spongepowered.api.command.source.ConsoleSource; //导入依赖的package包/类
@Override
public void apply(Player player) {
    ConsoleSource console_source = Sponge.getServer().getConsole();
    for (Command command : commands) {
        String cmd = command.getCmd().replace("%PLAYER%", player.getName());
        boolean console = command.isConsole();
        Sponge.getCommandManager().process(console ? console_source : player, cmd);
    }
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:10,代码来源:CommandsDrop.java

示例15: execute

import org.spongepowered.api.command.source.ConsoleSource; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	
	String argumentsLine;
	ArrayList<String> arguments;
	
	if (args.<String>getOne("cmd").isPresent()) {
		argumentsLine = args.<String>getOne("cmd").get();
		arguments = Lists.newArrayList(argumentsLine.split(" "));
	} else {
		argumentsLine = null;
		arguments = Lists.newArrayList();
	}
	
	Traveller traveller = null;
	
	if (src instanceof Player) {
	    Player player = (Player) src;
	    traveller =  Travellers.impl().get(player.getUniqueId());
	} else if(src instanceof ConsoleSource) {
		traveller =  Travellers.impl().get(null);
	} else {
		return CommandResult.builder().successCount(0).build();
	}
	
	CmdCam.get().preExec(traveller, arguments);
	
	return CommandResult.builder().successCount(1).build();
}
 
开发者ID:redstone,项目名称:RCameraStudio,代码行数:30,代码来源:SpongeCommandManager.java


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