Search in sources :

Example 6 with Settings

use of com.eintosti.buildsystem.object.settings.Settings in project BuildSystem by einTosti.

the class PlayerInteractListener method onIronPlayerInteract.

@EventHandler
public void onIronPlayerInteract(PlayerInteractEvent event) {
    if (event.isCancelled()) {
        return;
    }
    Block block = event.getClickedBlock();
    if (block == null) {
        return;
    }
    boolean duelHanded = XMaterial.supports(9);
    if (duelHanded && event.getHand() != EquipmentSlot.valueOf("HAND")) {
        return;
    }
    Player player = event.getPlayer();
    Settings settings = settingsManager.getSettings(player);
    if (!settings.isTrapDoor()) {
        return;
    }
    Action action = event.getAction();
    XMaterial material = XMaterial.matchXMaterial(block.getType());
    if (action == Action.RIGHT_CLICK_BLOCK && (material == XMaterial.IRON_DOOR || material == XMaterial.IRON_TRAPDOOR)) {
        if (player.isSneaking()) {
            return;
        }
        event.setCancelled(true);
        switch(material) {
            case IRON_TRAPDOOR:
                plugin.getCustomBlocks().toggleIronTrapdoor(event);
                break;
            case IRON_DOOR:
                plugin.getCustomBlocks().toggleIronDoor(event);
                break;
            default:
                break;
        }
    }
}
Also used : Player(org.bukkit.entity.Player) Action(org.bukkit.event.block.Action) Block(org.bukkit.block.Block) XBlock(com.cryptomorin.xseries.XBlock) XMaterial(com.cryptomorin.xseries.XMaterial) Settings(com.eintosti.buildsystem.object.settings.Settings) EventHandler(org.bukkit.event.EventHandler)

Example 7 with Settings

use of com.eintosti.buildsystem.object.settings.Settings in project BuildSystem by einTosti.

the class PlayerInteractListener method onSlabPlayerInteract.

@EventHandler
public void onSlabPlayerInteract(PlayerInteractEvent event) {
    if (event.isCancelled()) {
        return;
    }
    Player player = event.getPlayer();
    Action action = event.getAction();
    Settings settings = settingsManager.getSettings(player);
    if (settings.isSlabBreaking() && action == Action.LEFT_CLICK_BLOCK) {
        plugin.getCustomBlocks().modifySlab(event);
    }
}
Also used : Player(org.bukkit.entity.Player) Action(org.bukkit.event.block.Action) Settings(com.eintosti.buildsystem.object.settings.Settings) EventHandler(org.bukkit.event.EventHandler)

Example 8 with Settings

use of com.eintosti.buildsystem.object.settings.Settings in project BuildSystem by einTosti.

the class PlayerInteractListener method manageInstantPlaceSignsSetting.

@EventHandler
public void manageInstantPlaceSignsSetting(PlayerInteractEvent event) {
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
        return;
    }
    Player player = event.getPlayer();
    Settings settings = settingsManager.getSettings(player);
    if (!settings.isInstantPlaceSigns()) {
        return;
    }
    ItemStack itemStack = event.getItem();
    if (itemStack == null) {
        return;
    }
    Material material = itemStack.getType();
    XMaterial xMaterial = XMaterial.matchXMaterial(itemStack);
    if (!XTag.SIGNS.isTagged(xMaterial)) {
        return;
    }
    Block clickedBlock = event.getClickedBlock();
    BlockFace blockFace = event.getBlockFace();
    if (clickedBlock == null || blockFace == BlockFace.DOWN) {
        return;
    }
    Block adjacent = clickedBlock.getRelative(blockFace);
    if (adjacent.getType() != XMaterial.AIR.parseMaterial()) {
        return;
    }
    event.setUseItemInHand(Event.Result.DENY);
    event.setCancelled(true);
    switch(blockFace) {
        case UP:
            if (!XMaterial.supports(13)) {
                material = Material.getMaterial("SIGN_POST") != null ? Material.valueOf("SIGN_POST") : material;
            }
            adjacent.setType(material);
            plugin.getCustomBlocks().rotate(adjacent, player, getDirection(player).getOppositeFace());
            break;
        case NORTH:
        case EAST:
        case SOUTH:
        case WEST:
            String type = xMaterial.name().replace("_SIGN", "");
            XMaterial.matchXMaterial(type + "_WALL_SIGN").ifPresent(value -> adjacent.setType(value.parseMaterial()));
            plugin.getCustomBlocks().rotate(adjacent, player, blockFace);
            break;
        default:
            break;
    }
}
Also used : Player(org.bukkit.entity.Player) BlockFace(org.bukkit.block.BlockFace) Block(org.bukkit.block.Block) XBlock(com.cryptomorin.xseries.XBlock) Material(org.bukkit.Material) XMaterial(com.cryptomorin.xseries.XMaterial) ItemStack(org.bukkit.inventory.ItemStack) XMaterial(com.cryptomorin.xseries.XMaterial) Settings(com.eintosti.buildsystem.object.settings.Settings) EventHandler(org.bukkit.event.EventHandler)

