Java Code Examples for net.minecraft.entity.player.EntityPlayer.getName()

The following are Jave code examples for showing how to use getName() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Whoosh   File: ItemTransporter.java   View Source Code Vote up 6 votes
public static boolean canPlayerAccess(ItemStack stack, EntityPlayer player) {

        if (!SecurityHelper.isSecure(stack)) {
            return true;
        }
        String name = player.getName();
        ISecurable.AccessMode access = SecurityHelper.getAccess(stack);
        if (access.isPublic() || (CoreProps.enableOpSecureAccess && CoreUtils.isOp(name))) {
            return true;
        }
        GameProfile profile = SecurityHelper.getOwner(stack);
        UUID ownerID = profile.getId();
        if (SecurityHelper.isDefaultUUID(ownerID)) {
            return true;
        }
        UUID otherID = SecurityHelper.getID(player);
        return ownerID.equals(otherID) || access.isFriendsOnly() && RegistrySocial.playerHasAccess(name, profile);
    }
 
Example 2
Project: BaseClient   File: MiddleClickFriend.java   View Source Code Vote up 5 votes
@EventTarget
private void onMouseClick(MouseEvent event) {
    if (event.key == 2 && this.mc.objectMouseOver != null && this.mc.objectMouseOver.entityHit != null && this.mc.objectMouseOver.entityHit instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer)Minecraft.getMinecraft().objectMouseOver.entityHit;
        String name = player.getName();
        if (FriendManager.isFriend(name)) {
            FriendManager.removeFriend(name);
            ChatUtils.sendClientMessage("Removed: " + name);
        } else {
            FriendManager.addFriend(name, name);
            ChatUtils.sendClientMessage("Added: " + name);
        }
    }
}
 
Example 3
Project: pnc-repressurized   File: EntityDrone.java   View Source Code Vote up 4 votes
public EntityDrone(World world, EntityPlayer player) {
    this(world);
    playerUUID = player.getGameProfile().getId().toString();
    playerName = player.getName();
}
 
Example 4
Project: WirelessRedstone   File: WirelessPart.java   View Source Code Vote up 4 votes
public void setupPlacement(EntityPlayer player, int side) {
    setSide(side ^ 1);
    setRotation(Rotation.getSidedRotation(player, side) ^ 2);
    owner = player.getName();
}
 
Example 5
Project: DecompiledMinecraft   File: TileEntitySign.java   View Source Code Vote up 4 votes
public boolean executeCommand(final EntityPlayer playerIn)
{
    ICommandSender icommandsender = new ICommandSender()
    {
        public String getName()
        {
            return playerIn.getName();
        }
        public IChatComponent getDisplayName()
        {
            return playerIn.getDisplayName();
        }
        public void addChatMessage(IChatComponent component)
        {
        }
        public boolean canCommandSenderUseCommand(int permLevel, String commandName)
        {
            return permLevel <= 2;
        }
        public BlockPos getPosition()
        {
            return TileEntitySign.this.pos;
        }
        public Vec3 getPositionVector()
        {
            return new Vec3((double)TileEntitySign.this.pos.getX() + 0.5D, (double)TileEntitySign.this.pos.getY() + 0.5D, (double)TileEntitySign.this.pos.getZ() + 0.5D);
        }
        public World getEntityWorld()
        {
            return playerIn.getEntityWorld();
        }
        public Entity getCommandSenderEntity()
        {
            return playerIn;
        }
        public boolean sendCommandFeedback()
        {
            return false;
        }
        public void setCommandStat(CommandResultStats.Type type, int amount)
        {
            TileEntitySign.this.stats.func_179672_a(this, type, amount);
        }
    };

    for (int i = 0; i < this.signText.length; ++i)
    {
        ChatStyle chatstyle = this.signText[i] == null ? null : this.signText[i].getChatStyle();

        if (chatstyle != null && chatstyle.getChatClickEvent() != null)
        {
            ClickEvent clickevent = chatstyle.getChatClickEvent();

            if (clickevent.getAction() == ClickEvent.Action.RUN_COMMAND)
            {
                MinecraftServer.getServer().getCommandManager().executeCommand(icommandsender, clickevent.getValue());
            }
        }
    }

    return true;
}
 
