mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-14 02:24:16 +02:00
Report invalid enchantments in kits.
Improve error logging
This commit is contained in:
@@ -5,6 +5,7 @@ import static com.earth2me.essentials.I18n.capitalCase;
|
|||||||
import com.earth2me.essentials.commands.NoChargeException;
|
import com.earth2me.essentials.commands.NoChargeException;
|
||||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
@@ -31,7 +32,7 @@ public class Kit
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exception(_("kitError"));
|
throw new Exception(_("kitError"), ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -76,7 +77,7 @@ public class Kit
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
user.sendMessage(_("kitError2"));
|
user.sendMessage(_("kitError2"));
|
||||||
throw new Exception(_("kitErrorHelp"));
|
throw new Exception(_("kitErrorHelp"),e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,6 +105,10 @@ public class Kit
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final Enchantment enchantment = Enchantments.getByName(split[0]);
|
final Enchantment enchantment = Enchantments.getByName(split[0]);
|
||||||
|
if (enchantment == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Enchantment not found: " + split[0]);
|
||||||
|
}
|
||||||
int level;
|
int level;
|
||||||
if (split.length > 1)
|
if (split.length > 1)
|
||||||
{
|
{
|
||||||
@@ -113,7 +118,14 @@ public class Kit
|
|||||||
{
|
{
|
||||||
level = enchantment.getMaxLevel();
|
level = enchantment.getMaxLevel();
|
||||||
}
|
}
|
||||||
stack.addEnchantment(enchantment, level);
|
try
|
||||||
|
{
|
||||||
|
stack.addEnchantment(enchantment, level);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception("Enchantment " + enchantment.getName() + ": " + ex.getMessage(), ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +153,15 @@ public class Kit
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
user.updateInventory();
|
user.updateInventory();
|
||||||
throw new Exception(_("kitError2"));
|
if (ess.getSettings().isDebug())
|
||||||
|
{
|
||||||
|
ess.getLogger().log(Level.WARNING, e.getMessage());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ess.getLogger().log(Level.WARNING, e.getMessage());
|
||||||
|
}
|
||||||
|
throw new Exception(_("kitError2"), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -61,7 +61,7 @@ public class Commandkillall extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException e)
|
catch (NumberFormatException e)
|
||||||
{
|
{
|
||||||
throw new Exception(_("numberRequired"));
|
throw new Exception(_("numberRequired"), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -79,7 +79,7 @@ public class Commandptime extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException e)
|
catch (NumberFormatException e)
|
||||||
{
|
{
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -47,7 +47,7 @@ public class Commandremove extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException e)
|
catch (NumberFormatException e)
|
||||||
{
|
{
|
||||||
throw new Exception(_("numberRequired"));
|
throw new Exception(_("numberRequired"), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ public class Commandremove extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
catch (IllegalArgumentException e)
|
catch (IllegalArgumentException e)
|
||||||
{
|
{
|
||||||
throw new NotEnoughArgumentsException(); //TODO: translate and list types
|
throw new NotEnoughArgumentsException(e); //TODO: translate and list types
|
||||||
}
|
}
|
||||||
|
|
||||||
removeEntities(user, world, toRemove, radius);
|
removeEntities(user, world, toRemove, radius);
|
||||||
@@ -84,7 +84,7 @@ public class Commandremove extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
catch (IllegalArgumentException e)
|
catch (IllegalArgumentException e)
|
||||||
{
|
{
|
||||||
throw new NotEnoughArgumentsException(); //TODO: translate and list types
|
throw new NotEnoughArgumentsException(e); //TODO: translate and list types
|
||||||
}
|
}
|
||||||
removeEntities(sender, world, toRemove, 0);
|
removeEntities(sender, world, toRemove, 0);
|
||||||
}
|
}
|
||||||
@@ -92,8 +92,9 @@ public class Commandremove extends EssentialsCommand
|
|||||||
protected void removeEntities(final CommandSender sender, final World world, final ToRemove toRemove, int radius) throws Exception
|
protected void removeEntities(final CommandSender sender, final World world, final ToRemove toRemove, int radius) throws Exception
|
||||||
{
|
{
|
||||||
int removed = 0;
|
int removed = 0;
|
||||||
if (radius > 0) {
|
if (radius > 0)
|
||||||
radius*=radius;
|
{
|
||||||
|
radius *= radius;
|
||||||
}
|
}
|
||||||
for (Chunk chunk : world.getLoadedChunks())
|
for (Chunk chunk : world.getLoadedChunks())
|
||||||
{
|
{
|
||||||
|
@@ -103,7 +103,7 @@ public class Commandspawnmob extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
catch (MobException e)
|
catch (MobException e)
|
||||||
{
|
{
|
||||||
throw new Exception(_("unableToSpawnMob"));
|
throw new Exception(_("unableToSpawnMob"), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mountType != null)
|
if (mountType != null)
|
||||||
@@ -129,7 +129,7 @@ public class Commandspawnmob extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
catch (MobException e)
|
catch (MobException e)
|
||||||
{
|
{
|
||||||
throw new Exception(_("unableToSpawnMob"));
|
throw new Exception(_("unableToSpawnMob"), e);
|
||||||
}
|
}
|
||||||
spawnedMob.setPassenger(spawnedMount);
|
spawnedMob.setPassenger(spawnedMount);
|
||||||
}
|
}
|
||||||
@@ -164,7 +164,7 @@ public class Commandspawnmob extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
catch (MobException e)
|
catch (MobException e)
|
||||||
{
|
{
|
||||||
throw new Exception(_("unableToSpawnMob"));
|
throw new Exception(_("unableToSpawnMob"), e);
|
||||||
}
|
}
|
||||||
spawnedMob.setPassenger(spawnedMount);
|
spawnedMob.setPassenger(spawnedMount);
|
||||||
}
|
}
|
||||||
|
@@ -49,7 +49,7 @@ public class Commandtime extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException e)
|
catch (NumberFormatException e)
|
||||||
{
|
{
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
setWorldsTime(sender, worlds, ticks);
|
setWorldsTime(sender, worlds, ticks);
|
||||||
|
@@ -29,7 +29,7 @@ public class Commandunban extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
catch (NoSuchFieldException e)
|
catch (NoSuchFieldException e)
|
||||||
{
|
{
|
||||||
throw new Exception(_("playerNotFound"));
|
throw new Exception(_("playerNotFound"), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,7 @@ public class SignEnchant extends EssentialsSign
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
throw new SignException(ex.getMessage());
|
throw new SignException(ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
if (level < 1 || level > enchantment.getMaxLevel())
|
if (level < 1 || level > enchantment.getMaxLevel())
|
||||||
{
|
{
|
||||||
@@ -57,7 +57,7 @@ public class SignEnchant extends EssentialsSign
|
|||||||
}
|
}
|
||||||
catch (Throwable ex)
|
catch (Throwable ex)
|
||||||
{
|
{
|
||||||
throw new SignException(ex.getMessage());
|
throw new SignException(ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
getTrade(sign, 3, ess);
|
getTrade(sign, 3, ess);
|
||||||
return true;
|
return true;
|
||||||
|
@@ -224,7 +224,7 @@ public class SignTrade extends EssentialsSign
|
|||||||
}
|
}
|
||||||
catch (SignException e)
|
catch (SignException e)
|
||||||
{
|
{
|
||||||
throw new SignException(_("tradeSignEmpty"));
|
throw new SignException(_("tradeSignEmpty"), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user