added big events in craftattack plugin
This commit is contained in:
@@ -37,6 +37,11 @@ public class Event extends Appliance {
|
||||
DONE
|
||||
}
|
||||
|
||||
public enum EventType {
|
||||
BIG,
|
||||
SMALL
|
||||
}
|
||||
|
||||
Countdown advertiseCountdown = new Countdown(
|
||||
120,
|
||||
announcementData -> Component.text()
|
||||
@@ -50,6 +55,7 @@ public class Event extends Appliance {
|
||||
);
|
||||
public DisplayVillager.ConfigBound villager;
|
||||
private boolean isOpen = false;
|
||||
private EventType eventType;
|
||||
private AdvertisementStatus advertiseStatus = AdvertisementStatus.BEFORE;
|
||||
private UUID roomId;
|
||||
private final List<Reward> pendingRewards = new ArrayList<>();
|
||||
@@ -79,18 +85,24 @@ public class Event extends Appliance {
|
||||
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!");
|
||||
this.eventType = type;
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Main.instance(), () -> {
|
||||
ReqResp<EventRepository.CreatedRoom> sessionResponse = this.queryRepository(EventRepository.class).createSession();
|
||||
if(type.equals(EventType.SMALL)) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Main.instance(), () -> {
|
||||
ReqResp<EventRepository.CreatedRoom> sessionResponse = this.queryRepository(EventRepository.class).createSession();
|
||||
|
||||
if(sessionResponse.status() != HttpStatus.OK)
|
||||
throw new ApplianceCommand.Error("Event-Server meldet Fehler: " + sessionResponse.status());
|
||||
if(sessionResponse.status() != HttpStatus.OK)
|
||||
throw new ApplianceCommand.Error("Event-Server meldet Fehler: " + sessionResponse.status());
|
||||
|
||||
this.isOpen = true;
|
||||
this.roomId = sessionResponse.data().uuid();
|
||||
});
|
||||
this.isOpen = true;
|
||||
this.roomId = sessionResponse.data().uuid();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.isOpen = true;
|
||||
}
|
||||
|
||||
public void joinEvent(Player p) {
|
||||
@@ -112,18 +124,22 @@ public class Event extends Appliance {
|
||||
Main.instance().getLogger().info("Verbinde mit eventserver: " + p.getName());
|
||||
p.sendMessage(Component.text("Authentifiziere...", NamedTextColor.GREEN));
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Main.instance(), () -> {
|
||||
ReqResp<EventRepository.QueueRoom.Response> queueResponse = this.queryRepository(EventRepository.class)
|
||||
.queueRoom(new EventRepository.QueueRoom(p.getUniqueId(), this.roomId));
|
||||
if(this.eventType.equals(EventType.SMALL)) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Main.instance(), () -> {
|
||||
ReqResp<EventRepository.QueueRoom.Response> queueResponse = this.queryRepository(EventRepository.class)
|
||||
.queueRoom(new EventRepository.QueueRoom(p.getUniqueId(), this.roomId));
|
||||
|
||||
if(queueResponse.status() != HttpStatus.OK || queueResponse.data().error() != null) {
|
||||
p.sendMessage(Component.text("Fehler beim Betreten: " + queueResponse.data().error(), NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
if(queueResponse.status() != HttpStatus.OK || queueResponse.data().error() != null) {
|
||||
p.sendMessage(Component.text("Fehler beim Betreten: " + queueResponse.data().error(), NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
|
||||
p.sendMessage(Component.text("Betrete...", NamedTextColor.GREEN));
|
||||
PluginMessage.connect(p, this.localConfig().getString("connect-server-name"));
|
||||
});
|
||||
p.sendMessage(Component.text("Betrete...", NamedTextColor.GREEN));
|
||||
PluginMessage.connect(p, this.localConfig().getString("connect-server-name"));
|
||||
});
|
||||
}
|
||||
|
||||
PluginMessage.connect(p, "grand-event");
|
||||
}
|
||||
|
||||
public void endEvent() {
|
||||
|
||||
@@ -7,6 +7,10 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
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 EventOpenSessionCommand() {
|
||||
@@ -15,7 +19,17 @@ public class EventOpenSessionCommand extends ApplianceCommand<Event> {
|
||||
|
||||
@Override
|
||||
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));
|
||||
}
|
||||
|
||||
@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.appliance.Appliance;
|
||||
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.format.NamedTextColor;
|
||||
import net.kyori.adventure.util.Ticks;
|
||||
@@ -95,7 +95,7 @@ public class EventController extends Appliance {
|
||||
@Override
|
||||
protected @NotNull List<ApplianceCommand<?>> commands() {
|
||||
return List.of(
|
||||
new EventCommand()
|
||||
new BigEventCommand()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EventCommand extends ApplianceCommand<EventController> {
|
||||
public EventCommand() {
|
||||
public class BigEventCommand extends ApplianceCommand<EventController> {
|
||||
public BigEventCommand() {
|
||||
super("event");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user