Re-added PlayerEvent.NameFormat (#6992)

This commit is contained in:
Tschipp authored and GitHub committed 2020-07-27 14:16:35 -07:00
1 parent 27798c5804
commit 941b9a1d1f
5 files changed
+44 -11

No files matched your search

@@ -245,7 +245,7 @@ public class ForgeEventFactory
return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.getMaxPackSize() : entity.getMaxSpawnedInChunk();
}
public static String getPlayerDisplayName(PlayerEntity player, String username)
public static ITextComponent getPlayerDisplayName(PlayerEntity player, ITextComponent username)
{
PlayerEvent.NameFormat event = new PlayerEvent.NameFormat(player, username);
MinecraftForge.EVENT_BUS.post(event);
@@ -33,6 +33,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.eventbus.api.Event;
@@ -152,26 +153,27 @@ public class PlayerEvent extends LivingEvent
**/
public static class NameFormat extends PlayerEvent
{
private final String username;
private String displayname;
private final ITextComponent username;
private ITextComponent displayname;
public NameFormat(PlayerEntity player, String username) {
public NameFormat(PlayerEntity player, ITextComponent username)
{
super(player);
this.username = username;
this.setDisplayname(username);
}
public String getUsername()
public ITextComponent getUsername()
{
return username;
}
public String getDisplayname()
public ITextComponent getDisplayname()
{
return displayname;
}
public void setDisplayname(String displayname)
public void setDisplayname(ITextComponent displayname)
{
this.displayname = displayname;
}