diff --git a/.gitignore b/.gitignore
index 16510c4..8f7be04 100644
--- a/.gitignore
+++ b/.gitignore
@@ -152,3 +152,4 @@ fabric.properties
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
+run/
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 13566b8..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
-# Editor-based HTTP Client requests
-/httpRequests/
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 376f07a..e150ff6 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -21,15 +21,15 @@
-
-
-
-
-
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 5ccf79a..acff71d 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -9,7 +9,5 @@
-
-
-
+
\ No newline at end of file
diff --git a/LetThemEatCake.iml b/LetThemEatCake.iml
deleted file mode 100644
index d6ebd48..0000000
--- a/LetThemEatCake.iml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 098bdb4..113e1cc 100644
--- a/build.gradle
+++ b/build.gradle
@@ -22,7 +22,7 @@ repositories {
dependencies {
compileOnly 'io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT'
- compileOnly 'com.grinderwolf:slimeworldmanager-api:2.8.0-SNAPSHOT'
+ compileOnly 'com.grinderwolf:slimeworldmanager-api:2.10.0-SNAPSHOT'
}
def targetJavaVersion = 17
diff --git a/move.bat b/move.bat
new file mode 100644
index 0000000..e2af0c7
--- /dev/null
+++ b/move.bat
@@ -0,0 +1,3 @@
+@rem @echo off
+call .\gradlew.bat build
+copy /Y "x:\Java\Minecraft\BukkitBased\LetThemEatCake\build\libs\LetThemEatCake-1.0.0.jar" "x:\Java\Minecraft\BukkitBased\LetThemEatCake\run\plugins"
\ No newline at end of file
diff --git a/src/main/java/org/lunamc/letthemeatcake/Game.java b/src/main/java/org/lunamc/letthemeatcake/Game.java
index 77b12dc..87ee656 100644
--- a/src/main/java/org/lunamc/letthemeatcake/Game.java
+++ b/src/main/java/org/lunamc/letthemeatcake/Game.java
@@ -2,6 +2,7 @@ package org.lunamc.letthemeatcake;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
+import org.bukkit.scheduler.BukkitTask;
import java.util.ArrayList;
import java.util.List;
@@ -11,10 +12,18 @@ public class Game {
private boolean openStatus;
private List players;
+ private BukkitTask queueTimer;
+
public Game(JavaPlugin plugin) {
this.plugin = plugin;
openStatus = true;
players = new ArrayList<>();
+ startQueueTimer();
+ queueTimer.cancel();
+ }
+
+ public List getPlayers() {
+ return players;
}
/**
@@ -23,6 +32,10 @@ public class Game {
* @return 0 if the player has been added, 1 if the game is full
*/
public int addPlayer(Player player) {
+ if (players.size() >= 2 || queueTimer.isCancelled()) {
+ startQueueTimer();
+ }
+
players.add(player);
if (players.size() == 8) {
openStatus = false;
@@ -65,6 +78,17 @@ public class Game {
return 1;
}
+ public void startQueueTimer() {
+ queueTimer = plugin.getServer().getScheduler().runTaskLater(
+ plugin,
+ () -> {
+ openStatus = false;
+ start();
+ },
+ 200L
+ );
+ }
+
public void start() {
openStatus = false;
}
diff --git a/src/main/java/org/lunamc/letthemeatcake/GamesManager.java b/src/main/java/org/lunamc/letthemeatcake/GamesManager.java
deleted file mode 100644
index f39483a..0000000
--- a/src/main/java/org/lunamc/letthemeatcake/GamesManager.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.lunamc.letthemeatcake;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class GamesManager {
- private static List games = new ArrayList<>();
-
- public static void addToGame() {
- for (Game game : games) {
- if (game.isOpen()) {
- switch (game.addPlayers()) {
- case 0: {} // Success
- case 1: {} // Full
- case 2: {} // Success and Full
- }
- }
- }
- }
-}
diff --git a/src/main/java/org/lunamc/letthemeatcake/JoinGameCommand.java b/src/main/java/org/lunamc/letthemeatcake/JoinGameCommand.java
index 150b85e..661054e 100644
--- a/src/main/java/org/lunamc/letthemeatcake/JoinGameCommand.java
+++ b/src/main/java/org/lunamc/letthemeatcake/JoinGameCommand.java
@@ -7,8 +7,14 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
+import java.util.ArrayList;
+import java.util.List;
+
public class JoinGameCommand implements CommandExecutor {
+ private static List games = new ArrayList<>();
+ private static List playerQueue = new ArrayList<>();
+
private final JavaPlugin plugin;
public JoinGameCommand(JavaPlugin plugin) {
@@ -18,9 +24,12 @@ public class JoinGameCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (sender instanceof Player player) {
-
+ for (Game game : games) {
+ if (game.isOpen()) {
+ game.addPlayer(player);
+ }
+ }
}
-
return true;
}
}
diff --git a/src/main/java/org/lunamc/letthemeatcake/LetThemEatCake.java b/src/main/java/org/lunamc/letthemeatcake/LetThemEatCake.java
index 4cc893a..6c657fe 100644
--- a/src/main/java/org/lunamc/letthemeatcake/LetThemEatCake.java
+++ b/src/main/java/org/lunamc/letthemeatcake/LetThemEatCake.java
@@ -1,10 +1,7 @@
package org.lunamc.letthemeatcake;
import com.grinderwolf.swm.api.SlimePlugin;
-import com.grinderwolf.swm.api.exceptions.CorruptedWorldException;
-import com.grinderwolf.swm.api.exceptions.NewerFormatException;
-import com.grinderwolf.swm.api.exceptions.UnknownWorldException;
-import com.grinderwolf.swm.api.exceptions.WorldInUseException;
+import com.grinderwolf.swm.api.exceptions.*;
import com.grinderwolf.swm.api.loaders.SlimeLoader;
import com.grinderwolf.swm.api.world.SlimeWorld;
import com.grinderwolf.swm.api.world.properties.SlimeProperties;
@@ -12,6 +9,7 @@ import com.grinderwolf.swm.api.world.properties.SlimePropertyMap;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
+import java.io.File;
import java.io.IOException;
public final class LetThemEatCake extends JavaPlugin {
@@ -22,7 +20,8 @@ public final class LetThemEatCake extends JavaPlugin {
@Override
public void onEnable() {
-
+ this.getCommand("join").setExecutor(new JoinGameCommand(this));
+ loadSWM();
}
@Override
@@ -38,11 +37,18 @@ public final class LetThemEatCake extends JavaPlugin {
swm = (SlimePlugin) Bukkit.getPluginManager().getPlugin("SlimeWorldManager");
swmLoader = swm.getLoader("file");
+
+ File worldDir = new File(new File("").getAbsolutePath().replace('\\', '/') + "/import_worlds/");
+ worldDir.mkdirs();
+ System.out.println(worldDir.getAbsolutePath());
try {
- swmWorld = swm.loadWorld(swmLoader, "map", true, properties);
+ swm.importWorld(new File(worldDir.getAbsolutePath().replace('\\', '/') + "/steve"), "steve", swmLoader);
+ swmWorld = swm.loadWorld(swmLoader, "steve", true, properties);
swm.generateWorld(swmWorld);
} catch (UnknownWorldException | IOException | CorruptedWorldException | NewerFormatException | WorldInUseException e) {
e.printStackTrace();
+ } catch (InvalidWorldException | WorldLoadedException | WorldAlreadyExistsException | WorldTooBigException e) {
+ throw new RuntimeException(e);
}
}
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 52b2f74..b827f8c 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -2,7 +2,10 @@ name: LetThemEatCake
version: '${version}'
main: org.lunamc.letthemeatcake.LetThemEatCake
api-version: 1.19
-depend: [ slimeworldmanager ]
+depend: [ SlimeWorldManager ]
authors: [ nevets, 5gi ]
description: Description
website: https://lunamc.org
+commands:
+ join:
+ permission: ltec.join