SteamWar/BungeeCore
Archiviert
13
2

Add CalendarCommand
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2022-11-21 18:02:50 +01:00
Ursprung ef11620e2f
Commit 11a63101f1
2 geänderte Dateien mit 77 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -156,6 +156,7 @@ public class BungeeCore extends Plugin {
new LocalCommand(); new LocalCommand();
new SetLocaleCommand(); new SetLocaleCommand();
new BuilderCloudCommand(); new BuilderCloudCommand();
new CalendarCommand();
// Punishment Commands: // Punishment Commands:
new PunishmentCommand("ban", Punishment.PunishmentType.Ban); new PunishmentCommand("ban", Punishment.PunishmentType.Ban);

Datei anzeigen

@ -0,0 +1,76 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.bungeecore.commands;
import de.steamwar.bungeecore.inventory.SWInventory;
import de.steamwar.bungeecore.inventory.SWItem;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import sun.awt.OSInfo;
import java.time.LocalDate;
import java.time.Month;
import java.util.*;
public class CalendarCommand extends SWCommand {
private Map<Integer, Integer> dayToSchematicId = new HashMap<>();
{
for (int i = 1; i < 31; i++) {
dayToSchematicId.put(i, 0);
}
}
public CalendarCommand() {
super("calendar", null, "cal");
}
@Register
public void genericCommand(ProxiedPlayer player) {
LocalDate localDate = LocalDate.now();
int day = localDate.getDayOfMonth();
Month month = localDate.getMonth();
Random random = new Random(localDate.getYear());
if (month != Month.NOVEMBER && month != Month.DECEMBER && month != Month.JANUARY) {
return;
}
List<SWItem> items = new ArrayList<>();
for (Map.Entry<Integer, Integer> present : dayToSchematicId.entrySet()) {
boolean b = false; // TODO: Add check if player has schematic
SWItem swItem = new SWItem(b ? "iron_door" : "dark_oak_door", "§fTag " + present.getKey());
swItem.setCallback(click -> {
if (month != Month.DECEMBER) return;
if (present.getKey() != day) return;
// TODO: Add to schematic
});
items.add(swItem);
}
Collections.shuffle(items, random);
SWInventory inventory = new SWInventory(player, 36, "§6§lAdventskalender");
for (int i = 0; i < items.size(); i++) {
inventory.addItem(i, items.get(i));
}
inventory.open();
}
}