diff --git a/nicko-core/src/main/java/net/artelnatif/nicko/disguise/AppearanceManager.java b/nicko-core/src/main/java/net/artelnatif/nicko/disguise/AppearanceManager.java index 5a6d197..654a906 100644 --- a/nicko-core/src/main/java/net/artelnatif/nicko/disguise/AppearanceManager.java +++ b/nicko-core/src/main/java/net/artelnatif/nicko/disguise/AppearanceManager.java @@ -1,6 +1,5 @@ package net.artelnatif.nicko.disguise; -import io.vavr.control.Either; import net.artelnatif.nicko.NickoBukkit; import net.artelnatif.nicko.storage.PlayerDataStore; import org.bukkit.Bukkit; @@ -66,7 +65,7 @@ public class AppearanceManager { updatePlayer(true); } - public Either updatePlayer(boolean skinChange) { - return NickoBukkit.getInstance().getInternals().updateProfile(player, profile, skinChange); + public void updatePlayer(boolean skinChange) { + NickoBukkit.getInstance().getInternals().updateProfile(player, profile, skinChange); } } diff --git a/nicko-core/src/main/java/net/artelnatif/nicko/event/PlayerJoinListener.java b/nicko-core/src/main/java/net/artelnatif/nicko/event/PlayerJoinListener.java index f16e646..71ff57d 100644 --- a/nicko-core/src/main/java/net/artelnatif/nicko/event/PlayerJoinListener.java +++ b/nicko-core/src/main/java/net/artelnatif/nicko/event/PlayerJoinListener.java @@ -2,8 +2,6 @@ package net.artelnatif.nicko.event; import net.artelnatif.nicko.NickoBukkit; import net.artelnatif.nicko.disguise.AppearanceManager; -import net.artelnatif.nicko.i18n.I18N; -import net.artelnatif.nicko.i18n.I18NDict; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -19,9 +17,7 @@ public class PlayerJoinListener implements Listener { if (appearanceManager.hasData()) { final boolean skinChange = !player.getName().equals(appearanceManager.getSkin()); - appearanceManager.updatePlayer(skinChange) - .peek(unused -> player.sendMessage(I18N.translate(player, I18NDict.Event.PREVIOUS_SKIN_APPLIED.getKey()))) - .peekLeft(s -> player.sendMessage(I18N.translate(player, s))); + appearanceManager.updatePlayer(skinChange); } }, 20L); } diff --git a/nicko-core/src/main/java/net/artelnatif/nicko/i18n/I18NDict.java b/nicko-core/src/main/java/net/artelnatif/nicko/i18n/I18NDict.java index 216f91d..e84d39c 100644 --- a/nicko-core/src/main/java/net/artelnatif/nicko/i18n/I18NDict.java +++ b/nicko-core/src/main/java/net/artelnatif/nicko/i18n/I18NDict.java @@ -2,6 +2,8 @@ package net.artelnatif.nicko.i18n; public class I18NDict { public enum Event { + DISGUISE_SUCCESS("disguise.success"), + DISGUISE_FAIL("disguise.fail"), PREVIOUS_SKIN_APPLIED("previous_skin_applied.ok"), PREVIOUS_SKIN_APPLY_FAIL("previous_skin_applied.fail"); diff --git a/nicko-core/src/main/java/net/artelnatif/nicko/impl/Internals.java b/nicko-core/src/main/java/net/artelnatif/nicko/impl/Internals.java index 226fdf9..a68ff93 100644 --- a/nicko-core/src/main/java/net/artelnatif/nicko/impl/Internals.java +++ b/nicko-core/src/main/java/net/artelnatif/nicko/impl/Internals.java @@ -1,11 +1,12 @@ package net.artelnatif.nicko.impl; -import io.vavr.control.Either; import net.artelnatif.nicko.disguise.NickoProfile; import org.bukkit.entity.Player; public interface Internals { void updateSelf(Player player); + void updateOthers(Player player); - Either updateProfile(Player player, NickoProfile profile, boolean skinChange); + + void updateProfile(Player player, NickoProfile profile, boolean skinChange); } diff --git a/nicko-core/src/main/resources/locale_en.properties b/nicko-core/src/main/resources/locale_en.properties index 90442a7..6371836 100644 --- a/nicko-core/src/main/resources/locale_en.properties +++ b/nicko-core/src/main/resources/locale_en.properties @@ -1,7 +1,9 @@ -event.previous_skin_applied.ok=§2Applied your previous disguise back. -event.previous_skin_applied.fail=§cFailed to apply your §2previous §cdisguise back. +event.previous_skin_applied.ok=§aApplied your previous disguise back. +event.previous_skin_applied.fail=§cFailed to apply your previous disguise back. player.offline=§c{0} §fis offline, please try again. error.generic=§cAn unknown error occured. Please contact the developer. error.couldnt_get_name_from_mojang=§cFailed to get username from Mojang. Does the user exists? error.couldnt_get_skin_from_mojang=§cFailed to get skin from Mojang. -error.couldnt_get_skin_from_cache=§cFailed to get skin from cache. \ No newline at end of file +error.couldnt_get_skin_from_cache=§cFailed to get skin from cache. +event.disguise.ok=§aDisguise applied. +event.disguise.fail=§cUnable to apply your disguise. \ No newline at end of file diff --git a/nicko-core/src/main/resources/locale_fr.properties b/nicko-core/src/main/resources/locale_fr.properties index 344076a..b6cae4b 100644 --- a/nicko-core/src/main/resources/locale_fr.properties +++ b/nicko-core/src/main/resources/locale_fr.properties @@ -1,7 +1,9 @@ -event.previous_skin_applied.ok=§2Déguisement précédent appliqué. +event.previous_skin_applied.ok=§aDéguisement précédent appliqué. event.previous_skin_applied.fail=§cImpossible d'appliquer votre déguisement précédent. player.offline=§c{0} §fest hors-ligne, veuillez réessayer. error.generic=§cUne erreur inconnue est survenue. Veuillez contacter le développeur. error.couldnt_get_name_from_mojang=§cImpossible de récupérer le nom d'utilisateur depuis Mojang. Cet utilisateur existe-il? error.couldnt_get_skin_from_mojang=§cImpossible de récupérer le skin depuis Mojang. -error.couldnt_get_skin_from_cache=§cImpossible de récupérer le skin depuis le cache. \ No newline at end of file +error.couldnt_get_skin_from_cache=§cImpossible de récupérer le skin depuis le cache. +event.disguise.ok=§aDéguisement appliqué. +event.disguise.fail=§cImpossible d'appliquer votre déguisement. \ No newline at end of file diff --git a/v1_18_R1/src/main/java/net/artelnatif/nicko/impl/v1_18_R1.java b/v1_18_R1/src/main/java/net/artelnatif/nicko/impl/v1_18_R1.java index 8f14ff2..20a67bb 100644 --- a/v1_18_R1/src/main/java/net/artelnatif/nicko/impl/v1_18_R1.java +++ b/v1_18_R1/src/main/java/net/artelnatif/nicko/impl/v1_18_R1.java @@ -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 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 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); } } diff --git a/v1_18_R2/src/main/java/net/artelnatif/nicko/impl/v1_18_R2.java b/v1_18_R2/src/main/java/net/artelnatif/nicko/impl/v1_18_R2.java index ba3bf55..a06d305 100644 --- a/v1_18_R2/src/main/java/net/artelnatif/nicko/impl/v1_18_R2.java +++ b/v1_18_R2/src/main/java/net/artelnatif/nicko/impl/v1_18_R2.java @@ -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.core.Holder; import net.minecraft.network.chat.IChatBaseComponent; @@ -84,7 +82,7 @@ public class v1_18_R2 implements Internals { } @Override - public Either 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 skin; @@ -104,17 +102,14 @@ public class v1_18_R2 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_R2 implements Internals { onlineEntityPlayer.b.a(add); }); updateOthers(player); - return null; } } diff --git a/v1_19_R1/src/main/java/net/artelnatif/nicko/impl/v1_19_R1.java b/v1_19_R1/src/main/java/net/artelnatif/nicko/impl/v1_19_R1.java index 526bba2..b1858d9 100644 --- a/v1_19_R1/src/main/java/net/artelnatif/nicko/impl/v1_19_R1.java +++ b/v1_19_R1/src/main/java/net/artelnatif/nicko/impl/v1_19_R1.java @@ -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.*; @@ -85,7 +83,7 @@ public class v1_19_R1 implements Internals { } @Override - public Either 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 skin; @@ -105,34 +103,30 @@ public class v1_19_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; } + + add.b().clear(); + add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile, + player.getPing(), + EnumGamemode.a(player.getGameMode().ordinal()), + IChatBaseComponent.a(profile.getName()), + entityPlayer.fz().b())); + entityPlayer.b.a(add); + + Bukkit.getOnlinePlayers().forEach(online -> { + EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); + onlineEntityPlayer.b.a(remove); + onlineEntityPlayer.b.a(add); + }); + updateOthers(player); } - - add.b().clear(); - add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile, - player.getPing(), - EnumGamemode.a(player.getGameMode().ordinal()), - IChatBaseComponent.a(profile.getName()), - entityPlayer.fz().b())); - entityPlayer.b.a(add); - - Bukkit.getOnlinePlayers().forEach(online -> { - EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); - onlineEntityPlayer.b.a(remove); - onlineEntityPlayer.b.a(add); - }); - updateOthers(player); - return Either.right(null); } }