Fix incorrect armored elytra creation

- No longer making "armored elytra"s out of non-elytra items.
This commit is contained in:
Pim van der Loos 2020-08-04 14:25:53 +02:00
parent 163e6d22a2
commit 2f57f0df59
No known key found for this signature in database
GPG Key ID: C16F020ADAE6D5A8
5 changed files with 35 additions and 7 deletions

11
.gitignore vendored
View File

@ -24,3 +24,14 @@ hs_err_pid*
# Mac Files # # Mac Files #
**/.DS_Store **/.DS_Store
/target/ /target/
/lib/
.classpath
.directory
.externalToolBuilders/
.idea/
.project
.settings/
ArmoredElytra (1).iml
NBTChange
dependency-reduced-pom.xml
mover.xml

View File

@ -50,6 +50,14 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>n3kas.ae</groupId>-->
<!-- <artifactId>AdvancedEnchantments</artifactId>-->
<!-- <scope>system</scope>-->
<!-- <version>6.5.9</version>-->
<!-- <systemPath>${basedir}/lib/AdvancedEnchantments-6.5.9.jar</systemPath>-->
<!-- </dependency>-->
<!-- <!--
<dependency> <dependency>
<groupId>com.github.Arnuh</groupId> <groupId>com.github.Arnuh</groupId>

View File

@ -28,8 +28,7 @@ import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
// TODO: Figure out if the config really does read the list of enchantments accurately. A bug report with a customized config seemed to load the default settings... // TODO: Figure out if the config really does read the list of enchantments accurately. A bug report with a customized config seemed to load the default settings...
// TODO: Verify enchantments on startup. Remove them from the list if they're invalid. // TODO: Verify enchantments on startup.
// TODO: Don't delete the config/translation file. Look at BigDoors.
// TODO: Enchanting should require XP. // TODO: Enchanting should require XP.
public class ArmoredElytra extends JavaPlugin implements Listener public class ArmoredElytra extends JavaPlugin implements Listener
@ -58,6 +57,12 @@ public class ArmoredElytra extends JavaPlugin implements Listener
return; return;
} }
//// Material mat = Material.ELYTRA;
//// n3kas.ae.Core.canApplyTo(mat);
// for (String str : n3kas.ae.api.getAllEnchantments())
// System.out.println(str);
// System.exit(0);
nbtEditor = minecraftVersion.isNewerThan(MinecraftVersion.v1_15) ? new NBTEditor() : new NBTEditor_legacy(); nbtEditor = minecraftVersion.isNewerThan(MinecraftVersion.v1_15) ? new NBTEditor() : new NBTEditor_legacy();
if (isBlacklistedVersion()) if (isBlacklistedVersion())
{ {

View File

@ -98,9 +98,12 @@ public class EventHandlers implements Listener
// Clean >=1.10 inventories. // Clean >=1.10 inventories.
private void cleanAnvilNew(AnvilInventory anvilInventory) private void cleanAnvilNew(AnvilInventory anvilInventory)
{ {
anvilInventory.getItem(0).setAmount(0); if (anvilInventory.getItem(0) != null)
anvilInventory.getItem(1).setAmount(anvilInventory.getItem(1).getAmount() - 1); anvilInventory.getItem(0).setAmount(0);
anvilInventory.getItem(2).setAmount(0); if (anvilInventory.getItem(1) != null)
anvilInventory.getItem(1).setAmount(anvilInventory.getItem(1).getAmount() - 1);
if (anvilInventory.getItem(2) != null)
anvilInventory.getItem(2).setAmount(0);
} }
// Check if the enchantment is allowed on elytras. // Check if the enchantment is allowed on elytras.
@ -408,7 +411,7 @@ public class EventHandlers implements Listener
int slot = e.getRawSlot(); int slot = e.getRawSlot();
if (slot == 2 && anvilInventory.getItem(0) != null && anvilInventory.getItem(1) != null && if (slot == 2 && anvilInventory.getItem(0) != null && anvilInventory.getItem(1) != null &&
anvilInventory.getItem(2) != null) anvilInventory.getItem(2) != null && anvilInventory.getItem(2).getType() == Material.ELYTRA)
{ {
ArmorTier armortier = ArmoredElytra.getInstance().getNbtEditor().getArmorTier(anvilInventory.getItem(2)); ArmorTier armortier = ArmoredElytra.getInstance().getNbtEditor().getArmorTier(anvilInventory.getItem(2));

View File

@ -2,6 +2,7 @@ name: ArmoredElytra
main: nl.pim16aap2.armoredElytra.ArmoredElytra main: nl.pim16aap2.armoredElytra.ArmoredElytra
version: ${project.version} version: ${project.version}
author: pim16aap2 author: pim16aap2
softdepend: [AdvancedEnchantments]
api-version: 1.13 api-version: 1.13
commands: commands:
ArmoredElytra: ArmoredElytra:
@ -39,4 +40,4 @@ permissions:
armoredelytra.give.diamond: armoredelytra.give.diamond:
description: Allow the player to spawn in diamond tier armored elytras. description: Allow the player to spawn in diamond tier armored elytras.
armoredElytra.admin: armoredElytra.admin:
description: Receive a message if this plugin is out of date when joining the server. description: Receive a message if this plugin is out of date when joining the server.