Skip to content

Commit

Permalink
Throw meaningful warnings when wrong Essentials version is used with …
Browse files Browse the repository at this point in the history
…unsupported mod packs.
  • Loading branch information
khobbits committed Nov 15, 2013
1 parent 82be754 commit 53b1526
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
13 changes: 9 additions & 4 deletions Essentials/src/com/earth2me/essentials/Essentials.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,7 @@ public void onEnable()
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;
}
Expand Down Expand Up @@ -570,6 +567,14 @@ public void showError(final CommandSource sender, final Throwable exception, fin
}
}

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()
{
Expand Down
20 changes: 14 additions & 6 deletions Essentials/src/com/earth2me/essentials/Potions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 11 additions & 1 deletion Essentials/src/com/earth2me/essentials/utils/LocationUtil.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -160,6 +169,7 @@ public static class Vector3D
public int x;
public int y;
public int z;

public Vector3D(int x, int y, int z)
{
this.x = x;
Expand Down

0 comments on commit 53b1526

Please sign in to comment.