From 6b0c30c2415294667253dd88964c40df4e53d8ab Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 24 Nov 2022 17:26:29 +0100 Subject: [PATCH] Finalize CalendarCommand --- .../bungeecore/commands/CalendarCommand.java | 13 +++++++++---- src/de/steamwar/messages/BungeeCore.properties | 3 ++- src/de/steamwar/messages/BungeeCore_de.properties | 3 ++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/CalendarCommand.java b/src/de/steamwar/bungeecore/commands/CalendarCommand.java index 72863d0..65431e3 100644 --- a/src/de/steamwar/bungeecore/commands/CalendarCommand.java +++ b/src/de/steamwar/bungeecore/commands/CalendarCommand.java @@ -22,6 +22,9 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.inventory.SWInventory; import de.steamwar.bungeecore.inventory.SWItem; +import de.steamwar.bungeecore.sql.NodeMember; +import de.steamwar.bungeecore.sql.SchematicNode; +import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.command.SWCommand; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -78,16 +81,18 @@ public class CalendarCommand extends SWCommand { return; } + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); List items = new ArrayList<>(); for (Map.Entry present : dayToSchematicId.entrySet()) { - boolean b = false; // TODO: Add check if player has schematic + boolean b = NodeMember.getNodeMember(present.getValue(), user.getId()) != null; SWItem swItem = b ? SWItem.getSkull("MHF_Chest") : SWItem.getSkull("MHF_Present1"); swItem.setName(Message.parse("ADVENT_CALENDAR_DAY", player, present.getKey())); swItem.setCallback(click -> { - if (!click.isRightClick()) return; - if (month != Month.NOVEMBER) return; + if (b) return; + if (month != Month.DECEMBER) return; if (present.getKey() != day) return; - // TODO: Add to schematic + NodeMember.createNodeMember(present.getValue(), user.getId()); + Message.send("ADVENT_CALENDAR_OPEN", player, SchematicNode.getSchematicNode(present.getValue()).getName()); }); items.add(swItem); } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 583327d..314f26d 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -654,4 +654,5 @@ BUILDERCLOUD_VERSION=§cUnknown version. ADVENT_CALENDAR_TITLE=§eAdvent Calendar ADVENT_CALENDAR_DAY=§7Day§8: §e{0} ADVENT_CALENDAR_MESSAGE=§eDid you already open your advent calendar? -ADVENT_CALENDAR_MESSAGE_HOVER=§eClick to open! \ No newline at end of file +ADVENT_CALENDAR_MESSAGE_HOVER=§eClick to open! +ADVENT_CALENDAR_OPEN=§7You got §e{0} §7from the advent calendar! \ No newline at end of file diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index 89e1ea4..97de4ee 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -632,4 +632,5 @@ BUILDERCLOUD_VERSION=§cUnbekannte Version. ADVENT_CALENDAR_TITLE=§eAdventskalender ADVENT_CALENDAR_DAY=§7Tag§8: §e{0} ADVENT_CALENDAR_MESSAGE=§eHast du heute schon dein Geschenk geholt? -ADVENT_CALENDAR_MESSAGE_HOVER=§eKlicken zum öffnen! \ No newline at end of file +ADVENT_CALENDAR_MESSAGE_HOVER=§eKlicken zum öffnen! +ADVENT_CALENDAR_OPEN=§7Du hast §e{0}§7 aus dem Adventskalender erhalten! \ No newline at end of file