Search in sources :

Example 1 with PluginConfiguration

use of net.dzikoysk.funnyguilds.config.PluginConfiguration in project FunnyGuilds by FunnyGuilds.

the class SecurityReach method on.

public static void on(Player player, double distance) {
    MessageConfiguration messages = FunnyGuilds.getInstance().getMessageConfiguration();
    PluginConfiguration config = FunnyGuilds.getInstance().getPluginConfiguration();
    double ping = PingUtils.getPing(player);
    double tpsDelayMs = (1000.0 / MinecraftServerUtils.getTpsInLastMinute() - 50.0);
    double compensation = player.getGameMode().equals(GameMode.CREATIVE) ? CREATIVE_REACH : SURVIVAL_REACH;
    compensation += config.reachCompensation;
    compensation += SecurityUtils.compensationMs(IMPORTANCE_OF_PING * ping);
    compensation += SecurityUtils.compensationMs(IMPORTANCE_OF_TPS * tpsDelayMs);
    if (distance < compensation) {
        return;
    }
    String message = messages.securitySystemReach.replace("{DISTANCE}", FORMAT.format(distance));
    SecurityUtils.addViolationLevel(UserUtils.get(player.getUniqueId()));
    SecurityUtils.sendToOperator(player, "Reach", message);
}
Also used : MessageConfiguration(net.dzikoysk.funnyguilds.config.MessageConfiguration) PluginConfiguration(net.dzikoysk.funnyguilds.config.PluginConfiguration)

Example 2 with PluginConfiguration

use of net.dzikoysk.funnyguilds.config.PluginConfiguration in project FunnyGuilds by FunnyGuilds.

the class SecurityFreeCam method on.

public static void on(Player player, Vector origin, Vector hitPoint, double distance) {
    MessageConfiguration messages = FunnyGuilds.getInstance().getMessageConfiguration();
    PluginConfiguration config = FunnyGuilds.getInstance().getPluginConfiguration();
    Vector directionToHitPoint = hitPoint.clone().subtract(origin);
    BlockIterator blockIterator = new BlockIterator(player.getWorld(), origin, directionToHitPoint, 0, Math.max((int) distance, 1));
    // TODO: compensationSneaking will be removed after add the cursor height check on each client version.
    int compensationSneaking = player.isSneaking() ? 1 : 0;
    List<Block> blocks = StreamSupport.stream(Spliterators.spliteratorUnknownSize(blockIterator, Spliterator.NONNULL | Spliterator.IMMUTABLE), false).filter(block -> !block.isLiquid()).filter(block -> block.getType().isSolid()).filter(block -> block.getType().isOccluding() || block.getType().equals(Material.GLASS)).limit(8).collect(toList());
    if (blocks.size() <= config.freeCamCompensation + compensationSneaking) {
        return;
    }
    String message = messages.securitySystemFreeCam;
    message = StringUtils.replace(message, "{BLOCKS}", Joiner.on(", ").join(blocks, b -> MaterialUtils.getMaterialName(b.getType())).toString());
    SecurityUtils.addViolationLevel(UserUtils.get(player.getUniqueId()));
    SecurityUtils.sendToOperator(player, "FreeCam", message);
}
Also used : MessageConfiguration(net.dzikoysk.funnyguilds.config.MessageConfiguration) StringUtils(panda.utilities.StringUtils) Spliterators(java.util.Spliterators) MaterialUtils(net.dzikoysk.funnyguilds.shared.bukkit.MaterialUtils) SecurityUtils(net.dzikoysk.funnyguilds.feature.security.SecurityUtils) Player(org.bukkit.entity.Player) BlockIterator(org.bukkit.util.BlockIterator) Vector(org.bukkit.util.Vector) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) FunnyGuilds(net.dzikoysk.funnyguilds.FunnyGuilds) Block(org.bukkit.block.Block) PluginConfiguration(net.dzikoysk.funnyguilds.config.PluginConfiguration) StreamSupport(java.util.stream.StreamSupport) UserUtils(net.dzikoysk.funnyguilds.user.UserUtils) Spliterator(java.util.Spliterator) Material(org.bukkit.Material) Joiner(panda.utilities.text.Joiner) BlockIterator(org.bukkit.util.BlockIterator) MessageConfiguration(net.dzikoysk.funnyguilds.config.MessageConfiguration) PluginConfiguration(net.dzikoysk.funnyguilds.config.PluginConfiguration) Block(org.bukkit.block.Block) Vector(org.bukkit.util.Vector)

Example 3 with PluginConfiguration

use of net.dzikoysk.funnyguilds.config.PluginConfiguration in project FunnyGuilds by FunnyGuilds.

the class IndividualPrefix method initialize.

