-
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.
Merge pull request #43 from FTBTeam/dev
Dev
- Loading branch information
Showing
16 changed files
with
315 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,7 @@ logs | |
eclipse | ||
run | ||
.vscode | ||
**/extra-mods-*/ | ||
**/extra-mods-*/ | ||
|
||
.DS_Store | ||
.architectury-transformer |
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
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
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); | ||
} | ||
*/ | ||
} |
Oops, something went wrong.