added big events in craftattack plugin
This commit is contained in:
@@ -37,6 +37,11 @@ public class Event extends Appliance {
|
|||||||
DONE
|
DONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum EventType {
|
||||||
|
BIG,
|
||||||
|
SMALL
|
||||||
|
}
|
||||||
|
|
||||||
Countdown advertiseCountdown = new Countdown(
|
Countdown advertiseCountdown = new Countdown(
|
||||||
120,
|
120,
|
||||||
announcementData -> Component.text()
|
announcementData -> Component.text()
|
||||||
@@ -50,6 +55,7 @@ public class Event extends Appliance {
|
|||||||
);
|
);
|
||||||
public DisplayVillager.ConfigBound villager;
|
public DisplayVillager.ConfigBound villager;
|
||||||
private boolean isOpen = false;
|
private boolean isOpen = false;
|
||||||
|
private EventType eventType;
|
||||||
private AdvertisementStatus advertiseStatus = AdvertisementStatus.BEFORE;
|
private AdvertisementStatus advertiseStatus = AdvertisementStatus.BEFORE;
|
||||||
private UUID roomId;
|
private UUID roomId;
|
||||||
private final List<Reward> pendingRewards = new ArrayList<>();
|
private final List<Reward> pendingRewards = new ArrayList<>();
|
||||||
@@ -79,9 +85,11 @@ public class Event extends Appliance {
|
|||||||
if(this.isOpen) this.roomId = UUID.fromString(this.localConfig().getString("roomId", ""));
|
if(this.isOpen) this.roomId = UUID.fromString(this.localConfig().getString("roomId", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openEvent() {
|
public void openEvent(EventType type) {
|
||||||
if(this.isOpen) throw new ApplianceCommand.Error("Es läuft derzeit bereits ein Event!");
|
if(this.isOpen) throw new ApplianceCommand.Error("Es läuft derzeit bereits ein Event!");
|
||||||
|
this.eventType = type;
|
||||||
|
|
||||||
|
if(type.equals(EventType.SMALL)) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(Main.instance(), () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(Main.instance(), () -> {
|
||||||
ReqResp<EventRepository.CreatedRoom> sessionResponse = this.queryRepository(EventRepository.class).createSession();
|
ReqResp<EventRepository.CreatedRoom> sessionResponse = this.queryRepository(EventRepository.class).createSession();
|
||||||
|
|
||||||
@@ -91,6 +99,10 @@ public class Event extends Appliance {
|
|||||||
this.isOpen = true;
|
this.isOpen = true;
|
||||||
this.roomId = sessionResponse.data().uuid();
|
this.roomId = sessionResponse.data().uuid();
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isOpen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void joinEvent(Player p) {
|
public void joinEvent(Player p) {
|
||||||
@@ -112,6 +124,7 @@ public class Event extends Appliance {
|
|||||||
Main.instance().getLogger().info("Verbinde mit eventserver: " + p.getName());
|
Main.instance().getLogger().info("Verbinde mit eventserver: " + p.getName());
|
||||||
p.sendMessage(Component.text("Authentifiziere...", NamedTextColor.GREEN));
|
p.sendMessage(Component.text("Authentifiziere...", NamedTextColor.GREEN));
|
||||||
|
|
||||||
|
if(this.eventType.equals(EventType.SMALL)) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(Main.instance(), () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(Main.instance(), () -> {
|
||||||
ReqResp<EventRepository.QueueRoom.Response> queueResponse = this.queryRepository(EventRepository.class)
|
ReqResp<EventRepository.QueueRoom.Response> queueResponse = this.queryRepository(EventRepository.class)
|
||||||
.queueRoom(new EventRepository.QueueRoom(p.getUniqueId(), this.roomId));
|
.queueRoom(new EventRepository.QueueRoom(p.getUniqueId(), this.roomId));
|
||||||
@@ -126,6 +139,9 @@ public class Event extends Appliance {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PluginMessage.connect(p, "grand-event");
|
||||||
|
}
|
||||||
|
|
||||||
public void endEvent() {
|
public void endEvent() {
|
||||||
if(!this.isOpen) throw new ApplianceCommand.Error("Es läuft derzeit kein Event!");
|
if(!this.isOpen) throw new ApplianceCommand.Error("Es läuft derzeit kein Event!");
|
||||||
this.isOpen = false;
|
this.isOpen = false;
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class EventOpenSessionCommand extends ApplianceCommand<Event> {
|
public class EventOpenSessionCommand extends ApplianceCommand<Event> {
|
||||||
public EventOpenSessionCommand() {
|
public EventOpenSessionCommand() {
|
||||||
@@ -15,7 +19,17 @@ public class EventOpenSessionCommand extends ApplianceCommand<Event> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void execute(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) throws Exception {
|
protected void execute(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) throws Exception {
|
||||||
this.getAppliance().openEvent();
|
if(args.length == 1) {
|
||||||
|
this.getAppliance().openEvent(Event.EventType.SMALL);
|
||||||
|
} else {
|
||||||
|
this.getAppliance().openEvent(Event.EventType.valueOf(args[1]));
|
||||||
|
}
|
||||||
sender.sendMessage(Component.text("Event-Server gestartet!", NamedTextColor.GREEN));
|
sender.sendMessage(Component.text("Event-Server gestartet!", NamedTextColor.GREEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
if(args.length == 1) return Arrays.stream(Event.EventType.values()).map(Enum::toString).toList();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package eu.mhsl.craftattack.spawn.event.appliances.eventController;
|
|||||||
import eu.mhsl.craftattack.spawn.core.Main;
|
import eu.mhsl.craftattack.spawn.core.Main;
|
||||||
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
|
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
|
||||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceCommand;
|
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceCommand;
|
||||||
import eu.mhsl.craftattack.spawn.event.appliances.eventController.commands.EventCommand;
|
import eu.mhsl.craftattack.spawn.event.appliances.eventController.commands.BigEventCommand;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.util.Ticks;
|
import net.kyori.adventure.util.Ticks;
|
||||||
@@ -95,7 +95,7 @@ public class EventController extends Appliance {
|
|||||||
@Override
|
@Override
|
||||||
protected @NotNull List<ApplianceCommand<?>> commands() {
|
protected @NotNull List<ApplianceCommand<?>> commands() {
|
||||||
return List.of(
|
return List.of(
|
||||||
new EventCommand()
|
new BigEventCommand()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class EventCommand extends ApplianceCommand<EventController> {
|
public class BigEventCommand extends ApplianceCommand<EventController> {
|
||||||
public EventCommand() {
|
public BigEventCommand() {
|
||||||
super("event");
|
super("event");
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user