Search in sources :

Example 36 with Settings

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

the class SettingsManager method load.

public void load() {
    FileConfiguration configuration = settingsConfig.getFile();
    ConfigurationSection configurationSection = configuration.getConfigurationSection("settings");
    if (configurationSection == null) {
        return;
    }
    Set<String> uuids = configurationSection.getKeys(false);
    uuids.forEach(uuid -> {
        NavigatorType navigatorType = NavigatorType.valueOf(configuration.getString("settings." + uuid + ".type"));
        Color glassColor = configuration.getString("settings." + uuid + ".glass") != null ? Color.matchColor(configuration.getString("settings." + uuid + ".glass")) : Color.BLACK;
        WorldSort worldSort = WorldSort.matchWorldSort(configuration.getString("settings." + uuid + ".world-sort"));
        boolean clearInventory = configuration.isBoolean("settings." + uuid + ".clear-inventory") && configuration.getBoolean("settings." + uuid + ".clear-inventory");
        boolean disableInteract = configuration.isBoolean("settings." + uuid + ".disable-interact") && configuration.getBoolean("settings." + uuid + ".disable-interact");
        boolean hidePlayers = configuration.isBoolean("settings." + uuid + ".hide-players") && configuration.getBoolean("settings." + uuid + ".hide-players");
        boolean instantPlaceSigns = configuration.isBoolean("settings." + uuid + ".instant-place-signs") && configuration.getBoolean("settings." + uuid + ".instant-place-signs");
        boolean keepNavigator = configuration.isBoolean("settings." + uuid + ".keep-navigator") && configuration.getBoolean("settings." + uuid + ".keep-navigator");
        boolean nightVision = configuration.getBoolean("settings." + uuid + ".nightvision");
        boolean noClip = configuration.isBoolean("settings." + uuid + ".no-clip") && configuration.getBoolean("settings." + uuid + ".no-clip");
        boolean placePlants = configuration.isBoolean("settings." + uuid + ".place-plants") && configuration.getBoolean("settings." + uuid + ".place-plants");
        boolean scoreboard = !configuration.isBoolean("settings." + uuid + ".scoreboard") || configuration.getBoolean("settings." + uuid + ".scoreboard");
        boolean slabBreaking = configuration.isBoolean("settings." + uuid + ".slab-breaking") && configuration.getBoolean("settings." + uuid + ".slab-breaking");
        boolean spawnTeleport = !configuration.isBoolean("settings." + uuid + ".spawn-teleport") || configuration.getBoolean("settings." + uuid + ".spawn-teleport");
        boolean trapDoor = configuration.getBoolean("settings." + uuid + ".trapdoor");
        this.settings.put(UUID.fromString(uuid), new Settings(navigatorType, glassColor, worldSort, clearInventory, disableInteract, hidePlayers, instantPlaceSigns, keepNavigator, nightVision, noClip, placePlants, scoreboard, slabBreaking, spawnTeleport, trapDoor));
    });
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) Color(com.eintosti.buildsystem.object.settings.Color) NavigatorType(com.eintosti.buildsystem.object.navigator.NavigatorType) WorldSort(com.eintosti.buildsystem.object.settings.WorldSort) Settings(com.eintosti.buildsystem.object.settings.Settings) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Example 37 with Settings

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

the class SettingsManager method startScoreboard.

/**
 * Only set a player's scoreboard if {@link Settings#isScoreboard} is equal to {@code true}.
 *
 * @param player The player object
 */
public void startScoreboard(Player player) {
    if (!configValues.isScoreboard()) {
        return;
    }
    Settings settings = getSettings(player);
    FastBoard board = new FastBoard(player);
    this.boards.put(player.getUniqueId(), board);
    if (!settings.isScoreboard()) {
        stopScoreboard(player, settings);
        return;
    }
    board.updateTitle(this.scoreboardTitle);
    BukkitTask scoreboardTask = Bukkit.getScheduler().runTaskTimer(plugin, () -> updateScoreboard(player, board), 0L, 20L);
    settings.setScoreboardTask(scoreboardTask);
}
Also used : BukkitTask(org.bukkit.scheduler.BukkitTask) FastBoard(fr.mrmicky.fastboard.FastBoard) Settings(com.eintosti.buildsystem.object.settings.Settings)

Example 38 with Settings

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

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 39 with Settings

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

the class BuildSystem method onEnable.

@Override
public void onEnable() {
    this.getConfig().options().copyDefaults(true);
    this.saveConfig();
    this.configValues = new ConfigValues(this);
    initClasses();
    if (!initVersionedClasses()) {
        getLogger().severe("BuildSystem does not support your server version: " + version);
        getLogger().severe("Disabling plugin...");
        this.setEnabled(false);
        return;
    }
    registerCommands();
    registerTabCompleter();
    registerListeners();
    registerStats();
    registerExpansions();
    performUpdateCheck();
    worldManager.load();
    settingsManager.load();
    spawnManager.load();
    Bukkit.getOnlinePlayers().forEach(pl -> {
        getSkullCache().cacheSkull(pl.getName());
        Settings settings = settingsManager.createSettings(pl);
        settingsManager.startScoreboard(pl, settings);
        noClipManager.startNoClip(pl, settings);
    });
    Bukkit.getConsoleSender().sendMessage(ChatColor.RESET + "BuildSystem ยป Plugin " + ChatColor.GREEN + "enabled" + ChatColor.RESET + "!");
}
Also used : ConfigValues(com.eintosti.buildsystem.config.ConfigValues) Settings(com.eintosti.buildsystem.object.settings.Settings)

Example 40 with Settings

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

the class SettingsManager method startScoreboard.

/**
 * Only set a player's scoreboard if {@link Settings#isScoreboard} is equal to {@code true}.
 *
 * @param player The player object
 */
public void startScoreboard(Player player) {
    if (!configValues.isScoreboard()) {
        return;
    }
    Settings settings = getSettings(player);
    FastBoard board = new FastBoard(player);
    this.boards.put(player.getUniqueId(), board);
    if (!settings.isScoreboard()) {
        stopScoreboard(player, settings);
        return;
    }
    board.updateTitle(this.scoreboardTitle);
    BukkitTask scoreboardTask = Bukkit.getScheduler().runTaskTimer(plugin, () -> updateScoreboard(player, board), 0L, 20L);
    settings.setScoreboardTask(scoreboardTask);
}
Also used : BukkitTask(org.bukkit.scheduler.BukkitTask) FastBoard(fr.mrmicky.fastboard.FastBoard) Settings(com.eintosti.buildsystem.object.settings.Settings)

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