From a29d71b4c3046075c6633097c37eaffd06ea9818 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 30 Nov 2023 20:10:44 +0100 Subject: [PATCH] Add AdventsCalendar --- src/de/steamwar/lobby/Config.java | 8 +- src/de/steamwar/lobby/LobbySystem.java | 2 + src/de/steamwar/lobby/LobbySystem.properties | 8 +- .../steamwar/lobby/LobbySystem_de.properties | 8 +- src/de/steamwar/lobby/boatrace/BoatRace.java | 4 +- .../steamwar/lobby/jumpandrun/JumpAndRun.java | 7 +- .../steamwar/lobby/listener/PlayerSpawn.java | 16 +- .../lobby/special/advent/AdventCommand.java | 88 +++++++++++ .../lobby/special/advent/AdventListener.java | 62 ++++++++ .../lobby/special/advent/AdventsCalendar.java | 73 +++++++++ .../lobby/special/advent/Present.java | 149 ++++++++++++++++++ .../special/advent/PresentClickListener.java | 78 +++++++++ .../lobby/special/easter/EggHuntListener.java | 2 +- 13 files changed, 489 insertions(+), 16 deletions(-) create mode 100644 src/de/steamwar/lobby/special/advent/AdventCommand.java create mode 100644 src/de/steamwar/lobby/special/advent/AdventListener.java create mode 100644 src/de/steamwar/lobby/special/advent/AdventsCalendar.java create mode 100644 src/de/steamwar/lobby/special/advent/Present.java create mode 100644 src/de/steamwar/lobby/special/advent/PresentClickListener.java diff --git a/src/de/steamwar/lobby/Config.java b/src/de/steamwar/lobby/Config.java index 26369f9..fd8eeb1 100644 --- a/src/de/steamwar/lobby/Config.java +++ b/src/de/steamwar/lobby/Config.java @@ -44,7 +44,11 @@ public class Config { yml.getList("portals", Portal.getPortals()); yml.getList("holograms", Hologram.getHolograms()); - JumpAndRun.points = (List) yml.getList("jumpPoints", new ArrayList<>()); + JumpAndRun.actualPoints = (List) yml.getList("jumpPoints", new ArrayList<>()); + JumpAndRun.points.addAll(JumpAndRun.actualPoints); + // Remove 2 Blocks in Tree + JumpAndRun.points.remove(141); + JumpAndRun.points.remove(140); waitingHallSpawn = yml.getLocation("waitingHallSpawn"); } @@ -61,7 +65,7 @@ public class Config { yml.set("portals", Portal.getPortals()); yml.set("holograms", Hologram.getHolograms()); yml.set("waitingHallSpawn", waitingHallSpawn); - yml.set("jumpPoints", JumpAndRun.points); + yml.set("jumpPoints", JumpAndRun.actualPoints); LobbySystem.getPlugin().saveConfig(); } diff --git a/src/de/steamwar/lobby/LobbySystem.java b/src/de/steamwar/lobby/LobbySystem.java index 1e2774f..9345ba6 100644 --- a/src/de/steamwar/lobby/LobbySystem.java +++ b/src/de/steamwar/lobby/LobbySystem.java @@ -29,6 +29,7 @@ import de.steamwar.lobby.jumpandrun.JumpAndRunCommand; import de.steamwar.lobby.listener.*; import de.steamwar.lobby.map.CustomMapCommand; import de.steamwar.lobby.particle.ParticleListener; +import de.steamwar.lobby.special.advent.AdventsCalendar; import de.steamwar.lobby.team.TeamPlayer; import de.steamwar.message.Message; import org.bukkit.plugin.java.JavaPlugin; @@ -75,6 +76,7 @@ public class LobbySystem extends JavaPlugin { new TeamPlayer(); // EggHunt.init(); + AdventsCalendar.init(); new AlphaWall(l -> l.getX() > 999, AlphaWall.REFLECT_X); new AlphaWall(l -> l.getX() < 2977, AlphaWall.REFLECT_X); diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 9139b31..16521b7 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -266,4 +266,10 @@ EASTER_EGG_85 = Old server Team EASTER_EGG_86 = Union EASTER_EGG_87 = Mushroom EASTER_EGG_88 = Advertisement -EASTER_EGG_89 = Stairway to heaven \ No newline at end of file +EASTER_EGG_89 = Stairway to heaven + +# Advent Calendar +ADVENT_CALENDAR_TITLE=§eAdvent Calendar +ADVENT_CALENDAR_DAY=§7Day§8: §e{0} +ADVENT_CALENDAR_MESSAGE=§eDid you already open your advent calendar? Click the Big Presents to claim! +ADVENT_CALENDAR_OPEN=§7You got §e{0} §7from the advent calendar! diff --git a/src/de/steamwar/lobby/LobbySystem_de.properties b/src/de/steamwar/lobby/LobbySystem_de.properties index 4824c0e..d604903 100644 --- a/src/de/steamwar/lobby/LobbySystem_de.properties +++ b/src/de/steamwar/lobby/LobbySystem_de.properties @@ -255,4 +255,10 @@ EASTER_EGG_85 = Altes Serverteam EASTER_EGG_86 = Union EASTER_EGG_87 = Mushroom EASTER_EGG_88 = Werbung -EASTER_EGG_89 = Stairway to heaven \ No newline at end of file +EASTER_EGG_89 = Stairway to heaven + +# Advent Calendar +ADVENT_CALENDAR_TITLE=§eAdventskalender +ADVENT_CALENDAR_DAY=§7Tag§8: §e{0} +ADVENT_CALENDAR_MESSAGE=§eHast du heute schon dein Geschenk geholt? Klicke die großen Geschenke zum erhalten! +ADVENT_CALENDAR_OPEN=§7Du hast §e{0}§7 aus dem Adventskalender erhalten! diff --git a/src/de/steamwar/lobby/boatrace/BoatRace.java b/src/de/steamwar/lobby/boatrace/BoatRace.java index 9aecb3e..44a442e 100644 --- a/src/de/steamwar/lobby/boatrace/BoatRace.java +++ b/src/de/steamwar/lobby/boatrace/BoatRace.java @@ -2,7 +2,6 @@ package de.steamwar.lobby.boatrace; import de.steamwar.entity.REntity; import de.steamwar.entity.REntityServer; -import de.steamwar.entity.RPlayer; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.util.Leaderboard; import de.steamwar.sql.UserConfig; @@ -23,7 +22,8 @@ import org.bukkit.event.vehicle.VehicleExitEvent; import org.bukkit.event.vehicle.VehicleMoveEvent; import org.bukkit.scheduler.BukkitTask; -import java.util.*; +import java.util.EventListener; +import java.util.Random; import static de.steamwar.lobby.util.Leaderboard.renderTime; diff --git a/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java b/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java index b7dba0c..079dbd9 100644 --- a/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java +++ b/src/de/steamwar/lobby/jumpandrun/JumpAndRun.java @@ -14,7 +14,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; @@ -30,6 +29,7 @@ public class JumpAndRun extends BasicListener { private static final String BAR_EMPTY = "||||||||||||||||||||||||||||||"; public static List points = new ArrayList<>(); + public static List actualPoints = new ArrayList<>(); private static final Map CURRENT_POS = new HashMap<>(); private static final Map FAILS = new HashMap<>(); @@ -149,11 +149,6 @@ public class JumpAndRun extends BasicListener { } } - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) { - Player player = event.getPlayer(); - } - @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { Player player = event.getPlayer(); diff --git a/src/de/steamwar/lobby/listener/PlayerSpawn.java b/src/de/steamwar/lobby/listener/PlayerSpawn.java index e732668..3c18b31 100644 --- a/src/de/steamwar/lobby/listener/PlayerSpawn.java +++ b/src/de/steamwar/lobby/listener/PlayerSpawn.java @@ -36,6 +36,9 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import java.time.LocalDate; +import java.time.Month; + public class PlayerSpawn extends BasicListener { public static final int FIREWORK_SLOT = 2; @@ -71,11 +74,18 @@ public class PlayerSpawn extends BasicListener { inventory.setItem(EquipmentSlot.CHEST, ELYTRA); - player.getInventory().setItem(FIREWORK_SLOT, FIREWORK); + int offset = 0; + LocalDate localDate = LocalDate.now(); + Month month = localDate.getMonth(); + if (month == Month.NOVEMBER || month == Month.DECEMBER || month == Month.JANUARY) { + offset = -1; + } - player.getInventory().setItem(PARTICLE_SLOT, PARTICLE); + player.getInventory().setItem(FIREWORK_SLOT + offset, FIREWORK); - player.getInventory().setItem(NETHER_STAR_SLOT, NETHER_STAR); + player.getInventory().setItem(PARTICLE_SLOT + offset, PARTICLE); + + player.getInventory().setItem(NETHER_STAR_SLOT + offset, NETHER_STAR); } @EventHandler(priority = EventPriority.HIGH) diff --git a/src/de/steamwar/lobby/special/advent/AdventCommand.java b/src/de/steamwar/lobby/special/advent/AdventCommand.java new file mode 100644 index 0000000..7c737e2 --- /dev/null +++ b/src/de/steamwar/lobby/special/advent/AdventCommand.java @@ -0,0 +1,88 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.lobby.special.advent; + +import de.steamwar.command.SWCommand; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import de.steamwar.inventory.SWListInv; +import de.steamwar.lobby.LobbySystem; +import de.steamwar.sql.NodeMember; +import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserGroup; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import java.time.LocalDate; +import java.time.Month; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +public class AdventCommand extends SWCommand { + + public AdventCommand() { + super("advent", "calendar", "adventcalendar"); + } + + // @Register + public void show(Player player, @Min(intValue = 1) @Max(intValue = 31) int day) { + if (SteamwarUser.get(player.getUniqueId()).getUserGroup() == UserGroup.Member) { + return; + } + + AdventsCalendar.getPresentList().forEach(present -> { + present.removePlayer(player); + if (day == present.getDay()) { + present.addPlayer(player); + } + }); + } + + @Register + public void genericCommand(Player player, String... args) { + LocalDate localDate = LocalDate.now(); + Month month = localDate.getMonth(); + if (month != Month.NOVEMBER && month != Month.DECEMBER && month != Month.JANUARY) { + return; + } + + Random random = new Random(localDate.getYear()); + + List> itemList = new ArrayList<>(); + SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); + AdventsCalendar.getPresentList().forEach(present -> { + NodeMember nodeMember = NodeMember.getNodeMember(present.getSchematicId(), steamwarUser.getId()); + SWItem item; + if (nodeMember == null) { + item = SWItem.getPlayerSkull(random.nextBoolean() ? "MHF_Present1" : "MHF_Present2"); + } else { + item = new SWItem(Material.CHEST, ""); + } + item.setName(LobbySystem.getMessage().parse("ADVENT_CALENDAR_DAY", player, present.getDay())); + itemList.add(new SWListInv.SWListEntry<>(item, present)); + }); + SWInventory swInventory = new SWInventory(player, 27, LobbySystem.getMessage().parse("ADVENT_CALENDAR_TITLE", player)); + for (int i = 0; i < itemList.size(); i++) { + swInventory.setItem(i, itemList.get(i).getItem()); + } + swInventory.open(); + } +} diff --git a/src/de/steamwar/lobby/special/advent/AdventListener.java b/src/de/steamwar/lobby/special/advent/AdventListener.java new file mode 100644 index 0000000..d614d55 --- /dev/null +++ b/src/de/steamwar/lobby/special/advent/AdventListener.java @@ -0,0 +1,62 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.lobby.special.advent; + +import de.steamwar.inventory.SWItem; +import de.steamwar.lobby.listener.BasicListener; +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.inventory.ItemStack; + +import java.time.LocalDate; +import java.time.Month; + +public class AdventListener extends BasicListener { + + public static final int ADVENT_SLOT = 7; + public static final SWItem ADVENT = SWItem.getPlayerSkull("MHF_Present1"); + static { + ADVENT.setName("§fAdvent"); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void handlePlayerInteract(PlayerInteractEvent event) { + ItemStack item = event.getItem(); + if(item == null) + return; + + if (item.getType() == Material.PLAYER_HEAD && item.getItemMeta() != null && item.getItemMeta().getDisplayName().equals("§fAdvent")) { + event.getPlayer().performCommand("advent"); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onJoin(PlayerJoinEvent e) { + LocalDate localDate = LocalDate.now(); + Month month = localDate.getMonth(); + if (month != Month.NOVEMBER && month != Month.DECEMBER && month != Month.JANUARY) { + return; + } + e.getPlayer().getInventory().setItem(ADVENT_SLOT, ADVENT.getItemStack()); + } +} diff --git a/src/de/steamwar/lobby/special/advent/AdventsCalendar.java b/src/de/steamwar/lobby/special/advent/AdventsCalendar.java new file mode 100644 index 0000000..06d7af8 --- /dev/null +++ b/src/de/steamwar/lobby/special/advent/AdventsCalendar.java @@ -0,0 +1,73 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.lobby.special.advent; + +import de.steamwar.lobby.LobbySystem; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public class AdventsCalendar { + + private static List presentList = new ArrayList<>(); + + private static File file = new File(LobbySystem.getPlugin().getDataFolder(), "presents.yml"); + private static FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(file); + + public static void init() { + new AdventCommand(); + new AdventListener(); + new PresentClickListener(); + } + + static { + for (int i = 1; i <= 31; i++) { + if (i > 24 && i < 31) continue; + ConfigurationSection section = fileConfiguration.getConfigurationSection(i + ""); + if (section == null) { + section = fileConfiguration.createSection(i + ""); + } + presentList.add(new Present(i, section)); + if (i == 24) { + presentList.add(new Present(25, section)); + presentList.add(new Present(26, section)); + } + } + } + + public static List getPresentList() { + return presentList; + } + + public static void save() { + long time = System.currentTimeMillis(); + try { + fileConfiguration.save(file); + } catch (IOException e) { + // Ignore + } + System.out.println("Save time: " + (System.currentTimeMillis() - time) + "ms"); + } +} diff --git a/src/de/steamwar/lobby/special/advent/Present.java b/src/de/steamwar/lobby/special/advent/Present.java new file mode 100644 index 0000000..8688470 --- /dev/null +++ b/src/de/steamwar/lobby/special/advent/Present.java @@ -0,0 +1,149 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.lobby.special.advent; + +import de.steamwar.lobby.LobbySystem; +import de.steamwar.sql.NodeMember; +import de.steamwar.sql.SchematicNode; +import de.steamwar.sql.SteamwarUser; +import lombok.Data; +import lombok.Getter; +import org.bukkit.*; +import org.bukkit.block.data.BlockData; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.entity.Player; + +import java.util.*; + +public class Present { + + private static final World WORLD = Bukkit.getWorlds().get(0); + + @Data + private static class Point { + private final int x; + private final int y; + private final int z; + + public static Point toPoint(Location location) { + return new Point(location.getBlockX(), location.getBlockY(), location.getBlockZ()); + } + } + + private final List> blockList; + private final Set locations = new HashSet<>(); + + @Getter + private final int day; + + @Getter + private final int schematicId; + + private Set players = new HashSet<>(); + + public Present(int day, ConfigurationSection configurationSection) { + this.day = day; + if (configurationSection.contains("schematicId")) { + schematicId = configurationSection.getInt("schematicId"); + } else { + configurationSection.set("schematicId", -1); + schematicId = -1; + } + List blockList = configurationSection.getList("blocks"); + if (blockList == null) { + blockList = new ArrayList<>(); + configurationSection.set("blocks", blockList); + } + this.blockList = (List>) blockList; + blockList.forEach(object -> { + if (!(object instanceof Map)) return; + Map map = (Map) object; + locations.add(new Point((int) map.get("x"), (int) map.get("y"), (int) map.get("z"))); + }); + // generate(); + } + + public void click(Player player, SteamwarUser user, int day, Location location) { + if (day != this.day) return; + if (!locations.contains(Point.toPoint(location))) return; + if (NodeMember.getNodeMember(schematicId, user.getId()) != null) return; + NodeMember.createNodeMember(schematicId, user.getId()); + LobbySystem.getMessage().send("ADVENT_CALENDAR_OPEN", player, SchematicNode.getSchematicNode(schematicId).getName()); + player.playSound(location, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); + } + + public void removePlayer(Player player) { + players.remove(player); + locations.forEach(p -> { + Location loc = new Location(WORLD, p.x, p.y, p.z); + BlockData blockData = loc.getBlock().getBlockData(); + player.sendBlockChange(loc, blockData); + }); + } + + public void addPlayer(Player player) { + players.add(player); + locations.forEach(p -> { + Location loc = new Location(WORLD, p.x, p.y, p.z); + player.sendBlockChange(loc, BEDROCK); + }); + } + + public void edit(Player player, Location location) { + if (!players.contains(player)) return; + Point point = Point.toPoint(location); + if (locations.contains(point)) { + locations.remove(point); + } else { + locations.add(point); + } + generate(); + Bukkit.getScheduler().runTaskLater(LobbySystem.getPlugin(), () -> { + BlockData blockData = location.getBlock().getBlockData(); + players.forEach(pl -> { + if (pl == player) return; + if (locations.contains(point)) { + pl.sendBlockChange(location, blockData); + } else { + pl.sendBlockChange(location, BEDROCK); + } + }); + player.sendBlockChange(location, blockData); + locations.forEach(p -> { + Location loc = new Location(WORLD, p.x, p.y, p.z); + player.sendBlockChange(loc, BEDROCK); + }); + }, 4); + } + + private static final BlockData BEDROCK = Material.BEDROCK.createBlockData(); + + private void generate() { + blockList.clear(); + locations.forEach(point -> { + Map pos = new HashMap<>(); + pos.put("x", point.x); + pos.put("y", point.y); + pos.put("z", point.z); + blockList.add(pos); + }); + AdventsCalendar.save(); + } +} diff --git a/src/de/steamwar/lobby/special/advent/PresentClickListener.java b/src/de/steamwar/lobby/special/advent/PresentClickListener.java new file mode 100644 index 0000000..9180791 --- /dev/null +++ b/src/de/steamwar/lobby/special/advent/PresentClickListener.java @@ -0,0 +1,78 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.lobby.special.advent; + +import de.steamwar.lobby.LobbySystem; +import de.steamwar.lobby.listener.BasicListener; +import de.steamwar.sql.NodeMember; +import de.steamwar.sql.SteamwarUser; +import org.bukkit.block.Block; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; + +import java.time.LocalDate; +import java.time.Month; + +public class PresentClickListener extends BasicListener { + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) { + LocalDate localDate = LocalDate.now(); + int day = localDate.getDayOfMonth(); + Month month = localDate.getMonth(); + + if (month != Month.DECEMBER) { + return; + } + AdventsCalendar.getPresentList().forEach(present -> { + if (present.getDay() != day) return; + if (NodeMember.getNodeMember(present.getSchematicId(), SteamwarUser.get(event.getPlayer().getUniqueId()).getId()) != null) return; + LobbySystem.getMessage().send("ADVENT_CALENDAR_MESSAGE", event.getPlayer()); + }); + } + + @EventHandler + public void onPlayerInteract(PlayerInteractEvent event) { + Block block = event.getClickedBlock(); + if (block == null) return; + + LocalDate localDate = LocalDate.now(); + int day = localDate.getDayOfMonth(); + Month month = localDate.getMonth(); + + if (month != Month.DECEMBER) { + return; + } + + AdventsCalendar.getPresentList().forEach(present -> { + present.click(event.getPlayer(), SteamwarUser.get(event.getPlayer().getUniqueId()), day, block.getLocation()); + }); + } + + // @EventHandler + public void onPresentSetup(PlayerInteractEvent event) { + Block block = event.getClickedBlock(); + if (block == null) return; + AdventsCalendar.getPresentList().forEach(present -> { + present.edit(event.getPlayer(), block.getLocation()); + }); + } +} diff --git a/src/de/steamwar/lobby/special/easter/EggHuntListener.java b/src/de/steamwar/lobby/special/easter/EggHuntListener.java index 7492a02..92c903c 100644 --- a/src/de/steamwar/lobby/special/easter/EggHuntListener.java +++ b/src/de/steamwar/lobby/special/easter/EggHuntListener.java @@ -11,7 +11,7 @@ import org.bukkit.inventory.ItemStack; public class EggHuntListener extends BasicListener { - public static final int EASTER_EGG_SLOT = 7; + public static final int EASTER_EGG_SLOT = 8; public static final ItemStack EASTER_HUNT = new ItemBuilder(Material.DRAGON_EGG, 1).setDisplayName("§fEaster Hunt").build(); @EventHandler(priority = EventPriority.LOWEST)