public void initialize() {
    Set<Guild> guilds = plugin.getGuildManager().getGuilds();
    Scoreboard scoreboard = getScoreboard();
    if (user.hasGuild()) {
        Guild guild = user.getGuild().get();
        guilds.remove(guild);
        PluginConfiguration config = plugin.getPluginConfiguration();
        String our = config.prefixOur.getValue();
        String ally = config.prefixAllies.getValue();
        String enemy = config.prefixEnemies.getValue();
        String other = config.prefixOther.getValue();
        Team team = scoreboard.getTeam(guild.getTag());
        if (team == null) {
            team = scoreboard.registerNewTeam(guild.getTag());
        }
        for (User member : guild.getMembers()) {
            if (!team.hasEntry(member.getName())) {
                team.addEntry(member.getName());
            }
        }
        team.setPrefix(preparePrefix(our, guild));
        for (Guild one : guilds) {
            if (one == null || one.getTag() == null) {
                continue;
            }
            team = scoreboard.getTeam(one.getTag());
            if (team == null) {
                team = scoreboard.registerNewTeam(one.getTag());
            }
            for (User member : one.getMembers()) {
                if (!team.hasEntry(member.getName())) {
                    team.addEntry(member.getName());
                }
            }
            if (guild.getAllies().contains(one)) {
                team.setPrefix(preparePrefix(ally, one));
            } else if (guild.getEnemies().contains(one) || one.getEnemies().contains(guild)) {
                team.setPrefix(preparePrefix(enemy, one));
            } else {
                team.setPrefix(preparePrefix(other, one));
            }
        }
    } else {
        String other = plugin.getPluginConfiguration().prefixOther.getValue();
        registerSoloTeam(this.user);
        for (Guild one : guilds) {
            if (one == null || one.getTag() == null) {
                continue;
            }
            Team team = scoreboard.getTeam(one.getTag());
            if (team == null) {
                team = scoreboard.registerNewTeam(one.getTag());
            }
            for (User member : one.getMembers()) {
                if (!team.hasEntry(member.getName())) {
                    team.addEntry(member.getName());
                }
            }
            team.setPrefix(preparePrefix(other, one));
        }
    }
}
Also used : User(net.dzikoysk.funnyguilds.user.User) Scoreboard(org.bukkit.scoreboard.Scoreboard) PluginConfiguration(net.dzikoysk.funnyguilds.config.PluginConfiguration) Team(org.bukkit.scoreboard.Team) Guild(net.dzikoysk.funnyguilds.guild.Guild)

Example 4 with PluginConfiguration

use of net.dzikoysk.funnyguilds.config.PluginConfiguration in project FunnyGuilds by FunnyGuilds.

the class MVdWPlaceholderAPIHook method init.

