-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from CSSUoB/multiplatform-plugin
Convert to multiplatform plugin
- Loading branch information
Showing
93 changed files
with
3,379 additions
and
490 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
* @Thatsmusic99 @MattyTheHacker | ||
* @Thatsmusic99 @MattyTheHacker @LMBishop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
target/ | ||
*.iml | ||
.idea | ||
.gradle | ||
**/build/ | ||
!src/**/build/ | ||
gradle-app.setting | ||
!gradle-wrapper.jar | ||
!gradle-wrapper.properties | ||
.gradletasknamecache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,110 @@ | ||
## CSS-Minecraft | ||
This is the source code for CSS' Minecraft plugin. | ||
# CSS Minecraft | ||
This is the source code for CSS' Minecraft plugin/mod. | ||
|
||
## Building | ||
|
||
Ensure that you have maven installed. | ||
Then: | ||
To compile, run the `build` Gradle task. | ||
|
||
``` | ||
maven clean package | ||
./gradlew build | ||
``` | ||
|
||
This will automatically execute the shadow-jar goal in the package cycle. | ||
|
||
There will now be a .jar file located in /target | ||
|
||
You can now put this .jar file in the /plugins folder in a Spigot/CraftBukkit 1.17.1 server and run the server. | ||
Jars will be output to `**/build/libs/cssminecraft-*.jar`. | ||
|
||
## Configuration | ||
|
||
The configuration file will be located in the server configuration directory, which depends on the platform. | ||
Typically, this will be at: | ||
|
||
MEMBER_ROLE_ID: The ID of the role that the plugin checks against when someone runs the /makegreen command. | ||
* **bukkit**: `plugins/CSSMinecraft/config.yml` | ||
* **fabric**: `config/cssminecraft/config.yml` | ||
* **forge**: `config/cssminecraft/config.yml` | ||
|
||
BRIDGE_CHANNEL_ID: The ID of the channel to send bridged messages to Minecraft. | ||
```yaml | ||
# The ID of the role that the plugin checks against when someone runs the /makegreen command. | ||
member-role-id: 0 | ||
|
||
DISCORD_SERVER_ID: The ID of the guild to interact with. | ||
# The ID of the channel to send bridged messages to Minecraft. | ||
bridge-channel-id: 0 | ||
|
||
WEBHOOK_URL: The URL of the Discord webhook to send bridged messages from Minecraft. | ||
# The ID of the guild to interact with. | ||
discord-server-id: 0 | ||
|
||
AVATAR_SERVICE: A link to an avatar service, with %s as a placeholder of the user's minecraft username. | ||
# The URL of the Discord webhook to send bridged messages from Minecraft. | ||
webhook-url: "" | ||
|
||
BOT_TOKEN: The token of the Discord bot that will be detecting messages to send to Minecraft, as well as Member roles. | ||
# The token of the Discord bot that will be detecting messages to send to Minecraft, as well as Member roles. | ||
bot-token: "" | ||
|
||
# A link to an avatar service, with %s as a placeholder of the user's minecraft username. | ||
# This is used as the profile picture URL in webhook messages. | ||
# We'd recommend the following value: https://cravatar.eu/helmhead/%s/190.png | ||
avatar-service: "" | ||
|
||
# The verbosity of logging (0 = error only, 1 = +warnings, 2 = +info, 3 = +debug) | ||
logging-level: 2 | ||
``` | ||
## Dependencies | ||
This plugin depends on [LuckPerms](https://www.spigotmc.org/resources/luckperms.28140/), which needs to be placed alongside this in the /plugins folder. | ||
This plugin optionally depends on [LuckPerms](https://luckperms.net/) to grant the member role. | ||
Without it, only the Discord message bridge will be functional. | ||
## Development | ||
PR's welcome, feel free to do whatever. | ||
The project is written mostly in an abstract fashion to help re-use code across | ||
different platforms. | ||
Each Gradle subproject has the following purpose: | ||
* `/common`: platform-independent interfaces and implementations which houses most logic - the | ||
following subprojects depend on this | ||
* `/bukkit`: specific implementation for Bukkit / Spigot / Paper etc. | ||
* `/fabric`: specific implementation for Fabric servers | ||
* `/forge`: specific implementation for Forge servers | ||
|
||
Note that this is a server only mod, and will not work on clients. | ||
|
||
## Version matrix | ||
|
||
The following table documents mod compatibility for older versions of Minecraft and their platforms. | ||
Any versions prior to 1.12.1 are backports. | ||
|
||
If a Minecraft version is not listed here, then no version of the mod exists for it. | ||
|
||
All version branches will follow the name `minecraft/<version>`. | ||
|
||
| Minecraft | Java | Bukkit | Forge | Fabric | Links | | ||
|-----------|------|--------|-------|--------|-------------------------------------------------------------------------| | ||
| 1.21.1 | 21 | ✅ | ✅ | ✅ | (master) | | ||
| 1.18.2 | 17 | ❌ | ❌ | ✅ | [Branch](https://github.com/CSSUoB/CSS-Minecraft/tree/minecraft/1.18.2) | | ||
| 1.12.2 | 8 | ❌ | ✅ | ❌ | [Branch](https://github.com/CSSUoB/CSS-Minecraft/tree/minecraft/1.12.2) | | ||
|
||
**Never merge `minecraft/*` branches into master.** Build features/fixes in master and cherry-pick backwards. | ||
|
||
### Upgrading to future versions | ||
|
||
The `master` branch should always target the latest version. | ||
Before upgrading, create a new release branch for the current version using the naming | ||
scheme `minecraft/<version>`. | ||
|
||
Then, make the necessary changes to upgrade Minecraft version. Bukkit / Spigot / Paper | ||
has a stable enough API where not many changes will be needed (if any at all), but | ||
other platforms will likely break. | ||
|
||
Once changes are done, update the version matrix and open a new PR to `master`. | ||
|
||
### Backporting to older versions | ||
|
||
This mod was originally made for Minecraft 1.21, thus | ||
it will require backporting to work on older modpacks. | ||
|
||
Create a branch from the nearest Minecraft version and name it `minecraft/<version>`. | ||
You may be required to change the Java version, or upgrade/downgrade Gradle. | ||
It should be noted that Fabric does not exist prior to Minecraft 1.14. | ||
|
||
Once finished, push the branch to GitHub and update this version matrix with the platform | ||
and version you have backported. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
plugins { | ||
id "java" | ||
id "com.gradleup.shadow" version "8.3.0" | ||
} | ||
|
||
subprojects { | ||
apply plugin: "java" | ||
apply plugin: "com.gradleup.shadow" | ||
|
||
group = "com.cssbham" | ||
version = "1.0.0" | ||
|
||
sourceCompatibility = 21 | ||
targetCompatibility = 21 | ||
|
||
tasks.withType(JavaCompile) { | ||
options.encoding = "UTF-8" | ||
} | ||
|
||
tasks.withType(Javadoc) { | ||
options.encoding = "UTF-8" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
assemble.dependsOn shadowJar | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
plugins { | ||
id "java" | ||
} | ||
|
||
processResources { | ||
duplicatesStrategy = duplicatesStrategy.INCLUDE | ||
from(sourceSets.main.resources.srcDirs) { | ||
include "plugin.yml" | ||
expand("version": project.version) | ||
} | ||
} | ||
|
||
repositories { | ||
maven { url = "https://repo.papermc.io/repository/maven-public/" } | ||
} | ||
|
||
dependencies { | ||
compileOnly "io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT" | ||
|
||
implementation project(path: ":common", configuration: "shadow") | ||
} | ||
|
||
shadowJar { | ||
dependencies { | ||
include(project(":common")) | ||
} | ||
|
||
archiveFileName = "cssminecraft-bukkit-${project.version}.jar" | ||
|
||
minimize() | ||
} |
71 changes: 71 additions & 0 deletions
71
bukkit/src/main/java/com/cssbham/cssminecraft/bukkit/BukkitCSSMinecraftPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.cssbham.cssminecraft.bukkit; | ||
|
||
import com.cssbham.cssminecraft.bukkit.adapter.BukkitServerChatAdapter; | ||
import com.cssbham.cssminecraft.bukkit.command.BukkitCommandService; | ||
import com.cssbham.cssminecraft.bukkit.executor.BukkitServerExecutor; | ||
import com.cssbham.cssminecraft.bukkit.listener.BukkitEventListener; | ||
import com.cssbham.cssminecraft.bukkit.logger.BukkitLogger; | ||
import com.cssbham.cssminecraft.common.AbstractCSSMinecraftPlugin; | ||
import com.cssbham.cssminecraft.common.adapter.ServerChatAdapter; | ||
import com.cssbham.cssminecraft.common.command.CommandService; | ||
import com.cssbham.cssminecraft.common.executor.ServerExecutor; | ||
import com.cssbham.cssminecraft.common.logger.Logger; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
/** | ||
* Implementation of CSS Minecraft Plugin for Bukkit | ||
*/ | ||
public class BukkitCSSMinecraftPlugin extends AbstractCSSMinecraftPlugin { | ||
|
||
private final JavaPlugin plugin; | ||
private final BukkitLogger logger; | ||
private final BukkitServerChatAdapter serverChatAdapter; | ||
private final BukkitServerExecutor executor; | ||
private final BukkitCommandService commandService; | ||
|
||
public BukkitCSSMinecraftPlugin(JavaPlugin plugin) { | ||
this.plugin = plugin; | ||
this.logger = new BukkitLogger(plugin); | ||
this.serverChatAdapter = new BukkitServerChatAdapter(); | ||
this.executor = new BukkitServerExecutor(logger, plugin); | ||
this.commandService = new BukkitCommandService(logger, executor, serverChatAdapter); | ||
} | ||
|
||
@Override | ||
public void enable() { | ||
super.enable(); | ||
|
||
BukkitEventListener eventListener = new BukkitEventListener(plugin, executor); | ||
eventListener.bindPlatformToEventBus(super.getEventBus()); | ||
|
||
plugin.getCommand("makegreen").setExecutor(commandService); | ||
} | ||
|
||
@Override | ||
public Logger getLogger() { | ||
return logger; | ||
} | ||
|
||
@Override | ||
public ServerChatAdapter provideServerChatAdapter() { | ||
return serverChatAdapter; | ||
} | ||
|
||
@Override | ||
public Path provideConfigurationPath() { | ||
return Paths.get(plugin.getDataFolder().getPath(), "config.yml"); | ||
} | ||
|
||
@Override | ||
public ServerExecutor provideServerExecutor() { | ||
return executor; | ||
} | ||
|
||
@Override | ||
public CommandService provideCommandService() { | ||
return commandService; | ||
} | ||
} |
Oops, something went wrong.