Skip to content

Commit

Permalink
Update to Minecraft 1.21
Browse files Browse the repository at this point in the history
Co-authored-by: Gegy <[email protected]>
  • Loading branch information
NotActuallyTerry and Gegy committed Jul 21, 2024
1 parent 72d6ce5 commit 108b08d
Show file tree
Hide file tree
Showing 33 changed files with 289 additions and 264 deletions.
154 changes: 79 additions & 75 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,120 +1,124 @@
plugins {
id 'java-library'
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
id 'org.spongepowered.mixin' version '0.7+'
id 'net.neoforged.moddev' version '1.0.8'
}

jarJar.enable()

group = "com.lovetropics"
group = mod_group_id
base {
archivesName = 'LTPermissions'
archivesName = mod_id
}


ext.buildnumber = 0
version = "${mod_version}"

if (System.getenv('GITHUB_RUN_NUMBER')) {
project.buildnumber = System.getenv('GITHUB_RUN_NUMBER')
project.buildnumber = System.getenv('GITHUB_RUN_NUMBER') as Integer
version = "${mod_version}+${buildnumber}-gha"
} else {
version = "${mod_version}"
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

minecraft {
mappings channel: 'parchment', version: parchment_version
runs {
configureEach {
copyIdeResources = true
workingDirectory project.file('run')
property 'forge.logging.console.level', 'info'
arg "-mixin.config=ltpermissions.mixins.json"
jvmArg '-Dmixin.env.disableRefMap=true'
mods {
ltperms {
sources sourceSets.main
}
}
}
client {
}
server {
}
}
}

repositories {
maven { url "https://maven.tterrag.com/" }
maven { url "https://maven.enginehub.org/repo/" }
maven { url "https://maven.tterrag.com/" }
mavenLocal()
}


java.toolchain.languageVersion = JavaLanguageVersion.of(21)


dependencies {
minecraft "net.minecraftforge:forge:$minecraft_version-$forge_version"

jarJar(implementation(fg.deobf("com.lovetropics.lib:LTLib:$ltlib_version")))
jarJar(implementation("com.lovetropics.lib:LTLib:$ltlib_version"))

minecraftLibrary("com.sk89q.worldedit:worldedit-core:7.2.16-SNAPSHOT") {
additionalRuntimeClasspath(implementation("com.sk89q.worldedit:worldedit-core:$worldedit_version")) {
exclude group: "com.google.guava"
exclude group: "com.google.code.gson"
exclude group: "it.unimi.dsi"
exclude group: "org.apache.logging.log4j"
exclude group: "org.antlr"
}
implementation fg.deobf("com.sk89q.worldedit:worldedit-forge-mc1.20:7.2.16-SNAPSHOT")

// implementation fg.deobf('com.github.hexomod:WorldEdit-CUI-FE3:1.16.5-3.0.9')

if (System.getProperty("idea.sync.active") != "true") {
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'

implementation("com.sk89q.worldedit:worldedit-neoforge-mc$minecraft_version:$worldedit_version") {
exclude group: "com.google.guava"
}
}

mixin {
add sourceSets.main, "ltpermissions.refmap.json"
}

tasks.named('jar', Jar).configure {
archiveClassifier = 'slim'
finalizedBy 'reobfJar'

manifest {
attributes([
"Specification-Title": "ltpermissions",
"Specification-Vendor": "lovetropics",
"Specification-Version": "1",
"Implementation-Title": project.name,
"Implementation-Version": archiveVersion,
"Implementation-Vendor" :"lovetropics",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"MixinConfigs": "ltpermissions.mixins.json"
])

neoForge {
version = project.neo_version

parchment {
minecraftVersion = project.minecraft_version
mappingsVersion = project.parchment_version
}
}

tasks.named('jarJar').configure {
archiveClassifier = ''
finalizedBy 'reobfJarJar'
}
runs {
configureEach {
logLevel = org.slf4j.event.Level.INFO
gameDirectory = project.file('run')
}
client {
client()
}
server {
server()
}
data {
data()
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
}

mods {
"${mod_id}" {
sourceSet sourceSets.main
}
}

reobf {
jarJar { }
}

tasks.named('processResources', ProcessResources).configure {
var replaceProperties = [
mod_version: mod_version,
]
inputs.properties replaceProperties

filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
expand replaceProperties + [project: project]
}
sourceSets.main.resources { srcDir 'src/generated/resources' }


tasks.withType(ProcessResources).configureEach {
var replaceProperties = [
minecraft_version : minecraft_version,
minecraft_version_range: minecraft_version_range,
neo_version : neo_version,
neo_version_range : neo_version_range,
fml_version_range : fml_version_range,
worldedit_version_range: worldedit_version_range,
mod_id : mod_id,
mod_name : mod_name,
mod_license : mod_license,
mod_version : mod_version,
mod_authors : mod_authors,
mod_description : mod_description
]
inputs.properties replaceProperties

filesMatching(['META-INF/neoforge.mods.toml']) {
expand replaceProperties
}
}


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


idea {
module {
downloadSources = true
downloadJavadoc = true
}
}
29 changes: 23 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
mod_version=0.2.0
minecraft_version=1.20.1
forge_version=47.1.0
parchment_version=2023.06.26-1.20.1
mod_id=ltpermissions
mod_group_id=com.lovetropics.ltpermissions
mod_name=LT Permissions
mod_version=0.3.0

ltlib_version=[1.3,1.4)
mod_license=All Rights Reserved
mod_authors=The Love Tropics Modding team
mod_description=Manages permissions for your Minecraft server\nLT Permissions allows you to define multiple role levels that can be assigned to users. These role levels can be given access to server commands etc.\nFor more info, visit the GitHub repository at https://github.com/LoveTropics/LTPermissions

minecraft_version=1.21
minecraft_version_range=[1.21,1.21,1)

ltlib_version=[1.4,1.5)
worldedit_version=7.4.0-SNAPSHOT
worldedit_version_range=[7.4,8.0)

neo_version=21.0.83-beta
neo_version_range=[21.0.0-beta,)
fml_version_range=[4,)
parchment_version=2024.06.23

org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configuration-cache=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
11 changes: 5 additions & 6 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
maven { url = 'https://maven.minecraftforge.net/' }
maven { url = 'https://repo.spongepowered.org/maven' }
maven { url = 'https://maven.parchmentmc.org' }
mavenCentral()
maven { url = 'https://maven.neoforged.net/releases' }
}
}


plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
}

rootProject.name = 'LTPermissions'
rootProject.name = 'ltpermissions'
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static CommandAliasConfiguration load() {
}

private static boolean setupDefaultConfig(Path path) {
try (InputStream input = LTPermissions.class.getResourceAsStream("/data/ltperms/default_command_aliases.json")) {
try (InputStream input = LTPermissions.class.getResourceAsStream("/data/" + LTPermissions.ID + "/default_command_aliases.json")) {
Files.copy(input, path);
return true;
} catch (IOException e) {
Expand Down
31 changes: 13 additions & 18 deletions src/main/java/com/lovetropics/perms/LTPermissions.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.event.ServerChatEvent;
import net.minecraftforge.fml.IExtensionPoint;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.network.NetworkConstants;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.IExtensionPoint;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.RegisterCommandsEvent;
import net.neoforged.neoforge.event.ServerChatEvent;
import org.slf4j.Logger;

import javax.annotation.Nonnull;
Expand All @@ -44,7 +43,7 @@

@Mod(LTPermissions.ID)
public class LTPermissions {
public static final String ID = "ltperms";
public static final String ID = "ltpermissions";
public static final Logger LOGGER = LogUtils.getLogger();

public static final RoleOverrideType<CommandOverride> COMMANDS = RoleOverrideType.register("commands", CommandOverride.CODEC)
Expand Down Expand Up @@ -87,14 +86,10 @@ public RoleReader bySource(CommandSourceStack source) {
}
};

public LTPermissions() {
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
MinecraftForge.EVENT_BUS.addListener(this::registerCommands);
MinecraftForge.EVENT_BUS.addListener(this::onServerChat);

// Make sure the mod being absent on the other network side does not cause the client to display the server as incompatible
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class,
() -> new IExtensionPoint.DisplayTest(() -> NetworkConstants.IGNORESERVERONLY, (a, b) -> true));
public LTPermissions(IEventBus modBus) {
modBus.addListener(this::setup);
NeoForge.EVENT_BUS.addListener(this::registerCommands);
NeoForge.EVENT_BUS.addListener(this::onServerChat);

PermissionsApi.setRoleLookup(LOOKUP);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.lovetropics.lib.permission.PermissionsApi;
import com.lovetropics.lib.permission.role.Role;
import com.lovetropics.perms.LTPermissions;
import com.lovetropics.perms.config.RolesConfig;
import com.lovetropics.perms.override.command.CommandOverride;
import com.lovetropics.perms.store.PlayerRoleManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public interface ConfigErrorConsumer {
void report(String message);

default void report(String message, DataResult.PartialResult<?> error) {
default void report(String message, DataResult.Error<?> error) {
this.report(message + ": " + error.message());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private static boolean createDefaultConfig(Path path) {
Files.createDirectories(path.getParent());
}

try (InputStream input = LTPermissions.class.getResourceAsStream("/data/ltperms/default_roles.json")) {
try (InputStream input = LTPermissions.class.getResourceAsStream("/data/" + LTPermissions.ID + "/default_roles.json")) {
Files.copy(input, path);
return true;
}
Expand Down
Loading

0 comments on commit 108b08d

Please sign in to comment.