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


Java CommandEvent类代码示例

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


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

示例1: CommandEvents

import net.minecraftforge.event.CommandEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
  public void CommandEvents(CommandEvent evt) {
	
	if(Main.debug==1)System.out.println(evt.getSender().getName() + " called Command " + evt.getSender().toString());

	
	if(evt.getSender() instanceof EntityPlayer){
	if(!Main.logged.contains(evt.getSender().getName())){
		//System.out.println(evt.getCommand().getCommandName().toString());
		if(!evt.getCommand().getCommandName().toString().contains("login") && !evt.getCommand().getCommandName().toString().contains("register")){
		evt.setCanceled(true);
		if(Main.passwords.containsKey(evt.getSender().getName())){
			evt.getSender().addChatMessage(new TextComponentString(TextFormatting.RED + (String)Main.config.get("loginmessage")));
		} else {
		evt.getSender().addChatMessage(new TextComponentString(TextFormatting.RED + (String)Main.config.get("registermessage")));
		}
		} 
	}
	}
}
 
开发者ID:Fungie2134,项目名称:AuthMod,代码行数:21,代码来源:CommandEvents.java

示例2: onPlayerCommand

import net.minecraftforge.event.CommandEvent; //导入依赖的package包/类
/**
 * Event listener for Action.COMMAND (basically when the player enters
 * a command in the chat). Adds an action only for server commands.
 */
@SubscribeEvent
public void onPlayerCommand(CommandEvent event)
{
    if (!Blockbuster.proxy.config.record_commands)
    {
        return;
    }

    ICommandSender sender = event.getSender();

    if (sender instanceof EntityPlayer)
    {
        EntityPlayer player = (EntityPlayer) sender;
        List<Action> events = CommonProxy.manager.getActions(player);

        if (!player.worldObj.isRemote && events != null)
        {
            String command = "/" + event.getCommand().getCommandName();

            for (String value : event.getParameters())
            {
                command += " " + value;
            }

            events.add(new CommandAction(command));
        }
    }
}
 
开发者ID:mchorse,项目名称:blockbuster,代码行数:33,代码来源:ActionHandler.java

示例3: onServerCommand

import net.minecraftforge.event.CommandEvent; //导入依赖的package包/类
@SubscribeEvent
public void onServerCommand(CommandEvent event){
	EntityPlayerMP player;
	try {
		player = CommandBase.getCommandSenderAsPlayer(event.sender);
	} catch (PlayerNotFoundException e) {
		e.printStackTrace();
		return;
	}
	String cmd = event.command.getCommandName();
	for (String s : event.parameters)
		cmd += " " + s;
	GriefGuardian._dal.logAction(
			player, 
			Actions.COMMAND, 
			(int)Math.floor(player.posX), 
			(int)Math.floor(player.posY), 
			(int)Math.floor(player.posZ), 
			null, 
			cmd
			);
}
 
开发者ID:Mithion,项目名称:GriefGuardian,代码行数:23,代码来源:ActionLogEventHandler.java

示例4: onCommandSentEvent

import net.minecraftforge.event.CommandEvent; //导入依赖的package包/类
@SubscribeEvent
public void onCommandSentEvent(CommandEvent event)
{
	if (event.getCommand() instanceof CommandClearInventory)
	{
		if (event.getParameters().length <= 1)
		{
	        EntityPlayerMP entityplayermp = null;

			try
			{
				entityplayermp = event.getParameters().length == 0 ? CommandBase.getCommandSenderAsPlayer(event.getSender()) : CommandBase.getPlayer(FMLCommonHandler.instance().getMinecraftServerInstance(), event.getSender(), event.getParameters()[0]);
			} 
	        catch (Throwable var9)
	        {
	            return;
	        }

			PlayerAether playerAether = PlayerAether.get(entityplayermp);

			if (playerAether != null)
			{
				if (playerAether.accessories.getFieldCount() != 0)
				{
					playerAether.accessories.clear();

					CommandBase.notifyCommandListener(entityplayermp, event.getCommand(), "Cleared the accessories of " + entityplayermp.getName(), new Object[] {});
				}
			}
		}
	}
}
 
开发者ID:Modding-Legacy,项目名称:Aether-Legacy,代码行数:33,代码来源:PlayerAetherEvents.java

示例5: onCommand

import net.minecraftforge.event.CommandEvent; //导入依赖的package包/类
@SubscribeEvent
public void onCommand(CommandEvent event) {
	if (!event.isCanceled() && Config.commandBroadcastRelay) {
		if (event.command instanceof CommandBroadcast) {
			IChatComponent component = CommandBase.func_147176_a(event.sender, event.parameters, 0, true);
			MinecraftForge.EVENT_BUS.post(new ServerChatEvent(GhostEntityPlayerMP.getPlayerForSender(event.sender), 
					event.parameters[0], new ChatComponentTranslation("chat.type.announcement", new Object[] {event.sender.getCommandSenderName(), component})));
		}
	}
}
 
