Skip to content

Commit

Permalink
Back ported to 1.14
Browse files Browse the repository at this point in the history
  • Loading branch information
p0t4t0sandwich committed Aug 20, 2023
1 parent 104270f commit 9f81882
Show file tree
Hide file tree
Showing 69 changed files with 2,000 additions and 58 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ TaterComms supports: Bukkit, Fabric, and Forge

## Configuration

<plugins/config>/TaterComms/tatercomms.config.yml

```yaml
---
version: 1
Expand Down
93 changes: 45 additions & 48 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,26 +188,23 @@ rm -rf ./common

# --------------------------- Prepare Sponge --------------------------------

#SPONGE_VERSIONS=(8)
SPONGE_VERSIONS=()
SPONGE_VERSIONS=(8)
for SPONGE_VERSION in "${SPONGE_VERSIONS[@]}"
do
prepareFiles sponge$SPONGE_VERSION
done

# --------------------------- Prepare Fabric --------------------------------

#FABRIC_VERSIONS=(1.14 1.15 1.16 1.17 1.20)
FABRIC_VERSIONS=(1.20)
FABRIC_VERSIONS=(1.14 1.17 1.20)
for FABRIC_VERSION in "${FABRIC_VERSIONS[@]}"
do
prepareFiles fabric-$FABRIC_VERSION
done

# --------------------------- Prepare Forge --------------------------------

#FORGE_VERSIONS=(1.14.3 1.15.1 1.16.1 1.17.1 1.18 1.19 1.20)
FORGE_VERSIONS=(1.20)
FORGE_VERSIONS=(1.14.3 1.15.1 1.16.1 1.17.1 1.18 1.19 1.20)
for FORGE_VERSION in "${FORGE_VERSIONS[@]}"
do
prepareFiles forge-$FORGE_VERSION
Expand All @@ -221,48 +218,48 @@ do
prepareFiles neoforge-$NEOFORGE_VERSION
done

## --------------------------- Build 1.14 --------------------------------
#MC_VERSION=1.14
#FABRIC_VERSION=1.14
#FORGE_VERSION=1.14.3
#OUT_FILE=$PROJ_NAME-$MC_VERSION-$VERSION
#build $FABRIC_VERSION $FORGE_VERSION $OUT_FILE
#
## --------------------------- Build 1.15 --------------------------------
#MC_VERSION=1.15
#FABRIC_VERSION=1.15
#FORGE_VERSION=1.15.1
#OUT_FILE=$PROJ_NAME-$MC_VERSION-$VERSION
#build $FABRIC_VERSION $FORGE_VERSION $OUT_FILE
#
## --------------------------- Build 1.16 --------------------------------
#MC_VERSION=1.16
#FABRIC_VERSION=1.16
#FORGE_VERSION=1.16.1
#SPONGE_VERSION=8
#OUT_FILE=$PROJ_NAME-$MC_VERSION-$VERSION
#spongebuild $FABRIC_VERSION $FORGE_VERSION $SPONGE_VERSION $OUT_FILE
#
## --------------------------- Build 1.17 --------------------------------
#MC_VERSION=1.17
#FABRIC_VERSION=1.17
#FORGE_VERSION=1.17.1
#OUT_FILE=$PROJ_NAME-$MC_VERSION-$VERSION
#build $FABRIC_VERSION $FORGE_VERSION $OUT_FILE
#
## --------------------------- Build 1.18 --------------------------------
#MC_VERSION=1.18
#FABRIC_VERSION=1.17
#FORGE_VERSION=1.18
#OUT_FILE=$PROJ_NAME-$MC_VERSION-$VERSION
#build $FABRIC_VERSION $FORGE_VERSION $OUT_FILE
#
## --------------------------- Build 1.19 --------------------------------
#MC_VERSION=1.19
#FABRIC_VERSION=1.17
#FORGE_VERSION=1.19
#OUT_FILE=$PROJ_NAME-$MC_VERSION-$VERSION
#build $FABRIC_VERSION $FORGE_VERSION $OUT_FILE
# --------------------------- Build 1.14 --------------------------------
MC_VERSION=1.14
FABRIC_VERSION=1.14
FORGE_VERSION=1.14.3
OUT_FILE=$PROJ_NAME-$MC_VERSION-$VERSION
build $FABRIC_VERSION $FORGE_VERSION $OUT_FILE

# --------------------------- Build 1.15 --------------------------------
MC_VERSION=1.15
FABRIC_VERSION=1.14
FORGE_VERSION=1.15.1
OUT_FILE=$PROJ_NAME-$MC_VERSION-$VERSION
build $FABRIC_VERSION $FORGE_VERSION $OUT_FILE

# --------------------------- Build 1.16 --------------------------------
MC_VERSION=1.16
FABRIC_VERSION=1.14
FORGE_VERSION=1.16.1
SPONGE_VERSION=8
OUT_FILE=$PROJ_NAME-$MC_VERSION-$VERSION
spongebuild $FABRIC_VERSION $FORGE_VERSION $SPONGE_VERSION $OUT_FILE

# --------------------------- Build 1.17 --------------------------------
MC_VERSION=1.17
FABRIC_VERSION=1.17
FORGE_VERSION=1.17.1
OUT_FILE=$PROJ_NAME-$MC_VERSION-$VERSION
build $FABRIC_VERSION $FORGE_VERSION $OUT_FILE

# --------------------------- Build 1.18 --------------------------------
MC_VERSION=1.18
FABRIC_VERSION=1.17
FORGE_VERSION=1.18
OUT_FILE=$PROJ_NAME-$MC_VERSION-$VERSION
build $FABRIC_VERSION $FORGE_VERSION $OUT_FILE

# --------------------------- Build 1.19 --------------------------------
MC_VERSION=1.19
FABRIC_VERSION=1.17
FORGE_VERSION=1.19
OUT_FILE=$PROJ_NAME-$MC_VERSION-$VERSION
build $FABRIC_VERSION $FORGE_VERSION $OUT_FILE

# --------------------------- Build 1.20 --------------------------------
MC_VERSION=1.20
Expand Down
75 changes: 75 additions & 0 deletions fabric-1.14/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import net.fabricmc.loom.task.RemapJarTask

plugins {
id('com.github.johnrengelman.shadow') version('8.1.1')
id('fabric-loom') version('1.3-SNAPSHOT')
}

dependencies {
implementation(project(path: ':common', configuration: 'shadow'))

// Minecraft and Fabric mappings
minecraft("com.mojang:minecraft:${project.minecraft_version}")
mappings("net.fabricmc:yarn:${project.yarn_mappings}")
modImplementation("net.fabricmc:fabric-loader:${project.loader_version}")

// Fabric API
Set<String> apiModules = [
'fabric-api-base',
'fabric-command-api-v1',
'fabric-lifecycle-events-v1'
]

apiModules.forEach {
modImplementation(fabricApi.module(it, project.fabric_version))
}

// TaterLib
modImplementation("dev.neuralnexus:TaterLib:${minecraft_version}-${taterlib_version}")
}

processResources {
inputs.property("version", project.version)
inputs.property("minecraft_version", project.minecraft_version)
inputs.property("loader_version", project.loader_version)
filteringCharset("UTF-8")

filesMatching("fabric.mod.json") {
expand("version": project.version,
"minecraft_version": project.minecraft_version,
"loader_version": project.loader_version)
}
}

shadowJar {
dependencies {
exclude('net.fabricmc:.*')
include(project(":common"))
exclude('/mappings/*')
}

archiveFileName = "${project_name}-fabric-${minecraft_version}-${version}-dev.jar"
}

task remappedShadowJar(type: RemapJarTask) {
dependsOn(tasks.shadowJar)
input.set(tasks.shadowJar.archiveFile)
addNestedDependencies.set(true)

destinationDirectory = file('../target')
archiveFileName = "${project_name}-fabric-${minecraft_version}-${version}.jar"
}
remappedShadowJar.doLast {
task ->
ant.checksum(file: task.archivePath) {
hashAlgorithm = 'md5'
property = 'md5sum'
}
}

tasks.assemble.dependsOn(tasks.remappedShadowJar)

artifacts {
archives(remappedShadowJar)
archives(shadowJar)
}
5 changes: 5 additions & 0 deletions fabric-1.14/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# https://fabricmc.net/develop/
minecraft_version=1.14
yarn_mappings=1.14+build.21
loader_version=0.14.21
fabric_version=0.28.5+1.14
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package dev.neuralnexus.tatercomms.fabric;

import dev.neuralnexus.tatercomms.common.TaterCommsPlugin;
import dev.neuralnexus.tatercomms.fabric.commands.FabricDiscordCommand;
import dev.neuralnexus.taterlib.common.abstractions.logger.AbstractLogger;
import dev.neuralnexus.taterlib.fabric.TemplateFabricPlugin;
import dev.neuralnexus.taterlib.fabric.abstractions.logger.FabricLogger;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import org.apache.logging.log4j.LogManager;

/**
* The TaterComms Fabric plugin.
*/
public class FabricTaterCommsPlugin extends TemplateFabricPlugin implements TaterCommsPlugin {
private static final String MOD_ID = "tatercomms";

/**
* @inheritDoc
*/
@Override
public AbstractLogger pluginLogger() {
return new FabricLogger("[TaterComms] ", LogManager.getLogger(MOD_ID));
}

/**
* @inheritDoc
*/
@Override
public void registerCommands() {
CommandRegistrationCallback.EVENT.register(FabricDiscordCommand::register);
}

/**
* @inheritDoc
*/
@Override
public void onInitializeServer() {
pluginStart();
ServerLifecycleEvents.SERVER_STOPPED.register(server -> pluginStop());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package dev.neuralnexus.tatercomms.fabric.commands;

import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import dev.neuralnexus.tatercomms.common.commands.DiscordCommand;
import dev.neuralnexus.taterlib.common.commands.TaterLibCommand;
import dev.neuralnexus.taterlib.common.hooks.LuckPermsHook;
import dev.neuralnexus.taterlib.fabric.abstractions.player.FabricPlayer;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;

import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.server.command.CommandManager.literal;

/**
* The Fabric implementation of the Discord command.
*/
public class FabricDiscordCommand {
/**
* Registers the command.
* @param dispatcher The command dispatcher.
* @param dedicated Whether the server is dedicated or not.
*/
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, boolean dedicated) {
int permissionLevel;
if (dedicated) {
// Check if LuckPerms is hooked
permissionLevel = LuckPermsHook.isHooked() ? 0 : 4;
} else {
permissionLevel = 0;
}

dispatcher.register(literal(TaterLibCommand.getCommandName())
.requires(source -> source.hasPermissionLevel(permissionLevel))
.then(argument("command", StringArgumentType.greedyString())
.executes(context -> {
try {
String[] args = context.getArgument("command", String.class).split(" ");

// Check if sender is a player
boolean isPlayer = context.getSource().getEntity() instanceof ServerPlayerEntity;
FabricPlayer player = isPlayer ? new FabricPlayer((ServerPlayerEntity) context.getSource().getEntity()) : null;

// Execute command
DiscordCommand.executeCommand(player, isPlayer, args);
} catch (Exception e) {
System.err.println(e);
e.printStackTrace();
return 0;
}
return 1;
})
));
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions fabric-1.14/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"schemaVersion": 1,
"id": "tatercomms",
"version": "${version}",
"name": "TaterComms",
"description": "A simple, cross API plugin that bridges communication between servers, using built-in Proxy methods, Discord channels and websockets.",
"authors": [
{
"name": "p0t4t0sandwich",
"contact": {
"sources": "https://github.com/p0t4t0sandwich/",
"homepage": "https://links.sperrer.ca/"
}
}
],
"contact": {
"repo": "https://github.com/p0t4t0sandwich/TaterComms"
},
"license": "GPL-3",
"icon": "assets/TaterComms/icon.png",
"environment": "*",
"entrypoints": {
"server": [
"dev.neuralnexus.tatercomms.fabric.FabricTaterCommsPlugin"
]
},
"mixins": [
"tatercomms.mixins.json"
],
"depends": {
"fabricloader": ">=0.9.0",
"minecraft": ">=${minecraft_version}",
"fabric-api-base": "*",
"fabric-command-api-v1": "*",
"fabric-lifecycle-events-v1": "*",
"taterlib": "*"
},
"suggests": {
"luckperms": "*"
}
}
15 changes: 15 additions & 0 deletions fabric-1.14/src/main/resources/tatercomms.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"required": true,
"minVersion": "0.8",
"package": "dev.neuralnexus.tatercomms.fabric.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
],
"client": [
],
"server": [
],
"injectors": {
"defaultRequire": 1
}
}

0 comments on commit 9f81882

Please sign in to comment.