Skip to content

Commit

Permalink
add world and game state management
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyDotWS committed Nov 25, 2024
1 parent 3476182 commit eb26de4
Show file tree
Hide file tree
Showing 27 changed files with 921 additions and 186 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
hs_err_pid*
replay_pid*

# maven files
settings.xml
# gradle
.gradle/
build/
40 changes: 28 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,60 @@
![MineplexSK Banner](https://i.imgur.com/zO4o6Rb.png)
![SKMineplex Banner](https://i.imgur.com/RO7AAD4.png)

An unofficially supported Skript addon that allows you to use Skript within the Mineplex ecosystem, and interact with the special provided [Mineplex SDK](https://studio.mineplex.com/docs/sdk).
An unofficially supported Skript addon that allows you to use Skript within the Mineplex ecosystem, and interact with
the special provided [Mineplex SDK](https://studio.mineplex.com/docs/sdk).

> [!IMPORTANT]
> This isn't an official addon provided by Mineplex itself. This is a community developed and supported addon. We rely on contributions for this!
> This isn't an official addon provided by Mineplex itself. This is a community developed and supported addon. We rely
> on contributions for this!
## Addon Documentation
[Expressions](/docs/expressions.md)[Conditions](/docs/conditions.md)[Effects](/docs/effects.md)[Events](/docs/events.md)[Functions](/docs/functions.md)

[Expressions](/docs/expressions.md)[Conditions](/docs/conditions.md)[Effects](/docs/effects.md)
[Events](/docs/events.md)[Functions](/docs/functions.md)[Examples](/docs/examples.md)

## Purpose
This exists to make it easier for people without Java knowledge to setup and use the Mineplex ecosystem, with the goal being to make it far easier for people to manage and create their projects quickly.

This exists to make it easier for people without Java knowledge to setup and use the Mineplex ecosystem, with the goal
being to make it far easier for people to manage and create their projects quickly.
Our goal with this addon is to have this addon have full feature parity with the actual Mineplex Java SDK.

### Pre-requisites
- You must have [Skript plugin](https://github.com/SkriptLang/Skript/releases) downloaded already, this addon requires it!

- You must have [Skript plugin](https://github.com/SkriptLang/Skript/releases) downloaded already, this addon requires
it!
- You must have a [Mineplex Studio project](https://studio.mineplex.com/docs/getting-started) created and ready to use

## How to install

- Add your **Skript** plugin into a directory within your Mineplex project named `external-plugins`
- Download the [latest version](https://github.com/BillyDotWS/MineplexSK/releases) of the addon from the Releases.
- Download the [latest version](https://github.com/BillyDotWS/MineplexSK/releases) of the addon from the Releases.
- Add this addon jar into the same `external-plugins` directory

## How to use
This Skript addon allows you to use the Skript 'way of coding' with the Mineplex SDK. In order to do this, it adds some custom language to Skript to allow for usage.

This Skript addon allows you to use the Skript 'way of coding' with the Mineplex SDK. In order to do this, it adds some
custom language to Skript to allow for usage.

### Using skript within Mineplex projects

*Note: requires you to have followed the Installation steps first*

In order to use Skript scripts within a project, drop your skript's into a folder (within your project). Within `external-plugins`, create a directory called `Skript`, within this directory, create another called `scripts`.
In order to use Skript scripts within a project, drop your skript's into a folder (within your project). Within
`external-plugins`, create a directory called `Skript`, within this directory, create another called `scripts`.

Then create your Skript file (the same way as everywhere else): `scriptName.sk`

After that, use Skript the same way as normal, dropping extra scripts into the folder(s) and building your project!

## Contributing

> [!CAUTION]
> This library enforces a licence, which states that you cannot create a private version of this work. Please contribute any improvements you make back to the base repository to assist in making it easier to use Skript on Mineplex for everyone! See [the license](/LICENSE) for more information.
> This library enforces a licence, which states that you cannot create a private version of this work. Please contribute
> any improvements you make back to the base repository to assist in making it easier to use Skript on Mineplex for
> everyone! See [the license](/LICENSE) for more information.
We welcome contributions to improve this project! Please follow these guidelines to ensure a smooth contribution process:
We welcome contributions to improve this project! Please follow these guidelines to ensure a smooth contribution
process:

### How to Contribute

Expand All @@ -60,7 +76,7 @@ We welcome contributions to improve this project! Please follow these guidelines
5. **Run Tests**
Run all tests to confirm that your changes do not break existing functionality:
```bash
mvn test
./gradlew test
```
6. **Commit Your Changes**
Write clear and concise commit messages:
Expand Down
51 changes: 51 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
plugins {
id 'java'
id 'com.mineplex.sdk.plugin' version "1.6.0"
}

group = 'ws.billy.skmineplex'
version = '1.0-SNAPSHOT'
sourceCompatibility = '21'
targetCompatibility = '21'

ext {
spigotApiVersion = '1.21.1-R0.1-SNAPSHOT'
lombokVersion = '1.18.30'
jacksonCoreVersion = '2.15.2'
jacksonDatabindVersion = '2.15.2'
skriptVersion = '2.9.4'
}

repositories {
mavenCentral()
maven { url 'https://repo.papermc.io/repository/maven-public/' }
maven { url 'https://repo.skriptlang.org/releases' }
}

dependencies {
compileOnly "org.spigotmc:spigot-api:${spigotApiVersion}"
compileOnly "org.projectlombok:lombok:${lombokVersion}"
implementation "com.fasterxml.jackson.core:jackson-core:${jacksonCoreVersion}"
implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonDatabindVersion}"
implementation "com.github.SkriptLang:Skript:${skriptVersion}"
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}

tasks.register('shade', Jar) {
archiveClassifier = 'all'
from sourceSets.main.output
dependsOn configurations.runtimeClasspath
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
duplicatesStrategy = DuplicatesStrategy.INCLUDE // or DuplicatesStrategy.IGNORE
manifest {
attributes(
'Implementation-Title': project.name,
'Implementation-Version': project.version
)
}
}

build.dependsOn shade
12 changes: 11 additions & 1 deletion docs/effects.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
## Effects
# Effects

## Game

## World

### Create a world

```
[create] mineplex world with template %string%
```
18 changes: 17 additions & 1 deletion docs/events.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
## Events
# Events

## Game

### Game state change

```
on game state change
```

This also then exposes the previous and new state.

```
on game state change:
broadcast "%past event-gamestate%" # the previous state
broadcast "%event-gamestate%" # the new state
```
49 changes: 49 additions & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Examples

## World

### Loading a world

Load the world from a template name and save it to a variable for further usage

```
set {_world} to "world-name" parsed as a mineplex world
```

## Game

### Creating a game

Create a game and register it as the current game running on this server

```
set {_game} to "Micro Battles" parsed as a mineplex game
set {_game}'s game world to {_world}
set {_game}'s maximum players to 20
set {_game}'s minimum players to 4
set the current game to {_game}
```

### Starting a game

```
on join:
add player to {_players::*}
on player quit:
remove player from {_players::*}
every 1 second:
if size of {_players::*} is greater than or equal to {_game}'s minimum players:
wait 10 seconds
set game state of {_game} to "STARTED"
clear {_players::*}
```

### Game state changed

```
on game state change:
if event-gamestate = "STARTED":
broadcast "The game has started!"
```
46 changes: 45 additions & 1 deletion docs/expressions.md
Original file line number Diff line number Diff line change
@@ -1 +1,45 @@
## Expressions
# Expressions

## Game

### Set game state

```
set %game%'s game state to %state%
```

State options: `PREPARING`, `PRE_START`, `STARTED`, `ENDED`

### Get current game state

```
%game%'s game state
```

### Set game world

```
set %game%'s game world to %mineplex world%
```

See effects -> Create a world for information

### Get game world

```
%game%'s game world
```

## Game Manager

### Set the current game of the server

```
set [the] current game to {_game}
```

### Get the current game

```
[the] current game
```
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit eb26de4

Please sign in to comment.