Search in sources :

Example 1 with VaultHook

use of net.dzikoysk.funnyguilds.feature.hooks.vault.VaultHook in project FunnyGuilds by FunnyGuilds.

the class HookManager method setupHooks.

public void setupHooks() {
    this.setupHook("WorldEdit", true, pluginName -> {
        try {
            Class.forName("com.sk89q.worldedit.Vector");
            return new WorldEdit6Hook(pluginName);
        } catch (ClassNotFoundException exception) {
            return new WorldEdit7Hook(pluginName);
        }
    }, true).subscribe(hook -> WORLD_EDIT = hook);
    this.setupHook("BungeeTabListPlus", true, pluginName -> {
        try {
            Class.forName("codecrafter47.bungeetablistplus.api.bukkit.Variable");
            return new BungeeTabListPlusHook(pluginName, plugin);
        } catch (ClassNotFoundException exception) {
            return null;
        }
    }, true).subscribe(hook -> BUNGEE_TAB_LIST_PLUS = hook);
    this.setupHook("Vault", true, VaultHook::new, true).subscribe(hook -> VAULT = hook);
    this.setupHook("MVdWPlaceholderAPI", true, pluginName -> new MVdWPlaceholderAPIHook(pluginName, plugin), true).subscribe(hook -> MVDW_PLACEHOLDER_API = hook);
    this.setupHook("PlaceholderAPI", true, pluginName -> new PlaceholderAPIHook(pluginName, plugin), true).subscribe(hook -> PLACEHOLDER_API = hook);
    this.setupHook("LeaderHeads", true, pluginName -> new LeaderHeadsHook(pluginName, plugin), true).subscribe(hook -> LEADER_HEADS = hook);
    this.<HologramHook>setupHook("HolographicDisplays", true, pluginName -> new HolographicDisplaysHook(pluginName, plugin), true).subscribe(hook -> HOLOGRAPHIC_DISPLAYS = hook);
}
Also used : Plugin(org.bukkit.plugin.Plugin) VaultHook(net.dzikoysk.funnyguilds.feature.hooks.vault.VaultHook) WorldEdit6Hook(net.dzikoysk.funnyguilds.feature.hooks.worldedit.WorldEdit6Hook) MVdWPlaceholderAPIHook(net.dzikoysk.funnyguilds.feature.hooks.mvdwplaceholderapi.MVdWPlaceholderAPIHook) HolographicDisplaysHook(net.dzikoysk.funnyguilds.feature.hooks.hologram.HolographicDisplaysHook) HashMap(java.util.HashMap) WorldGuard7Hook(net.dzikoysk.funnyguilds.feature.hooks.worldguard.WorldGuard7Hook) PandaStream(panda.std.stream.PandaStream) Function(java.util.function.Function) FunnyTabHook(net.dzikoysk.funnyguilds.feature.hooks.funnytab.FunnyTabHook) Option(panda.std.Option) BungeeTabListPlusHook(net.dzikoysk.funnyguilds.feature.hooks.bungeetablist.BungeeTabListPlusHook) FunnyGuilds(net.dzikoysk.funnyguilds.FunnyGuilds) LeaderHeadsHook(net.dzikoysk.funnyguilds.feature.hooks.leaderheads.LeaderHeadsHook) WorldEdit7Hook(net.dzikoysk.funnyguilds.feature.hooks.worldedit.WorldEdit7Hook) Map(java.util.Map) WorldEditHook(net.dzikoysk.funnyguilds.feature.hooks.worldedit.WorldEditHook) PlaceholderAPIHook(net.dzikoysk.funnyguilds.feature.hooks.placeholderapi.PlaceholderAPIHook) HologramHook(net.dzikoysk.funnyguilds.feature.hooks.hologram.HologramHook) Completable(panda.std.reactive.Completable) WorldGuardHook(net.dzikoysk.funnyguilds.feature.hooks.worldguard.WorldGuardHook) WorldGuard6Hook(net.dzikoysk.funnyguilds.feature.hooks.worldguard.WorldGuard6Hook) Bukkit(org.bukkit.Bukkit) HolographicDisplaysHook(net.dzikoysk.funnyguilds.feature.hooks.hologram.HolographicDisplaysHook) BungeeTabListPlusHook(net.dzikoysk.funnyguilds.feature.hooks.bungeetablist.BungeeTabListPlusHook) WorldEdit6Hook(net.dzikoysk.funnyguilds.feature.hooks.worldedit.WorldEdit6Hook) LeaderHeadsHook(net.dzikoysk.funnyguilds.feature.hooks.leaderheads.LeaderHeadsHook) MVdWPlaceholderAPIHook(net.dzikoysk.funnyguilds.feature.hooks.mvdwplaceholderapi.MVdWPlaceholderAPIHook) PlaceholderAPIHook(net.dzikoysk.funnyguilds.feature.hooks.placeholderapi.PlaceholderAPIHook) WorldEdit7Hook(net.dzikoysk.funnyguilds.feature.hooks.worldedit.WorldEdit7Hook) MVdWPlaceholderAPIHook(net.dzikoysk.funnyguilds.feature.hooks.mvdwplaceholderapi.MVdWPlaceholderAPIHook)

