Cleanup
- Now using correct Maven imports for Spigot etc. - Removed redundant else (if) statements. - Added stripped-down version of XMaterial v2. - Using XMaterial for chest-plate checking because some names were different in some versions.
This commit is contained in:
parent
81e4111359
commit
1e986d60da
47
pom.xml
47
pom.xml
@ -16,53 +16,10 @@
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-1.9</artifactId>
|
||||
<version>1.9-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-1.9.4</artifactId>
|
||||
<version>1.9.4-R0.2-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-1.10</artifactId>
|
||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-1.11</artifactId>
|
||||
<version>1.11.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-1.12</artifactId>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-1.13</artifactId>
|
||||
<version>1.13-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-1.13.1</artifactId>
|
||||
<version>1.13.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-1.14</artifactId>
|
||||
<version>1.14-R0.1-SNAPSHOT</version>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.14.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -41,7 +41,6 @@ public class CommandHandler implements CommandExecutor
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (cmd.getName().equalsIgnoreCase("ArmoredElytra"))
|
||||
if (args.length == 1 || args.length == 2)
|
||||
{
|
||||
@ -111,13 +110,10 @@ public class CommandHandler implements CommandExecutor
|
||||
plugin.myLogger(Level.INFO, ("Giving an armored elytra of the " + ArmorTier.getArmor(armorTier) + " armor tier to player " + player.getName()));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.myLogger(Level.INFO, ("Player " + args[1] + " not found!"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import nl.pim16aap2.armoredElytra.util.Action;
|
||||
import nl.pim16aap2.armoredElytra.util.AllowedToWearEnum;
|
||||
import nl.pim16aap2.armoredElytra.util.ArmorTier;
|
||||
import nl.pim16aap2.armoredElytra.util.Util;
|
||||
import nl.pim16aap2.armoredElytra.util.XMaterial;
|
||||
|
||||
public class EventHandlers implements Listener
|
||||
{
|
||||
@ -46,7 +47,7 @@ public class EventHandlers implements Listener
|
||||
private void unenquipChestPlayer(Player p)
|
||||
{
|
||||
if (is1_9)
|
||||
p.getInventory().getChestplate().setType(Material.AIR);
|
||||
p.getInventory().getChestplate().setType(XMaterial.AIR.parseMaterial());
|
||||
else
|
||||
{
|
||||
p.getInventory().addItem(p.getInventory().getChestplate());
|
||||
@ -60,7 +61,7 @@ public class EventHandlers implements Listener
|
||||
{
|
||||
if (is1_9)
|
||||
{
|
||||
ItemStack air = new ItemStack(Material.AIR, 1);
|
||||
ItemStack air = new ItemStack(XMaterial.AIR.parseMaterial(), 1);
|
||||
anvilInventory.setItem(0, air);
|
||||
anvilInventory.setItem(1, air);
|
||||
anvilInventory.setItem(2, air);
|
||||
@ -112,7 +113,7 @@ public class EventHandlers implements Listener
|
||||
combined.put(entry.getKey(), enchantLevel);
|
||||
}
|
||||
}
|
||||
else if (enchantLevel == null)
|
||||
else
|
||||
combined.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
@ -150,16 +151,16 @@ public class EventHandlers implements Listener
|
||||
{
|
||||
// Get the multiplier for the repair items.
|
||||
double mult = 0.01;
|
||||
if ( repairItem.getType() == Material.LEATHER)
|
||||
if ( repairItem.getType().equals(Material.LEATHER))
|
||||
mult *= (100.0f / plugin.getConfigLoader().LEATHER_TO_FULL());
|
||||
|
||||
else if (repairItem.getType() == Material.GOLD_INGOT)
|
||||
else if (repairItem.getType().equals(Material.GOLD_INGOT))
|
||||
mult *= (100.0f / plugin.getConfigLoader().GOLD_TO_FULL());
|
||||
|
||||
else if (repairItem.getType() == Material.IRON_INGOT)
|
||||
else if (repairItem.getType().equals(Material.IRON_INGOT))
|
||||
mult *= (100.0f / plugin.getConfigLoader().IRON_TO_FULL());
|
||||
|
||||
else if (repairItem.getType() == Material.DIAMOND)
|
||||
else if (repairItem.getType().equals(Material.DIAMOND))
|
||||
mult *= (100.0f / plugin.getConfigLoader().DIAMONDS_TO_FULL());
|
||||
|
||||
int maxDurability = Material.ELYTRA.getMaxDurability();
|
||||
@ -466,7 +467,8 @@ public class EventHandlers implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
// Because the armored elytra doesn't actually give any armor, the damage received by players wearing an armored elytra is calculated here.
|
||||
// Because the armored elytra doesn't actually give any armor, the damage
|
||||
// received by players wearing an armored elytra is calculated here.
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerDamage(EntityDamageEvent e)
|
||||
{
|
||||
|
@ -32,16 +32,19 @@ public class Util
|
||||
}
|
||||
|
||||
// Get the armor tier from a chest plate.
|
||||
public static ArmorTier armorToTier(Material item)
|
||||
public static ArmorTier armorToTier(Material mat)
|
||||
{
|
||||
ArmorTier ret = ArmorTier.NONE;
|
||||
XMaterial xmat = XMaterial.matchXMaterial(mat);
|
||||
if (xmat == null)
|
||||
return ret;
|
||||
|
||||
switch (item)
|
||||
switch (xmat)
|
||||
{
|
||||
case LEATHER_CHESTPLATE:
|
||||
ret = ArmorTier.LEATHER;
|
||||
break;
|
||||
case GOLD_CHESTPLATE:
|
||||
case GOLDEN_CHESTPLATE:
|
||||
ret = ArmorTier.GOLD;
|
||||
break;
|
||||
case CHAINMAIL_CHESTPLATE:
|
||||
@ -62,9 +65,12 @@ public class Util
|
||||
// Check if mat is a chest plate.
|
||||
public static boolean isChestPlate(Material mat)
|
||||
{
|
||||
if (mat == Material.LEATHER_CHESTPLATE || mat == Material.GOLD_CHESTPLATE ||
|
||||
mat == Material.CHAINMAIL_CHESTPLATE || mat == Material.IRON_CHESTPLATE ||
|
||||
mat == Material.DIAMOND_CHESTPLATE)
|
||||
XMaterial xmat = XMaterial.matchXMaterial(mat);
|
||||
if (xmat == null)
|
||||
return false;
|
||||
if (xmat == XMaterial.LEATHER_CHESTPLATE || xmat == XMaterial.GOLDEN_CHESTPLATE ||
|
||||
xmat == XMaterial.CHAINMAIL_CHESTPLATE || xmat == XMaterial.IRON_CHESTPLATE ||
|
||||
xmat == XMaterial.DIAMOND_CHESTPLATE)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user