Skip to content

Commit 73fde34

Browse files
authored
feat: replace triconsumers with biconsumers to be able to remove log4j (#197)
1 parent 56b5b93 commit 73fde34

File tree

4 files changed

+22
-80
lines changed

4 files changed

+22
-80
lines changed

pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,6 @@
8585
<version>LATEST</version>
8686
<scope>provided</scope>
8787
</dependency>
88-
<dependency>
89-
<groupId>org.apache.logging.log4j</groupId>
90-
<artifactId>log4j-api</artifactId>
91-
<version>2.20.0</version>
92-
<scope>compile</scope>
93-
</dependency>
9488
<dependency>
9589
<groupId>com.google.code.gson</groupId>
9690
<artifactId>gson</artifactId>

src/main/java/minevalley/core/api/Core.java

Lines changed: 18 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import net.md_5.bungee.api.chat.BaseComponent;
4646
import net.md_5.bungee.api.chat.ComponentBuilder;
4747
import net.md_5.bungee.api.chat.HoverEvent;
48-
import org.apache.logging.log4j.util.TriConsumer;
4948
import org.bukkit.Chunk;
5049
import org.bukkit.Location;
5150
import org.bukkit.Material;
@@ -55,7 +54,7 @@
5554
import org.bukkit.entity.Player;
5655
import org.bukkit.event.Event;
5756
import org.bukkit.event.Listener;
58-
import org.bukkit.event.inventory.ClickType;
57+
import org.bukkit.event.inventory.InventoryClickEvent;
5958
import org.bukkit.event.player.PlayerInteractEvent;
6059
import org.bukkit.inventory.Inventory;
6160
import org.bukkit.inventory.ItemStack;
@@ -513,109 +512,62 @@ public static GuiItem createGuiItem(ItemStack itemStack, Consumer<OnlineUser> co
513512

514513
/**
515514
* Creates new gui-item, based on a specific itemstack with a specific callback.
516-
* Gui-items can be added to inventory-guis (built by gui-builder). If a player clicks the gui-item, the callback is called with the player-object.
517-
*
518-
* @param itemBuilder item which should be displayed in the inventory
519-
* @param consumer consumer which gets called if a player clicks the item
520-
* @return gui-item-object to add to the gui-builder
521-
*/
522-
public static GuiItem createGuiItem(ItemBuilder itemBuilder, Consumer<OnlineUser> consumer) {
523-
return server.createGuiItem(itemBuilder.build(), consumer);
524-
}
525-
526-
/**
527-
* Creates new gui-item, based on a specific itemstack with a specific callback.
528-
* Gui-items can be added to inventory-guis (built by gui-builder). If a player clicks the gui-item, the callback is called with the player-object.
529-
*
530-
* @param item item which should be displayed in the inventory
531-
* @param consumer consumer which gets called if a player clicks the item
532-
* @return gui-item-object to add to the gui-builder
533-
*/
534-
public static GuiItem createGuiItem(InterfaceItem item, Consumer<OnlineUser> consumer) {
535-
return server.createGuiItem(item.toItemStack(), consumer);
536-
}
537-
538-
/**
539-
* Creates new gui-item, based on a specific itemstack with a specific callback.
540-
* Gui-items can be added to inventory-guis (built by gui-builder). If a player clicks the gui-item, the callback is called with the player-object.
541-
*
542-
* @param itemStack item which should be displayed in the inventory
543-
* @param consumer consumer which gets called if a player clicks the item
544-
* @return gui-item-object to add to the gui-builder
545-
*/
546-
public static GuiItem createGuiItem(ItemStack itemStack, BiConsumer<OnlineUser, ClickType> consumer) {
547-
return server.createAdvancedGuiItem(itemStack, consumer);
548-
}
549-
550-
/**
551-
* Creates new gui-item, based on a specific itemstack with a specific callback.
552-
* Gui-items can be added to inventory-guis (built by gui-builder). If a player clicks the gui-item, the callback is called with the player-object.
515+
* Gui-items can be added to inventory-guis (built by gui-builder).
553516
*
554517
* @param itemBuilder item which should be displayed in the inventory
555-
* @param consumer consumer which gets called if a player clicks the item
518+
* @param callback consumer which gets called if a player clicks the item
556519
* @return gui-item-object to add to the gui-builder
557520
*/
558-
public static GuiItem createGuiItem(ItemBuilder itemBuilder, BiConsumer<OnlineUser, ClickType> consumer) {
559-
return server.createAdvancedGuiItem(itemBuilder.build(), consumer);
521+
public static GuiItem createGuiItem(ItemBuilder itemBuilder, Consumer<OnlineUser> callback) {
522+
return server.createGuiItem(itemBuilder.build(), callback);
560523
}
561524

562525
/**
563526
* Creates new gui-item, based on a specific itemstack with a specific callback.
564-
* Gui-items can be added to inventory-guis (built by gui-builder). If a player clicks the gui-item, the callback is called with the player-object.
527+
* Gui-items can be added to inventory-guis (built by gui-builder).
565528
*
566529
* @param item item which should be displayed in the inventory
567-
* @param consumer consumer which gets called if a player clicks the item
530+
* @param callback consumer which gets called if a player clicks the item
568531
* @return gui-item-object to add to the gui-builder
569532
*/
570-
public static GuiItem createGuiItem(InterfaceItem item, BiConsumer<OnlineUser, ClickType> consumer) {
571-
return server.createAdvancedGuiItem(item.toItemStack(), consumer);
533+
public static GuiItem createGuiItem(InterfaceItem item, Consumer<OnlineUser> callback) {
534+
return server.createGuiItem(item.toItemStack(), callback);
572535
}
573536

574537
/**
575538
* Creates new gui-item, based on a specific itemstack with a specific callback.
576539
* Gui-items can be added to inventory-guis (built by gui-builder). If a player clicks the gui-item, the callback is called with the player-object.
577540
*
578541
* @param itemStack item which should be displayed in the inventory
579-
* @param consumer consumer which gets called if a player clicks the item
542+
* @param callback consumer which gets called if a player clicks the item
580543
* @return gui-item-object to add to the gui-builder
581544
*/
582-
public static GuiItem createGuiItem(ItemStack itemStack, TriConsumer<OnlineUser, ClickType, Inventory> consumer) {
583-
return server.createAdvancedGuiItem(itemStack, consumer);
545+
public static GuiItem createGuiItem(ItemStack itemStack, BiConsumer<OnlineUser, InventoryClickEvent> callback) {
546+
return server.createAdvancedGuiItem(itemStack, callback);
584547
}
585548

586549
/**
587550
* Creates new gui-item, based on a specific itemstack with a specific callback.
588551
* Gui-items can be added to inventory-guis (built by gui-builder). If a player clicks the gui-item, the callback is called with the player-object.
589552
*
590553
* @param itemBuilder item which should be displayed in the inventory
591-
* @param consumer consumer which gets called if a player clicks the item
554+
* @param callback consumer which gets called if a player clicks the item
592555
* @return gui-item-object to add to the gui-builder
593556
*/
594-
public static GuiItem createGuiItem(ItemBuilder itemBuilder, TriConsumer<OnlineUser, ClickType, Inventory> consumer) {
595-
return server.createAdvancedGuiItem(itemBuilder.build(), consumer);
557+
public static GuiItem createGuiItem(ItemBuilder itemBuilder, BiConsumer<OnlineUser, InventoryClickEvent> callback) {
558+
return server.createAdvancedGuiItem(itemBuilder.build(), callback);
596559
}
597560

598561
/**
599562
* Creates new gui-item, based on a specific itemstack with a specific callback.
600563
* Gui-items can be added to inventory-guis (built by gui-builder). If a player clicks the gui-item, the callback is called with the player-object.
601564
*
602565
* @param item item which should be displayed in the inventory
603-
* @param consumer consumer which gets called if a player clicks the item
604-
* @return gui-item-object to add to the gui-builder
605-
*/
606-
public static GuiItem createGuiItem(InterfaceItem item, TriConsumer<OnlineUser, ClickType, Inventory> consumer) {
607-
return server.createAdvancedGuiItem(item.toItemStack(), consumer);
608-
}
609-
610-
/**
611-
* Creates new gui-item, based on a specific itemstack without any callback.
612-
* Gui-items can be added to inventory-guis (built by gui-builder). If a player clicks the gui-item, the callback is called with the player-object.
613-
*
614-
* @param itemStack item which should be displayed in the inventory (use item-builder to create this item)
566+
* @param callback consumer which gets called if a player clicks the item
615567
* @return gui-item-object to add to the gui-builder
616568
*/
617-
public static GuiItem createGuiItem(ItemStack itemStack) {
618-
return server.createGuiItem(itemStack, null);
569+
public static GuiItem createGuiItem(InterfaceItem item, BiConsumer<OnlineUser, InventoryClickEvent> callback) {
570+
return server.createAdvancedGuiItem(item.toItemStack(), callback);
619571
}
620572

621573
/**

src/main/java/minevalley/core/api/CoreServer.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import minevalley.smart.api.Session;
4242
import minevalley.smart.api.SmartApp;
4343
import net.md_5.bungee.api.chat.BaseComponent;
44-
import org.apache.logging.log4j.util.TriConsumer;
4544
import org.bukkit.Chunk;
4645
import org.bukkit.Location;
4746
import org.bukkit.Material;
@@ -51,7 +50,7 @@
5150
import org.bukkit.entity.Player;
5251
import org.bukkit.event.Event;
5352
import org.bukkit.event.Listener;
54-
import org.bukkit.event.inventory.ClickType;
53+
import org.bukkit.event.inventory.InventoryClickEvent;
5554
import org.bukkit.event.player.PlayerInteractEvent;
5655
import org.bukkit.inventory.Inventory;
5756
import org.bukkit.inventory.ItemStack;
@@ -162,9 +161,7 @@ public interface CoreServer {
162161

163162
GuiItem createGuiItem(ItemStack itemStack, Consumer<OnlineUser> consumer);
164163

165-
GuiItem createAdvancedGuiItem(ItemStack itemStack, BiConsumer<OnlineUser, ClickType> consumer);
166-
167-
GuiItem createAdvancedGuiItem(ItemStack itemStack, TriConsumer<OnlineUser, ClickType, Inventory> consumer);
164+
GuiItem createAdvancedGuiItem(ItemStack itemStack, BiConsumer<OnlineUser, InventoryClickEvent> callback);
168165

169166
ItemBuilder createItem(ItemStack itemStack);
170167

src/main/java/minevalley/core/api/npc/NPC.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import minevalley.core.api.ChatMenu;
66
import minevalley.core.api.users.OnlineUser;
77
import net.md_5.bungee.api.chat.BaseComponent;
8-
import org.apache.logging.log4j.util.TriConsumer;
98
import org.bukkit.Location;
109
import org.bukkit.block.Block;
1110
import org.bukkit.entity.Player;
@@ -79,9 +78,9 @@ default void zoomIn(OnlineUser user) {
7978

8079
void setSneaking(boolean sneaking);
8180

82-
NPC onClick(TriConsumer<OnlineUser, Click, NPC> callback);
81+
NPC onClick(BiConsumer<OnlineUser, Click> callback);
8382

84-
NPC onComingClose(BiConsumer<OnlineUser, NPC> callback);
83+
NPC onComingClose(Consumer<OnlineUser> callback);
8584

8685
String getChatName();
8786

0 commit comments

Comments
 (0)