diff --git a/pom.xml b/pom.xml
index 5238cb9..fcc66ec 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
nl.pim16aap2
ArmoredElytra
- 2.1.9-SNAPSHOT
+ 2.2.1-SNAPSHOT
diff --git a/src/main/java/nl/pim16aap2/armoredElytra/ArmoredElytra.java b/src/main/java/nl/pim16aap2/armoredElytra/ArmoredElytra.java
index e3e38ea..5be0285 100644
--- a/src/main/java/nl/pim16aap2/armoredElytra/ArmoredElytra.java
+++ b/src/main/java/nl/pim16aap2/armoredElytra/ArmoredElytra.java
@@ -26,32 +26,32 @@ import nl.pim16aap2.armoredElytra.util.Update;
public class ArmoredElytra extends JavaPlugin implements Listener
{
- private NBTEditor nbtEditor;
- private ConfigLoader config;
+ private NBTEditor nbtEditor;
+ private ConfigLoader config;
- private String usageDeniedMessage;
- private String elytraReceivedMessage;
- private String elytraName;
- private String elytraLore;
- private boolean upToDate;
- private boolean uninstallMode;
+ private String usageDeniedMessage;
+ private String elytraReceivedMessage;
+ private String elytraName;
+ private String elytraLore;
+ private boolean upToDate;
+ private boolean uninstallMode;
@Override
public void onEnable()
{
// Load the settings from the config file.
- config = new ConfigLoader(this);
+ config = new ConfigLoader(this);
// Replace color codes by the corresponding colors.
- usageDeniedMessage = config.getString("usageDeniedMessage" ).replaceAll("&((?i)[0-9a-fk-or])", "\u00A7$1");
- elytraReceivedMessage = config.getString("elytraReceivedMessage").replaceAll("&((?i)[0-9a-fk-or])", "\u00A7$1");
- elytraName = config.getString("elytraName" ).replaceAll("&((?i)[0-9a-fk-or])", "\u00A7$1");
- elytraLore = config.getString("elytraLore" ).replaceAll("&((?i)[0-9a-fk-or])", "\u00A7$1");
+ usageDeniedMessage = config.getString("usageDeniedMessage" ).replaceAll("&((?i)[0-9a-fk-or])", "\u00A7$1");
+ elytraReceivedMessage = config.getString("elytraReceivedMessage" ).replaceAll("&((?i)[0-9a-fk-or])", "\u00A7$1");
+ elytraName = config.getString("elytraName" ).replaceAll("&((?i)[0-9a-fk-or])", "\u00A7$1");
+ elytraLore = config.getString("elytraLore" ).replaceAll("&((?i)[0-9a-fk-or])", "\u00A7$1");
// Change the string to null if it says "NONE".
- usageDeniedMessage = (Objects.equals(usageDeniedMessage, new String("NONE")) ? null : usageDeniedMessage );
- elytraReceivedMessage = (Objects.equals(elytraReceivedMessage, new String("NONE")) ? null : elytraReceivedMessage);
- elytraLore = (Objects.equals(elytraLore, new String("NONE")) ? null : elytraLore );
+ usageDeniedMessage = (Objects.equals(usageDeniedMessage, new String("NONE")) ? null : usageDeniedMessage );
+ elytraReceivedMessage = (Objects.equals(elytraReceivedMessage, new String("NONE")) ? null : elytraReceivedMessage);
+ elytraLore = (Objects.equals(elytraLore, new String("NONE")) ? null : elytraLore );
// Check if the plugin should go into uninstall mode.
uninstallMode = config.getBool("uninstallMode");
@@ -69,6 +69,7 @@ public class ArmoredElytra extends JavaPlugin implements Listener
if (updateStatus > 0)
{
// TODO: Insert download link to latest version.
+ // TODO: Use Spiget instead of the unreliable BukkitDev's update stuff?
// TODO: Add auto update option?
// Load the loginHandler to show messages to the user when they join.
@@ -91,13 +92,13 @@ public class ArmoredElytra extends JavaPlugin implements Listener
// Are stats allowed?
if (config.getBool("allowStats"))
{
- myLogger(Level.INFO, "Enabling stats!");
+ myLogger(Level.INFO, "Enabling stats! Thanks, it really helps!");
@SuppressWarnings("unused")
Metrics metrics = new Metrics(this);
}
else
// Y u do dis? :(
- myLogger(Level.INFO, "Stats disabled, not laoding stats :(");
+ myLogger(Level.INFO, "Stats disabled, not laoding stats ::(... Please consider enabling it! I am a simple man, seeing higher user numbers helps me stay motivated!");
diff --git a/src/main/java/nl/pim16aap2/armoredElytra/handlers/EventHandlers.java b/src/main/java/nl/pim16aap2/armoredElytra/handlers/EventHandlers.java
index 38c4856..8d1729e 100644
--- a/src/main/java/nl/pim16aap2/armoredElytra/handlers/EventHandlers.java
+++ b/src/main/java/nl/pim16aap2/armoredElytra/handlers/EventHandlers.java
@@ -1,17 +1,13 @@
package nl.pim16aap2.armoredElytra.handlers;
-import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.logging.Level;
-import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
-import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
-import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventoryAnvil;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -28,9 +24,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.bukkit.scheduler.BukkitRunnable;
-import net.minecraft.server.v1_12_R1.ContainerAnvil;
-import net.minecraft.server.v1_12_R1.Container;
-import net.minecraft.server.v1_12_R1.ContainerDispenser;
import nl.pim16aap2.armoredElytra.ArmoredElytra;
import nl.pim16aap2.armoredElytra.nms.NBTEditor;
import nl.pim16aap2.armoredElytra.util.Action;
@@ -390,8 +383,8 @@ public class EventHandlers implements Listener
}
// Check if either itemA or itemB is unoccupied.
- if (itemA == null || itemB == null)
- // If Item2 is occupied despite itemA or itemB not being occupied.
+ if ((itemA == null || itemB == null) && nbtEditor.getArmorTier(event.getInventory().getItem(2)) != ArmorTier.NONE)
+ // If Item2 is occupied despite itemA or itemB not being occupied. (only for armored elytra)/
event.setResult(null);
p.updateInventory();
}
diff --git a/src/main/java/nl/pim16aap2/armoredElytra/nms/NBTEditor_V1_10_R1.java b/src/main/java/nl/pim16aap2/armoredElytra/nms/NBTEditor_V1_10_R1.java
index 5d61ed8..bb4a1c8 100644
--- a/src/main/java/nl/pim16aap2/armoredElytra/nms/NBTEditor_V1_10_R1.java
+++ b/src/main/java/nl/pim16aap2/armoredElytra/nms/NBTEditor_V1_10_R1.java
@@ -3,6 +3,7 @@ package nl.pim16aap2.armoredElytra.nms;
import java.util.Arrays;
import org.bukkit.ChatColor;
+import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@@ -77,7 +78,12 @@ public class NBTEditor_V1_10_R1 implements NBTEditor
// Get the armor tier of the supplied item.
@Override
public ArmorTier getArmorTier(ItemStack item)
- {
+ {
+ if (item == null)
+ return ArmorTier.NONE;
+ if (item.getType() != Material.ELYTRA)
+ return ArmorTier.NONE;
+
// Get the NBT tags from the item.
NBTTagCompound compound = CraftItemStack.asNMSCopy(item).getTag();
if (compound == null)
diff --git a/src/main/java/nl/pim16aap2/armoredElytra/nms/NBTEditor_V1_11_R1.java b/src/main/java/nl/pim16aap2/armoredElytra/nms/NBTEditor_V1_11_R1.java
index 4e367ef..a171e34 100644
--- a/src/main/java/nl/pim16aap2/armoredElytra/nms/NBTEditor_V1_11_R1.java
+++ b/src/main/java/nl/pim16aap2/armoredElytra/nms/NBTEditor_V1_11_R1.java
@@ -78,7 +78,9 @@ public class NBTEditor_V1_11_R1 implements NBTEditor
// Get the armor tier of the supplied item.
@Override
public ArmorTier getArmorTier(ItemStack item)
- {
+ {
+ if (item == null)
+ return ArmorTier.NONE;
if (item.getType() != Material.ELYTRA)
return ArmorTier.NONE;
diff --git a/src/main/java/nl/pim16aap2/armoredElytra/nms/NBTEditor_V1_12_R1.java b/src/main/java/nl/pim16aap2/armoredElytra/nms/NBTEditor_V1_12_R1.java
index d99e43c..664e1c2 100644
--- a/src/main/java/nl/pim16aap2/armoredElytra/nms/NBTEditor_V1_12_R1.java
+++ b/src/main/java/nl/pim16aap2/armoredElytra/nms/NBTEditor_V1_12_R1.java
@@ -3,6 +3,7 @@ package nl.pim16aap2.armoredElytra.nms;
import java.util.Arrays;
import org.bukkit.ChatColor;
+import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@@ -77,7 +78,12 @@ public class NBTEditor_V1_12_R1 implements NBTEditor
// Get the armor tier of the supplied item.
@Override
public ArmorTier getArmorTier(ItemStack item)
- {
+ {
+ if (item == null)
+ return ArmorTier.NONE;
+ if (item.getType() != Material.ELYTRA)
+ return ArmorTier.NONE;
+
// Get the NBT tags from the item.
NBTTagCompound compound = CraftItemStack.asNMSCopy(item).getTag();
if (compound == null)
diff --git a/src/main/java/nl/pim16aap2/armoredElytra/util/Metrics.java b/src/main/java/nl/pim16aap2/armoredElytra/util/Metrics.java
index 2ba64bc..a515abe 100644
--- a/src/main/java/nl/pim16aap2/armoredElytra/util/Metrics.java
+++ b/src/main/java/nl/pim16aap2/armoredElytra/util/Metrics.java
@@ -20,11 +20,9 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.UUID;
-import java.util.concurrent.Callable;
import java.util.logging.Level;
import java.util.zip.GZIPOutputStream;
@@ -108,35 +106,21 @@ public class Metrics {
// Load the data
serverUUID = config.getString("serverUuid");
logFailedRequests = config.getBoolean("logFailedRequests", false);
- if (config.getBoolean("enabled", true)) {
- boolean found = false;
- // Search for all other bStats Metrics classes to see if we are the first one
- for (Class> service : Bukkit.getServicesManager().getKnownServices()) {
- try {
- service.getField("B_STATS_VERSION"); // Our identifier :)
- found = true; // We aren't the first
- break;
- } catch (NoSuchFieldException ignored) { }
- }
- // Register our service
- Bukkit.getServicesManager().register(Metrics.class, this, plugin, ServicePriority.Normal);
- if (!found) {
- // We are the first!
- startSubmitting();
- }
+ boolean found = false;
+ // Search for all other bStats Metrics classes to see if we are the first one
+ for (Class> service : Bukkit.getServicesManager().getKnownServices()) {
+ try {
+ service.getField("B_STATS_VERSION"); // Our identifier :)
+ found = true; // We aren't the first
+ break;
+ } catch (NoSuchFieldException ignored) { }
}
- }
-
- /**
- * Adds a custom chart.
- *
- * @param chart The chart to add.
- */
- public void addCustomChart(CustomChart chart) {
- if (chart == null) {
- throw new IllegalArgumentException("Chart cannot be null!");
+ // Register our service
+ Bukkit.getServicesManager().register(Metrics.class, this, plugin, ServicePriority.Normal);
+ if (!found) {
+ // We are the first!
+ startSubmitting();
}
- charts.add(chart);
}
/**
@@ -376,303 +360,6 @@ public class Metrics {
}
return chart;
}
-
protected abstract JSONObject getChartData() throws Exception;
-
- }
-
- /**
- * Represents a custom simple pie.
- */
- public static class SimplePie extends CustomChart {
-
- private final Callable callable;
-
- /**
- * Class constructor.
- *
- * @param chartId The id of the chart.
- * @param callable The callable which is used to request the chart data.
- */
- public SimplePie(String chartId, Callable callable) {
- super(chartId);
- this.callable = callable;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected JSONObject getChartData() throws Exception {
- JSONObject data = new JSONObject();
- String value = callable.call();
- if (value == null || value.isEmpty()) {
- // Null = skip the chart
- return null;
- }
- data.put("value", value);
- return data;
- }
- }
-
- /**
- * Represents a custom advanced pie.
- */
- public static class AdvancedPie extends CustomChart {
-
- private final Callable