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);
}
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);
}
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));
}
}
}
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;
}
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()));
}
Aggregations