Skip to content

Commit

Permalink
Disable command override if a bukkit/forge hybrid is detected. (#13)
Browse files Browse the repository at this point in the history
* Disable command override if any bukkit/forge hybrid is detected.

* update bs

* add bukkit path aswell
  • Loading branch information
Lyfts authored Dec 12, 2023
1 parent 78e7d27 commit 23f1faa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
31 changes: 9 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 1699290261
//version: 1702141377
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Expand Down Expand Up @@ -28,27 +28,12 @@ import java.util.concurrent.TimeUnit

buildscript {
repositories {
mavenCentral()

maven {
name 'forge'
url 'https://maven.minecraftforge.net'
}
maven {
// GTNH RetroFuturaGradle and ASM Fork
name "GTNH Maven"
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
allowInsecureProtocol = true
}
maven {
name 'sonatype'
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven {
name 'Scala CI dependencies'
url 'https://repo1.maven.org/maven2/'
}

mavenLocal()
}
}
Expand All @@ -69,7 +54,7 @@ plugins {
id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version
id 'com.modrinth.minotaur' version '2.+' apply false
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.24'
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.26'
}

print("You might want to check out './gradlew :faq' if your build fails.\n")
Expand Down Expand Up @@ -302,7 +287,7 @@ if (apiPackage) {
}

if (accessTransformersFile) {
for (atFile in accessTransformersFile.split(",")) {
for (atFile in accessTransformersFile.split(" ")) {
String targetFile = "src/main/resources/META-INF/" + atFile.trim()
if (!getFile(targetFile).exists()) {
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
Expand Down Expand Up @@ -628,7 +613,7 @@ repositories {
}
maven {
name = "ic2"
url = getURL("https://maven.ic2.player.to/", "https://maven2.ic2.player.to/")
url = getURL("https://maven2.ic2.player.to/", "https://maven.ic2.player.to/")
content {
includeGroup "net.industrial-craft"
}
Expand Down Expand Up @@ -687,6 +672,8 @@ configurations.all {
substitute module('com.github.GTNewHorizons:SpongePoweredMixin') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
substitute module('com.github.GTNewHorizons:SpongeMixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
substitute module('io.github.legacymoddingmc:unimixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Our previous unimixins upload was missing the dev classifier")

substitute module('org.scala-lang:scala-library:2.11.1') using module('org.scala-lang:scala-library:2.11.5') because('To allow mixing with Java 8 targets')
}
}

Expand Down Expand Up @@ -793,12 +780,12 @@ ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies"
}

dependencies {
def lwjgl3ifyVersion = '1.5.1'
def lwjgl3ifyVersion = '1.5.7'
if (modId != 'lwjgl3ify') {
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
}
if (modId != 'hodgepodge') {
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.17')
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.35')
}

java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false}
Expand Down Expand Up @@ -1310,7 +1297,7 @@ def addCurseForgeRelation(String type, String name) {

// Updating

def buildscriptGradleVersion = "8.2.1"
def buildscriptGradleVersion = "8.5"

tasks.named('wrapper', Wrapper).configure {
gradleVersion = buildscriptGradleVersion
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/serverutils/ServerUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.apache.logging.log4j.Logger;

import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.SidedProxy;
Expand Down Expand Up @@ -134,14 +133,16 @@ public void onServerStarted(FMLServerStartedEvent event) {
if (Ranks.isActive()) {
Ranks.INSTANCE.commands.clear();

boolean crucibleLoaded = Loader.isModLoaded("Crucible");
boolean bukkitLoaded = CommonUtils.getClassExists("thermos.ThermosRemapper")
|| CommonUtils.getClassExists("org.ultramine.server.UltraminePlugin")
|| CommonUtils.getClassExists("org.bukkit.World");

if (crucibleLoaded) {
if (bukkitLoaded) {
LOGGER.warn(
"Crucible detected, command overriding has been disabled. If there are any issues with Server Utilities ranks or permissions, please test them without Crucible!");
"Thermos/Ultramine detected, command overriding has been disabled. If there are any issues with Server Utilities ranks or permissions, please test them without those mods!");
}

if (!ServerUtilitiesConfig.ranks.override_commands || crucibleLoaded) {
if (!ServerUtilitiesConfig.ranks.override_commands || bukkitLoaded) {
return;
}

Expand Down
9 changes: 9 additions & 0 deletions src/main/java/serverutils/lib/util/CommonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,13 @@ public static ModContainer getModContainerForClass(Class<?> clazz) {
String pkg = clazz.getName().substring(0, clazz.getName().lastIndexOf('.'));
return packageOwners.containsKey(pkg) ? packageOwners.get(pkg).get(0) : null;
}

public static boolean getClassExists(String className) {
try {
Class.forName(className, false, CommonUtils.class.getClassLoader());
return true;
} catch (ClassNotFoundException e) {
return false;
}
}
}

0 comments on commit 23f1faa

Please sign in to comment.