feat: error handling on invalid skin/name

This commit is contained in:
ineanto 2023-12-22 15:01:30 +01:00
parent 30803363ba
commit 3377dcf2bf
2 changed files with 7 additions and 2 deletions

View file

@ -114,15 +114,22 @@ public class AppearanceManager {
properties.get("textures").clear();
properties.put("textures", new WrappedSignedProperty("textures", skinResult.value(), skinResult.signature()));
} else {
profile.setSkin(null);
dataStore.updateCache(player.getUniqueId(), profile);
return ActionResult.error(I18NDict.Error.MOJANG_SKIN);
}
} else {
profile.setName(null);
dataStore.updateCache(player.getUniqueId(), profile);
return ActionResult.error(I18NDict.Error.MOJANG_NAME);
}
return ActionResult.ok();
} catch (ExecutionException e) {
return ActionResult.error(I18NDict.Error.CACHE);
} catch (IOException e) {
profile.setName(null);
profile.setSkin(null);
dataStore.updateCache(player.getUniqueId(), profile);
return ActionResult.error(I18NDict.Error.MOJANG_NAME);
}
}

View file

@ -1,6 +1,5 @@
package xyz.ineanto.nicko.event;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -41,7 +40,6 @@ public class PlayerJoinListener implements Listener {
optionalProfile.ifPresent(profile -> {
// Random Skin on connection feature
if (profile.isRandomSkin()) {
Bukkit.broadcast(Component.text("§c[ELITE DEBUG] §fJoined with Random Skin."));
final String name = instance.getNameFetcher().getRandomUsername();
final String skin = instance.getNameFetcher().getRandomUsername();
profile.setName(name);