From 53b1526906f80e7da20441a9b29c61557e8336ca Mon Sep 17 00:00:00 2001 From: KHobbits Date: Fri, 15 Nov 2013 00:22:10 +0000 Subject: Throw meaningful warnings when wrong Essentials version is used with unsupported mod packs. --- .../src/com/earth2me/essentials/Essentials.java | 13 +++++++++---- Essentials/src/com/earth2me/essentials/Potions.java | 20 ++++++++++++++------ .../com/earth2me/essentials/utils/LocationUtil.java | 12 +++++++++++- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 044f8bc93..c7bf6c307 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -158,10 +158,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials final int versionNumber = Integer.parseInt(versionMatch.group(1)); if (versionNumber < BUKKIT_VERSION && versionNumber > 100) { - LOGGER.log(Level.SEVERE, " * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! *"); - LOGGER.log(Level.SEVERE, _("notRecommendedBukkit")); - LOGGER.log(Level.SEVERE, _("requiredBukkit", Integer.toString(BUKKIT_VERSION))); - LOGGER.log(Level.SEVERE, " * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! *"); + wrongVersion(); this.setEnabled(false); return; } @@ -570,6 +567,14 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials } } + static public void wrongVersion() + { + LOGGER.log(Level.SEVERE, " * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! *"); + LOGGER.log(Level.SEVERE, _("notRecommendedBukkit")); + LOGGER.log(Level.SEVERE, _("requiredBukkit", Integer.toString(BUKKIT_VERSION))); + LOGGER.log(Level.SEVERE, " * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! *"); + } + @Override public BukkitScheduler getScheduler() { diff --git a/Essentials/src/com/earth2me/essentials/Potions.java b/Essentials/src/com/earth2me/essentials/Potions.java index a01774a5a..7cc967ecb 100644 --- a/Essentials/src/com/earth2me/essentials/Potions.java +++ b/Essentials/src/com/earth2me/essentials/Potions.java @@ -100,14 +100,22 @@ public class Potions POTIONS.put("wither", PotionEffectType.WITHER); ALIASPOTIONS.put("decay", PotionEffectType.WITHER); - POTIONS.put("healthboost", PotionEffectType.HEALTH_BOOST); - ALIASPOTIONS.put("boost", PotionEffectType.HEALTH_BOOST); - POTIONS.put("absorption", PotionEffectType.ABSORPTION); - ALIASPOTIONS.put("absorb", PotionEffectType.ABSORPTION); + try // 1.6 update + { + POTIONS.put("healthboost", PotionEffectType.HEALTH_BOOST); + ALIASPOTIONS.put("boost", PotionEffectType.HEALTH_BOOST); + + POTIONS.put("absorption", PotionEffectType.ABSORPTION); + ALIASPOTIONS.put("absorb", PotionEffectType.ABSORPTION); - POTIONS.put("saturation", PotionEffectType.SATURATION); - ALIASPOTIONS.put("food", PotionEffectType.SATURATION); + POTIONS.put("saturation", PotionEffectType.SATURATION); + ALIASPOTIONS.put("food", PotionEffectType.SATURATION); + } + catch (java.lang.NoSuchFieldError e) + { + Essentials.wrongVersion(); + } } public static PotionEffectType getByName(String name) diff --git a/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java b/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java index 0059e9f8c..66a2ef581 100644 --- a/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java +++ b/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java @@ -1,5 +1,6 @@ package com.earth2me.essentials.utils; +import com.earth2me.essentials.Essentials; import static com.earth2me.essentials.I18n._; import java.util.ArrayList; import java.util.Collections; @@ -60,7 +61,15 @@ public class LocationUtil HOLLOW_MATERIALS.add(Material.FENCE_GATE.getId()); HOLLOW_MATERIALS.add(Material.WATER_LILY.getId()); HOLLOW_MATERIALS.add(Material.NETHER_WARTS.getId()); - HOLLOW_MATERIALS.add(Material.CARPET.getId()); + + try // 1.6 update + { + HOLLOW_MATERIALS.add(Material.CARPET.getId()); + } + catch (java.lang.NoSuchFieldError e) + { + Essentials.wrongVersion(); + } for (Integer integer : HOLLOW_MATERIALS) { @@ -160,6 +169,7 @@ public class LocationUtil public int x; public int y; public int z; + public Vector3D(int x, int y, int z) { this.x = x; -- cgit v1.2.3