fix: mojangapi returns
This commit is contained in:
parent
4fa7082bf5
commit
c8c55611a0
5 changed files with 29 additions and 15 deletions
|
@ -1,7 +1,9 @@
|
||||||
package xyz.atnrch.nicko.command.sub;
|
package xyz.atnrch.nicko.command.sub;
|
||||||
|
|
||||||
import xyz.atnrch.nicko.NickoBukkit;
|
import xyz.atnrch.nicko.NickoBukkit;
|
||||||
|
import xyz.atnrch.nicko.disguise.ActionResult;
|
||||||
import xyz.atnrch.nicko.disguise.AppearanceManager;
|
import xyz.atnrch.nicko.disguise.AppearanceManager;
|
||||||
|
import xyz.atnrch.nicko.i18n.I18N;
|
||||||
import xyz.atnrch.nicko.mojang.MojangUtils;
|
import xyz.atnrch.nicko.mojang.MojangUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
@ -35,14 +37,25 @@ public class NickoDebugSubCmd {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final AppearanceManager appearanceManager = AppearanceManager.get(target.getPlayer());
|
if (MojangUtils.isUsernameInvalid(name)) {
|
||||||
|
|
||||||
if (MojangUtils.isUsernameInvalid(name) || MojangUtils.isUsernameInvalid(skin)) {
|
|
||||||
sender.sendMessage(prefix + "§cSpecified username is invalid.");
|
sender.sendMessage(prefix + "§cSpecified username is invalid.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (MojangUtils.isUsernameInvalid(skin)) {
|
||||||
|
sender.sendMessage(prefix + "§cSpecified skin is invalid.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final AppearanceManager appearanceManager = AppearanceManager.get(target.getPlayer());
|
||||||
appearanceManager.setNameAndSkin(name, skin);
|
appearanceManager.setNameAndSkin(name, skin);
|
||||||
target.sendMessage(prefix + "§aWhoosh!");
|
final ActionResult result = appearanceManager.updatePlayer(true, false);
|
||||||
target.playSound(target.getLocation(), Sound.ENTITY_ITEM_FRAME_PLACE, 1, 1);
|
if (!result.isError()) {
|
||||||
|
target.sendMessage(prefix + "§aWhoosh!");
|
||||||
|
target.playSound(target.getLocation(), Sound.ENTITY_ITEM_FRAME_PLACE, 1, 1);
|
||||||
|
} else {
|
||||||
|
final I18N i18n = new I18N(target);
|
||||||
|
target.sendMessage(prefix + "§cWhoops. Something happened: " + i18n.translateWithoutPrefix(result.getErrorKey()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,6 @@ public class AppearanceManager {
|
||||||
public void setNameAndSkin(String name, String skin) {
|
public void setNameAndSkin(String name, String skin) {
|
||||||
this.profile.setName(name);
|
this.profile.setName(name);
|
||||||
this.profile.setSkin(skin);
|
this.profile.setSkin(skin);
|
||||||
updatePlayer(true, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult reset() {
|
public ActionResult reset() {
|
||||||
|
@ -105,11 +104,11 @@ public class AppearanceManager {
|
||||||
updateTabList(gameProfile, displayName);
|
updateTabList(gameProfile, displayName);
|
||||||
respawnPlayer();
|
respawnPlayer();
|
||||||
updateOthers();
|
updateOthers();
|
||||||
|
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||||
|
player.setFlying(wasFlying);
|
||||||
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
return result;
|
||||||
player.setFlying(wasFlying);
|
|
||||||
player.updateInventory();
|
|
||||||
return ActionResult.ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateOthers() {
|
public void updateOthers() {
|
||||||
|
@ -144,6 +143,8 @@ public class AppearanceManager {
|
||||||
} else {
|
} else {
|
||||||
return ActionResult.error(I18NDict.Error.MOJANG_SKIN);
|
return ActionResult.error(I18NDict.Error.MOJANG_SKIN);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return ActionResult.error(I18NDict.Error.MOJANG_NAME);
|
||||||
}
|
}
|
||||||
return ActionResult.ok();
|
return ActionResult.ok();
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class MojangAPI {
|
||||||
final MojangSkin skin = MojangSkin.buildFromJson(object);
|
final MojangSkin skin = MojangSkin.buildFromJson(object);
|
||||||
return Optional.of(skin);
|
return Optional.of(skin);
|
||||||
}
|
}
|
||||||
|
System.out.println("got empty optional !!!");
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error:
|
error:
|
||||||
generic: "Unknown error"
|
generic: "Unknown error"
|
||||||
invalid_username: "§cThis is not a valid Minecraft username."
|
invalid_username: "§cThis is not a valid Minecraft username."
|
||||||
mojang_name: "Unable to get username from Mojang."
|
mojang_name: "There is no Minecraft account with this name."
|
||||||
mojang_skin: "Unable to get skin from Mojang."
|
mojang_skin: "This Minecraft account has no skin."
|
||||||
offline: "§c{0} §fis offline!"
|
offline: "§c{0} §fis offline!"
|
||||||
cache: "Unable to get skin from the cache."
|
cache: "Unable to get skin from the cache."
|
||||||
sql: "SQL Error"
|
sql: "SQL Error"
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error:
|
error:
|
||||||
generic: Erreur inconnue"
|
generic: Erreur inconnue"
|
||||||
invalid_username: "§cLe pseudo n''est pas un pseudo Minecraft valide."
|
invalid_username: "§cLe pseudo n''est pas un pseudo Minecraft valide."
|
||||||
mojang_name: "Impossible de récupérer le nom d''utilisateur depuis Mojang."
|
mojang_name: "Un compte Minecraft avec ce nom n'existe pas."
|
||||||
mojang_skin: "Impossible de récupérer le skin depuis Mojang."
|
mojang_skin: "Ce compte Minecraft n'a pas de skin."
|
||||||
offline: "§c{0} §fest hors-ligne!"
|
offline: "§c{0} §fest hors-ligne!"
|
||||||
cache: "Impossible de récupérer le skin depuis le cache."
|
cache: "Impossible de récupérer le skin depuis le cache."
|
||||||
sql: "Erreur SQL"
|
sql: "Erreur SQL"
|
||||||
|
|
Loading…
Reference in a new issue