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


Java ICommandSender.sendMessage方法代码示例

本文整理汇总了Java中net.minecraft.command.ICommandSender.sendMessage方法的典型用法代码示例。如果您正苦于以下问题:Java ICommandSender.sendMessage方法的具体用法?Java ICommandSender.sendMessage怎么用?Java ICommandSender.sendMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.command.ICommandSender的用法示例。


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

示例1: getUsage

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public String getUsage(ICommandSender sender)
{
    TextComponentTranslation chatcomponenttranslation1 = new TextComponentTranslation("creeperhostserver.command.pregen.usage1");
    chatcomponenttranslation1.getStyle().setColor(TextFormatting.RED);
    sender.sendMessage(chatcomponenttranslation1);
    TextComponentTranslation chatcomponenttranslation2 = new TextComponentTranslation("creeperhostserver.command.pregen.usage2");
    chatcomponenttranslation2.getStyle().setColor(TextFormatting.RED);
    sender.sendMessage(chatcomponenttranslation2);
    TextComponentTranslation chatcomponenttranslation3 = new TextComponentTranslation("creeperhostserver.command.pregen.usage3");
    chatcomponenttranslation3.getStyle().setColor(TextFormatting.RED);
    sender.sendMessage(chatcomponenttranslation3);
    TextComponentTranslation chatcomponenttranslation4 = new TextComponentTranslation("creeperhostserver.command.pregen.usage4");
    chatcomponenttranslation4.getStyle().setColor(TextFormatting.RED);
    sender.sendMessage(chatcomponenttranslation4);
    return "creeperhostserver.command.pregen.usage5";
}
 
开发者ID:CreeperHost,项目名称:CreeperHostGui,代码行数:18,代码来源:CommandPregen.java

示例2: execute

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (sender instanceof EntityPlayerMP) {
        if (((EntityPlayerMP) sender).capabilities.isCreativeMode && sender.canUseCommand(2, "")) {
            ServerActionManager.getManager().clearOptions(sender, null);
        } else {
            ServerActionManager.getManager().clearOptions(sender, (EntityPlayerMP) sender);
        }
    } else {
        if (sender.canUseCommand(2, "creep_clear")) {
            ServerActionManager.getManager().clearOptions(sender, null);
        } else {
            sender.sendMessage(new TextComponentString(TextFormatting.RED + "You have no permission for this command!"));
        }
    }
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:17,代码来源:CommandClearActions.java

