-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: ported to 1.20.4, added neoforge
- Loading branch information
Showing
10 changed files
with
296 additions
and
10 deletions.
There are no files selected for viewing
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 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 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 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,147 @@ | ||
plugins { | ||
id "com.github.johnrengelman.shadow" version "7.1.0" | ||
id "com.matthewprenger.cursegradle" version "1.4.0" | ||
} | ||
|
||
def ENV = System.getenv() | ||
|
||
architectury { | ||
platformSetupLoomIde() | ||
neoForge() | ||
} | ||
|
||
configurations { | ||
common | ||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. | ||
compileClasspath.extendsFrom common | ||
runtimeClasspath.extendsFrom common | ||
developmentNeoForge.extendsFrom common | ||
} | ||
|
||
//loom { | ||
// forge { | ||
// mixinConfigs = ["ftbranks-common.mixins.json"] | ||
// } | ||
//} | ||
|
||
repositories { | ||
maven { | ||
url "https://maven.neoforged.net/releases/" | ||
} | ||
} | ||
|
||
dependencies { | ||
neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}" | ||
|
||
modApi "dev.architectury:architectury-neoforge:${rootProject.architectury_version}" | ||
modApi("dev.ftb.mods:ftb-library-neoforge:${rootProject.ftb_library_version}") { transitive false } | ||
|
||
common(project(path: ":common", configuration: "namedElements")) { transitive false } | ||
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false } | ||
} | ||
|
||
apply from: "https://raw.githubusercontent.com/FTBTeam/mods-meta/main/gradle/extra-local-mods.gradle" | ||
|
||
processResources { | ||
exclude '.cache' | ||
|
||
inputs.property "version", project.version | ||
|
||
filesMatching("META-INF/mods.toml") { | ||
expand "version": project.version, | ||
"archversion": project.architectury_version, | ||
"neoforgeversion": project.neoforge_version, | ||
"neoforgeloaderversion": project.neoforge_loader_version, | ||
"mcversion": project.minecraft_version, | ||
"ftblibraryversion": project.ftb_library_version | ||
} | ||
} | ||
|
||
shadowJar { | ||
exclude "fabric.mod.json" | ||
|
||
configurations = [project.configurations.shadowCommon] | ||
setArchiveClassifier("dev-shadow") | ||
} | ||
|
||
remapJar { | ||
input.set shadowJar.archiveFile | ||
dependsOn shadowJar | ||
archiveBaseName.set "${rootProject.archives_base_name}-${project.name}" | ||
archiveClassifier.set null | ||
} | ||
|
||
jar { | ||
manifest { | ||
attributes([ | ||
"Specification-Title" : project.mod_id, | ||
"Specification-Vendor" : project.mod_author, | ||
"Specification-Version" : "1", | ||
"Implementation-Title" : project.name, | ||
"Implementation-Version" : version, | ||
"Implementation-Vendor" : project.mod_author, | ||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") | ||
]) | ||
} | ||
|
||
setArchiveClassifier("dev") | ||
} | ||
|
||
components.java { | ||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { | ||
skip() | ||
} | ||
} | ||
|
||
if (ENV.CURSEFORGE_KEY) { | ||
curseforge { | ||
apiKey = ENV.CURSEFORGE_KEY | ||
project { | ||
id = project.curseforge_id_forge | ||
releaseType = ftbPublishing.relType | ||
addGameVersion "Forge" | ||
addGameVersion project.minecraft_version | ||
mainArtifact(remapJar.archiveFile) | ||
relations { | ||
requiredDependency 'architectury-api' | ||
requiredDependency 'ftb-library-forge' | ||
} | ||
changelog = ENV.CHANGELOG // expected to exist if ENV.CURSEFORGE does | ||
changelogType = 'markdown' | ||
} | ||
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenForge(MavenPublication) { | ||
artifactId = "${rootProject.archives_base_name}-${project.name}" | ||
version ftbPublishing.mavenVersion | ||
from components.java | ||
} | ||
} | ||
|
||
repositories { | ||
if (ftbPublishing.ftbToken) { | ||
maven { | ||
url ftbPublishing.ftbURL | ||
credentials { | ||
username = ftbPublishing.ftbUser | ||
password = ftbPublishing.ftbToken | ||
} | ||
} | ||
} | ||
|
||
if (ftbPublishing.sapsToken) { | ||
maven { | ||
url ftbPublishing.sapsURL | ||
credentials { | ||
username = ftbPublishing.sapsUser | ||
password = ftbPublishing.sapsToken | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
rootProject.tasks.getByName("curseforgePublish").dependsOn tasks.getByName("curseforge") |
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 @@ | ||
loom.platform=neoforge |
41 changes: 41 additions & 0 deletions
41
neoforge/src/main/java/dev/ftb/mods/ftbranks/neoforge/FTBRanksNeoForge.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,41 @@ | ||
package dev.ftb.mods.ftbranks.neoforge; | ||
|
||
import dev.ftb.mods.ftbranks.FTBRanks; | ||
import dev.ftb.mods.ftbranks.PlayerNameFormatting; | ||
import dev.ftb.mods.ftbranks.impl.decorate.MessageDecorator; | ||
import net.minecraft.network.chat.MutableComponent; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.neoforged.fml.IExtensionPoint.DisplayTest; | ||
import net.neoforged.fml.ModLoadingContext; | ||
import net.neoforged.fml.common.Mod; | ||
import net.neoforged.neoforge.common.NeoForge; | ||
import net.neoforged.neoforge.event.ServerChatEvent; | ||
import net.neoforged.neoforge.event.entity.player.PlayerEvent; | ||
|
||
@Mod(FTBRanks.MOD_ID) | ||
public class FTBRanksNeoForge { | ||
public FTBRanksNeoForge() { | ||
NeoForge.EVENT_BUS.addListener(this::playerNameFormatting); | ||
NeoForge.EVENT_BUS.addListener(this::serverChat); | ||
|
||
FTBRanks.init(); | ||
|
||
// Nope. | ||
// PermissionAPI.setPermissionHandler(new PermissionAPIWrapper(PermissionAPI.getPermissionHandler())); | ||
|
||
ModLoadingContext.get().registerExtensionPoint(DisplayTest.class, () -> new DisplayTest(() -> DisplayTest.IGNORESERVERONLY, (a, b) -> true)); | ||
} | ||
|
||
private void playerNameFormatting(PlayerEvent.NameFormat event) { | ||
if (event.getEntity() instanceof ServerPlayer player) { | ||
event.setDisplayname(PlayerNameFormatting.formatPlayerName(player, event.getDisplayname())); | ||
} | ||
} | ||
|
||
private void serverChat(ServerChatEvent event) { | ||
MutableComponent text = event.getMessage().copy(); | ||
if (MessageDecorator.decorateMessage(event.getPlayer(), text)) { | ||
event.setMessage(text); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
neoforge/src/main/java/dev/ftb/mods/ftbranks/neoforge/PermissionAPIWrapper.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,44 @@ | ||
package dev.ftb.mods.ftbranks.neoforge; | ||
|
||
/** | ||
* @author LatvianModder | ||
*/ | ||
public class PermissionAPIWrapper /* implements IPermissionHandler */ { | ||
/* Nah, im not doing this lol | ||
private final IPermissionHandler original; | ||
public PermissionAPIWrapper(IPermissionHandler h) { | ||
original = h; | ||
} | ||
@Override | ||
public void registerNode(String node, DefaultPermissionLevel level, String desc) { | ||
original.registerNode(node, level, desc); | ||
} | ||
@Override | ||
public Collection<String> getRegisteredNodes() { | ||
return original.getRegisteredNodes(); | ||
} | ||
@Override | ||
public boolean hasPermission(GameProfile profile, String node, @Nullable IContext context) { | ||
if (context != null && context.getPlayer() instanceof ServerPlayer) { | ||
return FTBRanksAPI.getPermissionValue((ServerPlayer) context.getPlayer(), node).asBoolean().orElseGet(() -> original.hasPermission(profile, node, context)); | ||
} else if (context != null && context.getWorld() != null && !context.getWorld().isClientSide()) { | ||
ServerPlayer player = context.getWorld().getServer().getPlayerList().getPlayer(profile.getId()); | ||
if (player != null) { | ||
return FTBRanksAPI.getPermissionValue(player, node).asBoolean().orElseGet(() -> original.hasPermission(profile, node, context)); | ||
} | ||
} | ||
return original.hasPermission(profile, node, context); | ||
} | ||
@Override | ||
public String getNodeDescription(String node) { | ||
return original.getNodeDescription(node); | ||
} | ||
*/ | ||
} |
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,45 @@ | ||
modLoader = "javafml" | ||
loaderVersion = "[${neoforgeloaderversion},)" | ||
issueTrackerURL = "https://go.ftb.team/support-mod-issues" | ||
license = "All Rights Reserved" | ||
|
||
[[mods]] | ||
modId = "ftbranks" | ||
version = "${version}" | ||
displayName = "FTB Ranks" | ||
authors = "FTB Team" | ||
description = ''' | ||
A simple mod that lets you create ranks for players, similar to Discord roles, and manage permissions for them | ||
''' | ||
|
||
[[mixins]] | ||
config = "ftbranks-common.mixins.json" | ||
|
||
[[dependencies.ftbranks]] | ||
modId = "neoforge" | ||
mandatory = true | ||
versionRange = "[${neoforgeversion},)" | ||
ordering = "NONE" | ||
side = "BOTH" | ||
|
||
[[dependencies.ftbranks]] | ||
modId = "minecraft" | ||
mandatory = true | ||
versionRange = "[${mcversion},)" | ||
ordering = "NONE" | ||
side = "BOTH" | ||
|
||
[[dependencies.ftbranks]] | ||
modId = "architectury" | ||
mandatory = true | ||
versionRange = "[${archversion},)" | ||
ordering = "AFTER" | ||
side = "BOTH" | ||
|
||
[[dependencies.ftbranks]] | ||
modId = "ftblibrary" | ||
mandatory = true | ||
versionRange = "[${ftblibraryversion},)" | ||
ordering = "AFTER" | ||
side = "CLIENT" | ||
|
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,6 @@ | ||
{ | ||
"pack": { | ||
"description": "FTB Ranks Resources", | ||
"pack_format": 15 | ||
} | ||
} |
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