Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei1058 committed May 24, 2024
1 parent 8bd5992 commit d09650d
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 13 deletions.
6 changes: 6 additions & 0 deletions bedwars-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
<artifactId>bedwars-api</artifactId>
<version>${project.parent.version}</version>

<profiles>
<profile>
<id>prod</id>
</profile>
</profiles>

<repositories>
<repository>
<id>spigotmc-repo</id>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.andrei1058.bedwars.api.server;

public interface SetupSessionListeners {

void onWorldLoad(String worldName);
}
27 changes: 27 additions & 0 deletions bedwars-dev/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.andrei1058.bedwars</groupId>
<artifactId>BedWars1058</artifactId>
<version>23.12.1-SNAPSHOT</version>
</parent>

<groupId>com.andrei1058.bedwars.dev</groupId>
<artifactId>bedwars-dev</artifactId>

<profiles>
<profile>
<id>dev</id>
</profile>
</profiles>

<properties>
<maven.compiler.source>22</maven.compiler.source>
<maven.compiler.target>22</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package com.andrei1058.bedwars.arena;

import com.andrei1058.bedwars.BedWars;
import com.andrei1058.bedwars.api.arena.IArena;
import com.andrei1058.bedwars.api.arena.IGameService;
import com.andrei1058.bedwars.api.arena.constraints.ArenaConstraintViolation;
import com.andrei1058.bedwars.api.arena.constraints.ConstraintProvider;
Expand All @@ -33,6 +34,7 @@
import com.andrei1058.bedwars.configuration.ArenaConfig;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.ApiStatus;
Expand All @@ -57,6 +59,15 @@ public ArenaManager() {
constraintProviders.add(new DefaultConstraintProvider());
}

public static void onMapLoad(World world) {
for (IArena a : new LinkedList<>(Arena.getEnableQueue())) {
if (a.getWorldName().equalsIgnoreCase(world.getName())) {
a.init(world);
break;
}
}
}


public String generateGameID() {
SimpleDateFormat y = new SimpleDateFormat("yy"), m = new SimpleDateFormat("MM"), d = new SimpleDateFormat("dd");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.andrei1058.bedwars.api.region.Cuboid;
import com.andrei1058.bedwars.api.server.ISetupSession;
import com.andrei1058.bedwars.api.server.ServerType;
import com.andrei1058.bedwars.api.server.SetupSessionListeners;
import com.andrei1058.bedwars.api.server.SetupType;
import com.andrei1058.bedwars.commands.bedwars.MainCommand;
import com.andrei1058.bedwars.configuration.ArenaConfig;
Expand All @@ -52,7 +53,7 @@
import static com.andrei1058.bedwars.BedWars.plugin;
import static com.andrei1058.bedwars.commands.Misc.createArmorStand;

public class SetupSession implements ISetupSession {
public class SetupSession implements ISetupSession, SetupSessionListeners {

private static List<SetupSession> setupSessions = new ArrayList<>();

Expand All @@ -76,6 +77,14 @@ public SetupSession(Player player, String worldName) {
openGUI(player);
}

public static void onMapLoad(String name) {
for (SetupSession setupSession : getSetupSessions()) {
if (setupSession instanceof SetupSessionListeners) {
((SetupSessionListeners) setupSession).onWorldLoad(name);
}
}
}

public void setSetupType(SetupType setupType) {
this.setupType = setupType;
}
Expand Down Expand Up @@ -131,8 +140,8 @@ public boolean isStarted() {
public boolean startSetup() {
getPlayer().sendMessage("§6 ▪ §7Loading " + getWorldName());
cm = new ArenaConfig(BedWars.plugin, getWorldName(), plugin.getDataFolder().getPath() + "/Arenas");

BedWars.getAPI().getRestoreAdapter().onSetupSessionStart(this);
startWaitingLobbyParticleTask();
return true;
}

Expand Down Expand Up @@ -419,4 +428,11 @@ private void loadWaitingPositions() {
waitingLobbyCuboid = new Cuboid(pos1, pos2, true);
}
}

@Override
public void onWorldLoad(@NotNull String worldName) {
if (worldName.equals(this.getWorldName())) {
this.startWaitingLobbyParticleTask();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,18 @@

package com.andrei1058.bedwars.listeners;

import com.andrei1058.bedwars.api.arena.IArena;
import com.andrei1058.bedwars.arena.Arena;
import com.andrei1058.bedwars.arena.ArenaManager;
import com.andrei1058.bedwars.arena.SetupSession;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldLoadEvent;

import java.util.LinkedList;
import org.jetbrains.annotations.NotNull;

public class WorldLoadListener implements Listener {

@EventHandler
public void onLoad(WorldLoadEvent e) {
for (IArena a : new LinkedList<>(Arena.getEnableQueue())) {
if (a.getWorldName().equalsIgnoreCase(e.getWorld().getName())) {
a.init(e.getWorld());
return;
}
}
public void onLoad(@NotNull WorldLoadEvent e) {
ArenaManager.onMapLoad(e.getWorld());
SetupSession.onMapLoad(e.getWorld().getName());
}
}
37 changes: 37 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<profiles>
<profile>
<id>prod</id>
</profile>
<profile>
<id>dev</id>
<activation>
<activeByDefault>false</activeByDefault>
<property>
<name>env</name>
<value>dev</value>
</property>
</activation>
</profile>
</profiles>

<repositories>
<!--Bungeecord Repo-->
<!--Only include if using the Spigot API dependency-->
Expand Down Expand Up @@ -55,6 +71,12 @@
<version>24.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -66,6 +88,20 @@
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>show-profiles</id>
<phase>compile</phase>
<goals>
<goal>active-profiles</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down Expand Up @@ -115,6 +151,7 @@
<module>versionsupport_v1_20_R2</module>
<module>versionsupport_v1_20_R3</module>
<module>versionsupport_v1_20_R4</module>
<module>bedwars-dev</module>
</modules>

<distributionManagement>
Expand Down

0 comments on commit d09650d

Please sign in to comment.