diff --git a/eco-api/src/main/java/com/willfp/eco/internal/config/AbstractConfig.java b/eco-api/src/main/java/com/willfp/eco/internal/config/AbstractConfig.java index bcf81b77..2efb8fef 100644 --- a/eco-api/src/main/java/com/willfp/eco/internal/config/AbstractConfig.java +++ b/eco-api/src/main/java/com/willfp/eco/internal/config/AbstractConfig.java @@ -16,7 +16,7 @@ import java.io.InputStreamReader; import java.io.OutputStream; import java.nio.charset.StandardCharsets; -public abstract class AbstractConfig extends AbstractUndefinedConfig { +public abstract class AbstractConfig extends ConfigWrapper { /** * The physical config file, as stored on disk. */ diff --git a/eco-api/src/main/java/com/willfp/eco/internal/config/AbstractUndefinedConfig.java b/eco-api/src/main/java/com/willfp/eco/internal/config/ConfigWrapper.java similarity index 97% rename from eco-api/src/main/java/com/willfp/eco/internal/config/AbstractUndefinedConfig.java rename to eco-api/src/main/java/com/willfp/eco/internal/config/ConfigWrapper.java index 476481db..9731cb21 100644 --- a/eco-api/src/main/java/com/willfp/eco/internal/config/AbstractUndefinedConfig.java +++ b/eco-api/src/main/java/com/willfp/eco/internal/config/ConfigWrapper.java @@ -17,7 +17,7 @@ import java.util.Map; import java.util.Objects; @SuppressWarnings({"unchecked", "unused"}) -public abstract class AbstractUndefinedConfig extends PluginDependent { +public abstract class ConfigWrapper extends PluginDependent { /** * The linked {@link YamlConfiguration} where values are physically stored. */ @@ -35,8 +35,8 @@ public abstract class AbstractUndefinedConfig extends PluginDependent { * @param configName The name of the config * @param plugin The plugin. */ - protected AbstractUndefinedConfig(@NotNull final String configName, - @NotNull final AbstractEcoPlugin plugin) { + protected ConfigWrapper(@NotNull final String configName, + @NotNull final AbstractEcoPlugin plugin) { super(plugin); } diff --git a/eco-api/src/main/java/com/willfp/eco/internal/drops/impl/InternalDropQueue.java b/eco-api/src/main/java/com/willfp/eco/internal/drops/impl/InternalDropQueue.java index c2821812..e5671436 100644 --- a/eco-api/src/main/java/com/willfp/eco/internal/drops/impl/InternalDropQueue.java +++ b/eco-api/src/main/java/com/willfp/eco/internal/drops/impl/InternalDropQueue.java @@ -1,7 +1,7 @@ package com.willfp.eco.internal.drops.impl; import com.willfp.eco.internal.drops.AbstractDropQueue; -import com.willfp.eco.util.drops.telekinesis.TelekinesisUtils; +import com.willfp.eco.util.TelekinesisUtils; import lombok.AccessLevel; import lombok.Getter; import org.bukkit.Bukkit; diff --git a/eco-api/src/main/java/com/willfp/eco/internal/extensions/EcoExtensionLoader.java b/eco-api/src/main/java/com/willfp/eco/internal/extensions/EcoExtensionLoader.java index 09301860..c2ba31f7 100644 --- a/eco-api/src/main/java/com/willfp/eco/internal/extensions/EcoExtensionLoader.java +++ b/eco-api/src/main/java/com/willfp/eco/internal/extensions/EcoExtensionLoader.java @@ -3,7 +3,7 @@ package com.willfp.eco.internal.extensions; import com.willfp.eco.util.extensions.Extension; import com.willfp.eco.util.extensions.MalformedExtensionException; -import com.willfp.eco.util.extensions.loader.ExtensionLoader; +import com.willfp.eco.util.extensions.ExtensionLoader; import com.willfp.eco.util.internal.PluginDependent; import com.willfp.eco.util.plugin.AbstractEcoPlugin; import org.apache.commons.lang.Validate; @@ -99,7 +99,7 @@ public class EcoExtensionLoader extends PluginDependent implements ExtensionLoad Validate.notNull(name, "Name is missing!"); Validate.notNull(version, "Version is missing!"); - Extension.ExtensionMetadata metadata = new Extension.ExtensionMetadata(version, name); + ExtensionMetadata metadata = new ExtensionMetadata(version, name); Class> cls; Object object = null; @@ -129,15 +129,6 @@ public class EcoExtensionLoader extends PluginDependent implements ExtensionLoad extensions.clear(); } - /** - * Unloads, then loads all extensions. - */ - @Override - public void reloadExtensions() { - unloadExtensions(); - loadExtensions(); - } - /** * Returns all loaded extensions. * diff --git a/eco-api/src/main/java/com/willfp/eco/internal/extensions/ExtensionMetadata.java b/eco-api/src/main/java/com/willfp/eco/internal/extensions/ExtensionMetadata.java new file mode 100644 index 00000000..fbf41e32 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/internal/extensions/ExtensionMetadata.java @@ -0,0 +1,32 @@ +package com.willfp.eco.internal.extensions; + +import lombok.Getter; +import org.jetbrains.annotations.NotNull; + +public class ExtensionMetadata { + /** + * The version of the extension. + */ + @NotNull + @Getter + private final String version; + + /** + * The extension's name. + */ + @NotNull + @Getter + private final String name; + + /** + * Create a new extension metadata. + * + * @param version The version for the extension to be. + * @param name The name of the extension. + */ + public ExtensionMetadata(@NotNull final String version, + @NotNull final String name) { + this.version = version; + this.name = name; + } +} diff --git a/eco-api/src/main/java/com/willfp/eco/util/drops/telekinesis/TelekinesisUtils.java b/eco-api/src/main/java/com/willfp/eco/util/TelekinesisUtils.java similarity index 96% rename from eco-api/src/main/java/com/willfp/eco/util/drops/telekinesis/TelekinesisUtils.java rename to eco-api/src/main/java/com/willfp/eco/util/TelekinesisUtils.java index eeac26c8..aeb17082 100644 --- a/eco-api/src/main/java/com/willfp/eco/util/drops/telekinesis/TelekinesisUtils.java +++ b/eco-api/src/main/java/com/willfp/eco/util/TelekinesisUtils.java @@ -1,4 +1,4 @@ -package com.willfp.eco.util.drops.telekinesis; +package com.willfp.eco.util; import lombok.experimental.UtilityClass; import org.bukkit.entity.Player; diff --git a/eco-api/src/main/java/com/willfp/eco/util/config/StaticOptionalConfig.java b/eco-api/src/main/java/com/willfp/eco/util/config/StaticOptionalConfig.java index 53610821..91baa42a 100644 --- a/eco-api/src/main/java/com/willfp/eco/util/config/StaticOptionalConfig.java +++ b/eco-api/src/main/java/com/willfp/eco/util/config/StaticOptionalConfig.java @@ -1,11 +1,11 @@ package com.willfp.eco.util.config; -import com.willfp.eco.internal.config.AbstractUndefinedConfig; +import com.willfp.eco.internal.config.ConfigWrapper; import com.willfp.eco.util.plugin.AbstractEcoPlugin; import org.bukkit.configuration.file.YamlConfiguration; import org.jetbrains.annotations.NotNull; -public abstract class StaticOptionalConfig extends AbstractUndefinedConfig { +public abstract class StaticOptionalConfig extends ConfigWrapper { /** * Config implementation for passing YamlConfigurations. *
diff --git a/eco-api/src/main/java/com/willfp/eco/util/events/ArmorEquipEvent.java b/eco-api/src/main/java/com/willfp/eco/util/events/ArmorEquipEvent.java
new file mode 100644
index 00000000..ae2c82c5
--- /dev/null
+++ b/eco-api/src/main/java/com/willfp/eco/util/events/ArmorEquipEvent.java
@@ -0,0 +1,31 @@
+package com.willfp.eco.util.events;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.NotNull;
+
+
+public class ArmorEquipEvent extends PlayerEvent {
+ private static final HandlerList HANDLERS = new HandlerList();
+
+ public ArmorEquipEvent(@NotNull final Player player) {
+ super(player);
+ }
+
+ /**
+ * Gets a list of handlers handling this event.
+ *
+ * @return A list of handlers handling this event.
+ */
+
+ @Override
+ @NotNull
+ public HandlerList getHandlers() {
+ return HANDLERS;
+ }
+
+ public static HandlerList getHandlerList() {
+ return HANDLERS;
+ }
+}
diff --git a/eco-api/src/main/java/com/willfp/eco/util/events/entitydeathbyentity/EntityDeathByEntityEvent.java b/eco-api/src/main/java/com/willfp/eco/util/events/EntityDeathByEntityEvent.java
similarity index 97%
rename from eco-api/src/main/java/com/willfp/eco/util/events/entitydeathbyentity/EntityDeathByEntityEvent.java
rename to eco-api/src/main/java/com/willfp/eco/util/events/EntityDeathByEntityEvent.java
index 33cec908..bfe1da86 100644
--- a/eco-api/src/main/java/com/willfp/eco/util/events/entitydeathbyentity/EntityDeathByEntityEvent.java
+++ b/eco-api/src/main/java/com/willfp/eco/util/events/EntityDeathByEntityEvent.java
@@ -1,4 +1,4 @@
-package com.willfp.eco.util.events.entitydeathbyentity;
+package com.willfp.eco.util.events;
import lombok.Getter;
import org.bukkit.entity.Entity;
diff --git a/eco-api/src/main/java/com/willfp/eco/util/events/naturalexpgainevent/NaturalExpGainEvent.java b/eco-api/src/main/java/com/willfp/eco/util/events/NaturalExpGainEvent.java
similarity index 95%
rename from eco-api/src/main/java/com/willfp/eco/util/events/naturalexpgainevent/NaturalExpGainEvent.java
rename to eco-api/src/main/java/com/willfp/eco/util/events/NaturalExpGainEvent.java
index 8c772f12..7c355c74 100644
--- a/eco-api/src/main/java/com/willfp/eco/util/events/naturalexpgainevent/NaturalExpGainEvent.java
+++ b/eco-api/src/main/java/com/willfp/eco/util/events/NaturalExpGainEvent.java
@@ -1,4 +1,4 @@
-package com.willfp.eco.util.events.naturalexpgainevent;
+package com.willfp.eco.util.events;
import lombok.Getter;
import org.bukkit.event.Event;
diff --git a/eco-api/src/main/java/com/willfp/eco/util/events/armorequip/ArmorEquipEvent.java b/eco-api/src/main/java/com/willfp/eco/util/events/armorequip/ArmorEquipEvent.java
deleted file mode 100644
index 0251b50a..00000000
--- a/eco-api/src/main/java/com/willfp/eco/util/events/armorequip/ArmorEquipEvent.java
+++ /dev/null
@@ -1,127 +0,0 @@
-package com.willfp.eco.util.events.armorequip;
-
-import org.bukkit.entity.Player;
-import org.bukkit.event.Cancellable;
-import org.bukkit.event.HandlerList;
-import org.bukkit.event.player.PlayerEvent;
-import org.bukkit.inventory.ItemStack;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * @author Arnah
- * @since Jul 30, 2015
- */
-public class ArmorEquipEvent extends PlayerEvent implements Cancellable {
- private static final HandlerList HANDLERS = new HandlerList();
- private boolean cancel = false;
- private final EquipMethod equipType;
- private final ArmorType type;
- private ItemStack oldArmorPiece;
- private ItemStack newArmorPiece;
-
- public ArmorEquipEvent(@NotNull final Player player,
- @Nullable final EquipMethod equipType,
- @Nullable final ArmorType type,
- @Nullable final ItemStack oldArmorPiece,
- @Nullable final ItemStack newArmorPiece) {
- super(player);
- this.equipType = equipType;
- this.type = type;
- this.oldArmorPiece = oldArmorPiece;
- this.newArmorPiece = newArmorPiece;
- }
-
- /**
- * Gets a list of handlers handling this event.
- *
- * @return A list of handlers handling this event.
- */
-
- @Override
- public @NotNull HandlerList getHandlers() {
- return HANDLERS;
- }
-
- public static HandlerList getHandlerList() {
- return HANDLERS;
- }
-
- /**
- * Sets if this event should be cancelled.
- *
- * @param cancel If this event should be cancelled.
- */
- public final void setCancelled(final boolean cancel) {
- this.cancel = cancel;
- }
-
- /**
- * Gets if this event is cancelled.
- *
- * @return If this event is cancelled
- */
- public final boolean isCancelled() {
- return cancel;
- }
-
- public final ArmorType getType() {
- return type;
- }
-
- public final ItemStack getOldArmorPiece() {
- return oldArmorPiece;
- }
-
- public final void setOldArmorPiece(final ItemStack oldArmorPiece) {
- this.oldArmorPiece = oldArmorPiece;
- }
-
- public final ItemStack getNewArmorPiece() {
- return newArmorPiece;
- }
-
- public final void setNewArmorPiece(final ItemStack newArmorPiece) {
- this.newArmorPiece = newArmorPiece;
- }
-
- public EquipMethod getMethod() {
- return equipType;
- }
-
- public enum EquipMethod {
- /**
- * When you shift click an armor piece to equip or unequip
- */
- SHIFT_CLICK,
- /**
- * When you drag and drop the item to equip or unequip
- */
- DRAG,
- /**
- * When you manually equip or unequip the item. Use to be DRAG
- */
- PICK_DROP,
- /**
- * When you right click an armor piece in the hotbar without the inventory open to equip.
- */
- HOTBAR,
- /**
- * When you press the hotbar slot number while hovering over the armor slot to equip or unequip
- */
- HOTBAR_SWAP,
- /**
- * When in range of a dispenser that shoots an armor piece to equip.
- * Requires the spigot version to have {@link org.bukkit.event.block.BlockDispenseArmorEvent} implemented.
- */
- DISPENSER,
- /**
- * When an armor piece is removed due to it losing all durability.
- */
- BROKE,
- /**
- * When you die causing all armor to unequip
- */
- DEATH
- }
-}
diff --git a/eco-api/src/main/java/com/willfp/eco/util/extensions/Extension.java b/eco-api/src/main/java/com/willfp/eco/util/extensions/Extension.java
index 1301c228..ce55e4aa 100644
--- a/eco-api/src/main/java/com/willfp/eco/util/extensions/Extension.java
+++ b/eco-api/src/main/java/com/willfp/eco/util/extensions/Extension.java
@@ -1,10 +1,10 @@
package com.willfp.eco.util.extensions;
+import com.willfp.eco.internal.extensions.ExtensionMetadata;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import lombok.AccessLevel;
import lombok.Getter;
import org.apache.commons.lang.Validate;
-import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
public abstract class Extension {
@@ -71,7 +71,7 @@ public abstract class Extension {
*/
public final String getName() {
Validate.notNull(metadata, "Metadata cannot be null!");
- return this.metadata.name;
+ return this.metadata.getName();
}
/**
@@ -81,36 +81,6 @@ public abstract class Extension {
*/
public final String getVersion() {
Validate.notNull(metadata, "Metadata cannot be null!");
- return this.metadata.version;
- }
-
- /**
- * Wrapper for the string and version of the extension.
- * Contains versions and name.
- * Designed for internal use.
- */
- @ApiStatus.Internal
- public static final class ExtensionMetadata {
- /**
- * The version of the extension.
- */
- private final @NotNull String version;
-
- /**
- * The extension's name.
- */
- private final @NotNull String name;
-
- /**
- * Create a new extension metadata.
- *
- * @param version The version for the extension to be.
- * @param name The name of the extension.
- */
- public ExtensionMetadata(@NotNull final String version,
- @NotNull final String name) {
- this.version = version;
- this.name = name;
- }
+ return this.metadata.getVersion();
}
}
diff --git a/eco-api/src/main/java/com/willfp/eco/util/extensions/loader/ExtensionLoader.java b/eco-api/src/main/java/com/willfp/eco/util/extensions/ExtensionLoader.java
similarity index 75%
rename from eco-api/src/main/java/com/willfp/eco/util/extensions/loader/ExtensionLoader.java
rename to eco-api/src/main/java/com/willfp/eco/util/extensions/ExtensionLoader.java
index 48a502d4..8d9b5bee 100644
--- a/eco-api/src/main/java/com/willfp/eco/util/extensions/loader/ExtensionLoader.java
+++ b/eco-api/src/main/java/com/willfp/eco/util/extensions/ExtensionLoader.java
@@ -1,6 +1,4 @@
-package com.willfp.eco.util.extensions.loader;
-
-import com.willfp.eco.util.extensions.Extension;
+package com.willfp.eco.util.extensions;
import java.util.Set;
@@ -20,11 +18,6 @@ public interface ExtensionLoader {
*/
void unloadExtensions();
- /**
- * Reload all extensions.
- */
- void reloadExtensions();
-
/**
* Retrieve a set of all loaded extensions.
*
diff --git a/eco-api/src/main/java/com/willfp/eco/util/plugin/AbstractEcoPlugin.java b/eco-api/src/main/java/com/willfp/eco/util/plugin/AbstractEcoPlugin.java
index 7c3b353f..84e9d5e8 100644
--- a/eco-api/src/main/java/com/willfp/eco/util/plugin/AbstractEcoPlugin.java
+++ b/eco-api/src/main/java/com/willfp/eco/util/plugin/AbstractEcoPlugin.java
@@ -17,7 +17,7 @@ import com.willfp.eco.util.config.configs.Lang;
import com.willfp.eco.util.config.updating.ConfigHandler;
import com.willfp.eco.util.display.Display;
import com.willfp.eco.util.display.DisplayModule;
-import com.willfp.eco.util.extensions.loader.ExtensionLoader;
+import com.willfp.eco.util.extensions.ExtensionLoader;
import com.willfp.eco.util.integrations.IntegrationLoader;
import com.willfp.eco.util.integrations.placeholder.PlaceholderManager;
import com.willfp.eco.util.integrations.placeholder.plugins.PlaceholderIntegrationPAPI;
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/EcoPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/EcoPlugin.java
index ea18e092..9b2e686e 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/EcoPlugin.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/EcoPlugin.java
@@ -33,8 +33,8 @@ import com.willfp.eco.util.TridentUtils;
import com.willfp.eco.util.command.AbstractCommand;
import com.willfp.eco.util.display.Display;
import com.willfp.eco.util.display.DisplayModule;
-import com.willfp.eco.util.events.armorequip.ArmorListener;
-import com.willfp.eco.util.events.armorequip.DispenserArmorListener;
+import com.willfp.eco.spigot.eventlisteners.ArmorListener;
+import com.willfp.eco.spigot.eventlisteners.DispenserArmorListener;
import com.willfp.eco.util.integrations.IntegrationLoader;
import com.willfp.eco.util.integrations.anticheat.AnticheatManager;
import com.willfp.eco.util.integrations.antigrief.AntigriefManager;
diff --git a/eco-api/src/main/java/com/willfp/eco/util/events/armorequip/ArmorListener.java b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/eventlisteners/ArmorListener.java
similarity index 72%
rename from eco-api/src/main/java/com/willfp/eco/util/events/armorequip/ArmorListener.java
rename to eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/eventlisteners/ArmorListener.java
index 7649236a..5bd41e14 100644
--- a/eco-api/src/main/java/com/willfp/eco/util/events/armorequip/ArmorListener.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/eventlisteners/ArmorListener.java
@@ -1,5 +1,6 @@
-package com.willfp.eco.util.events.armorequip;
+package com.willfp.eco.spigot.eventlisteners;
+import com.willfp.eco.util.events.ArmorEquipEvent;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@@ -23,16 +24,7 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import static com.willfp.eco.util.events.armorequip.ArmorEquipEvent.EquipMethod;
-
-/**
- * @author Arnah
- * @since Jul 30, 2015
- */
-@SuppressWarnings("deprecation")
public class ArmorListener implements Listener {
- //Event Priority is highest because other plugins might cancel the events before we check.
-
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public final void inventoryClick(@NotNull final InventoryClickEvent event) {
boolean shift = false;
@@ -82,28 +74,17 @@ public class ArmorListener implements Listener {
|| newArmorType.equals(ArmorType.BOOTS)
&& (equipping == isAirOrNull(event.getWhoClicked().getInventory().getBoots()))) {
ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(
- (Player) event.getWhoClicked(),
- EquipMethod.SHIFT_CLICK,
- newArmorType,
- equipping ? null : event.getCurrentItem(),
- equipping ? event.getCurrentItem() : null
+ (Player) event.getWhoClicked()
);
Bukkit.getPluginManager().callEvent(armorEquipEvent);
- if (armorEquipEvent.isCancelled()) {
- event.setCancelled(true);
- }
}
}
} else {
- ItemStack newArmorPiece = event.getCursor();
- ItemStack oldArmorPiece = event.getCurrentItem();
if (numberkey) {
if (event.getClickedInventory().getType().equals(InventoryType.PLAYER)) {
ItemStack hotbarItem = event.getClickedInventory().getItem(event.getHotbarButton());
if (!isAirOrNull(hotbarItem)) {
newArmorType = ArmorType.matchType(hotbarItem);
- newArmorPiece = hotbarItem;
- oldArmorPiece = event.getClickedInventory().getItem(event.getSlot());
} else {
newArmorType = ArmorType.matchType(!isAirOrNull(event.getCurrentItem()) ? event.getCurrentItem() : event.getCursor());
}
@@ -114,15 +95,8 @@ public class ArmorListener implements Listener {
}
}
if (newArmorType != null && event.getRawSlot() == newArmorType.getSlot()) {
- ArmorEquipEvent.EquipMethod method = ArmorEquipEvent.EquipMethod.PICK_DROP;
- if (event.getAction().equals(InventoryAction.HOTBAR_SWAP) || numberkey) {
- method = ArmorEquipEvent.EquipMethod.HOTBAR_SWAP;
- }
- ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent((Player) event.getWhoClicked(), method, newArmorType, oldArmorPiece, newArmorPiece);
+ ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent((Player) event.getWhoClicked());
Bukkit.getPluginManager().callEvent(armorEquipEvent);
- if (armorEquipEvent.isCancelled()) {
- event.setCancelled(true);
- }
}
}
}
@@ -152,12 +126,8 @@ public class ArmorListener implements Listener {
&& isAirOrNull(e.getPlayer().getInventory().getLeggings())
|| newArmorType.equals(ArmorType.BOOTS)
&& isAirOrNull(e.getPlayer().getInventory().getBoots())) {
- ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(e.getPlayer(), ArmorEquipEvent.EquipMethod.HOTBAR, ArmorType.matchType(e.getItem()), null, e.getItem());
+ ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(e.getPlayer());
Bukkit.getPluginManager().callEvent(armorEquipEvent);
- if (armorEquipEvent.isCancelled()) {
- e.setCancelled(true);
- player.updateInventory();
- }
}
}
}
@@ -165,34 +135,25 @@ public class ArmorListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void inventoryDrag(@NotNull final InventoryDragEvent event) {
- // getType() seems to always be even.
- // Old Cursor gives the item you are equipping
- // Raw slot is the ArmorType slot
- // Can't replace armor using this method making getCursor() useless.
ArmorType type = ArmorType.matchType(event.getOldCursor());
if (event.getRawSlots().isEmpty()) {
return;
}
if (type != null && type.getSlot() == event.getRawSlots().stream().findFirst().orElse(0)) {
- ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent((Player) event.getWhoClicked(), EquipMethod.DRAG, type, null, event.getOldCursor());
+ ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent((Player) event.getWhoClicked());
Bukkit.getPluginManager().callEvent(armorEquipEvent);
- if (armorEquipEvent.isCancelled()) {
- event.setResult(Result.DENY);
- event.setCancelled(true);
- }
}
- // Debug shit
}
@EventHandler
public void playerJoinEvent(@NotNull final PlayerJoinEvent event) {
- ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(event.getPlayer(), null, null, null, null);
+ ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(event.getPlayer());
Bukkit.getPluginManager().callEvent(armorEquipEvent);
}
@EventHandler
public void playerRespawnEvent(@NotNull final PlayerRespawnEvent event) {
- ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(event.getPlayer(), null, null, null, null);
+ ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(event.getPlayer());
Bukkit.getPluginManager().callEvent(armorEquipEvent);
}
@@ -201,22 +162,8 @@ public class ArmorListener implements Listener {
ArmorType type = ArmorType.matchType(event.getBrokenItem());
if (type != null) {
Player p = event.getPlayer();
- ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(p, EquipMethod.BROKE, type, event.getBrokenItem(), null);
+ ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(p);
Bukkit.getPluginManager().callEvent(armorEquipEvent);
- if (armorEquipEvent.isCancelled()) {
- ItemStack i = event.getBrokenItem().clone();
- i.setAmount(1);
- i.setDurability((short) (i.getDurability() - 1));
- if (type.equals(ArmorType.HELMET)) {
- p.getInventory().setHelmet(i);
- } else if (type.equals(ArmorType.CHESTPLATE)) {
- p.getInventory().setChestplate(i);
- } else if (type.equals(ArmorType.LEGGINGS)) {
- p.getInventory().setLeggings(i);
- } else if (type.equals(ArmorType.BOOTS)) {
- p.getInventory().setBoots(i);
- }
- }
}
}
@@ -228,8 +175,7 @@ public class ArmorListener implements Listener {
}
for (ItemStack i : p.getInventory().getArmorContents()) {
if (!isAirOrNull(i)) {
- Bukkit.getPluginManager().callEvent(new ArmorEquipEvent(p, EquipMethod.DEATH, ArmorType.matchType(i), i, null));
- // No way to cancel a death event.
+ Bukkit.getPluginManager().callEvent(new ArmorEquipEvent(p));
}
}
}
diff --git a/eco-api/src/main/java/com/willfp/eco/util/events/armorequip/ArmorType.java b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/eventlisteners/ArmorType.java
similarity index 92%
rename from eco-api/src/main/java/com/willfp/eco/util/events/armorequip/ArmorType.java
rename to eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/eventlisteners/ArmorType.java
index 3e8c39e1..893ba858 100644
--- a/eco-api/src/main/java/com/willfp/eco/util/events/armorequip/ArmorType.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/eventlisteners/ArmorType.java
@@ -1,11 +1,7 @@
-package com.willfp.eco.util.events.armorequip;
+package com.willfp.eco.spigot.eventlisteners;
import org.bukkit.inventory.ItemStack;
-/**
- * @author Arnah
- * @since Jul 30, 2015
- */
public enum ArmorType {
HELMET(5),
CHESTPLATE(6),
diff --git a/eco-api/src/main/java/com/willfp/eco/util/events/armorequip/DispenserArmorListener.java b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/eventlisteners/DispenserArmorListener.java
similarity index 72%
rename from eco-api/src/main/java/com/willfp/eco/util/events/armorequip/DispenserArmorListener.java
rename to eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/eventlisteners/DispenserArmorListener.java
index 826d6ef5..fcf38002 100644
--- a/eco-api/src/main/java/com/willfp/eco/util/events/armorequip/DispenserArmorListener.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/eventlisteners/DispenserArmorListener.java
@@ -1,5 +1,6 @@
-package com.willfp.eco.util.events.armorequip;
+package com.willfp.eco.spigot.eventlisteners;
+import com.willfp.eco.util.events.ArmorEquipEvent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -7,21 +8,14 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockDispenseArmorEvent;
import org.jetbrains.annotations.NotNull;
-/**
- * @author Arnah
- * @since Feb 08, 2019
- */
public class DispenserArmorListener implements Listener {
@EventHandler
public void dispenseArmorEvent(@NotNull final BlockDispenseArmorEvent event) {
ArmorType type = ArmorType.matchType(event.getItem());
if (type != null && event.getTargetEntity() instanceof Player) {
Player p = (Player) event.getTargetEntity();
- ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(p, ArmorEquipEvent.EquipMethod.DISPENSER, type, null, event.getItem());
+ ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(p);
Bukkit.getPluginManager().callEvent(armorEquipEvent);
- if (armorEquipEvent.isCancelled()) {
- event.setCancelled(true);
- }
}
}
}
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/eventlisteners/EntityDeathByEntityBuilder.java b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/eventlisteners/EntityDeathByEntityBuilder.java
index 3ae58d5b..9a15e41a 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/eventlisteners/EntityDeathByEntityBuilder.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/eventlisteners/EntityDeathByEntityBuilder.java
@@ -1,6 +1,6 @@
package com.willfp.eco.spigot.eventlisteners;
-import com.willfp.eco.util.events.entitydeathbyentity.EntityDeathByEntityEvent;
+import com.willfp.eco.util.events.EntityDeathByEntityEvent;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang.Validate;
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/eventlisteners/NaturalExpGainBuilder.java b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/eventlisteners/NaturalExpGainBuilder.java
index 9e3976a5..8509560e 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/eventlisteners/NaturalExpGainBuilder.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/eventlisteners/NaturalExpGainBuilder.java
@@ -1,6 +1,6 @@
package com.willfp.eco.spigot.eventlisteners;
-import com.willfp.eco.util.events.naturalexpgainevent.NaturalExpGainEvent;
+import com.willfp.eco.util.events.NaturalExpGainEvent;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang.Validate;