feat: error handling on invalid skin/name
This commit is contained in:
parent
30803363ba
commit
3377dcf2bf
2 changed files with 7 additions and 2 deletions
|
@ -114,15 +114,22 @@ public class AppearanceManager {
|
||||||
properties.get("textures").clear();
|
properties.get("textures").clear();
|
||||||
properties.put("textures", new WrappedSignedProperty("textures", skinResult.value(), skinResult.signature()));
|
properties.put("textures", new WrappedSignedProperty("textures", skinResult.value(), skinResult.signature()));
|
||||||
} else {
|
} else {
|
||||||
|
profile.setSkin(null);
|
||||||
|
dataStore.updateCache(player.getUniqueId(), profile);
|
||||||
return ActionResult.error(I18NDict.Error.MOJANG_SKIN);
|
return ActionResult.error(I18NDict.Error.MOJANG_SKIN);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
profile.setName(null);
|
||||||
|
dataStore.updateCache(player.getUniqueId(), profile);
|
||||||
return ActionResult.error(I18NDict.Error.MOJANG_NAME);
|
return ActionResult.error(I18NDict.Error.MOJANG_NAME);
|
||||||
}
|
}
|
||||||
return ActionResult.ok();
|
return ActionResult.ok();
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
return ActionResult.error(I18NDict.Error.CACHE);
|
return ActionResult.error(I18NDict.Error.CACHE);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
profile.setName(null);
|
||||||
|
profile.setSkin(null);
|
||||||
|
dataStore.updateCache(player.getUniqueId(), profile);
|
||||||
return ActionResult.error(I18NDict.Error.MOJANG_NAME);
|
return ActionResult.error(I18NDict.Error.MOJANG_NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package xyz.ineanto.nicko.event;
|
package xyz.ineanto.nicko.event;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -41,7 +40,6 @@ public class PlayerJoinListener implements Listener {
|
||||||
optionalProfile.ifPresent(profile -> {
|
optionalProfile.ifPresent(profile -> {
|
||||||
// Random Skin on connection feature
|
// Random Skin on connection feature
|
||||||
if (profile.isRandomSkin()) {
|
if (profile.isRandomSkin()) {
|
||||||
Bukkit.broadcast(Component.text("§c[ELITE DEBUG] §fJoined with Random Skin."));
|
|
||||||
final String name = instance.getNameFetcher().getRandomUsername();
|
final String name = instance.getNameFetcher().getRandomUsername();
|
||||||
final String skin = instance.getNameFetcher().getRandomUsername();
|
final String skin = instance.getNameFetcher().getRandomUsername();
|
||||||
profile.setName(name);
|
profile.setName(name);
|
||||||
|
|
Loading…
Add table
Reference in a new issue