diff --git a/Essentials/src/main/java/com/earth2me/essentials/MobCompat.java b/Essentials/src/main/java/com/earth2me/essentials/MobCompat.java index 092e8d775b3..f939d42ec97 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/MobCompat.java +++ b/Essentials/src/main/java/com/earth2me/essentials/MobCompat.java @@ -296,7 +296,7 @@ public enum VillagerProfession { } private Villager.Profession asEnum() { - return EnumUtil.valueOf(Villager.Profession.class, newProfession, oldProfession); + return RegistryUtil.valueOf(Villager.Profession.class, newProfession, oldProfession); } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandpay.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandpay.java index 734c90fc8f2..38778c2fa1a 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandpay.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandpay.java @@ -109,8 +109,10 @@ public void run(final Server server, final User user, final String commandLabel, user.setMoney(user.getMoney().add(amount)); } catch (final MaxMoneyException ignored) { } + } catch (final TranslatableException e) { + throw e; } catch (final Exception e) { - user.sendMessage(e.getMessage()); + throw new TranslatableException("errorWithMessage", e.getMessage()); } }); if (informToConfirm.get()) { diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/EssentialsLoopCommand.java b/Essentials/src/main/java/com/earth2me/essentials/commands/EssentialsLoopCommand.java index 4c48caa3e55..18418c58734 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/EssentialsLoopCommand.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/EssentialsLoopCommand.java @@ -6,6 +6,7 @@ import com.earth2me.essentials.utils.FormatUtil; import com.earth2me.essentials.utils.StringUtil; import net.ess3.api.MaxMoneyException; +import net.ess3.api.TranslatableException; import org.bukkit.Server; import org.bukkit.entity.Player; @@ -18,11 +19,11 @@ public EssentialsLoopCommand(final String command) { super(command); } - protected void loopOfflinePlayers(final Server server, final CommandSource sender, final boolean multipleStringMatches, final boolean matchWildcards, final String searchTerm, final String[] commandArgs) throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException { + protected void loopOfflinePlayers(final Server server, final CommandSource sender, final boolean multipleStringMatches, final boolean matchWildcards, final String searchTerm, final String[] commandArgs) throws TranslatableException, NotEnoughArgumentsException { loopOfflinePlayersConsumer(server, sender, multipleStringMatches, matchWildcards, searchTerm, user -> updatePlayer(server, sender, user, commandArgs)); } - protected void loopOfflinePlayersConsumer(final Server server, final CommandSource sender, final boolean multipleStringMatches, final boolean matchWildcards, final String searchTerm, final UserConsumer userConsumer) throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException { + protected void loopOfflinePlayersConsumer(final Server server, final CommandSource sender, final boolean multipleStringMatches, final boolean matchWildcards, final String searchTerm, final UserConsumer userConsumer) throws TranslatableException, NotEnoughArgumentsException { if (searchTerm.isEmpty()) { throw new PlayerNotFoundException(); } @@ -68,11 +69,11 @@ protected void loopOfflinePlayersConsumer(final Server server, final CommandSour } } - protected void loopOnlinePlayers(final Server server, final CommandSource sender, final boolean multipleStringMatches, final boolean matchWildcards, final String searchTerm, final String[] commandArgs) throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException { + protected void loopOnlinePlayers(final Server server, final CommandSource sender, final boolean multipleStringMatches, final boolean matchWildcards, final String searchTerm, final String[] commandArgs) throws TranslatableException, NotEnoughArgumentsException { loopOnlinePlayersConsumer(server, sender, multipleStringMatches, matchWildcards, searchTerm, user -> updatePlayer(server, sender, user, commandArgs)); } - protected void loopOnlinePlayersConsumer(final Server server, final CommandSource sender, final boolean multipleStringMatches, final boolean matchWildcards, final String searchTerm, final UserConsumer userConsumer) throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException { + protected void loopOnlinePlayersConsumer(final Server server, final CommandSource sender, final boolean multipleStringMatches, final boolean matchWildcards, final String searchTerm, final UserConsumer userConsumer) throws NotEnoughArgumentsException, TranslatableException { if (searchTerm.isEmpty()) { throw new PlayerNotFoundException(); } @@ -143,6 +144,6 @@ protected List getPlayers(final Server server, final User interactor) { } public interface UserConsumer { - void accept(User user) throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException; + void accept(User user) throws NotEnoughArgumentsException, TranslatableException; } } diff --git a/EssentialsXMPP/src/main/java/com/earth2me/essentials/xmpp/Commandxmppspy.java b/EssentialsXMPP/src/main/java/com/earth2me/essentials/xmpp/Commandxmppspy.java index ef586c4b12c..ad6c7d1a540 100644 --- a/EssentialsXMPP/src/main/java/com/earth2me/essentials/xmpp/Commandxmppspy.java +++ b/EssentialsXMPP/src/main/java/com/earth2me/essentials/xmpp/Commandxmppspy.java @@ -1,13 +1,10 @@ package com.earth2me.essentials.xmpp; -import com.earth2me.essentials.ChargeException; import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.User; import com.earth2me.essentials.commands.EssentialsLoopCommand; import com.earth2me.essentials.commands.NotEnoughArgumentsException; -import com.earth2me.essentials.commands.PlayerExemptException; -import com.earth2me.essentials.commands.PlayerNotFoundException; -import net.ess3.api.MaxMoneyException; +import net.ess3.api.TranslatableException; import org.bukkit.Server; public class Commandxmppspy extends EssentialsLoopCommand { @@ -16,7 +13,7 @@ public Commandxmppspy() { } @Override - protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws NotEnoughArgumentsException, PlayerExemptException, MaxMoneyException, ChargeException, PlayerNotFoundException { + protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws NotEnoughArgumentsException, TranslatableException { if (args.length == 0) { throw new NotEnoughArgumentsException(); }