- Fixed leather elytra being unenchantable.

- Added color codes support
This commit is contained in:
Pim van der Loos 2017-10-02 17:41:05 +02:00
parent 23889c0845
commit 61a8c872cb
4 changed files with 18 additions and 25 deletions

View File

@ -1,7 +1,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
<groupId>nl.pim16aap2</groupId> <groupId>nl.pim16aap2</groupId>
<artifactId>ArmoredElytra</artifactId> <artifactId>ArmoredElytra</artifactId>
<version>1.7.0-SNAPSHOT</version> <version>1.7.2-SNAPSHOT</version>
<repositories> <repositories>

View File

@ -47,11 +47,11 @@ public class ArmoredElytra extends JavaPlugin implements Listener
config.addDefault("allowCurses", true); config.addDefault("allowCurses", true);
config.addDefault("allowedEnchantments", new String[]{"DURABILITY","PROTECTION_FIRE","PROTECTION_EXPLOSIONS", config.addDefault("allowedEnchantments", new String[]{"DURABILITY","PROTECTION_FIRE","PROTECTION_EXPLOSIONS",
"PROTECTION_PROJECTILE","PROTECTION_ENVIRONMENTAL","THORNS"}); "PROTECTION_PROJECTILE","PROTECTION_ENVIRONMENTAL","THORNS"});
config.addDefault("usageDeniedMessage", "You do not have the required permissions to wear %ARMOR_TIER% armored elytras!"); config.addDefault("usageDeniedMessage", "&CYou do not have the required permissions to wear %ARMOR_TIER% armored elytras!");
config.addDefault("elytraReceivedMessage", "A(n) %ARMOR_TIER% armored elytra has been bestowed upon you!"); config.addDefault("elytraReceivedMessage", "&2A(n) %ARMOR_TIER% armored elytra has been bestowed upon you!");
config.addDefault("elytraName", "%ARMOR_TIER% Armored Elytra"); config.addDefault("elytraName", "%ARMOR_TIER% Armored Elytra");
config.addDefault("elytraLore", "Elytra with %ARMOR_TIER% level protection."); config.addDefault("elytraLore", "&DElytra with %ARMOR_TIER% level protection.");
config.addDefault("checkForUpdates", true); config.addDefault("checkForUpdates", true);
saveDefaultConfig(); saveDefaultConfig();
@ -63,10 +63,12 @@ public class ArmoredElytra extends JavaPlugin implements Listener
cursesAllowed = config.getBoolean("allowCurses", true); cursesAllowed = config.getBoolean("allowCurses", true);
List<String> list = config.getStringList("allowedEnchantments"); List<String> list = config.getStringList("allowedEnchantments");
allowedEnchants = list.toArray(new String[0]); allowedEnchants = list.toArray(new String[0]);
usageDeniedMessage = config.getString("usageDeniedMessage");
elytraReceivedMessage = config.getString("elytraReceivedMessage"); usageDeniedMessage = config.getString("usageDeniedMessage").replaceAll("(&([a-f0-9]))", "\u00A7$2");;
elytraName = config.getString("elytraName"); elytraReceivedMessage = config.getString("elytraReceivedMessage").replaceAll("(&([a-f0-9]))", "\u00A7$2");;
elytraLore = config.getString("elytraLore"); elytraName = config.getString("elytraName").replaceAll("(&([a-f0-9]))", "\u00A7$2");;
elytraLore = config.getString("elytraLore").replaceAll("(&([a-f0-9]))", "\u00A7$2");;
checkForUpdates = config.getBoolean("checkForUpdates"); checkForUpdates = config.getBoolean("checkForUpdates");
usageDeniedMessage = (Objects.equals(usageDeniedMessage, new String("NONE")) ? null : usageDeniedMessage); usageDeniedMessage = (Objects.equals(usageDeniedMessage, new String("NONE")) ? null : usageDeniedMessage);

View File

