feat: Send message to chat when item is used

This commit is contained in:
2024-12-23 18:02:41 +01:00
parent 89d9799ae2
commit 143c4761f5
5 changed files with 28 additions and 2 deletions

View File

@ -68,6 +68,23 @@ public class Message {
yield "Hráč " + author.getName() + " sice získal item, ale měl plný inventář a tím pádem ho navždy ztratil.";
}
}
case ITEM_USED -> {
try {
var response = apiService.getItemInfo(playerKey, Long.valueOf(content)).execute();
var body = response.body();
if (!body.getSuccess()) {
yield "Hráč " + Cli.Colors.BLUE + author.getName() + Cli.Colors.RESET + " využil item unknown.";
}
var item = body.getData().get();
yield "Hráč " + Cli.Colors.BLUE + author.getName() + Cli.Colors.RESET + " využil item " + Cli.Colors.BLUE + item + Cli.Colors.RESET + ".";
} catch (IOException e) {
yield "Hráč " + Cli.Colors.BLUE + author.getName() + Cli.Colors.RESET + " využil item unknown.";
}
}
};
}
}

View File

@ -5,5 +5,6 @@ public enum MessageType {
MOVE_TO_ROOM,
GOT_ITEM,
LOST_ITEM,
ITEM_USED,
JOINED,
}

View File

@ -79,7 +79,7 @@ public class CommandPalette {
return switch (command.getCommandType()) {
case CUSTOM -> selectedOption;
case EXIT -> {
System.out.println("Exiting game...");
Cli.info("Odpojuji se ze hry...");
System.exit(0);
yield 0;