Skip to content

Commit

Permalink
1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
efekos committed May 30, 2023
1 parent 1263bea commit 4862238
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/main/java/me/efekos/simpler/events/PlayerEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public void onPlayerInteract(PlayerInteractEvent e){

switch (e.getAction()){
case LEFT_CLICK_AIR:case LEFT_CLICK_BLOCK:
item.onLeftClick(e.getPlayer());
item.onLeftClick(e);
break;
case RIGHT_CLICK_AIR:case RIGHT_CLICK_BLOCK:
item.onRightClick(e.getPlayer());
item.onRightClick(e);
break;
default:
break;
Expand Down Expand Up @@ -74,7 +74,7 @@ public void onPlayerPickup(EntityPickupItemEvent e){
constructor.setAccessible(true);
CustomItem item = constructor.newInstance();

item.onPickup((Player) e.getEntity());
item.onPickup(e);
} catch (Exception ex){
ex.printStackTrace();
}
Expand All @@ -97,7 +97,7 @@ public void onPlayerDrop(PlayerDropItemEvent e){
constructor.setAccessible(true);
CustomItem item = constructor.newInstance();

item.onDrop(e.getPlayer());
item.onDrop(e);
} catch (Exception ex){
ex.printStackTrace();
}
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/me/efekos/simpler/items/CustomItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDropItemEvent;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;

Expand All @@ -11,25 +15,25 @@ public abstract class CustomItem {
* executes when a player left clicks with this item.
* @param player Player that left-clicked to the item.
*/
public abstract void onLeftClick(Player player);
public abstract void onLeftClick(PlayerInteractEvent player);

/**
* executes when a player right clicks with this item.
* @param player Player that right-clicked to the item
*/
public abstract void onRightClick(Player player);
public abstract void onRightClick(PlayerInteractEvent player);

/**
* executes when a player drops this item.
* @param player Player that dropped the item
*/
public abstract void onDrop(Player player);
public abstract void onDrop(PlayerDropItemEvent player);

/**
* executes when a player picks up this item.
* @param player Player that dropped this item
*/
public abstract void onPickup(Player player);
public abstract void onPickup(EntityPickupItemEvent player);

/**
* @return An ID for this item. This ID is unique and used to know that an {@link org.bukkit.inventory.ItemStack} is this item.
Expand Down

0 comments on commit 4862238

Please sign in to comment.