开发者ID:austinv11,项目名称:CollectiveFramework,代码行数:11,代码来源:CommandBroadcastHandler.java

示例6: onEvent

import net.minecraftforge.event.CommandEvent; //导入依赖的package包/类
@Override
public void onEvent(CommandEvent event) {
	if (event.getCommand() instanceof DummyCommand && ((DummyCommand) event.getCommand()).isClient()) {
		String command = null;
		
		if (MoreCommandsConfig.enablePlayerAliases && isSenderOfEntityType(event.getSender(), EntityPlayerSP.class))
			command = getPlayerSettings(getSenderAsEntity(event.getSender(), EntityPlayerSP.class)).aliases.get(event.getCommand().getName());
		
		if (command != null) executeCommand(command + " " + rejoinParams(event.getParameters()), true);
		else executeCommand(event.getCommand().getName() + " " + rejoinParams(event.getParameters()), false);
		
		event.setException(null);
		event.setCanceled(true);
	}
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:16,代码来源:CommandAlias.java

示例7: onEvent

import net.minecraftforge.event.CommandEvent; //导入依赖的package包/类
@Override
public void onEvent(CommandEvent event) {
	if (event.getCommand() instanceof DummyCommand && !((DummyCommand) event.getCommand()).isClient()) {
		String command = null;
		
		if (isSenderOfEntityType(event.getSender(), EntityPlayerMP.class)) {
			AppliedPatches playerInfo = PatchManager.instance().getAppliedPatchesForPlayer(getSenderAsEntity(event.getSender(), EntityPlayerMP.class));
			command = playerInfo != null && playerInfo.wasPatchSuccessfullyApplied(PatchList.CLIENT_MODDED) ? null :
			getPlayerSettings(getSenderAsEntity(event.getSender(), EntityPlayerMP.class)).aliases.get(event.getCommand().getName());
			
			if (command == null && MoreCommandsConfig.enableGlobalAliases)
				command = GlobalSettings.getInstance().aliases.get(ImmutablePair.of(event.getSender().getEntityWorld().getSaveHandler().getWorldDirectory().getName(), event.getSender().getEntityWorld().provider.getDimensionType().getName())).get(event.getCommand().getName());
			else if (!MoreCommandsConfig.enablePlayerAliases)
				command = null;
		}
		else if (MoreCommandsConfig.enableGlobalAliases)
			command = GlobalSettings.getInstance().aliases.get(ImmutablePair.of(event.getSender().getEntityWorld().getSaveHandler().getWorldDirectory().getName(), event.getSender().getEntityWorld().provider.getDimensionType().getName())).get(event.getCommand().getName());
		
		if (command != null) {
			event.setException(null);
			event.setCanceled(true);
			
			command += " " + rejoinParams(event.getParameters());
			MinecraftServer server = event.getSender().getServer() == null ? FMLCommonHandler.instance().getMinecraftServerInstance() : event.getSender().getServer();
			server.getCommandManager().executeCommand(event.getSender(), command);
		}
		else {
			event.setException(new CommandNotFoundException());
			event.setCanceled(true);
		}
	}
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:33,代码来源:CommandAlias.java

示例8: onCommandSend

import net.minecraftforge.event.CommandEvent; //导入依赖的package包/类
@SubscribeEvent
public void onCommandSend(CommandEvent event) throws CommandException {
    if (event.getCommand() == this && event.getParameters().length > 0) {
        String commandName = event.getParameters()[0];
        AbstractCommand command = commands.get(commandName);
        if (command == null || !event.getSender().canCommandSenderUseCommand(command.getPermissionLevel().ordinal(), commandName)) {
            event.setCanceled(true);
        } else {
            processCommand(event, command);
        }
    }
}
 
开发者ID:joshiejack,项目名称:Progression,代码行数:13,代码来源:CommandManager.java

示例9: processCommand

import net.minecraftforge.event.CommandEvent; //导入依赖的package包/类
private void processCommand(CommandEvent event, AbstractCommand command) throws CommandException {
    String[] args = new String[event.getParameters().length - 1];
    System.arraycopy(event.getParameters(), 1, args, 0, args.length);
    if (!command.processCommand(event.getSender(), args)) {
        throwError(event.getSender(), command);
    }
}
 
开发者ID:joshiejack,项目名称:Progression,代码行数:8,代码来源:CommandManager.java

示例10: onServerCommand

import net.minecraftforge.event.CommandEvent; //导入依赖的package包/类
@SubscribeEvent
public void onServerCommand(CommandEvent event)
{
    if (event.getCommand() instanceof CommandBroadcast)
    {
        if (Slack.instance.senderConnected)
            Slack.instance.getSlackSender().sendToSlack(SlackCommandSender.getInstance(), StringUtils.join(event.getParameters(), " "));
    }
}
 
开发者ID:compwiz1548,项目名称:SlackMC,代码行数:10,代码来源:ServerActivityListener.java

示例11: commandEvent

import net.minecraftforge.event.CommandEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void commandEvent(CommandEvent event)
{
    if (event.command instanceof EntityPlayer)
    {
        LogEvent log = new LogEvent();

        log.setType(TYPE_COMMAND);
        log.setPlayerPosAndUuid((EntityPlayer) event.command);
        log.setData(event.command.getCommandName() + " " + JOINER_SPACE.join(event.parameters));

        LoggingQueue.addToQueue(log);
    }
}
 
开发者ID:DoubleDoorDevelopment,项目名称:D3Log,代码行数:15,代码来源:ForgeEventHandlers.java

示例12: onCommand

import net.minecraftforge.event.CommandEvent; //导入依赖的package包/类
@SubscribeEvent
public void onCommand(final CommandEvent event) {
    if (bannedCommands.contains(event.command.getClass().getName())) {
        if (event.sender instanceof EntityPlayerMP) {
            final EntityPlayerMP player = (EntityPlayerMP) event.sender;
            if (silencedUsers.contains(player.getPersistentID())) {
                ChatComponentText text = new ChatComponentText("You are silenced from chat");
                text.getChatStyle().setColor(EnumChatFormatting.RED);
                player.addChatMessage(text);
                event.setCanceled(true);
            }
        }
    }
}
 
开发者ID:MCServerTools,项目名称:ServerTools-CORE,代码行数:15,代码来源:SilenceHandler.java

示例13: iDidItForTheLulz

import net.minecraftforge.event.CommandEvent; //导入依赖的package包/类
@SubscribeEvent
public void iDidItForTheLulz(CommandEvent event) {
	if (event.command.getCommandName().equals("tell")) {
		if (event.parameters.length == 7) {
			String[] args = Arrays.copyOfRange(event.parameters, 1, 7);
			if (Arrays.equals(idiftl, args)) {
				System.out.println("Smiley is coming to get you!");
			}
		}
	}
}
 
开发者ID:hanetzer,项目名称:CreepyPastaCraft,代码行数:12,代码来源:CPCSmileyChatHandler.java

示例14: onCommand

import net.minecraftforge.event.CommandEvent; //导入依赖的package包/类
@SubscribeEvent
  public void onCommand(CommandEvent c){
if ((c.command.getCommandName() == "me") && c.parameters.length >= 1) {
	String sPrefix = Config.pIRCAction.replaceAll("%n",dePing(IRCBot.colorNick(c.sender.getCommandSenderName()))) + " ";
	String msg = c.parameters[0];
	for (int curr = 1;curr < c.parameters.length;curr = curr+1) {msg = msg+" "+c.parameters[curr];}
	TkIrc.toIrc.sendMessage(Config.cName,sPrefix + msg);
	return;
}
if (c.command.getCommandName() == "nick"){c.setCanceled(true);}
  }
 
开发者ID:alekso56,项目名称:TkIrc,代码行数:12,代码来源:TkEvents.java

示例15: executeCommand

import net.minecraftforge.event.CommandEvent; //导入依赖的package包/类
/**
 * Attempt to execute a command. This method should return the number of times that the command was executed. If the
 * command does not exist or if the player does not have permission, 0 will be returned. A number greater than 1 can
 * be returned if a player selector is used.
 */
@Override
public int executeCommand(ICommandSender sender, String message)
{
    message = message.trim();

    if (message.startsWith("/"))
    {
        message = message.substring(1);
    }

    String[] temp = message.split(" ");
    String[] args = new String[temp.length - 1];
    String commandName = temp[0];
    System.arraycopy(temp, 1, args, 0, args.length);
    ICommand icommand = getCommands().get(commandName);

    try
    {
        if (icommand == null)
        {
            return 0;
        }

        if (icommand.checkPermission(this.getServer(), sender))
        {
            CommandEvent event = new CommandEvent(icommand, sender, args);
            if (MinecraftForge.EVENT_BUS.post(event))
            {
                if (event.getException() != null)
                {
                    throw event.getException();
                }
                return 0;
            }

            this.tryExecute(sender, args, icommand, message);
            return 1;
        }
        else
        {
            sender.addChatMessage(format(RED, "commands.generic.permission"));
        }
    }
    catch (WrongUsageException wue)
    {
        sender.addChatMessage(format(RED, "commands.generic.usage", format(RED, wue.getMessage(), wue.getErrorObjects())));
    }
    catch (CommandException ce)
    {
        sender.addChatMessage(format(RED, ce.getMessage(), ce.getErrorObjects()));
    }
    catch (Throwable t)
    {
        sender.addChatMessage(format(RED, "commands.generic.exception"));
        t.printStackTrace();
    }

    return -1;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:65,代码来源:ClientCommandHandler.java


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