- 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:
Pim van der Loos 2019-06-20 16:59:13 +02:00
parent 81e4111359
commit 1e986d60da
No known key found for this signature in database
GPG Key ID: C16F020ADAE6D5A8
4 changed files with 26 additions and 65 deletions

47
pom.xml
View File

@ -16,53 +16,10 @@
</repositories> </repositories>
<dependencies> <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> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-1.13.1</artifactId> <artifactId>spigot</artifactId>
<version>1.13.1-R0.1-SNAPSHOT</version> <version>1.14.2-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>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

View File

@ -41,7 +41,6 @@ public class CommandHandler implements CommandExecutor
return true; return true;
} }
if (cmd.getName().equalsIgnoreCase("ArmoredElytra")) if (cmd.getName().equalsIgnoreCase("ArmoredElytra"))
if (args.length == 1 || args.length == 2) if (args.length == 1 || args.length == 2)
{ {
@ -111,11 +110,8 @@ public class CommandHandler implements CommandExecutor
plugin.myLogger(Level.INFO, ("Giving an armored elytra of the " + ArmorTier.getArmor(armorTier) + " armor tier to player " + player.getName())); plugin.myLogger(Level.INFO, ("Giving an armored elytra of the " + ArmorTier.getArmor(armorTier) + " armor tier to player " + player.getName()));
return true; return true;
} }
else plugin.myLogger(Level.INFO, ("Player " + args[1] + " not found!"));
{ return true;
plugin.myLogger(Level.INFO, ("Player " + args[1] + " not found!"));
return true;
}
} }
} }
return false; return false;

View File

@ -28,6 +28,7 @@ import nl.pim16aap2.armoredElytra.util.Action;
import nl.pim16aap2.armoredElytra.util.AllowedToWearEnum; import nl.pim16aap2.armoredElytra.util.AllowedToWearEnum;
import nl.pim16aap2.armoredElytra.util.ArmorTier; import nl.pim16aap2.armoredElytra.util.ArmorTier;
import nl.pim16aap2.armoredElytra.util.Util; import nl.pim16aap2.armoredElytra.util.Util;
import nl.pim16aap2.armoredElytra.util.XMaterial;
public class EventHandlers implements Listener public class EventHandlers implements Listener
{ {
@ -46,7 +47,7 @@ public class EventHandlers implements Listener
private void unenquipChestPlayer(Player p) private void unenquipChestPlayer(Player p)
{ {
if (is1_9) if (is1_9)
p.getInventory().getChestplate().setType(Material.AIR); p.getInventory().getChestplate().setType(XMaterial.AIR.parseMaterial());
else else
{ {
p.getInventory().addItem(p.getInventory().getChestplate()); p.getInventory().addItem(p.getInventory().getChestplate());
@ -60,7 +61,7 @@ public class EventHandlers implements Listener
{ {
if (is1_9) if (is1_9)
{ {
ItemStack air = new ItemStack(Material.AIR, 1); ItemStack air = new ItemStack(XMaterial.AIR.parseMaterial(), 1);
anvilInventory.setItem(0, air); anvilInventory.setItem(0, air);
anvilInventory.setItem(1, air); anvilInventory.setItem(1, air);
anvilInventory.setItem(2, air); anvilInventory.setItem(2, air);
@ -112,7 +113,7 @@ public class EventHandlers implements Listener
combined.put(entry.getKey(), enchantLevel); combined.put(entry.getKey(), enchantLevel);
} }
} }
else if (enchantLevel == null) else
combined.put(entry.getKey(), entry.getValue()); combined.put(entry.getKey(), entry.getValue());
} }
@ -150,16 +151,16 @@ public class EventHandlers implements Listener
{ {
// Get the multiplier for the repair items. // Get the multiplier for the repair items.
double mult = 0.01; double mult = 0.01;
if ( repairItem.getType() == Material.LEATHER) if ( repairItem.getType().equals(Material.LEATHER))
mult *= (100.0f / plugin.getConfigLoader().LEATHER_TO_FULL()); 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()); 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()); 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()); mult *= (100.0f / plugin.getConfigLoader().DIAMONDS_TO_FULL());
int maxDurability = Material.ELYTRA.getMaxDurability(); 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) @EventHandler(ignoreCancelled = true)
public void onPlayerDamage(EntityDamageEvent e) public void onPlayerDamage(EntityDamageEvent e)
{ {

View File

@ -32,16 +32,19 @@ public class Util
} }
// Get the armor tier from a chest plate. // Get the armor tier from a chest plate.
public static ArmorTier armorToTier(Material item) public static ArmorTier armorToTier(Material mat)
{ {
ArmorTier ret = ArmorTier.NONE; ArmorTier ret = ArmorTier.NONE;
XMaterial xmat = XMaterial.matchXMaterial(mat);
if (xmat == null)
return ret;
switch (item) switch (xmat)
{ {
case LEATHER_CHESTPLATE: case LEATHER_CHESTPLATE:
ret = ArmorTier.LEATHER; ret = ArmorTier.LEATHER;
break; break;
case GOLD_CHESTPLATE: case GOLDEN_CHESTPLATE:
ret = ArmorTier.GOLD; ret = ArmorTier.GOLD;
break; break;
case CHAINMAIL_CHESTPLATE: case CHAINMAIL_CHESTPLATE:
@ -62,9 +65,12 @@ public class Util
// Check if mat is a chest plate. // Check if mat is a chest plate.
public static boolean isChestPlate(Material mat) public static boolean isChestPlate(Material mat)
{ {
if (mat == Material.LEATHER_CHESTPLATE || mat == Material.GOLD_CHESTPLATE || XMaterial xmat = XMaterial.matchXMaterial(mat);
mat == Material.CHAINMAIL_CHESTPLATE || mat == Material.IRON_CHESTPLATE || if (xmat == null)
mat == Material.DIAMOND_CHESTPLATE) 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 true;
return false; return false;
} }