forked from SteamWar/SteamWar
Add BauSystem module
Fix ci java version Fix LinkageProcessor
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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 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.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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user