Skip to content

Commit 53b1526

Browse files
committed
Throw meaningful warnings when wrong Essentials version is used with unsupported mod packs.
1 parent 82be754 commit 53b1526

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

Essentials/src/com/earth2me/essentials/Essentials.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,7 @@ public void onEnable()
158158
final int versionNumber = Integer.parseInt(versionMatch.group(1));
159159
if (versionNumber < BUKKIT_VERSION && versionNumber > 100)
160160
{
161-
LOGGER.log(Level.SEVERE, " * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! *");
162-
LOGGER.log(Level.SEVERE, _("notRecommendedBukkit"));
163-
LOGGER.log(Level.SEVERE, _("requiredBukkit", Integer.toString(BUKKIT_VERSION)));
164-
LOGGER.log(Level.SEVERE, " * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! *");
161+
wrongVersion();
165162
this.setEnabled(false);
166163
return;
167164
}
@@ -570,6 +567,14 @@ public void showError(final CommandSource sender, final Throwable exception, fin
570567
}
571568
}
572569

570+
static public void wrongVersion()
571+
{
572+
LOGGER.log(Level.SEVERE, " * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! *");
573+
LOGGER.log(Level.SEVERE, _("notRecommendedBukkit"));
574+
LOGGER.log(Level.SEVERE, _("requiredBukkit", Integer.toString(BUKKIT_VERSION)));
575+
LOGGER.log(Level.SEVERE, " * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! *");
576+
}
577+
573578
@Override
574579
public BukkitScheduler getScheduler()
575580
{

Essentials/src/com/earth2me/essentials/Potions.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,22 @@ public class Potions
100100
POTIONS.put("wither", PotionEffectType.WITHER);
101101
ALIASPOTIONS.put("decay", PotionEffectType.WITHER);
102102

103-
POTIONS.put("healthboost", PotionEffectType.HEALTH_BOOST);
104-
ALIASPOTIONS.put("boost", PotionEffectType.HEALTH_BOOST);
105103

106-
POTIONS.put("absorption", PotionEffectType.ABSORPTION);
107-
ALIASPOTIONS.put("absorb", PotionEffectType.ABSORPTION);
104+
try // 1.6 update
105+
{
106+
POTIONS.put("healthboost", PotionEffectType.HEALTH_BOOST);
107+
ALIASPOTIONS.put("boost", PotionEffectType.HEALTH_BOOST);
108+
109+
POTIONS.put("absorption", PotionEffectType.ABSORPTION);
110+
ALIASPOTIONS.put("absorb", PotionEffectType.ABSORPTION);
108111

109-
POTIONS.put("saturation", PotionEffectType.SATURATION);
110-
ALIASPOTIONS.put("food", PotionEffectType.SATURATION);
112+
POTIONS.put("saturation", PotionEffectType.SATURATION);
113+
ALIASPOTIONS.put("food", PotionEffectType.SATURATION);
114+
}
115+
catch (java.lang.NoSuchFieldError e)
116+
{
117+
Essentials.wrongVersion();
118+
}
111119
}
112120

113121
public static PotionEffectType getByName(String name)

Essentials/src/com/earth2me/essentials/utils/LocationUtil.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.earth2me.essentials.utils;
22

3+
import com.earth2me.essentials.Essentials;
34
import static com.earth2me.essentials.I18n._;
45
import java.util.ArrayList;
56
import java.util.Collections;
@@ -60,7 +61,15 @@ public class LocationUtil
6061
HOLLOW_MATERIALS.add(Material.FENCE_GATE.getId());
6162
HOLLOW_MATERIALS.add(Material.WATER_LILY.getId());
6263
HOLLOW_MATERIALS.add(Material.NETHER_WARTS.getId());
63-
HOLLOW_MATERIALS.add(Material.CARPET.getId());
64+
65+
try // 1.6 update
66+
{
67+
HOLLOW_MATERIALS.add(Material.CARPET.getId());
68+
}
69+
catch (java.lang.NoSuchFieldError e)
70+
{
71+
Essentials.wrongVersion();
72+
}
6473

6574
for (Integer integer : HOLLOW_MATERIALS)
6675
{
@@ -160,6 +169,7 @@ public static class Vector3D
160169
public int x;
161170
public int y;
162171
public int z;
172+
163173
public Vector3D(int x, int y, int z)
164174
{
165175
this.x = x;

0 commit comments

Comments
 (0)