diff --git a/README.md b/README.md
index 890a380..c5c8ee6 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
GlobalChallenges Minecraft Plugin
-GlobalChallenges is a Minecraft plugin designed to add global challenges and tasks to enhance the gameplay experience. This README.md file provides essential information on installing the plugin, system requirements, developer API, and additional resources.
+GlobalChallenges is a Minecraft plugin designed to add global challenges and tasks to enhance the gameplay experience.
+This README.md file provides essential information on installing the plugin, system requirements, developer API, and
+additional resources.
## Installation
@@ -11,16 +13,17 @@ GlobalChallenges is a Minecraft plugin designed to add global challenges and tas
### Steps
1. **Download:**
- - Download the latest version of GlobalChallenges from the [Releases page](https://github.com/your-username/GlobalChallenges/releases).
+ - Download the latest version of GlobalChallenges from
+ the [Releases page](https://github.com/your-username/GlobalChallenges/releases).
2. **Installation:**
- - Place the downloaded JAR file into your server's `plugins` directory.
+ - Place the downloaded JAR file into your server's `plugins` directory.
3. **Configuration:**
- - Customize the plugin settings in the `config.yml` file located in the `plugins/GlobalChallenges` folder.
+ - Customize the plugin settings in the `config.yml` file located in the `plugins/GlobalChallenges` folder.
4. **Restart:**
- - Restart your Minecraft server to apply the changes.
+ - Restart your Minecraft server to apply the changes.
## Wiki
@@ -34,10 +37,8 @@ To add GlobalChallenges to your Gradle project, include the following dependency
```groovy
repositories {
- repositories {
- mavenCentral()
- maven { url 'https://jitpack.io' }
- }
+ mavenCentral()
+ maven { url 'https://jitpack.io' }
}
dependencies {
diff --git a/api/src/main/java/sk/adr3ez/globalchallenges/api/util/ConfigRoutes.java b/api/src/main/java/sk/adr3ez/globalchallenges/api/util/ConfigRoutes.java
index 317b2de..29ae554 100644
--- a/api/src/main/java/sk/adr3ez/globalchallenges/api/util/ConfigRoutes.java
+++ b/api/src/main/java/sk/adr3ez/globalchallenges/api/util/ConfigRoutes.java
@@ -20,6 +20,7 @@ public enum ConfigRoutes {
SETTINGS_REQUIRED_PLAYERS("settings.players_required"),
SETTINGS_CHALLENGE_TIME("settings.challenge_time"),
+ SETTINGS_AUTO_START("settings.auto_start"),
SETTINGS_MONITOR_BLOCKS("settings.monitor_blocks"),
MESSAGES_BROADCAST_GAMESTART_CHAT("messages.broadcast.game_start.chat"),
diff --git a/build.gradle b/build.gradle
index 2e24599..f79f6ad 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ plugins {
}
group = 'sk.adr3ez'
-version = '1.0.1-BETA'
+version = '1.0.2-BETA'
ext {
targetJavaVersion = 17
diff --git a/build/tmp/jar/MANIFEST.MF b/build/tmp/jar/MANIFEST.MF
new file mode 100644
index 0000000..59499bc
--- /dev/null
+++ b/build/tmp/jar/MANIFEST.MF
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+
diff --git a/core/src/main/java/sk/adr3ez/globalchallenges/core/challenges/HarvestCropsChallenge.java b/core/src/main/java/sk/adr3ez/globalchallenges/core/challenges/HarvestCropsChallenge.java
index f443fb2..f1b5320 100644
--- a/core/src/main/java/sk/adr3ez/globalchallenges/core/challenges/HarvestCropsChallenge.java
+++ b/core/src/main/java/sk/adr3ez/globalchallenges/core/challenges/HarvestCropsChallenge.java
@@ -124,7 +124,7 @@ public void blockBoneMealEvent(PlayerInteractEvent event) {
public void blockPlaceEvent(BlockPlaceEvent event) {
int blockHash = event.getBlock().getLocation().hashCode();
- if (event.getBlock().getType() == material)
+ if (event.getBlock().getType() == material && PlantAges.valueOf(material.toString().toUpperCase()).getMaximumAge() == 0)
blocks.add(blockHash);
}*/
diff --git a/core/src/main/java/sk/adr3ez/globalchallenges/core/model/GameManagerAdapter.java b/core/src/main/java/sk/adr3ez/globalchallenges/core/model/GameManagerAdapter.java
index def41e7..df01ea3 100644
--- a/core/src/main/java/sk/adr3ez/globalchallenges/core/model/GameManagerAdapter.java
+++ b/core/src/main/java/sk/adr3ez/globalchallenges/core/model/GameManagerAdapter.java
@@ -3,6 +3,8 @@
import dev.dejvokep.boostedyaml.YamlDocument;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.title.Title;
+import org.bukkit.Bukkit;
+import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.reflections.Reflections;
@@ -33,6 +35,8 @@ public class GameManagerAdapter implements GameManager {
@NotNull
private final List registeredChallenges = new ArrayList<>();
+ private final BukkitTask autoStartTask; //TODO ADD SHUTDOWN ACTION
+
public GameManagerAdapter(@NotNull GlobalChallenges plugin) {
this.plugin = plugin;
@@ -59,6 +63,22 @@ public GameManagerAdapter(@NotNull GlobalChallenges plugin) {
} catch (Exception ignored) {
}
}
+
+ long autoStartTime = plugin.getConfiguration().getLong(ConfigRoutes.SETTINGS_AUTO_START.getRoute(), 900L) * 20;
+ autoStartTask = Bukkit.getScheduler().runTaskTimer(plugin.getJavaPlugin(), () -> {
+
+ if (getActiveChallenge().isPresent()) {
+ plugin.getPluginLogger().info("Automatic challenge cannot be started because there is already an active challenge.");
+ return;
+ }
+
+ if (plugin.getOnlinePlayers().isEmpty() || plugin.getOnlinePlayers().size() < plugin.getConfiguration().getInt(ConfigRoutes.SETTINGS_REQUIRED_PLAYERS.getRoute())) {
+ plugin.getPluginLogger().info("Not enough players online to start a game.");
+ return;
+ }
+ startRandom();
+
+ }, autoStartTime, autoStartTime);
}
@Nullable
diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml
index b0f47af..a2f7f11 100644
--- a/core/src/main/resources/config.yml
+++ b/core/src/main/resources/config.yml
@@ -14,7 +14,7 @@
##########################################################################################
# Please do not change! Unless developer told you to do so.
-file-version: 1
+file-version: 2
##########################################################################################
# |- -| #
@@ -39,7 +39,6 @@ storage:
minimumConnections: 1
maximumConnections: 20
connectionTimeout: 2000
- driverClassName: "com.mysql.cj.jdbc.Driver"
# You can set this value to your own server name or leave it as global.
# If you have network with more different servers that are using GlobalChallenges
@@ -62,6 +61,9 @@ settings:
# How many seconds will one challange be run for.
challenge_time: 300 #5 minutes
+ # How many seconds between each automatic challenge
+ auto_start: 900 # 15 minutes
+
# If placed blocks should be monitored for player_placed condition in challenges
monitor_blocks: false
diff --git a/spigot/build.gradle b/spigot/build.gradle
index a7856de..55fef6d 100644
--- a/spigot/build.gradle
+++ b/spigot/build.gradle
@@ -5,7 +5,7 @@ dependencies {
compileOnly "org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT"
compileOnly "dev.jorel:commandapi-bukkit-core:9.3.0"
- implementation "net.kyori:adventure-platform-bukkit:4.3.2"
+ implementation "net.kyori:adventure-platform-bukkit:4.3.3"
implementation "net.kyori:adventure-text-minimessage:4.14.0"
implementation "dev.jorel:commandapi-bukkit-shade:9.5.0"