Skip to content

Commit

Permalink
Create base for a "delayed commands" example project
Browse files Browse the repository at this point in the history
  • Loading branch information
willkroboth committed Jun 8, 2023
1 parent 4a1b42b commit ece9477
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/bukkit/delayed-commands/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Delayed Commands

A simple example showcasing various ways to implement "delayed commands" with the CommandAPI. This was inspired by [#451](https://github.com/JorelAli/CommandAPI/issues/451). While delayed commands are not directly implemented in the CommandAPI, this example aims to show various ways to add them yourself. Developers are encouraged to find solutions that fit their own needs, perhaps adding them to this project for others to use.

### What is a "delayed command"?

Per the [original issue](https://github.com/JorelAli/CommandAPI/issues/451), a delayed command is limited to only run once within a certain time period. This can prevent users from spamming commands that might perform CPU-intensive tasks. This creates a delay between executions of a command, hence, a "delayed command".

### TODO: Write some examples and explain them
47 changes: 47 additions & 0 deletions examples/bukkit/delayed-commands/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-trees</artifactId>
<version>0.0.1-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
<!-- This adds the Spigot Maven repository to the build -->
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-core</artifactId>
<version>9.0.2</version>
</dependency>

<!--This adds the Spigot API artifact to the build -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<release>17</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.github.jorelali;

import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin {
@Override
public void onEnable() {
// TODO: Write some commands
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: DelayedCommands
main: io.github.jorelali.Main
version: 0.0.1
website: https://www.jorel.dev/CommandAPI/
api-version: 1.13
depend: [CommandAPI]

0 comments on commit ece9477

Please sign in to comment.