@Override
public HookInitResult init() {
    PluginConfiguration pluginConfiguration = this.plugin.getPluginConfiguration();
    UserManager userManager = this.plugin.getUserManager();
    UserRankManager userRankManager = this.plugin.getUserRankManager();
    GuildRankManager guildRankManager = this.plugin.getGuildRankManager();
    DefaultTablistVariables.getFunnyVariables().forEach((id, variable) -> PlaceholderAPI.registerPlaceholder(plugin, "funnyguilds_" + id, event -> {
        OfflinePlayer target = event.getOfflinePlayer();
        if (target == null) {
            return StringUtils.EMPTY;
        }
        return userManager.findByUuid(target.getUniqueId()).map(variable::get).orElseGet("none");
    }));
    Set<String> userTopIds = userRankManager.getTopIds();
    Set<String> guildTopIds = guildRankManager.getTopIds();
    // User TOP, positions 1-100
    for (int i = 1; i <= 100; i++) {
        final int position = i;
        userTopIds.forEach(id -> PlaceholderAPI.registerPlaceholder(plugin, "funnyguilds_ptop-" + id + "-" + position, event -> {
            User user = userManager.findByPlayer(event.getPlayer()).getOrNull();
            return RankUtils.parseTop(user, "{PTOP-" + id.toUpperCase() + "-" + position + "}");
        }));
        if (pluginConfiguration.top.enableLegacyPlaceholders) {
            PlaceholderAPI.registerPlaceholder(plugin, "funnyguilds_ptop-" + position, event -> {
                User user = userManager.findByPlayer(event.getPlayer()).getOrNull();
                return RankUtils.parseRank(user, "{PTOP-" + position + "}");
            });
        }
    }
    // Guild TOP, positions 1-100
    for (int i = 1; i <= 100; i++) {
        final int position = i;
        guildTopIds.forEach(id -> PlaceholderAPI.registerPlaceholder(plugin, "funnyguilds_gtop-" + id + "-" + position, event -> {
            User user = userManager.findByPlayer(event.getPlayer()).getOrNull();
            return RankUtils.parseTop(user, "{GTOP-" + id.toUpperCase() + "-" + position + "}");
        }));
        if (pluginConfiguration.top.enableLegacyPlaceholders) {
            PlaceholderAPI.registerPlaceholder(plugin, "funnyguilds_gtop-" + position, event -> {
                User user = userManager.findByPlayer(event.getPlayer()).getOrNull();
                return RankUtils.parseRank(user, "{GTOP-" + position + "}");
            });
        }
    }
    userTopIds.forEach(id -> PlaceholderAPI.registerPlaceholder(plugin, "funnyguilds_position-" + id, event -> {
        User user = userManager.findByPlayer(event.getPlayer()).getOrNull();
        return RankUtils.parseTopPosition(user, "{POSITION-" + id.toUpperCase() + "}");
    }));
    guildTopIds.forEach(id -> PlaceholderAPI.registerPlaceholder(plugin, "funnyguilds_g-position-" + id, event -> {
        User user = userManager.findByPlayer(event.getPlayer()).getOrNull();
        return RankUtils.parseTopPosition(user, "{G-POSITION-" + id.toUpperCase() + "}");
    }));
    return HookInitResult.SUCCESS;
}
Also used : StringUtils(panda.utilities.StringUtils) Set(java.util.Set) RankUtils(net.dzikoysk.funnyguilds.rank.RankUtils) AbstractPluginHook(net.dzikoysk.funnyguilds.feature.hooks.AbstractPluginHook) Player(org.bukkit.entity.Player) UserRankManager(net.dzikoysk.funnyguilds.user.UserRankManager) PlaceholderAPI(be.maximvdw.placeholderapi.PlaceholderAPI) OfflinePlayer(org.bukkit.OfflinePlayer) GuildRankManager(net.dzikoysk.funnyguilds.guild.GuildRankManager) FunnyGuilds(net.dzikoysk.funnyguilds.FunnyGuilds) UserManager(net.dzikoysk.funnyguilds.user.UserManager) PluginConfiguration(net.dzikoysk.funnyguilds.config.PluginConfiguration) DefaultTablistVariables(net.dzikoysk.funnyguilds.feature.tablist.variable.DefaultTablistVariables) User(net.dzikoysk.funnyguilds.user.User) UserRankManager(net.dzikoysk.funnyguilds.user.UserRankManager) User(net.dzikoysk.funnyguilds.user.User) GuildRankManager(net.dzikoysk.funnyguilds.guild.GuildRankManager) UserManager(net.dzikoysk.funnyguilds.user.UserManager) PluginConfiguration(net.dzikoysk.funnyguilds.config.PluginConfiguration) OfflinePlayer(org.bukkit.OfflinePlayer)

Example 5 with PluginConfiguration

use of net.dzikoysk.funnyguilds.config.PluginConfiguration in project FunnyGuilds by FunnyGuilds.

the class WorldGuard7Hook method isInIgnoredRegion.

@Override
public boolean isInIgnoredRegion(Location location) {
    PluginConfiguration config = FunnyGuilds.getInstance().getPluginConfiguration();
    ApplicableRegionSet regionSet = getRegionSet(location);
    if (regionSet == null) {
        return false;
    }
    return regionSet.getRegions().stream().anyMatch(region -> config.assistsRegionsIgnored.contains(region.getId()));
}
Also used : PluginConfiguration(net.dzikoysk.funnyguilds.config.PluginConfiguration) ApplicableRegionSet(com.sk89q.worldguard.protection.ApplicableRegionSet)

Aggregations

PluginConfiguration (net.dzikoysk.funnyguilds.config.PluginConfiguration)22 User (net.dzikoysk.funnyguilds.user.User)9 FunnyGuilds (net.dzikoysk.funnyguilds.FunnyGuilds)7 Guild (net.dzikoysk.funnyguilds.guild.Guild)7 UserManager (net.dzikoysk.funnyguilds.user.UserManager)6 MessageConfiguration (net.dzikoysk.funnyguilds.config.MessageConfiguration)5 Player (org.bukkit.entity.Player)5 GuildRankManager (net.dzikoysk.funnyguilds.guild.GuildRankManager)3 Region (net.dzikoysk.funnyguilds.guild.Region)3 ApplicableRegionSet (com.sk89q.worldguard.protection.ApplicableRegionSet)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Set (java.util.Set)2 DefaultConcurrencyRequest (net.dzikoysk.funnyguilds.concurrency.util.DefaultConcurrencyRequest)2 GuildManager (net.dzikoysk.funnyguilds.guild.GuildManager)2 Location (org.bukkit.Location)2 Option (panda.std.Option)2 StringUtils (panda.utilities.StringUtils)2 PlaceholderAPI (be.maximvdw.placeholderapi.PlaceholderAPI)1 BungeeTabListPlusBukkitAPI (codecrafter47.bungeetablistplus.api.bukkit.BungeeTabListPlusBukkitAPI)1