Example 2 with VaultHook

use of net.dzikoysk.funnyguilds.feature.hooks.vault.VaultHook in project FunnyGuilds by FunnyGuilds.

the class DefaultTablistVariables method install.

public static void install(TablistVariablesParser parser) {
    parser.add(new TimeFormattedVariable("HOUR", (user, time) -> time.getHour()));
    parser.add(new TimeFormattedVariable("MINUTE", (user, time) -> time.getMinute()));
    parser.add(new TimeFormattedVariable("SECOND", (user, time) -> time.getSecond()));
    parser.add(new TimeFormattedVariable("DAY_OF_WEEK", (user, time) -> time.getDayOfWeek().getDisplayName(TextStyle.FULL, POLISH_LOCALE)));
    parser.add(new TimeFormattedVariable("DAY_OF_MONTH", (user, time) -> time.getDayOfMonth()));
    parser.add(new TimeFormattedVariable("MONTH", (user, time) -> time.getMonth().getDisplayName(TextStyle.FULL, POLISH_LOCALE)));
    parser.add(new TimeFormattedVariable("MONTH_NUMBER", (user, time) -> time.getMonthValue()));
    parser.add(new TimeFormattedVariable("YEAR", (user, time) -> time.getYear()));
    parser.add(new SimpleTablistVariable("TPS", user -> MinecraftServerUtils.getFormattedTPS()));
    parser.add(new SimpleTablistVariable("WORLD", user -> user.getPlayer().map(Player::getWorld).map(World::getName).orElseGet("")));
    parser.add(new SimpleTablistVariable("ONLINE", user -> user.getPlayer().map(player -> Bukkit.getOnlinePlayers().stream().filter(player::canSee).count()).map(value -> Long.toString(value)).orElseGet("")));
    for (TablistVariable variable : getFunnyVariables().values()) {
        parser.add(variable);
    }
    if (HookManager.WORLD_GUARD.isPresent()) {
        String wgRegionNoValue = FunnyGuilds.getInstance().getMessageConfiguration().wgRegionNoValue;
        parser.add(new SimpleTablistVariable("WG-REGION", user -> {
            List<String> regionNames = getWorldGuardRegionNames(user);
            return regionNames != null && !regionNames.isEmpty() ? regionNames.get(0) : wgRegionNoValue;
        }));
        parser.add(new SimpleTablistVariable("WG-REGIONS", user -> {
            List<String> regionNames = getWorldGuardRegionNames(user);
            return regionNames != null && !regionNames.isEmpty() ? Joiner.on(", ").join(regionNames) : wgRegionNoValue;
        }));
    }
    if (HookManager.VAULT.isPresent() && VaultHook.isEconomyHooked()) {
        parser.add(new SimpleTablistVariable("VAULT-MONEY", user -> {
            return user.getPlayer().map(VaultHook::accountBalance).map(value -> Double.toString(value)).orElseGet("");
        }));
    }
}
Also used : VaultHook(net.dzikoysk.funnyguilds.feature.hooks.vault.VaultHook) SimpleTablistVariable(net.dzikoysk.funnyguilds.feature.tablist.variable.impl.SimpleTablistVariable) MessageConfiguration(net.dzikoysk.funnyguilds.config.MessageConfiguration) StringUtils(panda.utilities.StringUtils) Player(org.bukkit.entity.Player) Function(java.util.function.Function) Option(panda.std.Option) TimeFormattedVariable(net.dzikoysk.funnyguilds.feature.tablist.variable.impl.TimeFormattedVariable) StandaloneUserResolver(net.dzikoysk.funnyguilds.feature.tablist.variable.impl.GuildDependentTablistVariable.StandaloneUserResolver) UserManager(net.dzikoysk.funnyguilds.user.UserManager) Location(org.bukkit.Location) Locale(java.util.Locale) World(org.bukkit.World) Map(java.util.Map) MemberResolver(net.dzikoysk.funnyguilds.feature.tablist.variable.impl.GuildDependentTablistVariable.MemberResolver) Region(net.dzikoysk.funnyguilds.guild.Region) User(net.dzikoysk.funnyguilds.user.User) Bukkit(org.bukkit.Bukkit) Entity(net.dzikoysk.funnyguilds.Entity) TextStyle(java.time.format.TextStyle) MinecraftServerUtils(net.dzikoysk.funnyguilds.shared.bukkit.MinecraftServerUtils) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) GuildManager(net.dzikoysk.funnyguilds.guild.GuildManager) GuildRankManager(net.dzikoysk.funnyguilds.guild.GuildRankManager) List(java.util.List) FunnyGuilds(net.dzikoysk.funnyguilds.FunnyGuilds) NumberRange(net.dzikoysk.funnyguilds.config.NumberRange) GuildDependentTablistVariable(net.dzikoysk.funnyguilds.feature.tablist.variable.impl.GuildDependentTablistVariable) DefaultTops(net.dzikoysk.funnyguilds.rank.DefaultTops) PluginConfiguration(net.dzikoysk.funnyguilds.config.PluginConfiguration) Collections(java.util.Collections) HookManager(net.dzikoysk.funnyguilds.feature.hooks.HookManager) ChatUtils(net.dzikoysk.funnyguilds.shared.bukkit.ChatUtils) Joiner(panda.utilities.text.Joiner) SimpleTablistVariable(net.dzikoysk.funnyguilds.feature.tablist.variable.impl.SimpleTablistVariable) GuildDependentTablistVariable(net.dzikoysk.funnyguilds.feature.tablist.variable.impl.GuildDependentTablistVariable) TimeFormattedVariable(net.dzikoysk.funnyguilds.feature.tablist.variable.impl.TimeFormattedVariable) SimpleTablistVariable(net.dzikoysk.funnyguilds.feature.tablist.variable.impl.SimpleTablistVariable) Player(org.bukkit.entity.Player) List(java.util.List)

Aggregations

Map (java.util.Map)2 Function (java.util.function.Function)2 FunnyGuilds (net.dzikoysk.funnyguilds.FunnyGuilds)2 VaultHook (net.dzikoysk.funnyguilds.feature.hooks.vault.VaultHook)2 Bukkit (org.bukkit.Bukkit)2 Option (panda.std.Option)2 TextStyle (java.time.format.TextStyle)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Locale (java.util.Locale)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Entity (net.dzikoysk.funnyguilds.Entity)1 MessageConfiguration (net.dzikoysk.funnyguilds.config.MessageConfiguration)1 NumberRange (net.dzikoysk.funnyguilds.config.NumberRange)1 PluginConfiguration (net.dzikoysk.funnyguilds.config.PluginConfiguration)1 HookManager (net.dzikoysk.funnyguilds.feature.hooks.HookManager)1 BungeeTabListPlusHook (net.dzikoysk.funnyguilds.feature.hooks.bungeetablist.BungeeTabListPlusHook)1 FunnyTabHook (net.dzikoysk.funnyguilds.feature.hooks.funnytab.FunnyTabHook)1 HologramHook (net.dzikoysk.funnyguilds.feature.hooks.hologram.HologramHook)1