Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double paywall send #243

Merged
merged 3 commits into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public String cpPlaceholders(Panel panel, PanelPosition position, Player p, Stri
case("online-players"): {
return Integer.toString(Bukkit.getServer().getOnlinePlayers().size());
}
case("online-players-true"): {
return Integer.toString(Bukkit.getOnlinePlayers().stream().filter(player -> !player.getMetadata("vanished").get(0).asBoolean()).collect(Collectors.toList()).size());
}
case("panel-position"): {
return position.toString();
}
Expand Down Expand Up @@ -323,12 +326,22 @@ public String cpPlaceholders(Panel panel, PanelPosition position, Player p, Stri
//checks for players online
if(identifier.startsWith("player-online-")) {
try {
String playerLocation = identifier.replace("player-online-", "");
Player[] playerFind = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]);
if (Double.parseDouble(playerLocation) > playerFind.length) {
return plugin.tex.colour(Objects.requireNonNull(plugin.config.getString("config.format.offline")));
if (identifier.endsWith("-true")){
String playerLocation = identifier.replace("player-online-", "");
Player[] playerFind = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().stream().filter(player -> !player.getMetadata("vanished").get(0).asBoolean()).collect(Collectors.toList()).size()]);
if (Double.parseDouble(playerLocation) > playerFind.length) {
return plugin.tex.colour(Objects.requireNonNull(plugin.config.getString("config.format.offline")));
} else {
return playerFind[(int)(Double.parseDouble(playerLocation) - 1)].getName();
}
} else {
return playerFind[(int)(Double.parseDouble(playerLocation) - 1)].getName();
String playerLocation = identifier.replace("player-online-", "");
Player[] playerFind = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]);
if (Double.parseDouble(playerLocation) > playerFind.length) {
return plugin.tex.colour(Objects.requireNonNull(plugin.config.getString("config.format.offline")));
} else {
return playerFind[(int)(Double.parseDouble(playerLocation) - 1)].getName();
}
}
}catch (Exception ex){
plugin.debug(ex,p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public PaywallOutput commandPayWall(Panel panel, Player p, String rawCommand) {
if(plugin.config.getBoolean("purchase.tokens.enable")){
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
}
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", command.split("\\s")[1]));

return PaywallOutput.Passed;
} else {
if(plugin.config.getBoolean("purchase.tokens.enable")){
Expand Down