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

Expanding guild war rewards #752

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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 @@ -369,12 +369,36 @@ public void giveRewards(@NotNull SettingsManager settingsManager, @NotNull Guild
} else {
winners = challenge.getDefendPlayers();
}
List<String> commands = settingsManager.getProperty(WarSettings.WAR_REWARDS);
if (settingsManager.getProperty(WarSettings.WAR_REWARDS_ENABLED)) {

// Execute winner rewards
List<String> winnerCommands = settingsManager.getProperty(WarSettings.WAR_WINNER_COMMANDS);
if (settingsManager.getProperty(WarSettings.WAR_WINNER_COMMANDS_ENABLED)) {
winners.forEach(p -> {
Player player = Bukkit.getPlayer(p);
if (player != null) {
commands.forEach(c -> {
winnerCommands.forEach(c -> {
c = c.replace("{player}", player.getName());
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), c);
});
}
});
}

// Execute loser commands
List<UUID> losers;
UUID teamLoser = challenge.getLoser().getId();
if (teamLoser == challenge.getChallenger().getId()) {
losers = challenge.getDefendPlayers();
} else {
losers = challenge.getChallengePlayers();
}

List<String> loserCommands = settingsManager.getProperty(WarSettings.WAR_LOSER_COMMANDS);
if (settingsManager.getProperty(WarSettings.WAR_LOSER_COMMANDS_ENABLED)) {
losers.forEach(p -> {
Player player = Bukkit.getPlayer(p);
if (player != null) {
loserCommands.forEach(c -> {
c = c.replace("{player}", player.getName());
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), c);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,22 @@ public class WarSettings implements SettingsHolder {
"{loser} - The loser of the challenge"})
public static final Property<List<String>> POST_CHALLENGE_COMMANDS =
newListProperty("war.post-challenge-commands.commands", "");

@Comment("Would you like to give rewards to the winning guild?")
public static final Property<Boolean> WAR_REWARDS_ENABLED =
newProperty("war.rewards.enabled", false);
@Comment("Would you like to execute commands for the winning guild?")
public static final Property<Boolean> WAR_WINNER_COMMANDS_ENABLED =
newProperty("war.winnerCommands.enabled", false);

@Comment({"What rewards (commands) would you like to run for the winning Guild?",
"Current supports {player}."})
public static final Property<List<String>> WAR_REWARDS =
newListProperty("war.rewards.rewards", "");
public static final Property<List<String>> WAR_WINNER_COMMANDS =
newListProperty("war.winnerCommands.commands", "");

@Comment("Would you like to execute commands for the losing guild?")
public static final Property<Boolean> WAR_LOSER_COMMANDS_ENABLED =
newProperty("war.loserCommands.enabled", false);

@Comment({"What rewards (commands) would you like to run for the losing Guild?",
"Current supports {player}."})
public static final Property<List<String>> WAR_LOSER_COMMANDS =
newListProperty("war.loserCommands.commands", "");

}