Search in sources :

Example 21 with Settings

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

the class SettingsInteractListener method manageInstantPlaceSignsSetting.

@EventHandler
public void manageInstantPlaceSignsSetting(PlayerInteractEvent event) {
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK || !isValid(event)) {
        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 22 with Settings

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

the class SettingsInteractListener method managePlacePlantsSetting.

@EventHandler
public void managePlacePlantsSetting(PlayerInteractEvent event) {
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK || !isValid(event)) {
        return;
    }
    ItemStack itemStack = event.getItem();
    if (itemStack == null) {
        return;
    }
    Material material = itemStack.getType();
    if (!XTag.FLOWERS.isTagged(XMaterial.matchXMaterial(material))) {
        return;
    }
    Player player = event.getPlayer();
    Settings settings = settingsManager.getSettings(player);
    if (!settings.isPlacePlants()) {
        return;
    }
    event.setCancelled(true);
    plugin.getCustomBlocks().setPlant(event);
}
Also used : Player(org.bukkit.entity.Player) Material(org.bukkit.Material) XMaterial(com.cryptomorin.xseries.XMaterial) ItemStack(org.bukkit.inventory.ItemStack) Settings(com.eintosti.buildsystem.object.settings.Settings) EventHandler(org.bukkit.event.EventHandler)

Example 23 with Settings

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

the class PlaceholderApiExpansion method parseSettingsPlaceholder.

/**
 * This is the method called when a placeholder with the identifier
 * {@code %buildsystem_settings_<setting>%} is found
 *
 * @param player     A Player.
 * @param identifier A String containing the identifier/value.
 * @return possibly-null String of the requested identifier.
 */
@Nullable
private String parseSettingsPlaceholder(Player player, String identifier) {
    Settings settings = settingsManager.getSettings(player);
    String settingIdentifier = identifier.split("_")[1];
    switch(settingIdentifier.toLowerCase()) {
        case "navigatortype":
            return settings.getNavigatorType().toString();
        case "glasscolor":
            return settings.getGlassColor().toString();
        case "worldsort":
            return settings.getWorldSort().toString();
        case "clearinventory":
            return String.valueOf(settings.isClearInventory());
        case "disableinteract":
            return String.valueOf(settings.isDisableInteract());
        case "hideplayers":
            return String.valueOf(settings.isHidePlayers());
        case "instantplacesigns":
            return String.valueOf(settings.isInstantPlaceSigns());
        case "keepnavigator":
            return String.valueOf(settings.isKeepNavigator());
        case "nightvision":
            return String.valueOf(settings.isNightVision());
        case "noclip":
            return String.valueOf(settings.isNoClip());
        case "placeplants":
            return String.valueOf(settings.isPlacePlants());
        case "scoreboard":
            return String.valueOf(settings.isScoreboard());
        case "slabbreaking":
            return String.valueOf(settings.isSlabBreaking());
        case "spawnteleport":
            return String.valueOf(settings.isSpawnTeleport());
        case "opentrapdoors":
            return String.valueOf(settings.isTrapDoor());
        default:
            return null;
    }
}
Also used : Settings(com.eintosti.buildsystem.object.settings.Settings) Nullable(org.jetbrains.annotations.Nullable)

Example 24 with Settings

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

the class DesignInventory method setItem.

private void setItem(Player player, Inventory inventory, int position, XMaterial material, String displayName, Color color) {
    SettingsManager settingsManager = plugin.getSettingsManager();
    Settings settings = settingsManager.getSettings(player);
    ItemStack itemStack = inventoryManager.getItemStack(material, settings.getGlassColor() == color ? "§a" + displayName : "§7" + displayName);
    ItemMeta itemMeta = itemStack.getItemMeta();
    if (itemMeta != null) {
        itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
    }
    itemStack.setItemMeta(itemMeta);
    if (settings.getGlassColor() == color) {
        itemStack.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
    }
    inventory.setItem(position, itemStack);
}
Also used : SettingsManager(com.eintosti.buildsystem.manager.SettingsManager) ItemStack(org.bukkit.inventory.ItemStack) Settings(com.eintosti.buildsystem.object.settings.Settings) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 25 with Settings

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

the class DesignInventory method onInventoryClick.

@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    if (!inventoryManager.checkIfValidClick(event, "design_title")) {
        return;
    }
    Player player = (Player) event.getWhoClicked();
    Settings settings = plugin.getSettingsManager().getSettings(player);
    ItemStack itemStack = event.getCurrentItem();
    if (itemStack.getType().toString().contains("STAINED_GLASS_PANE")) {
        plugin.getSettingsInventory().openInventory(player);
        return;
    }
    switch(event.getSlot()) {
        case 10:
            settings.setGlassColor(Color.RED);
            break;
        case 11:
            settings.setGlassColor(Color.ORANGE);
            break;
        case 12:
            settings.setGlassColor(Color.YELLOW);
            break;
        case 13:
            settings.setGlassColor(Color.PINK);
            break;
        case 14:
            settings.setGlassColor(Color.MAGENTA);
            break;
        case 15:
            settings.setGlassColor(Color.PURPLE);
            break;
        case 16:
            settings.setGlassColor(Color.BROWN);
            break;
        case 18:
            settings.setGlassColor(Color.LIME);
            break;
        case 19:
            settings.setGlassColor(Color.GREEN);
            break;
        case 20:
            settings.setGlassColor(Color.BLUE);
            break;
        case 21:
            settings.setGlassColor(Color.CYAN);
            break;
        case 22:
            settings.setGlassColor(Color.LIGHT_BLUE);
            break;
        case 23:
            settings.setGlassColor(Color.WHITE);
            break;
        case 24:
            settings.setGlassColor(Color.LIGHT_GRAY);
            break;
        case 25:
            settings.setGlassColor(Color.GRAY);
            break;
        case 26:
            settings.setGlassColor(Color.BLACK);
            break;
    }
    openInventory(player);
}
Also used : Player(org.bukkit.entity.Player) 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