forked from SteamWar/SteamWar
88 lines
3.2 KiB
Java
88 lines
3.2 KiB
Java
/*
|
|
* 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.SchematicNode;
|
|
import de.steamwar.sql.SteamwarUser;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.entity.Player;
|
|
|
|
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) {
|
|
if (!AdventsCalendar.active()) {
|
|
return;
|
|
}
|
|
|
|
Random random = new Random();
|
|
|
|
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.setLore(List.of("§e>>>§7 " + SchematicNode.getSchematicNode(present.getSchematicId()).getName()));
|
|
}
|
|
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();
|
|
}
|
|
}
|