Skip to content
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 @@ -32,6 +32,7 @@
import net.tfminecraft.simplefactions.war.campaign.progression.BelligerentRole;
import net.tfminecraft.simplefactions.war.campaign.ui.CampaignRouteEntry;
import net.tfminecraft.simplefactions.war.campaign.ui.CampaignRouteRenderer;
import net.tfminecraft.simplefactions.war.campaign.ui.CampaignUiTimeFormatter;
import net.tfminecraft.simplefactions.war.campaign.progression.CampaignChoiceService;
import net.tfminecraft.simplefactions.war.campaign.progression.CampaignCapabilityService;
import net.tfminecraft.simplefactions.war.campaign.progression.postbattle.CampaignPostBattleChoiceService;
Expand All @@ -52,6 +53,7 @@
import net.tfminecraft.simplefactions.war.campaign.runtime.BattleWindowService;
import net.tfminecraft.simplefactions.war.campaign.runtime.CampaignClock;
import net.tfminecraft.simplefactions.enums.SFGUI;
import net.tfminecraft.tlibs.objects.api.subapi.StringFormatter;

public class CampaignView {
private static final int ROUTE_SLOT_COUNT = 9;
Expand Down Expand Up @@ -494,8 +496,11 @@ private void handleHourToggleClick(Player player, War war, int hour) {
BattleVoteToggleResult result = BattleVoteService.toggleVote(
war, player.getUniqueId(), hour, faction, player.isOnline());
switch (result) {
case ADDED -> player.sendMessage("搂aAdded " + hour + ":00 UTC to your availability.");
case REMOVED -> player.sendMessage("搂aRemoved " + hour + ":00 UTC from your availability.");
// Battle hours are schedule (Europe/Paris) hours; label them the way the vote items do (the label can carry hex).
case ADDED -> player.sendMessage(StringFormatter.formatHex("搂aAdded "
+ CampaignUiTimeFormatter.formatUtcHour(war.getBattleDay(), hour) + "搂a to your availability."));
case REMOVED -> player.sendMessage(StringFormatter.formatHex("搂aRemoved "
+ CampaignUiTimeFormatter.formatUtcHour(war.getBattleDay(), hour) + "搂a from your availability."));
case REJECTED_INVALID_HOUR -> player.sendMessage("搂cThat hour is not in the battle window.");
case REJECTED_NOT_PARTICIPANT -> player.sendMessage("搂cYou are not eligible to vote in this war.");
case REJECTED_OFFLINE -> player.sendMessage("搂cYou must be online to vote.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import net.tfminecraft.simplefactions.war.campaign.schedule.ScheduledCampaignBattle;
import net.tfminecraft.simplefactions.war.campaign.ui.CampaignRouteEntry;
import net.tfminecraft.simplefactions.war.campaign.ui.CampaignRouteRenderer;
import net.tfminecraft.simplefactions.war.campaign.ui.CampaignUiTimeFormatter;
import net.tfminecraft.simplefactions.war.campaign.ui.CampaignViewRefreshService;
import net.tfminecraft.simplefactions.war.campaign.vote.BattleVoteService;
import net.tfminecraft.simplefactions.war.campaign.vote.VoteResults.BattleHourTally;
Expand All @@ -63,6 +64,7 @@
import net.tfminecraft.tlibs.TLibs;
import net.tfminecraft.tlibs.objects.api.ItemAPI;
import net.tfminecraft.tlibs.objects.api.subapi.ItemCreator;
import net.tfminecraft.tlibs.objects.api.subapi.StringFormatter;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
Expand Down Expand Up @@ -588,11 +590,13 @@ void realHourTogglesAddRemovePersistAndRefreshAvailability() {
view.campaignView(player, war, true);
click(28);
assertEquals(Set.of(20), war.getBattleVotes().get(player.getUniqueId()));
verify(player).sendMessage("搂aAdded 20:00 UTC to your availability.");
String label = CampaignUiTimeFormatter.formatUtcHour(war.getBattleDay(), 20);
assertTrue(label.startsWith("20:00 CET"));
verify(player).sendMessage(StringFormatter.formatHex("搂aAdded " + label + "搂a to your availability."));
assertLore(top().getItem(28), "Click to remove");
click(28);
assertFalse(war.getBattleVotes().containsKey(player.getUniqueId()));
verify(player).sendMessage("搂aRemoved 20:00 UTC from your availability.");
verify(player).sendMessage(StringFormatter.formatHex("搂aRemoved " + label + "搂a from your availability."));
wars.verify(() -> WarManager.persist(war), times(2));
}

Expand Down
Loading