Example 6
Project: DecompiledMinecraft   File: TileEntitySign.java   View Source Code Vote up 4 votes
public boolean executeCommand(final EntityPlayer playerIn)
{
    ICommandSender icommandsender = new ICommandSender()
    {
        public String getName()
        {
            return playerIn.getName();
        }
        public IChatComponent getDisplayName()
        {
            return playerIn.getDisplayName();
        }
        public void addChatMessage(IChatComponent component)
        {
        }
        public boolean canCommandSenderUseCommand(int permLevel, String commandName)
        {
            return permLevel <= 2;
        }
        public BlockPos getPosition()
        {
            return TileEntitySign.this.pos;
        }
        public Vec3 getPositionVector()
        {
            return new Vec3((double)TileEntitySign.this.pos.getX() + 0.5D, (double)TileEntitySign.this.pos.getY() + 0.5D, (double)TileEntitySign.this.pos.getZ() + 0.5D);
        }
        public World getEntityWorld()
        {
            return playerIn.getEntityWorld();
        }
        public Entity getCommandSenderEntity()
        {
            return playerIn;
        }
        public boolean sendCommandFeedback()
        {
            return false;
        }
        public void setCommandStat(CommandResultStats.Type type, int amount)
        {
            TileEntitySign.this.stats.func_179672_a(this, type, amount);
        }
    };

    for (int i = 0; i < this.signText.length; ++i)
    {
        ChatStyle chatstyle = this.signText[i] == null ? null : this.signText[i].getChatStyle();

        if (chatstyle != null && chatstyle.getChatClickEvent() != null)
        {
            ClickEvent clickevent = chatstyle.getChatClickEvent();

            if (clickevent.getAction() == ClickEvent.Action.RUN_COMMAND)
            {
                MinecraftServer.getServer().getCommandManager().executeCommand(icommandsender, clickevent.getValue());
            }
        }
    }

    return true;
}
 
Example 7
Project: WirelessCharger   File: TilePersonalCharger.java   View Source Code Vote up 4 votes
public void setPlayer(EntityPlayer player) {
        playerUUID = player.getUniqueID();
        playerName = player.getName();
//        playerProfile = updateGameprofile(player.getGameProfile());
    }
 
Example 8
Project: BaseClient   File: TileEntitySign.java   View Source Code Vote up 4 votes
public boolean executeCommand(final EntityPlayer playerIn)
{
    ICommandSender icommandsender = new ICommandSender()
    {
        public String getName()
        {
            return playerIn.getName();
        }
        public IChatComponent getDisplayName()
        {
            return playerIn.getDisplayName();
        }
        public void addChatMessage(IChatComponent component)
        {
        }
        public boolean canCommandSenderUseCommand(int permLevel, String commandName)
        {
            return permLevel <= 2;
        }
        public BlockPos getPosition()
        {
            return TileEntitySign.this.pos;
        }
        public Vec3 getPositionVector()
        {
            return new Vec3((double)TileEntitySign.this.pos.getX() + 0.5D, (double)TileEntitySign.this.pos.getY() + 0.5D, (double)TileEntitySign.this.pos.getZ() + 0.5D);
        }
        public World getEntityWorld()
        {
            return playerIn.getEntityWorld();
        }
        public Entity getCommandSenderEntity()
        {
            return playerIn;
        }
        public boolean sendCommandFeedback()
        {
            return false;
        }
        public void setCommandStat(CommandResultStats.Type type, int amount)
        {
            TileEntitySign.this.stats.func_179672_a(this, type, amount);
        }
    };

    for (int i = 0; i < this.signText.length; ++i)
    {
        ChatStyle chatstyle = this.signText[i] == null ? null : this.signText[i].getChatStyle();

        if (chatstyle != null && chatstyle.getChatClickEvent() != null)
        {
            ClickEvent clickevent = chatstyle.getChatClickEvent();

            if (clickevent.getAction() == ClickEvent.Action.RUN_COMMAND)
            {
                MinecraftServer.getServer().getCommandManager().executeCommand(icommandsender, clickevent.getValue());
            }
        }
    }

    return true;
}
 
Example 9
Project: BaseClient   File: TileEntitySign.java   View Source Code Vote up 4 votes
public boolean executeCommand(final EntityPlayer playerIn)
{
    ICommandSender icommandsender = new ICommandSender()
    {
        public String getName()
        {
            return playerIn.getName();
        }
        public IChatComponent getDisplayName()
        {
            return playerIn.getDisplayName();
        }
        public void addChatMessage(IChatComponent component)
        {
        }
        public boolean canCommandSenderUseCommand(int permLevel, String commandName)
        {
            return permLevel <= 2;
        }
        public BlockPos getPosition()
        {
            return TileEntitySign.this.pos;
        }
        public Vec3 getPositionVector()
        {
            return new Vec3((double)TileEntitySign.this.pos.getX() + 0.5D, (double)TileEntitySign.this.pos.getY() + 0.5D, (double)TileEntitySign.this.pos.getZ() + 0.5D);
        }
        public World getEntityWorld()
        {
            return playerIn.getEntityWorld();
        }
        public Entity getCommandSenderEntity()
        {
            return playerIn;
        }
        public boolean sendCommandFeedback()
        {
            return false;
        }
        public void setCommandStat(CommandResultStats.Type type, int amount)
        {
            TileEntitySign.this.stats.func_179672_a(this, type, amount);
        }
    };

    for (int i = 0; i < this.signText.length; ++i)
    {
        ChatStyle chatstyle = this.signText[i] == null ? null : this.signText[i].getChatStyle();

        if (chatstyle != null && chatstyle.getChatClickEvent() != null)
        {
            ClickEvent clickevent = chatstyle.getChatClickEvent();

            if (clickevent.getAction() == ClickEvent.Action.RUN_COMMAND)
            {
                MinecraftServer.getServer().getCommandManager().executeCommand(icommandsender, clickevent.getValue());
            }
        }
    }

    return true;
}
 
