Skip to content

Commit 0bd3289

Browse files
authored
Adr3ez local (#21)
* xd * some fixes * Updated version of adventure-bukkit platform * Added auto start
1 parent 6bc397f commit 0bd3289

8 files changed

Lines changed: 40 additions & 14 deletions

File tree

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<h1 align="center">GlobalChallenges Minecraft Plugin</h1>
22

3-
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.
3+
GlobalChallenges is a Minecraft plugin designed to add global challenges and tasks to enhance the gameplay experience.
4+
This README.md file provides essential information on installing the plugin, system requirements, developer API, and
5+
additional resources.
46

57
## Installation
68

@@ -11,16 +13,17 @@ GlobalChallenges is a Minecraft plugin designed to add global challenges and tas
1113
### Steps
1214

1315
1. **Download:**
14-
- Download the latest version of GlobalChallenges from the [Releases page](https://github.com/your-username/GlobalChallenges/releases).
16+
- Download the latest version of GlobalChallenges from
17+
the [Releases page](https://github.com/your-username/GlobalChallenges/releases).
1518

1619
2. **Installation:**
17-
- Place the downloaded JAR file into your server's `plugins` directory.
20+
- Place the downloaded JAR file into your server's `plugins` directory.
1821

1922
3. **Configuration:**
20-
- Customize the plugin settings in the `config.yml` file located in the `plugins/GlobalChallenges` folder.
23+
- Customize the plugin settings in the `config.yml` file located in the `plugins/GlobalChallenges` folder.
2124

2225
4. **Restart:**
23-
- Restart your Minecraft server to apply the changes.
26+
- Restart your Minecraft server to apply the changes.
2427

2528
## Wiki
2629

@@ -34,10 +37,8 @@ To add GlobalChallenges to your Gradle project, include the following dependency
3437

3538
```groovy
3639
repositories {
37-
repositories {
38-
mavenCentral()
39-
maven { url 'https://jitpack.io' }
40-
}
40+
mavenCentral()
41+
maven { url 'https://jitpack.io' }
4142
}
4243
4344
dependencies {

api/src/main/java/sk/adr3ez/globalchallenges/api/util/ConfigRoutes.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public enum ConfigRoutes {
2020

2121
SETTINGS_REQUIRED_PLAYERS("settings.players_required"),
2222
SETTINGS_CHALLENGE_TIME("settings.challenge_time"),
23+
SETTINGS_AUTO_START("settings.auto_start"),
2324
SETTINGS_MONITOR_BLOCKS("settings.monitor_blocks"),
2425

2526
MESSAGES_BROADCAST_GAMESTART_CHAT("messages.broadcast.game_start.chat"),

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = 'sk.adr3ez'
8-
version = '1.0.1-BETA'
8+
version = '1.0.2-BETA'
99

1010
ext {
1111
targetJavaVersion = 17

build/tmp/jar/MANIFEST.MF

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Manifest-Version: 1.0
2+

core/src/main/java/sk/adr3ez/globalchallenges/core/challenges/HarvestCropsChallenge.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public void blockBoneMealEvent(PlayerInteractEvent event) {
124124
public void blockPlaceEvent(BlockPlaceEvent event) {
125125
int blockHash = event.getBlock().getLocation().hashCode();
126126
127-
if (event.getBlock().getType() == material)
127+
if (event.getBlock().getType() == material && PlantAges.valueOf(material.toString().toUpperCase()).getMaximumAge() == 0)
128128
blocks.add(blockHash);
129129
}*/
130130

core/src/main/java/sk/adr3ez/globalchallenges/core/model/GameManagerAdapter.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import dev.dejvokep.boostedyaml.YamlDocument;
44
import net.kyori.adventure.text.minimessage.MiniMessage;
55
import net.kyori.adventure.title.Title;
6+
import org.bukkit.Bukkit;
7+
import org.bukkit.scheduler.BukkitTask;
68
import org.jetbrains.annotations.NotNull;
79
import org.jetbrains.annotations.Nullable;
810
import org.reflections.Reflections;
@@ -33,6 +35,8 @@ public class GameManagerAdapter implements GameManager {
3335
@NotNull
3436
private final List<Challenge> registeredChallenges = new ArrayList<>();
3537

38+
private final BukkitTask autoStartTask; //TODO ADD SHUTDOWN ACTION
39+
3640
public GameManagerAdapter(@NotNull GlobalChallenges plugin) {
3741
this.plugin = plugin;
3842

@@ -59,6 +63,22 @@ public GameManagerAdapter(@NotNull GlobalChallenges plugin) {
5963
} catch (Exception ignored) {
6064
}
6165
}
66+
67+
long autoStartTime = plugin.getConfiguration().getLong(ConfigRoutes.SETTINGS_AUTO_START.getRoute(), 900L) * 20;
68+
autoStartTask = Bukkit.getScheduler().runTaskTimer(plugin.getJavaPlugin(), () -> {
69+
70+
if (getActiveChallenge().isPresent()) {
71+
plugin.getPluginLogger().info("Automatic challenge cannot be started because there is already an active challenge.");
72+
return;
73+
}
74+
75+
if (plugin.getOnlinePlayers().isEmpty() || plugin.getOnlinePlayers().size() < plugin.getConfiguration().getInt(ConfigRoutes.SETTINGS_REQUIRED_PLAYERS.getRoute())) {
76+
plugin.getPluginLogger().info("Not enough players online to start a game.");
77+
return;
78+
}
79+
startRandom();
80+
81+
}, autoStartTime, autoStartTime);
6282
}
6383

6484
@Nullable

core/src/main/resources/config.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
##########################################################################################
1515

1616
# Please do not change! Unless developer told you to do so.
17-
file-version: 1
17+
file-version: 2
1818

1919
##########################################################################################
2020
# |- -| #
@@ -39,7 +39,6 @@ storage:
3939
minimumConnections: 1
4040
maximumConnections: 20
4141
connectionTimeout: 2000
42-
driverClassName: "com.mysql.cj.jdbc.Driver"
4342

4443
# You can set this value to your own server name or leave it as global.
4544
# If you have network with more different servers that are using GlobalChallenges
@@ -62,6 +61,9 @@ settings:
6261
# How many seconds will one challange be run for.
6362
challenge_time: 300 #5 minutes
6463

64+
# How many seconds between each automatic challenge
65+
auto_start: 900 # 15 minutes
66+
6567
# If placed blocks should be monitored for player_placed condition in challenges
6668
monitor_blocks: false
6769

spigot/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ dependencies {
55
compileOnly "org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT"
66
compileOnly "dev.jorel:commandapi-bukkit-core:9.3.0"
77

8-
implementation "net.kyori:adventure-platform-bukkit:4.3.2"
8+
implementation "net.kyori:adventure-platform-bukkit:4.3.3"
99
implementation "net.kyori:adventure-text-minimessage:4.14.0"
1010

1111
implementation "dev.jorel:commandapi-bukkit-shade:9.5.0"

0 commit comments

Comments
 (0)