mirror of
https://github.com/filoghost/ChestCommands.git
synced 2024-11-26 03:55:40 +01:00
Refactoring
This commit is contained in:
parent
98ee458bc0
commit
85bdcd6408
@ -28,7 +28,6 @@ import me.filoghost.chestcommands.ChestCommands;
|
||||
import me.filoghost.chestcommands.MenuManager;
|
||||
import me.filoghost.chestcommands.api.Icon;
|
||||
import me.filoghost.chestcommands.api.IconMenu;
|
||||
import me.filoghost.chestcommands.task.ExecuteActionsTask;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -95,8 +94,14 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
// Closes the inventory and executes actions AFTER the event
|
||||
Bukkit.getScheduler().runTask(ChestCommands.getInstance(), new ExecuteActionsTask(clicker, icon));
|
||||
// Only handle the click AFTER the event has finished
|
||||
Bukkit.getScheduler().runTask(ChestCommands.getInstance(), () -> {
|
||||
boolean close = icon.onClick(clicker);
|
||||
|
||||
if (close) {
|
||||
clicker.closeInventory();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package me.filoghost.chestcommands.task;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.filoghost.chestcommands.api.Icon;
|
||||
|
||||
public class ExecuteActionsTask implements Runnable {
|
||||
|
||||
private Player player;
|
||||
private Icon icon;
|
||||
|
||||
|
||||
public ExecuteActionsTask(Player player, Icon icon) {
|
||||
this.player = player;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
boolean close = icon.onClick(player);
|
||||
|
||||
if (close) {
|
||||
player.closeInventory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user