示例3: execute

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void execute (MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {

    if (sender instanceof EntityPlayer) {

        String stages = PlayerDataHandler.getStageData((EntityPlayer) sender).getUnlockedStages().stream().map(Object::toString).collect(Collectors.joining(", ")).toString();

        if (stages.isEmpty()) {

            sender.sendMessage(new TextComponentTranslation("commands.gamestage.info.empty"));
            return;
        }

        if (((EntityPlayer) sender).getUniqueID().toString().equalsIgnoreCase(BIRTHDAY_BOY_UUID)) {
            stages += ", HAPPY BIRTHDAY!";
        }

        sender.sendMessage(new TextComponentString(stages));
    }
}
 
开发者ID:Darkhax-Minecraft,项目名称:Game-Stages,代码行数:21,代码来源:CommandStageInfo.java

示例4: execute

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void execute (MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {

    if (args.length == 2) {

        final EntityPlayer player = getPlayer(server, sender, args[0]);
        final String stageName = args[1];

        PlayerDataHandler.getStageData(player).lockStage(stageName);

        if (player instanceof EntityPlayerMP) {
            GameStages.NETWORK.sendTo(new PacketStage(stageName, false), (EntityPlayerMP) player);
        }

        player.sendMessage(new TextComponentTranslation("commands.gamestage.remove.target", stageName));

        if (player != sender) {
            sender.sendMessage(new TextComponentTranslation("commands.gamestage.remove.sender", stageName, player.getDisplayNameString()));
        }
    }
    else {
        throw new WrongUsageException("commands.gamestage.remove.usage", new Object[0]);
    }
}
 
开发者ID:Darkhax-Minecraft,项目名称:Game-Stages,代码行数:25,代码来源:CommandRemoveStage.java

示例5: execute

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void execute (MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {

    if (args.length == 2) {

        final EntityPlayer player = getPlayer(server, sender, args[0]);
        final String stageName = args[1];

        PlayerDataHandler.getStageData(player).unlockStage(stageName);

        if (player instanceof EntityPlayerMP) {
            GameStages.NETWORK.sendTo(new PacketStage(stageName, true), (EntityPlayerMP) player);
        }

        player.sendMessage(new TextComponentTranslation("commands.gamestage.add.target", stageName));

        if (player != sender) {
            sender.sendMessage(new TextComponentTranslation("commands.gamestage.add.sender", stageName, player.getDisplayNameString()));
        }
    }
    else {
        throw new WrongUsageException("commands.gamestage.add.usage", new Object[0]);
    }
}
 
开发者ID:Darkhax-Minecraft,项目名称:Game-Stages,代码行数:25,代码来源:CommandAddStage.java

示例6: execute

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (args.length != 4) throw new WrongUsageException("command.deliverAmazon.args");
    String varName = args[0].startsWith("#") ? args[0].substring(1) : args[0];
    BlockPos newPos = new BlockPos(parseInt(args[1]), parseInt(args[2]), parseInt(args[3]));
    GlobalVariableManager.getInstance().set(varName, newPos);
    sender.sendMessage(new TextComponentTranslation("command.setGlobalVariable.output", varName, newPos.getX(), newPos.getY(), newPos.getZ()));
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:9,代码来源:CommandSetGlobalVariable.java

示例7: listOptions

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
public void listOptions(ICommandSender sender) {
    for (Map.Entry<Integer, ActionOptions> entry : optionMap.entrySet()) {
        ActionOptions options = entry.getValue();
        Stage stage = options.getStage();
        MeeCreepActionType task = options.getTask();
        EntityMeeCreeps entity = findMeeCreep(sender.getEntityWorld(), entry.getKey());
        String name = entity == null ? "<none>" : entity.getUniqueID().toString();
        sender.sendMessage(new TextComponentString("Action " + entry.getKey() + ", Task " + task.getId() + ", Stage " + stage + ", Entity " + name));
    }
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:11,代码来源:ServerActionManager.java

示例8: execute

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length != 3 && args.length != 2)
    {
        throw new WrongUsageException(getUsage(sender));
    }
    String act = args[0];
    String res = args[1];
    String player = args.length > 2 ? args[2] : sender.getName();
    if (!Arrays.asList(server.getPlayerList().getOnlinePlayerNames()).contains(player))
    {
        throw new CommandException("command.pm_if.playerNotFound");
    }
    if (!(PurMag.INSTANCE.getIfRegistry().containsEntry(res) || res.equals("all")))
    {
        throw new CommandException("command.pm_if.entryNotFound");
    }

    EntityPlayerMP p = server.getPlayerList().getPlayerByUsername(player);
    IIfEntryStore store = p.getCapability(CapabilityRegistry.ENTRY_STORE_CAP, null);
    if(res.equals("all"))
    {
        for(IfEntry entr : PurMag.INSTANCE.getIfRegistry().entries)
        {
            setSteps(store, sender, act, entr.getId());
        }
    }
    else
    {
        setSteps(store, sender, act, res);
    }
    store.sync(p);
    sender.sendMessage(new TextComponentTranslation("command.pm_if.success." + act, "§5" + res, "§5" + player));
}
 
开发者ID:PearXTeam,项目名称:PurificatiMagicae,代码行数:36,代码来源:CommandIf.java

示例9: execute

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
	World world = sender.getEntityWorld();
	if (!world.isRemote)
	{

		if (args.length == 0)
		{
			for (Map.Entry<Integer, String> kvp : VillagerRegistryHelper.getProfessionIdsAndNamesSortedById())
			{
				sender.sendMessage(new TextComponentString(kvp.getKey() + ": " + kvp.getValue()));
			}
			return;
		}

		if (args.length == 2 && args[0].equals("profession"))
		{
			VillagerProfession profession = VillagerRegistryHelper.getProfession(args[1]);
			if (profession != null)
			{
				for (VillagerCareer career : new VTTVillagerProfession(profession).getCareers())
				{
					VTTVillagerCareer vttCareer = new VTTVillagerCareer(career);
					sender.sendMessage(new TextComponentString(vttCareer.getId() + ": " + vttCareer.getName()));
					sender.sendMessage(new TextComponentString("   " + vttCareer.getCareerLevels() + " levels"));
				}
			}
		}

	}
}
 
开发者ID:crazysnailboy,项目名称:VillagerTrades,代码行数:33,代码来源:ModCommand.java

示例10: execute

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void execute (MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {

    if (args.length == 1) {

        final EntityPlayer player = getPlayer(server, sender, args[0]);
        final IStageData stageInfo = PlayerDataHandler.getStageData(player);
        final int stageCount = stageInfo.getUnlockedStages().size();

        for (final String stage : stageInfo.getUnlockedStages()) {
            if (player instanceof EntityPlayerMP) {
                GameStages.NETWORK.sendTo(new PacketStage(stage, false), (EntityPlayerMP) player);
            }
        }

        stageInfo.clear();

        player.sendMessage(new TextComponentTranslation("commands.gamestage.clear.target", stageCount));

        if (player != sender) {
            sender.sendMessage(new TextComponentTranslation("commands.gamestage.clear.sender", stageCount, player.getDisplayNameString()));
        }
    }
    else {
        throw new WrongUsageException("commands.gamestage.clear.usage", new Object[0]);
    }
}
 
开发者ID:Darkhax-Minecraft,项目名称:Game-Stages,代码行数:28,代码来源:CommandStageClear.java

示例11: execute

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
	if (args.length == 0 || args.length > 1)
	{
		throw new WrongUsageException(getUsage(sender));
	}

	String code = args[0];
	if (code.equalsIgnoreCase(SMELTER))
	{
		SmelterConfig.INSTANCE.generateAutoConfig();
		BBConfigFolderLoader.saveAutoJson(SmelterConfig.INSTANCE);
	}
	else if (code.equalsIgnoreCase(BRICKOVEN))
	{
		BrickOvenConfig.INSTANCE.generateAutoConfig();
		BBConfigFolderLoader.saveAutoJson(BrickOvenConfig.INSTANCE);
	}
	else if (code.equalsIgnoreCase(KILN))
	{
		SmelterConfig.INSTANCE.generateAffectedInputs();
		BrickOvenConfig.INSTANCE.generateAffectedOutputs();

		KilnConfig.INSTANCE.generateAutoConfig();
		BBConfigFolderLoader.saveAutoJson(KilnConfig.INSTANCE);
	}
	else
	{
		throw new WrongUsageException(getUsage(sender));
	}

	sender.sendMessage(new TextComponentTranslation("command.jsongen.complete"));
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:35,代码来源:JsonGenerateCommand.java

示例12: execute

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (args.length < 2) throw new WrongUsageException("command.deliverAmazon.args");
    int x, y, z;
    int curArg;
    String regex = "-?\\d+";
    if (args[0].matches(regex)) {
        if (args.length < 4) throw new WrongUsageException("command.deliverAmazon.args");
        if (!args[1].matches(regex) || !args[2].matches(regex))
            throw new WrongUsageException("command.deliverAmazon.coords");
        x = Integer.parseInt(args[0]);
        y = Integer.parseInt(args[1]);
        z = Integer.parseInt(args[2]);
        curArg = 3;
    } else {
        EntityPlayerMP player = server.getPlayerList().getPlayerByUsername(args[0]);
        if (player != null) {
            x = (int) Math.floor(player.posX);
            y = (int) Math.floor(player.posY) + 1;
            z = (int) Math.floor(player.posZ);
            curArg = 1;
        } else {
            throw new WrongUsageException("command.deliverAmazon.playerName");
        }
    }

    // FIXME use IItemHandler
    if (args.length < curArg + 3) throw new WrongUsageException("command.deliverAmazon.args");
    if (!args[curArg].matches(regex) || !args[curArg + 1].matches(regex) || !args[curArg + 2].matches(regex))
        throw new WrongUsageException("command.deliverAmazon.coords");
    TileEntity te = sender.getEntityWorld().getTileEntity(new BlockPos(Integer.parseInt(args[curArg]), Integer.parseInt(args[curArg + 1]), Integer.parseInt(args[curArg + 2])));
    IItemHandler inv = IOHelper.getInventoryForTE(te);
    if (inv != null) {
        List<ItemStack> deliveredStacks = new ArrayList<ItemStack>();
        for (int i = 0; i < inv.getSlots() && deliveredStacks.size() < 65; i++) {
            if (!inv.getStackInSlot(i).isEmpty()) deliveredStacks.add(inv.getStackInSlot(i));
        }
        if (deliveredStacks.size() > 0) {
            PneumaticRegistry.getInstance().getDroneRegistry().deliverItemsAmazonStyle(sender.getEntityWorld(), new BlockPos(x, y, z), deliveredStacks.toArray(new ItemStack[deliveredStacks.size()]));
            sender.sendMessage(new TextComponentString("command.deliverAmazon.success"));
        } else {
            sender.sendMessage(new TextComponentString("command.deliverAmazon.noItems"));
        }
    } else {
        throw new WrongUsageException("command.deliverAmazon.noInventory");
    }

}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:49,代码来源:CommandAmazonDelivery.java

示例13: execute

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 1)
    {
        throw new WrongUsageException("creeperhostserver.commands.invite.usage", new Object[0]);
    }
    else
    {
        if ("list".equals(args[0]))
        {
            sender.sendMessage(new TextComponentTranslation("creeperhostserver.commands.invite.list", new Object[]{server.getPlayerList().getWhitelistedPlayerNames().length, server.getPlayerList().getAvailablePlayerDat().length}));
            String[] astring = server.getPlayerList().getWhitelistedPlayerNames();
            sender.sendMessage(new TextComponentString(joinNiceString(astring)));
        }
        else if ("add".equals(args[0]))
        {
            if (args.length < 2)
            {
                throw new WrongUsageException("creeperhostserver.commands.invite.add.usage", new Object[0]);
            }

            GameProfile gameprofile = server.getPlayerProfileCache().getGameProfileForUsername(args[1]);

            if (gameprofile == null)
            {
                throw new CommandException("creeperhostserver.commands.invite.add.failed", new Object[]{args[1]});
            }

            server.getPlayerList().addWhitelistedPlayer(gameprofile);
            inviteUser(gameprofile);
            notifyCommandListener(sender, this, "creeperhostserver.commands.invite.add.success", new Object[]{args[1]});
        }
        else if ("remove".equals(args[0]))
        {
            if (args.length < 2)
            {
                throw new WrongUsageException("creeperhostserver.commands.invite.remove.usage", new Object[0]);
            }

            GameProfile gameprofile1 = server.getPlayerList().getWhitelistedPlayers().getByName(args[1]);

            if (gameprofile1 == null)
            {
                throw new CommandException("creeperhostserver.commands.invite.remove.failed", new Object[]{args[1]});
            }

            server.getPlayerList().removePlayerFromWhitelist(gameprofile1);
            removeUser(gameprofile1);
            notifyCommandListener(sender, this, "creeperhostserver.commands.invite.remove.success", new Object[]{args[1]});
        }
        else if ("reload".equals(args[0]))
        {
            String[] prevNames = server.getPlayerList().getWhitelistedPlayerNames();
            server.getPlayerList().reloadWhitelist();
            reloadInvites(prevNames);
            notifyCommandListener(sender, this, "creeperhostserver.commands.invite.reloaded", new Object[0]);
        }
        else
        {
            throw new WrongUsageException("creeperhostserver.commands.invite.usage", new Object[0]);
        }
    }
}
 
