use of com.eintosti.buildsystem.event.player.PlayerInventoryClearEvent in project BuildSystem by Trichtern.
the class PlayerCommandPreprocessListener method onPlayerCommandPreprocess.
@EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
if (event.isCancelled()) {
return;
}
String command = event.getMessage().split(" ")[0];
Player player = event.getPlayer();
if (command.equalsIgnoreCase("/clear")) {
ItemStack navigatorItem = inventoryManager.getItemStack(configValues.getNavigatorItem(), plugin.getString("navigator_item"));
if (!player.getInventory().contains(navigatorItem)) {
return;
}
if (settingsManager.getSettings(player).isKeepNavigator()) {
List<Integer> navigatorSlots = inventoryManager.getNavigatorSlots(player);
Bukkit.getScheduler().runTaskLater(plugin, () -> {
PlayerInventoryClearEvent playerInventoryClearEvent = new PlayerInventoryClearEvent(player, navigatorSlots);
Bukkit.getServer().getPluginManager().callEvent(playerInventoryClearEvent);
}, 2L);
}
return;
}
if (configValues.isBlockWorldEditNonBuilder()) {
if (!DISABLED_COMMANDS.contains(command)) {
return;
}
BuildWorld buildWorld = worldManager.getBuildWorld(player.getWorld().getName());
if (buildWorld == null) {
return;
}
if (disableArchivedWorlds(buildWorld, player, event)) {
return;
}
checkBuilders(buildWorld, player, event);
}
}
use of com.eintosti.buildsystem.event.player.PlayerInventoryClearEvent in project BuildSystem by Trichtern.
the class InventoryCreativeListener method onClearInventory.
@EventHandler
public void onClearInventory(InventoryCreativeEvent event) {
if (event.getClick() != ClickType.CREATIVE || event.getSlotType() != InventoryType.SlotType.QUICKBAR || event.getAction() != InventoryAction.PLACE_ALL) {
return;
}
Player player = (Player) event.getWhoClicked();
List<Integer> navigatorSlots = inventoryManager.getNavigatorSlots(player);
Bukkit.getScheduler().runTaskLater(plugin, () -> {
PlayerInventoryClearEvent playerInventoryClearEvent = new PlayerInventoryClearEvent(player, navigatorSlots);
Bukkit.getServer().getPluginManager().callEvent(playerInventoryClearEvent);
}, 2L);
}
Aggregations