@ -49,7 +49,6 @@ public class EventHandlers implements Listener
this.IRON_TO_FULL = IRON_TO_FULL; this.IRON_TO_FULL = IRON_TO_FULL;
} }
// Clear the anvil's inventory (destroy all the items in all 3 slots (second slot is not emptied, when repairing you can safely give multiple items)). // Clear the anvil's inventory (destroy all the items in all 3 slots (second slot is not emptied, when repairing you can safely give multiple items)).
public void cleanAnvil(AnvilInventory anvilInventory) public void cleanAnvil(AnvilInventory anvilInventory)
{ {
@ -58,7 +57,6 @@ public class EventHandlers implements Listener
anvilInventory.getItem(2).setAmount(0); anvilInventory.getItem(2).setAmount(0);
} }
// Check if the enchantment is allowed on elytras. // Check if the enchantment is allowed on elytras.
public boolean isAllowedEnchantment(Enchantment enchant) public boolean isAllowedEnchantment(Enchantment enchant)
{ {
@ -75,7 +73,6 @@ public class EventHandlers implements Listener
return false; return false;
} }
// Check if the enchantment is a curse. // Check if the enchantment is a curse.
public boolean isCursedEnchantment(Enchantment enchant) public boolean isCursedEnchantment(Enchantment enchant)
{ {
@ -168,7 +165,6 @@ public class EventHandlers implements Listener
return result; return result;
} }
// Copy enchants of 2 items to one item. // Copy enchants of 2 items to one item.
public ItemStack repairItem(ItemStack one, ItemStack two) public ItemStack repairItem(ItemStack one, ItemStack two)
{ {
@ -201,7 +197,6 @@ public class EventHandlers implements Listener
return result; return result;
} }
// Handle the anvil related parts. // Handle the anvil related parts.
@EventHandler @EventHandler
public void onInventoryClick(InventoryClickEvent e) public void onInventoryClick(InventoryClickEvent e)
@ -254,7 +249,6 @@ public class EventHandlers implements Listener
} }
} }
// Check if there are items in both input slots. // Check if there are items in both input slots.
if (itemA != null && itemB != null) if (itemA != null && itemB != null)
{ {
@ -305,7 +299,7 @@ public class EventHandlers implements Listener
} }
// If the player tries to repair an armored elytra. Check if the armor tier and the repair item match. // If the player tries to repair an armored elytra. Check if the armor tier and the repair item match.
// If the repair item is leather it can only repair // If the repair item is leather it can only repair
else if ((itemB.getType() == Material.LEATHER && (!isArmoredElytra(itemA)) || currentArmorTier == 1) || else if ((itemB.getType() == Material.LEATHER && isArmoredElytra(itemA) && currentArmorTier == 1) ||
(itemB.getType() == Material.GOLD_INGOT && isArmoredElytra(itemA) && currentArmorTier == 2) || (itemB.getType() == Material.GOLD_INGOT && isArmoredElytra(itemA) && currentArmorTier == 2) ||
(itemB.getType() == Material.IRON_INGOT && isArmoredElytra(itemA) && currentArmorTier == 3) || (itemB.getType() == Material.IRON_INGOT && isArmoredElytra(itemA) && currentArmorTier == 3) ||
(itemB.getType() == Material.IRON_INGOT && isArmoredElytra(itemA) && currentArmorTier == 4) || (itemB.getType() == Material.IRON_INGOT && isArmoredElytra(itemA) && currentArmorTier == 4) ||
@ -364,8 +358,6 @@ 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 @EventHandler
public void onPlayerDamage(EntityDamageEvent e) public void onPlayerDamage(EntityDamageEvent e)
@ -418,7 +410,6 @@ public class EventHandlers implements Listener
p.getInventory().getChestplate().setAmount(0); p.getInventory().getChestplate().setAmount(0);
} }
// Check if the player tries to equip armor by richt clicking it. // Check if the player tries to equip armor by richt clicking it.
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@EventHandler @EventHandler
@ -433,11 +424,11 @@ public class EventHandlers implements Listener
if (item.getType() == Material.ELYTRA && isArmoredElytra(item)) if (item.getType() == Material.ELYTRA && isArmoredElytra(item))
{ {
int armorTier = nbtEditor.getArmorTier(item); int armorTier = nbtEditor.getArmorTier(item);
if ((armorTier == 1 && !player.hasPermission("armoredelytra.wear.leather")) || if ((armorTier == 1 && !player.hasPermission("armoredelytra.wear.leather")) ||
(armorTier == 2 && !player.hasPermission("armoredelytra.wear.gold")) || (armorTier == 2 && !player.hasPermission("armoredelytra.wear.gold")) ||
(armorTier == 3 && !player.hasPermission("armoredelytra.wear.chain")) || (armorTier == 3 && !player.hasPermission("armoredelytra.wear.chain")) ||
(armorTier == 4 && !player.hasPermission("armoredelytra.wear.iron")) || (armorTier == 4 && !player.hasPermission("armoredelytra.wear.iron")) ||
(armorTier == 5 && !player.hasPermission("armoredelytra.wear.diamond"))) (armorTier == 5 && !player.hasPermission("armoredelytra.wear.diamond")))
{ {
plugin.usageDeniedMessage(player, armorTier); plugin.usageDeniedMessage(player, armorTier);
event.setCancelled(true); event.setCancelled(true);

View File

@ -1,6 +1,6 @@
name: ArmoredElytra name: ArmoredElytra
main: nl.pim16aap2.armoredElytra.ArmoredElytra main: nl.pim16aap2.armoredElytra.ArmoredElytra
version: 1.7.0 version: 1.7.2
author: Pim author: Pim
commands: commands:
ArmoredElytra: ArmoredElytra: