Search in sources :

Example 41 with Settings

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

the class SettingsManager method createSettings.

private Settings createSettings(UUID uuid) {
    if (!this.settings.containsKey(uuid)) {
        Settings settings = new Settings();
        this.settings.put(uuid, settings);
        return settings;
    }
    return this.settings.get(uuid);
}
Also used : Settings(com.eintosti.buildsystem.object.settings.Settings)

Example 42 with Settings

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

the class SettingsInventory method onInventoryClick.

@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    if (!inventoryManager.checkIfValidClick(event, "settings_title")) {
        return;
    }
    Player player = (Player) event.getWhoClicked();
    Settings settings = settingsManager.getSettings(player);
    switch(event.getSlot()) {
        case 11:
            plugin.getDesignInventory().openInventory(player);
            XSound.ENTITY_ITEM_PICKUP.play(player);
            return;
        case 12:
            settings.setClearInventory(!settings.isClearInventory());
            break;
        case 13:
            settings.setDisableInteract(!settings.isDisableInteract());
            break;
        case 14:
            settings.setHidePlayers(!settings.isHidePlayers());
            toggleHidePlayers(player, settings);
            break;
        case 15:
            settings.setInstantPlaceSigns(!settings.isInstantPlaceSigns());
            break;
        case 20:
            settings.setKeepNavigator(!settings.isKeepNavigator());
            break;
        case 21:
            if (settings.getNavigatorType().equals(NavigatorType.OLD)) {
                settings.setNavigatorType(NavigatorType.NEW);
            } else {
                settings.setNavigatorType(NavigatorType.OLD);
                plugin.getArmorStandManager().removeArmorStands(player);
                if (player.hasPotionEffect(PotionEffectType.BLINDNESS)) {
                    player.removePotionEffect(PotionEffectType.BLINDNESS);
                }
            }
            break;
        case 22:
            if (!settings.isNightVision()) {
                settings.setNightVision(true);
                player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false));
            } else {
                settings.setNightVision(false);
                if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
                    player.removePotionEffect(PotionEffectType.NIGHT_VISION);
                }
            }
            break;
        case 23:
            NoClipManager noClipManager = plugin.getNoClipManager();
            if (!settings.isNoClip()) {
                settings.setNoClip(true);
                noClipManager.startNoClip(player);
            } else {
                settings.setNoClip(false);
                noClipManager.stopNoClip(player.getUniqueId());
            }
            break;
        case 24:
            settings.setTrapDoor(!settings.isTrapDoor());
            break;
        case 29:
            settings.setPlacePlants(!settings.isPlacePlants());
            break;
        case 30:
            if (!configValues.isScoreboard()) {
                XSound.ENTITY_ITEM_BREAK.play(player);
                return;
            }
            if (settings.isScoreboard()) {
                settings.setScoreboard(false);
                settingsManager.stopScoreboard(player);
            } else {
                settings.setScoreboard(true);
                settingsManager.startScoreboard(player);
                plugin.getPlayerManager().forceUpdateSidebar(player);
            }
            break;
        case 31:
            settings.setSlabBreaking(!settings.isSlabBreaking());
            break;
        case 32:
            settings.setSpawnTeleport(!settings.isSpawnTeleport());
            break;
        case 33:
            switch(settings.getWorldSort()) {
                case NAME_A_TO_Z:
                    settings.setWorldSort(WorldSort.NAME_Z_TO_A);
                    break;
                case NAME_Z_TO_A:
                    settings.setWorldSort(WorldSort.PROJECT_A_TO_Z);
                    break;
                case PROJECT_A_TO_Z:
                    settings.setWorldSort(WorldSort.PROJECT_Z_TO_A);
                    break;
                case PROJECT_Z_TO_A:
                    settings.setWorldSort(WorldSort.NEWEST_FIRST);
                    break;
                case NEWEST_FIRST:
                    settings.setWorldSort(WorldSort.OLDEST_FIRST);
                    break;
                case OLDEST_FIRST:
                    settings.setWorldSort(WorldSort.NAME_A_TO_Z);
                    break;
            }
            break;
        default:
            return;
    }
    XSound.ENTITY_ITEM_PICKUP.play(player);
    plugin.getSettingsInventory().openInventory(player);
}
Also used : Player(org.bukkit.entity.Player) PotionEffect(org.bukkit.potion.PotionEffect) NoClipManager(com.eintosti.buildsystem.manager.NoClipManager) Settings(com.eintosti.buildsystem.object.settings.Settings) EventHandler(org.bukkit.event.EventHandler)

Example 43 with Settings

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

the class InventoryManager method getColouredGlass.

public XMaterial getColouredGlass(BuildSystem plugin, Player player) {
    SettingsManager settingsManager = plugin.getSettingsManager();
    Settings settings = settingsManager.getSettings(player);
    Optional<XMaterial> glass = XMaterial.matchXMaterial(settings.getGlassColor().name() + "_STAINED_GLASS");
    return glass.orElse(XMaterial.BLACK_STAINED_GLASS);
}
Also used : XMaterial(com.cryptomorin.xseries.XMaterial) Settings(com.eintosti.buildsystem.object.settings.Settings)

Example 44 with Settings

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

the class InventoryManager method getColouredGlassPane.

public XMaterial getColouredGlassPane(BuildSystem plugin, Player player) {
    SettingsManager settingsManager = plugin.getSettingsManager();
    Settings settings = settingsManager.getSettings(player);
    Optional<XMaterial> glass = XMaterial.matchXMaterial(settings.getGlassColor().name() + "_STAINED_GLASS_PANE");
    return glass.orElse(XMaterial.BLACK_STAINED_GLASS_PANE);
}
Also used : XMaterial(com.cryptomorin.xseries.XMaterial) Settings(com.eintosti.buildsystem.object.settings.Settings)

Example 45 with Settings

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

the class PlayerJoinListener method onPlayerJoin.

@EventHandler
@SuppressWarnings("deprecation")
public void onPlayerJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    settingsManager.createSettings(player);
    plugin.getSkullCache().cacheSkull(player.getName());
    String worldName = player.getWorld().getName();
    BuildWorld buildWorld = worldManager.getBuildWorld(worldName);
    if (buildWorld != null) {
        if (!buildWorld.isPhysics() && player.hasPermission("buildsystem.physics.message")) {
            player.sendMessage(plugin.getString("physics_deactivated_in_world").replace("%world%", buildWorld.getName()));
        }
        if (configValues.isArchiveVanish() && buildWorld.getStatus() == WorldStatus.ARCHIVE) {
            player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, false), false);
            Bukkit.getOnlinePlayers().forEach(pl -> pl.hidePlayer(player));
        }
    }
    Settings settings = settingsManager.getSettings(player);
    if (settings.isNoClip()) {
        plugin.getNoClipManager().startNoClip(player);
    }
    if (settings.isScoreboard()) {
        settingsManager.startScoreboard(player);
        plugin.getPlayerManager().forceUpdateSidebar(player);
    }
    if (settings.isSpawnTeleport()) {
        spawnManager.teleport(player);
    }
    if (settings.isClearInventory()) {
        player.getInventory().clear();
    }
    manageHidePlayer(player);
    addJoinItem(player);
    if (player.hasPermission("buildsystem.updates")) {
        performUpdateCheck(player);
    }
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Player(org.bukkit.entity.Player) PotionEffect(org.bukkit.potion.PotionEffect) 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