13
0

Add AdventsCalendar
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
yoyosource 2023-11-30 20:10:44 +01:00
Ursprung 4d630f136a
Commit a29d71b4c3
13 geänderte Dateien mit 489 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -44,7 +44,11 @@ public class Config {
yml.getList("portals", Portal.getPortals()); yml.getList("portals", Portal.getPortals());
yml.getList("holograms", Hologram.getHolograms()); yml.getList("holograms", Hologram.getHolograms());
JumpAndRun.points = (List<Vector>) yml.getList("jumpPoints", new ArrayList<>()); JumpAndRun.actualPoints = (List<Vector>) 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"); waitingHallSpawn = yml.getLocation("waitingHallSpawn");
} }
@ -61,7 +65,7 @@ public class Config {
yml.set("portals", Portal.getPortals()); yml.set("portals", Portal.getPortals());
yml.set("holograms", Hologram.getHolograms()); yml.set("holograms", Hologram.getHolograms());
yml.set("waitingHallSpawn", waitingHallSpawn); yml.set("waitingHallSpawn", waitingHallSpawn);
yml.set("jumpPoints", JumpAndRun.points); yml.set("jumpPoints", JumpAndRun.actualPoints);
LobbySystem.getPlugin().saveConfig(); LobbySystem.getPlugin().saveConfig();
} }

Datei anzeigen

@ -29,6 +29,7 @@ import de.steamwar.lobby.jumpandrun.JumpAndRunCommand;
import de.steamwar.lobby.listener.*; import de.steamwar.lobby.listener.*;
import de.steamwar.lobby.map.CustomMapCommand; import de.steamwar.lobby.map.CustomMapCommand;
import de.steamwar.lobby.particle.ParticleListener; import de.steamwar.lobby.particle.ParticleListener;
import de.steamwar.lobby.special.advent.AdventsCalendar;
import de.steamwar.lobby.team.TeamPlayer; import de.steamwar.lobby.team.TeamPlayer;
import de.steamwar.message.Message; import de.steamwar.message.Message;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -75,6 +76,7 @@ public class LobbySystem extends JavaPlugin {
new TeamPlayer(); new TeamPlayer();
// EggHunt.init(); // EggHunt.init();
AdventsCalendar.init();
new AlphaWall(l -> l.getX() > 999, AlphaWall.REFLECT_X); new AlphaWall(l -> l.getX() > 999, AlphaWall.REFLECT_X);
new AlphaWall(l -> l.getX() < 2977, AlphaWall.REFLECT_X); new AlphaWall(l -> l.getX() < 2977, AlphaWall.REFLECT_X);

Datei anzeigen

@ -267,3 +267,9 @@ EASTER_EGG_86 = Union
EASTER_EGG_87 = Mushroom EASTER_EGG_87 = Mushroom
EASTER_EGG_88 = Advertisement EASTER_EGG_88 = Advertisement
EASTER_EGG_89 = Stairway to heaven 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!

Datei anzeigen

@ -256,3 +256,9 @@ EASTER_EGG_86 = Union
EASTER_EGG_87 = Mushroom EASTER_EGG_87 = Mushroom
EASTER_EGG_88 = Werbung EASTER_EGG_88 = Werbung
EASTER_EGG_89 = Stairway to heaven 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!

Datei anzeigen

@ -2,7 +2,6 @@ package de.steamwar.lobby.boatrace;
import de.steamwar.entity.REntity; import de.steamwar.entity.REntity;
import de.steamwar.entity.REntityServer; import de.steamwar.entity.REntityServer;
import de.steamwar.entity.RPlayer;
import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.util.Leaderboard; import de.steamwar.lobby.util.Leaderboard;
import de.steamwar.sql.UserConfig; import de.steamwar.sql.UserConfig;
@ -23,7 +22,8 @@ import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.event.vehicle.VehicleMoveEvent; import org.bukkit.event.vehicle.VehicleMoveEvent;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import java.util.*; import java.util.EventListener;
import java.util.Random;
import static de.steamwar.lobby.util.Leaderboard.renderTime; import static de.steamwar.lobby.util.Leaderboard.renderTime;

Datei anzeigen

@ -14,7 +14,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -30,6 +29,7 @@ public class JumpAndRun extends BasicListener {
private static final String BAR_EMPTY = "||||||||||||||||||||||||||||||"; private static final String BAR_EMPTY = "||||||||||||||||||||||||||||||";
public static List<Vector> points = new ArrayList<>(); public static List<Vector> points = new ArrayList<>();
public static List<Vector> actualPoints = new ArrayList<>();
private static final Map<Player, Integer> CURRENT_POS = new HashMap<>(); private static final Map<Player, Integer> CURRENT_POS = new HashMap<>();
private static final Map<Player, Integer> FAILS = new HashMap<>(); private static final Map<Player, Integer> FAILS = new HashMap<>();
@ -149,11 +149,6 @@ public class JumpAndRun extends BasicListener {
} }
} }
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
}
@EventHandler @EventHandler
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();

Datei anzeigen

@ -36,6 +36,9 @@ import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import java.time.LocalDate;
import java.time.Month;
public class PlayerSpawn extends BasicListener { public class PlayerSpawn extends BasicListener {
public static final int FIREWORK_SLOT = 2; public static final int FIREWORK_SLOT = 2;
@ -71,11 +74,18 @@ public class PlayerSpawn extends BasicListener {
inventory.setItem(EquipmentSlot.CHEST, ELYTRA); 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) @EventHandler(priority = EventPriority.HIGH)

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<SWListInv.SWListEntry<Present>> 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();
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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());
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<Present> 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<Present> 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");
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<Map<String, Integer>> blockList;
private final Set<Point> locations = new HashSet<>();
@Getter
private final int day;
@Getter
private final int schematicId;
private Set<Player> 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<Map<String, Integer>>) blockList;
blockList.forEach(object -> {
if (!(object instanceof Map)) return;
Map<String, ?> map = (Map<String, ?>) 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<String, Integer> pos = new HashMap<>();
pos.put("x", point.x);
pos.put("y", point.y);
pos.put("z", point.z);
blockList.add(pos);
});
AdventsCalendar.save();
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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());
});
}
}

Datei anzeigen

@ -11,7 +11,7 @@ import org.bukkit.inventory.ItemStack;
public class EggHuntListener extends BasicListener { 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(); public static final ItemStack EASTER_HUNT = new ItemBuilder(Material.DRAGON_EGG, 1).setDisplayName("§fEaster Hunt").build();
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)