mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-20 23:21:24 +01:00
Support for tablist in FakePlayerOption
This commit is contained in:
parent
9fc8012d9d
commit
85aad4f044
@ -4,6 +4,7 @@ import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.player.PlayerLoginEvent;
|
||||
import net.minestom.server.network.player.FakePlayerConnection;
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
import net.minestom.server.timer.TaskRunnable;
|
||||
import net.minestom.server.utils.time.TimeUnit;
|
||||
import net.minestom.server.utils.time.UpdateOption;
|
||||
@ -76,4 +77,19 @@ public class FakePlayer extends Player {
|
||||
public FakePlayerController getController() {
|
||||
return fakePlayerController;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showPlayer(PlayerConnection connection) {
|
||||
super.showPlayer(connection);
|
||||
if (!option.isInTabList()) {
|
||||
// Remove from tab-list
|
||||
MinecraftServer.getSchedulerManager().addDelayedTask(new TaskRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
connection.sendPacket(getRemovePlayerToList());
|
||||
}
|
||||
}, new UpdateOption(20, TimeUnit.TICK));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import net.minestom.server.network.ConnectionManager;
|
||||
public class FakePlayerOption {
|
||||
|
||||
private boolean registered = false;
|
||||
private boolean inTabList = true;
|
||||
private boolean inTabList = false;
|
||||
|
||||
/**
|
||||
* Get if the player is registered internally as a Player
|
||||
@ -44,7 +44,6 @@ public class FakePlayerOption {
|
||||
* @param inTabList should the player be in the tab-list
|
||||
*/
|
||||
public void setInTabList(boolean inTabList) {
|
||||
throw new UnsupportedOperationException("Tablist option doesn't work (yet?), need to find how to do it");
|
||||
//this.inTabList = inTabList;
|
||||
this.inTabList = inTabList;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user