本文整理汇总了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")));
}
}
}
}
}
示例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));
}
}
}
示例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
);
}
示例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[] {});
}
}
}
}
}
示例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})));
}
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
示例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(), " "));
}
}
示例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);
}
}
示例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);
}
}
}
}
示例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!");
}
}
}
}
示例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);}
}
示例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;
}