use of net.dzikoysk.funnyguilds.config.MessageConfiguration 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.MessageConfiguration 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.MessageConfiguration in project FunnyGuilds by FunnyGuilds.
the class ItemUtils method playerHasEnoughItems.
public static boolean playerHasEnoughItems(Player player, List<ItemStack> requiredItems) {
PluginConfiguration config = FunnyGuilds.getInstance().getPluginConfiguration();
MessageConfiguration messages = FunnyGuilds.getInstance().getMessageConfiguration();
for (ItemStack requiredItem : requiredItems) {
if (player.getInventory().containsAtLeast(requiredItem, requiredItem.getAmount())) {
continue;
}
if (messages.createItems.isEmpty()) {
return false;
}
if (config.enableItemComponent) {
player.spigot().sendMessage(ItemComponentUtils.translateComponentPlaceholder(messages.createItems, requiredItems, requiredItem));
} else {
player.sendMessage(ItemUtils.translateTextPlaceholder(messages.createItems, requiredItems, requiredItem));
}
return false;
}
return true;
}
use of net.dzikoysk.funnyguilds.config.MessageConfiguration in project FunnyGuilds by FunnyGuilds.
the class WarInfoRequest method execute.
@Override
public void execute() throws Exception {
for (Map.Entry<Guild, FakeEntity> entry : GuildEntityHelper.getGuildEntities().entrySet()) {
if (entry.getValue().getId() != entityId) {
continue;
}
Guild guild = entry.getKey();
Option<Player> playerOption = this.user.getPlayer();
if (playerOption.isEmpty()) {
return;
}
Player player = playerOption.get();
if (SecuritySystem.onHitCrystal(player, guild)) {
return;
}
FunnyGuilds plugin = FunnyGuilds.getInstance();
PluginConfiguration config = plugin.getPluginConfiguration();
MessageConfiguration messages = plugin.getMessageConfiguration();
if (config.informationMessageCooldowns.cooldown(player, TimeUnit.SECONDS, config.infoPlayerCooldown)) {
return;
}
try {
infoExecutor.execute(player, new String[] { entry.getKey().getTag() });
return;
} catch (ValidationException validatorException) {
validatorException.getValidationMessage().peek(message -> ChatUtils.sendMessage(player, message));
}
}
}
use of net.dzikoysk.funnyguilds.config.MessageConfiguration in project FunnyGuilds by FunnyGuilds.
the class DefaultTablistVariables method createFunnyVariables.
private static void createFunnyVariables() {
PluginConfiguration config = FunnyGuilds.getInstance().getPluginConfiguration();
MessageConfiguration messages = FunnyGuilds.getInstance().getMessageConfiguration();
UserManager userManager = FunnyGuilds.getInstance().getUserManager();
GuildManager guildManager = FunnyGuilds.getInstance().getGuildManager();
GuildRankManager guildRankManager = FunnyGuilds.getInstance().getGuildRankManager();
putSimple("player", "PLAYER", User::getName);
putSimple("users", "USERS", user -> userManager.countUsers());
putSimple("guilds", "GUILDS", user -> guildManager.countGuilds());
putSimple("ping", "PING", User::getPing);
putSimple("points", "POINTS", user -> user.getRank().getPoints());
putSimple("position", "POSITION", user -> user.getRank().getPosition(DefaultTops.USER_POINTS_TOP));
putSimple("kills", "KILLS", user -> user.getRank().getKills());
putSimple("deaths", "DEATHS", user -> user.getRank().getDeaths());
putSimple("assists", "ASSISTS", user -> user.getRank().getAssists());
putSimple("logouts", "LOGOUTS", user -> user.getRank().getLogouts());
putSimple("kdr", "KDR", user -> String.format(Locale.US, "%.2f", user.getRank().getKDR()));
putSimple("ping-format", "PING-FORMAT", user -> NumberRange.inRangeToString(user.getPing(), config.pingFormat).replace("{PING}", String.valueOf(user.getPing())));
putSimple("points-format", "POINTS-FORMAT", user -> NumberRange.inRangeToString(user.getRank().getPoints(), config.pointsFormat).replace("{POINTS}", String.valueOf(user.getRank().getPoints())));
putGuild("g-name", "G-NAME", (user, guild) -> guild.getName(), user -> messages.gNameNoValue);
putGuild("g-tag", "G-TAG", (user, guild) -> guild.getTag(), user -> messages.gTagNoValue);
putGuild("g-owner", "G-OWNER", (user, guild) -> guild.getOwner().getName(), user -> messages.gOwnerNoValue);
putGuild("g-deputies", "G-DEPUTIES", (user, guild) -> guild.getDeputies().isEmpty() ? messages.gDeputiesNoValue : ChatUtils.toString(Entity.names(guild.getDeputies()), false), user -> messages.gDeputiesNoValue);
putGuild("g-deputy", "G-DEPUTY", (user, guild) -> guild.getDeputies().isEmpty() ? messages.gDeputyNoValue : guild.getDeputies().iterator().next().getName(), user -> messages.gDeputyNoValue);
// FUNNY_VARIABLES.put("g-deputy", GuildDependentTablistVariable.ofGuild("G-DEPUTY", guild -> guild.getDeputies().isEmpty() ? messages.gDeputyNoValue : guild.getDeputies().iterator().next(RandomUtils.RANDOM_INSTANCE.nextInt(guild.getDeputies().size())).getName(), user -> messages.gDeputyNoValue));
putGuild("g-lives", "G-LIVES", (user, guild) -> guild.getLives(), user -> "0");
putGuild("g-lives-symbol", "G-LIVES-SYMBOL", (user, guild) -> {
int lives = guild.getLives();
if (lives <= config.warLives) {
return StringUtils.repeated(lives, config.livesRepeatingSymbol.full.getValue()) + StringUtils.repeated(config.warLives - lives, config.livesRepeatingSymbol.empty.getValue());
} else {
return StringUtils.repeated(config.warLives, config.livesRepeatingSymbol.full.getValue()) + config.livesRepeatingSymbol.more.getValue();
}
}, user -> messages.livesNoValue);
putGuild("g-lives-symbol-all", "G-LIVES-SYMBOL-ALL", (user, guild) -> StringUtils.repeated(guild.getLives(), config.livesRepeatingSymbol.full.getValue()), user -> messages.livesNoValue);
putGuild("g-allies", "G-ALLIES", (user, guild) -> guild.getAllies().size(), user -> "0");
putGuild("g-points", "G-POINTS", (user, guild) -> guild.getRank().getAveragePoints(), user -> "0");
putGuild("g-kills", "G-KILLS", (user, guild) -> guild.getRank().getKills(), user -> "0");
putGuild("g-deaths", "G-DEATHS", (user, guild) -> guild.getRank().getDeaths(), user -> "0");
putGuild("g-kdr", "G-KDR", (user, guild) -> String.format(Locale.US, "%.2f", guild.getRank().getKDR()), user -> "0.00");
putGuild("g-members-online", "G-MEMBERS-ONLINE", (user, guild) -> guild.getOnlineMembers().size(), user -> "0");
putGuild("g-members-all", "G-MEMBERS-ALL", (user, guild) -> guild.getMembers().size(), user -> "0");
putGuild("g-validity", "G-VALIDITY", (user, guild) -> messages.dateFormat.format(guild.getValidityDate()), user -> messages.gValidityNoValue);
putGuild("g-points-format", "G-POINTS-FORMAT", (user, guild) -> NumberRange.inRangeToString(guild.getRank().getAveragePoints(), config.pointsFormat).replace("{POINTS}", String.valueOf(guild.getRank().getAveragePoints())), user -> NumberRange.inRangeToString(0, config.pointsFormat).replace("{POINTS}", "0"));
putGuild("g-position", "G-POSITION", (user, guild) -> guildRankManager.isRankedGuild(guild) ? String.valueOf(guild.getRank().getPosition(DefaultTops.GUILD_AVG_POINTS_TOP)) : messages.minMembersToIncludeNoValue, user -> messages.minMembersToIncludeNoValue);
putGuild("g-region-size", "G-REGION-SIZE", (user, guild) -> guild.getRegion().map(Region::getSize).map(value -> Integer.toString(value)).orElseGet(messages.gRegionSizeNoValue), user -> messages.gRegionSizeNoValue);
}
Aggregations