Only remove the texture property from the player profile if forwardSkin is disabled

This commit is contained in:
juanmuscaria
2021-09-17 10:00:45 -03:00
parent 64fbbf759f
commit c458bd383a

View File

@ -42,8 +42,10 @@ import com.velocitypowered.api.event.player.ServerConnectedEvent;
import com.velocitypowered.api.proxy.InboundConnection;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.util.GameProfile;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@ -95,12 +97,20 @@ public class ConnectListener {
}
if (!plugin.getCore().getConfig().get("forwardSkin", true)) {
//FIXME: Do I need to remove *all* properties or only the skin related ones?
event.setGameProfile(event.getGameProfile().withProperties(new ArrayList<>()));
event.setGameProfile(event.getGameProfile().withProperties(removeSkin(event.getGameProfile().getProperties())));
}
}
}
private List<GameProfile.Property> removeSkin(List<GameProfile.Property> oldProperties) {
List<GameProfile.Property> newProperties = new ArrayList<>(oldProperties.size() - 1);
for (GameProfile.Property property : oldProperties) {
if (!property.getName().equals("textures"))
newProperties.add(property);
}
return newProperties;
}
@Subscribe
public void onServerConnected(ServerConnectedEvent serverConnectedEvent) {
Player player = serverConnectedEvent.getPlayer();