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;
|
||||
|
||||
import xyz.atnrch.nicko.NickoBukkit;
|
||||
import xyz.atnrch.nicko.disguise.ActionResult;
|
||||
import xyz.atnrch.nicko.disguise.AppearanceManager;
|
||||
import xyz.atnrch.nicko.i18n.I18N;
|
||||
import xyz.atnrch.nicko.mojang.MojangUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
|
@ -35,14 +37,25 @@ public class NickoDebugSubCmd {
|
|||
}
|
||||
}
|
||||
|
||||
final AppearanceManager appearanceManager = AppearanceManager.get(target.getPlayer());
|
||||
|
||||
if (MojangUtils.isUsernameInvalid(name) || MojangUtils.isUsernameInvalid(skin)) {
|
||||
if (MojangUtils.isUsernameInvalid(name)) {
|
||||
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);
|
||||
target.sendMessage(prefix + "§aWhoosh!");
|
||||
target.playSound(target.getLocation(), Sound.ENTITY_ITEM_FRAME_PLACE, 1, 1);
|
||||
final ActionResult result = appearanceManager.updatePlayer(true, false);
|
||||
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) {
|
||||
this.profile.setName(name);
|
||||
this.profile.setSkin(skin);
|
||||
updatePlayer(true, false);
|
||||
}
|
||||
|
||||
public ActionResult reset() {
|
||||
|
@ -105,11 +104,11 @@ public class AppearanceManager {
|
|||
updateTabList(gameProfile, displayName);
|
||||
respawnPlayer();
|
||||
updateOthers();
|
||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
player.setFlying(wasFlying);
|
||||
player.updateInventory();
|
||||
}
|
||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
player.setFlying(wasFlying);
|
||||
player.updateInventory();
|
||||
return ActionResult.ok();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void updateOthers() {
|
||||
|
@ -144,6 +143,8 @@ public class AppearanceManager {
|
|||
} else {
|
||||
return ActionResult.error(I18NDict.Error.MOJANG_SKIN);
|
||||
}
|
||||
} else {
|
||||
return ActionResult.error(I18NDict.Error.MOJANG_NAME);
|
||||
}
|
||||
return ActionResult.ok();
|
||||
} catch (ExecutionException e) {
|
||||
|
|
|
@ -62,7 +62,7 @@ public class MojangAPI {
|
|||
final MojangSkin skin = MojangSkin.buildFromJson(object);
|
||||
return Optional.of(skin);
|
||||
}
|
||||
|
||||
System.out.println("got empty optional !!!");
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue