Search in sources :

Example 46 with Settings

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

the class PlayerQuitListener method onPlayerQuit.

@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
    Player player = event.getPlayer();
    plugin.getPlayerManager().closeNavigator(player);
    Settings settings = settingsManager.getSettings(player);
    if (settings.isNoClip()) {
        plugin.getNoClipManager().stopNoClip(player.getUniqueId());
    }
    if (settings.isScoreboard()) {
        settingsManager.stopScoreboard(player);
    }
    if (settings.isClearInventory()) {
        player.getInventory().clear();
    }
    manageHidePlayer(player);
}
Also used : Player(org.bukkit.entity.Player) Settings(com.eintosti.buildsystem.object.settings.Settings) EventHandler(org.bukkit.event.EventHandler)

Example 47 with Settings

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

the class SettingsInteractListener method manageDisabledInteractSetting.

@EventHandler
public void manageDisabledInteractSetting(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK || !isValid(event)) {
        return;
    }
    Settings settings = settingsManager.getSettings(player);
    if (!settings.isDisableInteract()) {
        return;
    }
    Block block = event.getClickedBlock();
    if (block == null) {
        return;
    }
    ItemStack itemStack = event.getItem();
    if (itemStack == null) {
        return;
    }
    Material material = itemStack.getType();
    XMaterial xMaterial = XMaterial.matchXMaterial(material);
    if (xMaterial == configValues.getWorldEditWand()) {
        return;
    }
    cachePlayers.add(player.getUniqueId());
    event.setCancelled(true);
    event.setUseItemInHand(Event.Result.DENY);
    event.setUseInteractedBlock(Event.Result.DENY);
    if (!XMaterial.supports(13) && XTag.isItem(xMaterial)) {
        material = Material.valueOf(material.toString().replace("_ITEM", ""));
    }
    if (XTag.SIGNS.isTagged(xMaterial)) {
        if (!XMaterial.supports(13)) {
            material = Material.valueOf("WALL_SIGN");
        } else {
            String[] splitMaterial = material.toString().split("_");
            material = Material.valueOf(splitMaterial[0] + "_WALL_SIGN");
        }
    }
    if (!material.isBlock()) {
        return;
    }
    Block adjacent = block.getRelative(event.getBlockFace());
    adjacent.setType(material);
    XBlock.setColor(adjacent, getItemColor(itemStack));
    plugin.getCustomBlocks().rotate(adjacent, player, null);
}
Also used : Player(org.bukkit.entity.Player) 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 48 with Settings

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

the class SettingsInteractListener method manageIronDoorSetting.

@EventHandler
public void manageIronDoorSetting(PlayerInteractEvent event) {
    if (!isValid(event)) {
        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)

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