feat: revert either impl

This commit is contained in:
aroooo 2022-11-02 11:45:53 +01:00
parent 6314fe81b6
commit a1a0b04471
9 changed files with 47 additions and 63 deletions

View file

@ -3,10 +3,8 @@ package net.artelnatif.nicko.impl;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap;
import io.vavr.control.Either;
import net.artelnatif.nicko.NickoBukkit;
import net.artelnatif.nicko.disguise.NickoProfile;
import net.artelnatif.nicko.i18n.I18NDict;
import net.artelnatif.nicko.mojang.MojangSkin;
import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.network.protocol.game.*;
@ -84,7 +82,7 @@ public class v1_18_R1 implements Internals {
}
@Override
public Either<String, Void> updateProfile(Player player, NickoProfile profile, boolean skinChange) {
public void updateProfile(Player player, NickoProfile profile, boolean skinChange) {
final CraftPlayer craftPlayer = (CraftPlayer) player;
final EntityPlayer entityPlayer = craftPlayer.getHandle();
Optional<MojangSkin> skin;
@ -104,17 +102,14 @@ public class v1_18_R1 implements Internals {
final PropertyMap properties = gameProfile.getProperties();
properties.put("textures", new Property("textures", skin.get().value(), skin.get().signature()));
updateSelf(player);
return Either.right(null);
} else {
return Either.left(I18NDict.Error.SKIN_FAIL_MOJANG.getKey());
return;
}
} else {
return Either.left(I18NDict.Error.NAME_FAIL_MOJANG.getKey());
return;
}
} catch (IOException e) {
return Either.left(I18NDict.Error.UNEXPECTED_ERROR.getKey());
} catch (ExecutionException e) {
return Either.left(I18NDict.Error.SKIN_FAIL_CACHE.getKey());
} catch (IOException | ExecutionException e) {
return;
}
}
@ -130,6 +125,5 @@ public class v1_18_R1 implements Internals {
onlineEntityPlayer.b.a(add);
});
updateOthers(player);
return Either.right(null);
}
}