Skip to content

Commit

Permalink
Adr3ez local (#21)
Browse files Browse the repository at this point in the history
* xd

* some fixes

* Updated version of adventure-bukkit platform

* Added auto start
  • Loading branch information
Adreez authored Jul 27, 2024
1 parent 6bc397f commit 0bd3289
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 14 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<h1 align="center">GlobalChallenges Minecraft Plugin</h1>

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

Expand All @@ -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

Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'sk.adr3ez'
version = '1.0.1-BETA'
version = '1.0.2-BETA'

ext {
targetJavaVersion = 17
Expand Down
2 changes: 2 additions & 0 deletions build/tmp/jar/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Manifest-Version: 1.0

Original file line number Diff line number Diff line change
Expand Up @@ -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);
}*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -33,6 +35,8 @@ public class GameManagerAdapter implements GameManager {
@NotNull
private final List<Challenge> registeredChallenges = new ArrayList<>();

private final BukkitTask autoStartTask; //TODO ADD SHUTDOWN ACTION

public GameManagerAdapter(@NotNull GlobalChallenges plugin) {
this.plugin = plugin;

Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
##########################################################################################

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

##########################################################################################
# |- -| #
Expand All @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spigot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 0bd3289

Please sign in to comment.