Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix skin not carrying over on profile change #354

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
package vg.civcraft.mc.namelayer.misc;

import com.destroystokyo.paper.profile.CraftPlayerProfile;
import java.util.logging.Logger;
import com.destroystokyo.paper.profile.PlayerProfile;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player;

import java.util.logging.Logger;

public class ProfileModifier implements ProfileInterface {

private static final Logger LOGGER = Logger.getLogger(ProfileModifier.class.getSimpleName());

@Override
public void setPlayerProfile(final Player player, final String name) {
final String oldName = player.getName();
PlayerProfile oldProfile = player.getPlayerProfile();
PlayerProfile newProfile = new CraftPlayerProfile(player.getUniqueId(), name);
if (name.length() > 16) {
LOGGER.info(String.format("The player %s (%s) was kicked from the server due to their "
+ "name already existing but now becoming over 16 characters.",
name, player.getUniqueId()));
}
player.setPlayerProfile(new CraftPlayerProfile(player.getUniqueId(), name));
newProfile.setProperties(oldProfile.getProperties());
player.setPlayerProfile(newProfile);
player.displayName(Component.text(name));
player.playerListName(Component.text(name));
player.customName(Component.text(name));
Expand Down