开发者ID:CreeperHost,项目名称:CreeperHostGui,代码行数:65,代码来源:CommandInvite.java

示例14: showMessage

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
private void showMessage(String message, ICommandSender sender) {
  sender.sendMessage(new TextComponentString(message));
}
 
开发者ID:youtube,项目名称:youtube-chat-for-minecraft,代码行数:4,代码来源:YouTubeCommand.java

示例15: execute

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	if (args.length == 0 || args.length > 1) {
		throw new WrongUsageException("<Owner>");
	}
	
	ForgePlayer forgePlayer = Universe.get().getPlayer(args[0]);
	
	if (forgePlayer == null) {
		throw new CommandException(String.format("There is no player called %s that has been on this server", args[0]));
	}
	
	ForgeTeam team = forgePlayer.getTeam();
	
	if (team == null) {
		throw new CommandException(String.format("Player %s is not in a team", forgePlayer.getName()));
	}
	
	Set<ClaimedChunk> teamClaimedChunks = ClaimedChunks.get().getTeamChunks(team);
	
	if (teamClaimedChunks.isEmpty()) {
		throw new CommandException(String.format("team %s has not claimed any chunks", team.getName()));
	}
	
	ArrayList<PlayerInChunk> playersInChunks = new ArrayList<PlayerInChunk>();
	for (ClaimedChunk claimedChunk : teamClaimedChunks) {
		ChunkDimPos dimPos = claimedChunk.getPos();
		WorldServer world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(dimPos.dim);
		Chunk chunk = world.getChunkFromChunkCoords(dimPos.posX, dimPos.posZ);
		ChunkListOfPlayers chunkListOfPlayers = AllChunks.getChunk(chunk);
		if (chunkListOfPlayers == null) {
			continue;
		}
		
		playersInChunks.addAll(chunkListOfPlayers.playersInChunk);
	}
	
	Collections.sort(playersInChunks, new PlayersInChunkListComparator());
	for (PlayerInChunk player : playersInChunks) {
		String playerName = server.getPlayerProfileCache().getProfileByUUID(player.getPlayer()).getName();
		String enterTime = player.getEnterTimeCalendar().format(DateTimeFormatter.ofPattern("u/M/d H:m:s"));
		if (player.hasLeft()) {
			String leaveTime = player.getLeaveTimeCalendar().format(DateTimeFormatter.ofPattern("u/M/d H:m:s"));
			Duration stayTime = player.getStayTime();
			Long years = stayTime.toDays() / 365L;
			Long months = stayTime.toDays() / 30L;
			Long days = stayTime.toDays();
			Long hours = stayTime.toHours();
			Long minutes = stayTime.toMinutes();
			Long seconds = stayTime.getSeconds();
			if (months > 11) {
				months = months - (years * 12);
			}
			if (days > 29) {
				days = days - (days / 30 * 30);
			}
			if (hours > 23) {
				hours = hours - (hours / 24 * 24);
			}
			if (minutes > 59) {
				minutes = minutes - (minutes / 60 * 60);
			}
			if (seconds > 59) {
				seconds = seconds - (seconds / 60 * 60);
			}
			sender.sendMessage(new TextComponentString(String.format("Player %s was in one of the chunks from %s to %s for %s years and %s months and %s days and %s hours and %s minutes and %s seconds.", playerName, enterTime, leaveTime, years, months, days, hours, minutes, seconds)));
		} else {
			sender.sendMessage(new TextComponentString(String.format("Player %s was in one of the chunks from %s and has not left yet", playerName, enterTime)));
		}
	}
}
 
开发者ID:coehlrich,项目名称:chunk-logger,代码行数:72,代码来源:GetPlayersInClaimedChunks.java


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