- Final clean up.
This commit is contained in:
parent
cbc0fd4b79
commit
52c391d025
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>nl.pim16aap2</groupId>
|
||||
<artifactId>ArmoredElytra</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
|
@ -4,9 +4,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.rit.sucy.EnchantPlugin;
|
||||
import com.rit.sucy.EnchantmentAPI;
|
||||
|
||||
import nl.pim16aap2.armoredElytra.enchantments.DiamondArmor;
|
||||
|
||||
public class ArmoredElytra extends EnchantPlugin implements Listener {
|
||||
|
||||
@ -14,10 +11,4 @@ public class ArmoredElytra extends EnchantPlugin implements Listener {
|
||||
public void onEnable() {
|
||||
Bukkit.getPluginManager().registerEvents(new EventHandlers(this), this);
|
||||
}
|
||||
|
||||
// TODO: Remove this after updating elytras on my server.
|
||||
@Override
|
||||
public void registerEnchantments() {
|
||||
EnchantmentAPI.registerCustomEnchantment(new DiamondArmor());
|
||||
}
|
||||
}
|
@ -47,7 +47,6 @@ public class EventHandlers implements Listener {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 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){
|
||||
anvilInventory.getItem(0).setAmount(0);
|
||||
@ -56,7 +55,6 @@ public class EventHandlers implements Listener {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Check if the enchantment is allowed on elytras.
|
||||
public boolean isAllowedEnchantment(Enchantment enchant) {
|
||||
for (String s : allowedEnchantments) {
|
||||
@ -68,7 +66,6 @@ public class EventHandlers implements Listener {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Check if the enchantment is "special", i.e. cannot be enchanted by the EnchantmentAPI.
|
||||
public boolean isSpecialEnchantment(Enchantment enchant) {
|
||||
for (String s : specialEnchantments) {
|
||||
@ -80,7 +77,6 @@ public class EventHandlers implements Listener {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Check if the elytra being checked is an armored one.
|
||||
public boolean isArmoredElytra(ItemStack elytra) {
|
||||
if (elytra.hasItemMeta() && elytra.getType() == Material.ELYTRA)
|
||||
@ -92,12 +88,10 @@ public class EventHandlers implements Listener {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Copy enchants of 2 items to one item.
|
||||
public ItemStack addEnchants(ItemStack itemOne, ItemStack itemTwo, Player p) {
|
||||
// Create the resulting item and apply the diamond armor tier enchantment to it.
|
||||
ItemStack result = itemOne.clone();
|
||||
|
||||
// Get the enchantments of the first and second item in the anvil.
|
||||
Map<Enchantment, Integer> enchantments0 = itemOne.getEnchantments();
|
||||
Map<Enchantment, Integer> enchantments1 = itemTwo.getEnchantments();
|
||||
@ -106,7 +100,6 @@ public class EventHandlers implements Listener {
|
||||
EnchantmentStorageMeta meta = (EnchantmentStorageMeta)itemTwo.getItemMeta();
|
||||
enchantments1 = meta.getStoredEnchants();
|
||||
}
|
||||
|
||||
// Copy enchantments from item1 to result.
|
||||
if (enchantments1!=null) {
|
||||
for (Map.Entry<Enchantment, Integer> entry : enchantments1.entrySet()) {
|
||||
@ -133,12 +126,10 @@ public class EventHandlers implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Copy enchants of 2 items to one item.
|
||||
public ItemStack repairItem(ItemStack one, ItemStack two) {
|
||||
// Create the resulting item.
|
||||
@ -154,7 +145,6 @@ public class EventHandlers implements Listener {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Handle the anvil related parts.
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent e) {
|
||||
@ -176,8 +166,7 @@ public class EventHandlers implements Listener {
|
||||
// Clean the anvil's inventory after transferring the items.
|
||||
cleanAnvil(anvilInventory);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -260,7 +249,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.
|
||||
@EventHandler
|
||||
public void onPlayerDamage (EntityDamageEvent e) {
|
||||
@ -270,12 +258,11 @@ public class EventHandlers implements Listener {
|
||||
if (p.getInventory().getChestplate().getType() == Material.ELYTRA && isArmoredElytra(p.getInventory().getChestplate())) {
|
||||
DamageCause cause = e.getCause();
|
||||
if (cause!=DamageCause.DROWNING && cause!=DamageCause.STARVATION && cause!=DamageCause.SUFFOCATION &&
|
||||
cause!=DamageCause.SUICIDE && cause!=DamageCause.FLY_INTO_WALL && cause!=DamageCause.POISON) {
|
||||
cause!=DamageCause.SUICIDE && cause!=DamageCause.FLY_INTO_WALL && cause!=DamageCause.POISON) {
|
||||
|
||||
int durability = p.getInventory().getChestplate().getDurability();
|
||||
int maxDurability = p.getInventory().getChestplate().getType().getMaxDurability();
|
||||
int newDurability = (int) (durability + ((int)(e.getDamage()/4) > 1 ? (int)(e.getDamage()/4) : 1));
|
||||
|
||||
// If the elytra has the durability enchantment.
|
||||
if (p.getInventory().getChestplate().containsEnchantment(Enchantment.DURABILITY)) {
|
||||
Random r = new Random();
|
||||
@ -301,7 +288,6 @@ public class EventHandlers implements Listener {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Remove item from player's chestplate slot and puts it in their normal inventory.
|
||||
public void enquipChestPlayer(Player p) {
|
||||
p.getInventory().addItem(p.getInventory().getChestplate());
|
||||
@ -309,7 +295,6 @@ public class EventHandlers implements Listener {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Check if the player is trying to equip a broken elytra (and prevent that).
|
||||
@EventHandler
|
||||
public void playerEquipsArmor(InventoryClickEvent e){
|
||||
|
@ -1,18 +0,0 @@
|
||||
package nl.pim16aap2.armoredElytra.enchantments;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.rit.sucy.CustomEnchantment;
|
||||
|
||||
public class DiamondArmor extends CustomEnchantment {
|
||||
|
||||
// List of items to enchant onto through an enchanting table
|
||||
static final Material[] DIAMOND_ARMOR_ITEMS = new Material[] {Material.STICK};
|
||||
static final String name = "Diamond Armor Tier";
|
||||
|
||||
public DiamondArmor() {
|
||||
super(name, DIAMOND_ARMOR_ITEMS, 0);
|
||||
this.max = 1;
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
name: ArmoredElytra
|
||||
main: nl.pim16aap2.armoredElytra.ArmoredElytra
|
||||
version: 0.1
|
||||
version: 1.0
|
||||
author: Pim
|
||||
softdepend:
|
||||
- EnchantmentAPI
|
Loading…
x
Reference in New Issue
Block a user