Player's tablist and player's name?

Hello, i want to change the name of the player when he joins a game…
(exemple: i want a player named Marc with color red)
i want if it’s possible to change the name over the player, and the tablist…
i saw an server did it…

thx :wink:

I believe DisplayNameData should do what you need. I’m unsure whether that effects the Scoreboards, but it should at least get you started.

displaynamedata is correct i think, but i need the Key…
the optionss is if i want to desactivate the pseudo, but i need the pseudo…
or if i want to set, but i don’t know the key… how can i get the list of keys?

and for tablist, i saw i can remove a player, and add, but i don’t know how can i go inside the tablist

All Keys used in Sponge are listed as constants in the Keys Utility Class.

okay, i’m very bad for this… i can’t initialise the key…
how can i do it?
player.getDisplayNameData().set(Key<Value> DISPLAY_NAME, Texts.builder(“test”).build());

the underlines words is Key, Value and Text

and any idea for call the TabList?

This should do it

player.offer(Keys.DISPLAY_NAME, Texts.of("test"));

yes, thx…

but it’s not change the name over the player

if you know how do this?

You can’t change that name unfortunately. It’s the name of the player’s GameProfile which is read-only.

i see a server do it… not with sponge, but they did it in 1.8… but it’s not important
how can i hide it?

and i find player.getTabList().x
but when i want to change the header, i have an error

[16:40:17] [Server thread/ERROR] [Sponge]: Could not pass PlayerLoggedInEvent to
java.lang.AbstractMethodError: net.minecraft.entity.player.EntityPlayerMP.getTab
at myplug.Main.onPlayerJoin( ~[Main.class:?]
at org.spongepowered.common.event.listener.JoinListener_Main_onPlayerJoin3.handle(Unknown Source) ~[?:?]
at org.spongepowered.common.event.RegisteredListener.handle( ~[RegisteredListener.class:1.8-1515-2.1DEV-671+spongeproject-ci-b671.git-a049f89be800ef2d9e04ad93e619c8e9b5d0c580]
at [SpongeModEventManager.class:1.8-1515-2.1DEV-671+spongeproject-ci-b671.git-a049f89be800ef2d9e04ad93e619c8e9b5d0c580]
at [SpongeModEventManager.class:1.8-1515-2.1DEV-671+spongeproject-ci-b671.git-a049f89be800ef2d9e04ad93e619c8e9b5d0c580]
at [sn.class:?]
at [NetworkDispatcher.class:?]
at$100( [NetworkDispatcher.class:?]
at$1.func_73660_a( [NetworkDispatcher$1.class:?]
at [gr.class:?]
at [rc.class:?]
at net.minecraft.server.MinecraftServer.func_71190_q( [MinecraftServer.class:?]
at net.minecraft.server.dedicated.DedicatedServer.func_71190_q( [po.class:?]
at net.minecraft.server.MinecraftServer.func_71217_p( [MinecraftServer.class:?]
at [MinecraftServer.class:?]
at Source) [?:1.8.0_60]

AbstractMethodErrors occur when a method is called that hasn’t been implemented.

public abstract class MyAbstractClass {
    public abstract void doSomething();

public class MyNonAbstractClass extends MyAbstractClass {
    @Override public void doSomething();

Essentially, MyNonAbstractClass#doSomething() is the implementation of MyAbstractClass#doSomething().

When the abstract class is called, and there’s no implementation, you get that error, because it doesn’t “exist” in any form besides to point to its extending classes.

TL;DR - What you’re trying to do hasn’t been implemented, yet.

I think that the best way I’ve heard this explained is such:

An interface is a pointer class. It relies on implementation to actually “do” anything.
An abstract class is an interface, but with actual functionality. However, the abstract methods still require implementation.
A “normal” class is an interface and implementation rolled into one.

1 Like

thx i understand the difference, i have to create a class named “MynonAbstractClass” with extends TabList
and i create do my actions there?

No. I wasn’t telling you to do anything. I was trying to say that the implementation for the API hasn’t been completed. You’ll need to wait until it is.

1 Like