Support for tablist in FakePlayerOption

This commit is contained in:
Felix Cravic 2020-07-06 19:31:02 +02:00
parent 9fc8012d9d
commit 85aad4f044
2 changed files with 18 additions and 3 deletions

View File

@ -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));
}
}
}

View File

@ -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;
}
}