Skip to content

Commit

Permalink
Revert "Use empty collections in updates instead of nulls"
Browse files Browse the repository at this point in the history
This reverts commit 7f622da
  • Loading branch information
nypi committed Dec 15, 2021
1 parent af9347a commit d22da43
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions common/src/main/java/ru/croccode/hypernull/message/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,28 +277,35 @@ public static List<String> formatUpdate(Update message) {
public static Update parseUpdate(List<String> lines) {
checkMessage(lines, "update");
Update message = new Update();
message.setBots(new HashMap<>());
message.setBotCoins(new HashMap<>());
message.setBlocks(new HashSet<>());
message.setCoins(new HashSet<>());
parseParameters(lines, (name, values) -> {
switch (name) {
case "round":
message.setRound(Integer.parseInt(values.get(0)));
break;
case "bot":
if (message.getBots() == null)
message.setBots(new HashMap<>());
if (message.getBotCoins() == null)
message.setBotCoins(new HashMap<>());

Integer botId = Integer.parseInt(values.get(3));
message.getBots().put(botId, new Point(
Integer.parseInt(values.get(0)),
Integer.parseInt(values.get(1))));
message.getBotCoins().put(botId, Integer.parseInt(values.get(2)));
break;
case "block":
if (message.getBlocks() == null)
message.setBlocks(new HashSet<>());

message.getBlocks().add(new Point(
Integer.parseInt(values.get(0)),
Integer.parseInt(values.get(1))));
break;
case "coin":
if (message.getCoins() == null)
message.setCoins(new HashSet<>());

message.getCoins().add(new Point(
Integer.parseInt(values.get(0)),
Integer.parseInt(values.get(1))));
Expand Down

0 comments on commit d22da43

Please sign in to comment.