Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Pablete1234 <[email protected]>
  • Loading branch information
Pablete1234 committed Jan 5, 2020
1 parent 45ed042 commit 95c113b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
23 changes: 10 additions & 13 deletions src/main/java/tc/oc/pgm/rotation/MapPoll.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package tc.oc.pgm.rotation;

import app.ashcon.intake.CommandException;
import java.lang.ref.WeakReference;
import java.util.*;
import java.util.stream.Collectors;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
Expand All @@ -18,10 +21,6 @@
import tc.oc.pgm.map.PGMMap;
import tc.oc.world.NMSHacks;

import java.lang.ref.WeakReference;
import java.util.*;
import java.util.stream.Collectors;

/** Represents a polling process, with a set of options. */
public class MapPoll {
private static final String SYMBOL_IGNORE = "\u2715"; // ✕
Expand Down Expand Up @@ -102,8 +101,7 @@ public void sendBook(MatchPlayer viewer) {
List<Component> content = new ArrayList<>(votes.size() + 2);
content.add(
new PersonalizedText(
new PersonalizedTranslatable("command.pool.vote.book.header"),
ChatColor.DARK_PURPLE));
new PersonalizedTranslatable("command.pool.vote.book.header"), ChatColor.DARK_PURPLE));
content.add(new PersonalizedText("\n\n"));

for (PGMMap pgmMap : votes.keySet()) content.add(getMapBookComponent(viewer, pgmMap));
Expand All @@ -123,11 +121,11 @@ public void sendBook(MatchPlayer viewer) {
private Component getMapBookComponent(MatchPlayer viewer, PGMMap map) {
boolean voted = votes.get(map).contains(viewer.getId());
return new PersonalizedText(
new PersonalizedText(
voted ? SYMBOL_VOTED : SYMBOL_IGNORE,
voted ? ChatColor.DARK_GREEN : ChatColor.DARK_RED),
new PersonalizedText(" ").bold(!voted), // Fix 1px symbol diff
new PersonalizedText(map.getName() + "\n", ChatColor.BOLD, ChatColor.GOLD))
new PersonalizedText(
voted ? SYMBOL_VOTED : SYMBOL_IGNORE,
voted ? ChatColor.DARK_GREEN : ChatColor.DARK_RED),
new PersonalizedText(" ").bold(!voted), // Fix 1px symbol diff
new PersonalizedText(map.getName() + "\n", ChatColor.BOLD, ChatColor.GOLD))
.hoverEvent(
HoverEvent.Action.SHOW_TEXT,
new PersonalizedTranslatable("command.pool.vote.hover").render(viewer.getBukkit()))
Expand All @@ -144,8 +142,7 @@ private Component getMapBookComponent(MatchPlayer viewer, PGMMap map) {
*/
public boolean toggleVote(PGMMap vote, UUID player) throws CommandException {
Set<UUID> votes = this.votes.get(vote);
if (votes == null)
throw new CommandException(vote.getName() + " is not an option in the poll");
if (votes == null) throw new CommandException(vote.getName() + " is not an option in the poll");

if (votes.add(player)) return true;
votes.remove(player);
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/tc/oc/pgm/rotation/VotingPool.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package tc.oc.pgm.rotation;

import java.util.HashMap;
import java.util.Map;
import org.bukkit.configuration.ConfigurationSection;
import tc.oc.pgm.api.match.Match;
import tc.oc.pgm.api.match.MatchScope;
import tc.oc.pgm.map.PGMMap;

import java.util.HashMap;
import java.util.Map;

public class VotingPool extends MapPool {

// Number of maps in the vote, unless not enough maps in pool
Expand Down Expand Up @@ -78,5 +77,4 @@ public void matchEnded(Match match) {
.getScheduler(MatchScope.LOADED)
.runTaskLater(20 * 5, () -> match.getPlayers().forEach(currentPoll::sendBook));
}

}

0 comments on commit 95c113b

Please sign in to comment.