當前位置: 首頁>>代碼示例>>Java>>正文


Java CommandBase.getCommandSenderAsPlayer方法代碼示例

本文整理匯總了Java中net.minecraft.command.CommandBase.getCommandSenderAsPlayer方法的典型用法代碼示例。如果您正苦於以下問題:Java CommandBase.getCommandSenderAsPlayer方法的具體用法?Java CommandBase.getCommandSenderAsPlayer怎麽用?Java CommandBase.getCommandSenderAsPlayer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.command.CommandBase的用法示例。


在下文中一共展示了CommandBase.getCommandSenderAsPlayer方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import net.minecraft.command.CommandBase; //導入方法依賴的package包/類
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	EntityPlayerMP player = CommandBase.getCommandSenderAsPlayer(sender);
	
	if(args.length == 0) {
		throw new WrongUsageException("No parameters given!");
	}
	
	String newName = Strings.join(args, " ").trim();
	
	if(newName.isEmpty()) {
		return;
	}
	
	ItemStack itemStack = player.getHeldItemMainhand();
	
	if(itemStack != null) {
		itemStack.setStackDisplayName(newName);
	}
}
 
開發者ID:tiffit,項目名稱:TaleCraft,代碼行數:21,代碼來源:RenameCommand.java

示例2: processCommand

import net.minecraft.command.CommandBase; //導入方法依賴的package包/類
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
	if (args.length != 4 || (!("add").equals(args[1]) && !("set").equals(args[1])) || (!("current").equals(args[2]) && !("max").equals(args[2]))) {
		throw new WrongUsageException(getCommandUsage(sender));
	}
	EntityPlayerMP commandSender = CommandBase.getCommandSenderAsPlayer(sender);
	EntityPlayerMP player = CommandBase.getPlayer(sender, args[0]);
	ZSSPlayerInfo info = ZSSPlayerInfo.get(player);
	boolean max = ("max").equals(args[2]);
	boolean add = ("add").equals(args[1]);
	int mp = CommandBase.parseInt(args[3]);
	if (mp < 0 && !add) {
		throw new CommandException("commands.zssmagic.negative", args[2]);
	}
	if (add) {
		mp += (max ? info.getMaxMagic() : info.getCurrentMagic());
	}
	if (max) {
		info.setMaxMagic(mp);
		mp = Math.round(info.getMaxMagic());
	} else {
		info.setCurrentMagic(mp);
		mp = Math.round(info.getCurrentMagic());
	}
	PlayerUtils.sendTranslatedChat(commandSender, "commands.zssmagic.success", player.getName(), args[2], mp);
}
 
開發者ID:coolAlias,項目名稱:ZeldaSwordSkills,代碼行數:27,代碼來源:CommandSetMagic.java

示例3: onServerCommand

import net.minecraft.command.CommandBase; //導入方法依賴的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: pontuslevel

import net.minecraft.command.CommandBase; //導入方法依賴的package包/類
@HarshenCommand
public static void pontuslevel(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
	EntityPlayer player = args.length == 1 ? CommandBase.getCommandSenderAsPlayer(sender) : CommandBase.getPlayer(server, sender, args[0]);
	String rawInt = args[args.length == 1 ? 0 : 1];
	int i = CommandBase.parseInt(rawInt);
	player.getEntityData().setInteger("PontusBiomeLevel", i);
	HarshenNetwork.sendToPlayer(player, new MessagePacketPlayerHasAccess(player));
	HandlerPontusAllowed.setAllowed(player, i);
	message(sender, "success", player.getName(), i);
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:12,代碼來源:HarshenCastleCommands.java

示例5: onCommandSentEvent

import net.minecraft.command.CommandBase; //導入方法依賴的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

示例6: processCommand

import net.minecraft.command.CommandBase; //導入方法依賴的package包/類
@Override
public void processCommand(final ICommandSender sender, final String[] as) {

	final EntityPlayerMP player = CommandBase.getCommandSenderAsPlayer(sender);
	if (player != null) {

		if (as.length != 1) {
			player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED
					+ StatCollector.translateToLocal("msg.Pathways.TeleportCommandError.missingName")));
		} else {
			TargetManager.execute(player, as[0], false);
		}
	}
}
 
開發者ID:OreCruncher,項目名稱:Pathways,代碼行數:15,代碼來源:TeleportCommand.java

示例7: execute

import net.minecraft.command.CommandBase; //導入方法依賴的package包/類
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    EntityPlayer player = CommandBase.getCommandSenderAsPlayer(sender);

    if (!SoundEventListener.INSTANCE.isRecording(player))
    {
        SoundEventListener.INSTANCE.startRecording(player);

        sender.addChatMessage(new TextComponentString("Started recording sound events!"));
    }
    else
    {
        SoundSession session = SoundEventListener.INSTANCE.stopRecording(player);

        GsonBuilder builder = new GsonBuilder().setPrettyPrinting();
        Gson gson = builder.create();
        StringWriter writer = new StringWriter();
        JsonWriter jsonWriter = new JsonWriter(writer);

        jsonWriter.setIndent("    ");
        gson.toJson(session.sounds, List.class, jsonWriter);

        String output = writer.toString();
        String filename = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date()) + ".json";

        File target = new File(DimensionManager.getCurrentSaveRootDirectory(), "blockbuster/sounds/" + filename);

        target.getParentFile().mkdirs();

        try
        {
            Files.write(output, target, Charset.defaultCharset());

            sender.addChatMessage(new TextComponentString("Successfully recorded sound events in file " + filename + "!"));
        }
        catch (IOException e)
        {
            sender.addChatMessage(new TextComponentString("Sound events couldn't be recorded, because: " + e.getMessage()));

            e.printStackTrace();
        }
    }
}
 
開發者ID:mchorse,項目名稱:blockbuster,代碼行數:45,代碼來源:CommandRecordSound.java

示例8: canCommandSenderUseCommand

import net.minecraft.command.CommandBase; //導入方法依賴的package包/類
@Override
public boolean canCommandSenderUseCommand(final ICommandSender sender) {
	final EntityPlayerMP player = CommandBase.getCommandSenderAsPlayer(sender);
	return !ModOptions.getCommandTeleportOpOnly() || (player != null && player.capabilities.isCreativeMode); 
}
 
開發者ID:OreCruncher,項目名稱:Pathways,代碼行數:6,代碼來源:TeleportCommand.java

示例9: canCommandSenderUseCommand

import net.minecraft.command.CommandBase; //導入方法依賴的package包/類
@Override
public boolean canCommandSenderUseCommand(final ICommandSender sender) {
	final EntityPlayerMP player = CommandBase.getCommandSenderAsPlayer(sender);
	return !ModOptions.getCommandConfigureOpOnly() || (player != null && player.capabilities.isCreativeMode);
}
 
開發者ID:OreCruncher,項目名稱:Pathways,代碼行數:6,代碼來源:ConfigureCommand.java


注:本文中的net.minecraft.command.CommandBase.getCommandSenderAsPlayer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。