Example 9 with Settings

use of com.eintosti.buildsystem.object.settings.Settings in project BuildSystem by einTosti.

the class PlayerInteractListener method openNavigator.

private void openNavigator(Player player) {
    Settings settings = settingsManager.getSettings(player);
    if (settings.getNavigatorType() == NavigatorType.OLD) {
        plugin.getNavigatorInventory().openInventory(player);
        XSound.BLOCK_CHEST_OPEN.play(player);
    } else {
        // NEW
        if (playerManager.getOpenNavigator().contains(player)) {
            player.sendMessage(plugin.getString("worlds_navigator_open"));
            return;
        }
        summonNewNavigator(player);
        String findItemName = plugin.getString("navigator_item");
        ItemStack replaceItem = inventoryManager.getItemStack(XMaterial.BARRIER, plugin.getString("barrier_item"));
        inventoryManager.replaceItem(player, findItemName, configValues.getNavigatorItem(), replaceItem);
    }
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) Settings(com.eintosti.buildsystem.object.settings.Settings)

Example 10 with Settings

use of com.eintosti.buildsystem.object.settings.Settings in project BuildSystem by einTosti.

the class PlayerInventoryClearListener method onPlayerInventoryClear.

@EventHandler
public void onPlayerInventoryClear(PlayerInventoryClearEvent event) {
    Player player = event.getPlayer();
    Settings settings = settingsManager.getSettings(player);
    if (!settings.isKeepNavigator()) {
        return;
    }
    if (!player.hasPermission("buildsystem.gui")) {
        return;
    }
    PlayerInventory playerInventory = player.getInventory();
    ItemStack navigatorItem = inventoryManager.getItemStack(plugin.getConfigValues().getNavigatorItem(), plugin.getString("navigator_item"));
    event.getNavigatorSlots().forEach(slot -> playerInventory.setItem(slot, navigatorItem));
}
Also used : Player(org.bukkit.entity.Player) PlayerInventory(org.bukkit.inventory.PlayerInventory) ItemStack(org.bukkit.inventory.ItemStack) Settings(com.eintosti.buildsystem.object.settings.Settings) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Settings (com.eintosti.buildsystem.object.settings.Settings)48 Player (org.bukkit.entity.Player)24 EventHandler (org.bukkit.event.EventHandler)24 ItemStack (org.bukkit.inventory.ItemStack)16 XMaterial (com.cryptomorin.xseries.XMaterial)14 XBlock (com.cryptomorin.xseries.XBlock)6 Material (org.bukkit.Material)6 Block (org.bukkit.block.Block)6 Action (org.bukkit.event.block.Action)4 ItemMeta (org.bukkit.inventory.meta.ItemMeta)4 PotionEffect (org.bukkit.potion.PotionEffect)4 NoClipManager (com.eintosti.buildsystem.manager.NoClipManager)2 SettingsManager (com.eintosti.buildsystem.manager.SettingsManager)2 NavigatorType (com.eintosti.buildsystem.object.navigator.NavigatorType)2 Color (com.eintosti.buildsystem.object.settings.Color)2 WorldSort (com.eintosti.buildsystem.object.settings.WorldSort)2 BuildWorld (com.eintosti.buildsystem.object.world.BuildWorld)2 FastBoard (fr.mrmicky.fastboard.FastBoard)2 Location (org.bukkit.Location)2 BlockFace (org.bukkit.block.BlockFace)2