forked from SteamWar/SteamWar
Remove code Duplication HotbarKit
This commit is contained in:
@@ -31,6 +31,7 @@ import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.fightsystem.utils.ItemBuilder;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
@@ -108,15 +109,7 @@ public class HotbarKit extends Kit {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
int slot = player.getInventory().getHeldItemSlot();
|
||||
Kit activeKit = activeKits.get(player);
|
||||
if(!(activeKit instanceof HotbarKit) || PersonalKitCreator.inKitCreator(player) || activeKit.getInventory()[slot] == null)
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
if(!clicked.add(player))
|
||||
return;
|
||||
|
||||
((HotbarKit)activeKit).onClicks[slot].accept(player);
|
||||
click(player, slot, event);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -125,6 +118,10 @@ public class HotbarKit extends Kit {
|
||||
if (slot < 0 || slot >= HOTBAR_SIZE) return;
|
||||
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
click(player, slot, event);
|
||||
}
|
||||
|
||||
private void click(Player player, int slot, Cancellable event) {
|
||||
Kit activeKit = activeKits.get(player);
|
||||
if(!(activeKit instanceof HotbarKit) || PersonalKitCreator.inKitCreator(player) || activeKit.getInventory()[slot] == null)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user