本文整理匯總了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);
}
}
示例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);
}
示例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
);
}
示例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);
}
示例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[] {});
}
}
}
}
}
示例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);
}
}
}
示例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();
}
}
}
示例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);
}
示例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);
}