Java Code Examples for org.bukkit.entity.Player#setPlayerListName()

The following examples show how to use org.bukkit.entity.Player#setPlayerListName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Team.java    From BedwarsRel with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
public void removePlayer(Player player) {
  if (BedwarsRel.getInstance().isSpigot()) {
    if (this.getScoreboardTeam().hasEntry(player.getName())) {
      this.getScoreboardTeam().removeEntry(player.getName());
    }
  } else {
    if (this.getScoreboardTeam().hasPlayer(player)) {
      this.getScoreboardTeam().removePlayer(player);
    }
  }

  if (BedwarsRel.getInstance().getBooleanConfig("overwrite-names", false) && player.isOnline()) {
    player.setDisplayName(ChatColor.RESET + ChatColor.stripColor(player.getName()));
    player.setPlayerListName(ChatColor.RESET + player.getPlayer().getName());
  }
}
 
Example 2
Source File: Protocol_v1_7_R4.java    From StaffPlus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void listVanish(Player player, boolean shouldEnable)
{
	if(shouldEnable)
	{
		player.setPlayerListName("");
	}else player.setPlayerListName(player.getName());
}
 
Example 3
Source File: Protocol_v1_7_R3.java    From StaffPlus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void listVanish(Player player, boolean shouldEnable)
{
	if(shouldEnable)
	{
		player.setPlayerListName("");
	}else player.setPlayerListName(player.getName());
}
 
Example 4
Source File: Protocol_v1_7_R1.java    From StaffPlus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void listVanish(Player player, boolean shouldEnable)
{
	if(shouldEnable)
	{
		player.setPlayerListName("");
	}else player.setPlayerListName(player.getName());
}
 
Example 5
Source File: Protocol_v1_7_R2.java    From StaffPlus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void listVanish(Player player, boolean shouldEnable)
{
	if(shouldEnable)
	{
		player.setPlayerListName("");
	}else player.setPlayerListName(player.getName());
}
 
Example 6
Source File: RankModule.java    From CardinalPGM with MIT License 5 votes vote down vote up
@EventHandler
public void onPlayerNameUpdate(PlayerNameUpdateEvent event) {
    Player player = event.getPlayer();
    String prefix = Rank.getPrefix(player.getUniqueId());
    player.setDisplayName(prefix + Teams.getTeamColorByPlayer(player) + player.getName());
    if (GameHandler.getGameHandler().getMatch().getModules().getModule(TitleRespawn.class).isDeadUUID(event.getPlayer().getUniqueId())) {
        player.setPlayerListName(prefix + ChatColor.DARK_GRAY + player.getName());
    } else {
        player.setPlayerListName(prefix + Teams.getTeamColorByPlayer(player) + player.getName());
    }
}
 
Example 7
Source File: TagDataHandler.java    From TabooLib with MIT License 4 votes vote down vote up
private void updatePlayerListName(Player player) {
    TagPlayerData playerData = getPlayerDataComputeIfAbsent(player);
    player.setPlayerListName(!playerData.getNameDisplay().equals(player.getName()) ? playerData.getPrefix() + playerData.getNameDisplay() + playerData.getSuffix() : playerData.getNameDisplay());
}
 
Example 8
Source File: Team.java    From BedwarsRel with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
public boolean addPlayer(Player player) {

  BedwarsPlayerJoinTeamEvent playerJoinTeamEvent = new BedwarsPlayerJoinTeamEvent(this, player);
  BedwarsRel.getInstance().getServer().getPluginManager().callEvent(playerJoinTeamEvent);

  if (playerJoinTeamEvent.isCancelled()) {
    return false;
  }

  if (BedwarsRel.getInstance().isSpigot()) {
    if (this.getScoreboardTeam().getEntries().size() >= this.getMaxPlayers()) {
      return false;
    }
  } else {
    if (this.getScoreboardTeam().getPlayers().size() >= this.getMaxPlayers()) {
      return false;
    }
  }

  String displayName = player.getDisplayName();
  String playerListName = player.getPlayerListName();

  if (BedwarsRel.getInstance().getBooleanConfig("overwrite-names", false)) {
    displayName = this.getChatColor() + ChatColor.stripColor(player.getName());
    playerListName = this.getChatColor() + ChatColor.stripColor(player.getName());
  }

  if (BedwarsRel.getInstance().getBooleanConfig("teamname-on-tab", true)) {
    playerListName = this.getChatColor() + this.getName() + ChatColor.WHITE + " | "
        + this.getChatColor() + ChatColor.stripColor(player.getDisplayName());
  }

  BedwarsPlayerSetNameEvent playerSetNameEvent =
      new BedwarsPlayerSetNameEvent(this, displayName, playerListName, player);
  BedwarsRel.getInstance().getServer().getPluginManager().callEvent(playerSetNameEvent);

  if (!playerSetNameEvent.isCancelled()) {
    player.setDisplayName(playerSetNameEvent.getDisplayName());
    player.setPlayerListName(playerSetNameEvent.getPlayerListName());
  }

  if (BedwarsRel.getInstance().isSpigot()) {
    this.getScoreboardTeam().addEntry(player.getName());
  } else {
    this.getScoreboardTeam().addPlayer(player);
  }
  this.equipPlayerWithLeather(player);

  return true;
}