Example 10
Project: Zombe-Modpack   File: ZWrapper.java   View Source Code Vote up 4 votes
public static String getPlayerName(EntityPlayer ent) {
    //return ent.username;
    return ent.getName();
}
 
Example 11
Project: Backmemed   File: TileEntitySign.java   View Source Code Vote up 4 votes
public boolean executeCommand(final EntityPlayer playerIn)
{
    ICommandSender icommandsender = new ICommandSender()
    {
        public String getName()
        {
            return playerIn.getName();
        }
        public ITextComponent getDisplayName()
        {
            return playerIn.getDisplayName();
        }
        public void addChatMessage(ITextComponent component)
        {
        }
        public boolean canCommandSenderUseCommand(int permLevel, String commandName)
        {
            return permLevel <= 2;
        }
        public BlockPos getPosition()
        {
            return TileEntitySign.this.pos;
        }
        public Vec3d getPositionVector()
        {
            return new Vec3d((double)TileEntitySign.this.pos.getX() + 0.5D, (double)TileEntitySign.this.pos.getY() + 0.5D, (double)TileEntitySign.this.pos.getZ() + 0.5D);
        }
        public World getEntityWorld()
        {
            return playerIn.getEntityWorld();
        }
        public Entity getCommandSenderEntity()
        {
            return playerIn;
        }
        public boolean sendCommandFeedback()
        {
            return false;
        }
        public void setCommandStat(CommandResultStats.Type type, int amount)
        {
            if (TileEntitySign.this.world != null && !TileEntitySign.this.world.isRemote)
            {
                TileEntitySign.this.stats.setCommandStatForSender(TileEntitySign.this.world.getMinecraftServer(), this, type, amount);
            }
        }
        public MinecraftServer getServer()
        {
            return playerIn.getServer();
        }
    };

    for (ITextComponent itextcomponent : this.signText)
    {
        Style style = itextcomponent == null ? null : itextcomponent.getStyle();

        if (style != null && style.getClickEvent() != null)
        {
            ClickEvent clickevent = style.getClickEvent();

            if (clickevent.getAction() == ClickEvent.Action.RUN_COMMAND)
            {
                playerIn.getServer().getCommandManager().executeCommand(icommandsender, clickevent.getValue());
            }
        }
    }

    return true;
}
 
Example 12
Project: minecraft-territorialdealings   File: TerritoryHandler.java   View Source Code Vote up 4 votes
private static void addFaction(EntityPlayer player, Chunk chunk)
{
	_Territory territory  = new _Territory(player.worldObj.provider.getDimension(), player.getName() + "'s Group");

	Main.console("[TERRITORY HANDLER] Added a new faction in dimension " + territory.getDimensionID() +
			". Core chunk pos: X " + chunk.xPosition + " / Z " + chunk.zPosition);

	territory.addMember(player);	// Adding them to the faction
	territory.setLeader(player);	// And then declaring them leader

	territory.addChunk(chunk);		// Adding the core chunk first
	territory.setUpkeepPaid(true);	// Starting out paid

	factions.add(territory);	// And making that known

	// SFX
	Main.startFireworks(player);

	Main.sendMessageToPlayer(player, "New faction successfully founded and territory claimed! Faction name: " + territory.getFactionName());

	SaveHandler.saveFactionsToFile();	// Saving, just to make sure
}
 
Example 13
Project: minecraft-territorialdealings   File: TerritoryHandler.java   View Source Code Vote up 4 votes
public static _FactionSaveData startFactionInChunk(World world, EntityPlayer player, Chunk chunk) 
{
	// Safeties
	if (player == null) { return null; }	// Who're you?
	if (world == null) { return null; }		// Where are you?
	if (chunk == null) { return null; }		// What're you trying to do?
	
	UUID playerID = getIDFromPlayer(player);
	
	Main.console("Starting a new faction for player " + player.getName() + " (ID " + playerID + ")...");
	
	// Step 1, create the faction
	_FactionSaveData faction = new _FactionSaveData(UUID.randomUUID(), world.provider.getDimension(), player.getName() + "'s faction");
	
	// Step 1.1, claiming the first chunk
	faction.addChunk(chunk.getChunkCoordIntPair());
	
	// Step 2, add the player both as member and leader
	_PlayerSaveData playerData;
	
	if (saveData.getPlayerMap().containsKey(playerID))
	{
		// Is already known, so we can use their profile
		Main.console("...player is known, using their profile...");
		
		playerData = saveData.getPlayerMap().get(playerID);
	}
	else
	{
		// Is not yet known, so adding them now
		Main.console("...player is not known, making a new profile...");
		
		playerData = new _PlayerSaveData(playerID);
		saveData.getPlayerMap().put(playerID, playerData);
	}
	
	Main.console("...adding player as member and leader...");

	ArrayList<UUID> memberships = playerData.getMemberList();	// Get...
	memberships.add(faction.getID());							// ..set...
	playerData.setMemberList(memberships);						// ...return
	
	playerData.setLeadership(faction.getID());					// You're the leader now.
	
	
	// Step 3, make the faction known
	saveData.getFactionMap().put(faction.getID(), faction);
	
	Main.console("...done.");
	
	// Step 4, handing the new faction back
	return faction;
}