forked from SteamWar/SteamWar
Add BauSystem module
Fix ci java version Fix LinkageProcessor
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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.time.LocalDate;
|
||||
import java.time.Month;
|
||||
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");
|
||||
}
|
||||
|
||||
public static boolean active() {
|
||||
LocalDate localDate = LocalDate.now();
|
||||
Month month = localDate.getMonth();
|
||||
return month == Month.DECEMBER;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user