Remove CalendarCommand and CalendarListener from Bungee
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Ursprung
19903e9548
Commit
183d43dadb
@ -156,9 +156,6 @@ public class BungeeCore extends Plugin {
|
||||
new SetLocaleCommand();
|
||||
new BuilderCloudCommand();
|
||||
|
||||
new CalendarCommand();
|
||||
new CalendarListener();
|
||||
|
||||
new ModCommand();
|
||||
|
||||
// Punishment Commands:
|
||||
|
@ -1,113 +0,0 @@
|
||||
/*
|
||||
* 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.Message;
|
||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.sql.NodeMember;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Month;
|
||||
import java.util.*;
|
||||
|
||||
public class CalendarCommand extends SWCommand {
|
||||
|
||||
private static Map<Integer, Integer> dayToSchematicId = new HashMap<>();
|
||||
|
||||
static {
|
||||
dayToSchematicId.put(1, 105386);
|
||||
dayToSchematicId.put(2, 105463);
|
||||
dayToSchematicId.put(3, 105438);
|
||||
dayToSchematicId.put(4, 105383);
|
||||
dayToSchematicId.put(5, 105381);
|
||||
dayToSchematicId.put(6, 105396);
|
||||
dayToSchematicId.put(7, 105462);
|
||||
dayToSchematicId.put(8, 105457);
|
||||
dayToSchematicId.put(9, 105388);
|
||||
dayToSchematicId.put(10, 105390);
|
||||
dayToSchematicId.put(11, 105385);
|
||||
dayToSchematicId.put(12, 105397);
|
||||
dayToSchematicId.put(13, 105455);
|
||||
dayToSchematicId.put(14, 105389);
|
||||
dayToSchematicId.put(15, 105454);
|
||||
dayToSchematicId.put(16, 105394);
|
||||
dayToSchematicId.put(17, 105459);
|
||||
dayToSchematicId.put(18, 105384);
|
||||
dayToSchematicId.put(19, 105392);
|
||||
dayToSchematicId.put(20, 105465);
|
||||
dayToSchematicId.put(21, 105393);
|
||||
dayToSchematicId.put(22, 105464);
|
||||
dayToSchematicId.put(23, 105380);
|
||||
dayToSchematicId.put(24, 105505);
|
||||
dayToSchematicId.put(25, 107355);
|
||||
dayToSchematicId.put(26, 107355);
|
||||
dayToSchematicId.put(31, 105507);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
List<SWItem> items = new ArrayList<>();
|
||||
for (Map.Entry<Integer, Integer> present : dayToSchematicId.entrySet()) {
|
||||
boolean b = NodeMember.getNodeMember(present.getValue(), user.getId()) != null;
|
||||
SWItem randomPresent = random.nextDouble() > 0.5 ? SWItem.getSkull("MHF_Present1") : SWItem.getSkull("MHF_Present2");
|
||||
SWItem swItem = b ? SWItem.getSkull("MHF_Chest") : randomPresent;
|
||||
swItem.setName(Message.parse("ADVENT_CALENDAR_DAY", player, present.getKey()));
|
||||
swItem.setCallback(click -> {
|
||||
if (b) return;
|
||||
if (month != Month.DECEMBER) return;
|
||||
if (present.getKey() != day) return;
|
||||
if (NodeMember.getNodeMember(present.getValue(), user.getId()) != null) return;
|
||||
NodeMember.createNodeMember(present.getValue(), user.getId());
|
||||
Message.send("ADVENT_CALENDAR_OPEN", player, SchematicNode.getSchematicNode(present.getValue()).getName());
|
||||
});
|
||||
items.add(swItem);
|
||||
}
|
||||
Collections.shuffle(items, random);
|
||||
|
||||
SWInventory inventory = new SWInventory(player, 27, Message.parse("ADVENT_CALENDAR_TITLE", player));
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
inventory.addItem(i, items.get(i));
|
||||
}
|
||||
inventory.open();
|
||||
}
|
||||
|
||||
public static boolean hasDay(int day) {
|
||||
return dayToSchematicId.containsKey(day);
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* 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.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.commands.CalendarCommand;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Month;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class CalendarListener extends BasicListener {
|
||||
|
||||
@EventHandler
|
||||
public void onPostLogin(PostLoginEvent event) {
|
||||
LocalDate localDate = LocalDate.now();
|
||||
int day = localDate.getDayOfMonth();
|
||||
Month month = localDate.getMonth();
|
||||
|
||||
if (month != Month.DECEMBER) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CalendarCommand.hasDay(day)) {
|
||||
return;
|
||||
}
|
||||
|
||||
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
Message.send("ADVENT_CALENDAR_MESSAGE", event.getPlayer(), Message.parse("ADVENT_CALENDAR_MESSAGE_HOVER", event.getPlayer()), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/calendar"));
|
||||
}, 2, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren