fix: replace vavr's either with in-house implementation
This commit is contained in:
parent
a1a0b04471
commit
c217db98e8
7 changed files with 74 additions and 31 deletions
|
@ -65,7 +65,7 @@ public class AppearanceManager {
|
|||
updatePlayer(true);
|
||||
}
|
||||
|
||||
public void updatePlayer(boolean skinChange) {
|
||||
NickoBukkit.getInstance().getInternals().updateProfile(player, profile, skinChange);
|
||||
public UpdateResult updatePlayer(boolean skinChange) {
|
||||
return NickoBukkit.getInstance().getInternals().updateProfile(player, profile, skinChange);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package net.artelnatif.nicko.disguise;
|
||||
|
||||
import net.artelnatif.nicko.i18n.I18NDict;
|
||||
|
||||
public class UpdateResult {
|
||||
private final I18NDict.Error errorMessage;
|
||||
private boolean error = false;
|
||||
|
||||
public UpdateResult(I18NDict.Error errorMessage) {
|
||||
this.error = true;
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
public UpdateResult() {
|
||||
this.errorMessage = null;
|
||||
}
|
||||
|
||||
public boolean isError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public I18NDict.Error getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
}
|
|
@ -2,6 +2,9 @@ package net.artelnatif.nicko.event;
|
|||
|
||||
import net.artelnatif.nicko.NickoBukkit;
|
||||
import net.artelnatif.nicko.disguise.AppearanceManager;
|
||||
import net.artelnatif.nicko.disguise.UpdateResult;
|
||||
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;
|
||||
|
@ -17,7 +20,12 @@ public class PlayerJoinListener implements Listener {
|
|||
|
||||
if (appearanceManager.hasData()) {
|
||||
final boolean skinChange = !player.getName().equals(appearanceManager.getSkin());
|
||||
appearanceManager.updatePlayer(skinChange);
|
||||
final UpdateResult updateResult = appearanceManager.updatePlayer(skinChange);
|
||||
if (updateResult.isError()) {
|
||||
player.sendMessage(I18N.translate(player, I18NDict.Event.DISGUISE_FAIL.getKey(), I18N.translate(player, updateResult.getErrorMessage().getKey())));
|
||||
} else {
|
||||
player.sendMessage(I18N.translate(player, I18NDict.Event.DISGUISE_SUCCESS.getKey()));
|
||||
}
|
||||
}
|
||||
}, 20L);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.artelnatif.nicko.impl;
|
||||
|
||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
||||
import net.artelnatif.nicko.disguise.UpdateResult;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface Internals {
|
||||
|
@ -8,5 +9,5 @@ public interface Internals {
|
|||
|
||||
void updateOthers(Player player);
|
||||
|
||||
void updateProfile(Player player, NickoProfile profile, boolean skinChange);
|
||||
UpdateResult updateProfile(Player player, NickoProfile profile, boolean skinChange);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue