Skip to content

Commit cd48d1a

Browse files
committed
Update official mappings warning, and add to Patcher Plugin.
1 parent a5ffcad commit cd48d1a

File tree

5 files changed

+46
-15
lines changed

5 files changed

+46
-15
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* ForgeGradle
3+
* Copyright (C) 2018 Forge Development LLC
4+
*
5+
* This library is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU Lesser General Public
7+
* License as published by the Free Software Foundation; either
8+
* version 2.1 of the License, or (at your option) any later version.
9+
*
10+
* This library is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this library; if not, write to the Free Software
17+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18+
* USA
19+
*/
20+
21+
package net.minecraftforge.gradle.common.util;
22+
23+
import org.gradle.api.Project;
24+
25+
public class MojangLicenseHelper {
26+
//TODO: Add a task that people can run to quiet this warning.
27+
//Also output the specific text from the targeted MC version.
28+
public static void displayWarning(Project project, String channel) {
29+
if ("official".equals(channel)) {
30+
String warning = "WARNING: "
31+
+ "This project is configured to use the official obfuscation mappings provided by Mojang. "
32+
+ "These mapping fall under their associated license, you should be fully aware of this license. "
33+
+ "For the latest license text, refer to the mapping file itself, or the reference copy here: "
34+
+ "https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md";
35+
project.getLogger().warn(warning);
36+
}
37+
}
38+
}

src/common/java/net/minecraftforge/gradle/common/util/Utils.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,6 @@ public class Utils {
108108
public static final String INSTALLERTOOLS = "net.minecraftforge:installertools:1.1.10:fatjar";
109109
public static final long ZIPTIME = 628041600000L;
110110
public static final TimeZone GMT = TimeZone.getTimeZone("GMT");
111-
public static final String OFFICIAL_MAPPING_USAGE =
112-
"These mapping files are licensed as All Rights Reserved with permission to use the contents for INTERNAL, "
113-
+ "REFERENCE purposes. Please avoid publishing any source code referencing these mappings. A full copy of "
114-
+ "the license can be found at the top of the mapping file itself and in the 19w36a snapshot article at: "
115-
+ "https://www.minecraft.net/en-us/article/minecraft-snapshot-19w36a.";
116111

117112
public static void extractFile(ZipFile zip, String name, File output) throws IOException {
118113
extractFile(zip, zip.getEntry(name), output);

src/mcp/java/net/minecraftforge/gradle/mcp/util/MCPEnvironment.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
package net.minecraftforge.gradle.mcp.util;
2222

2323
import net.minecraftforge.srgutils.MinecraftVersion;
24-
import net.minecraftforge.gradle.mcp.function.MCPFunction;
2524
import org.gradle.api.Project;
2625
import org.gradle.api.logging.Logger;
2726

src/patcher/java/net/minecraftforge/gradle/patcher/PatcherPlugin.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import net.minecraftforge.gradle.common.util.BaseRepo;
3232
import net.minecraftforge.gradle.common.util.MavenArtifactDownloader;
3333
import net.minecraftforge.gradle.common.util.MinecraftRepo;
34+
import net.minecraftforge.gradle.common.util.MojangLicenseHelper;
3435
import net.minecraftforge.gradle.common.util.Utils;
3536
import net.minecraftforge.gradle.common.util.VersionJson;
3637
import net.minecraftforge.gradle.mcp.MCPExtension;
@@ -304,6 +305,7 @@ public void apply(@Nonnull Project project) {
304305
if (doingUpdate) {
305306
String version = (String) project.property("UPDATE_MAPPINGS");
306307
String channel = project.hasProperty("UPDATE_MAPPINGS_CHANNEL") ? (String) project.property("UPDATE_MAPPINGS_CHANNEL") : "snapshot";
308+
MojangLicenseHelper.displayWarning(project, channel);
307309

308310
TaskProvider<DownloadMCPMappingsTask> dlMappingsNew = project.getTasks().register("downloadMappingsNew", DownloadMCPMappingsTask.class);
309311
dlMappingsNew.get().setMappings(channel + '_' + version);
@@ -327,6 +329,8 @@ public void apply(@Nonnull Project project) {
327329
}
328330

329331
project.afterEvaluate(p -> {
332+
MojangLicenseHelper.displayWarning(p, extension.getMappingChannel());
333+
330334
//Add PatchedSrc to a main sourceset and build range tasks
331335
SourceSet mainSource = javaConv.getSourceSets().getByName("main");
332336
applyRangeConfig.get().setSources(mainSource.getJava().getSrcDirs().stream().filter(f -> !f.equals(extension.patchedSrc)).collect(Collectors.toList()));

src/userdev/java/net/minecraftforge/gradle/userdev/UserDevPlugin.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import net.minecraftforge.gradle.common.task.*;
2424
import net.minecraftforge.gradle.common.util.BaseRepo;
2525
import net.minecraftforge.gradle.common.util.MinecraftRepo;
26+
import net.minecraftforge.gradle.common.util.MojangLicenseHelper;
2627
import net.minecraftforge.gradle.common.util.Utils;
2728
import net.minecraftforge.gradle.common.util.VersionJson;
2829
import net.minecraftforge.gradle.mcp.MCPRepo;
@@ -162,10 +163,7 @@ public void apply(@Nonnull Project project) {
162163
String channel = project.hasProperty("UPDATE_MAPPINGS_CHANNEL") ? (String)project.property("UPDATE_MAPPINGS_CHANNEL") : "snapshot";
163164

164165
logger.lifecycle("This process uses Srg2Source for java source file renaming. Please forward relevant bug reports to https://github.com/MinecraftForge/Srg2Source/issues.");
165-
if ("official".equals(channel)) {
166-
String warning = "WARNING: This project will be updated to use the official obfuscation mappings provided by Mojang. " + Utils.OFFICIAL_MAPPING_USAGE;
167-
logger.warn(warning);
168-
}
166+
MojangLicenseHelper.displayWarning(project, channel);
169167

170168
JavaCompile javaCompile = (JavaCompile) project.getTasks().getByName("compileJava");
171169
JavaPluginConvention javaConv = (JavaPluginConvention) project.getConvention().getPlugins().get("java");
@@ -211,10 +209,7 @@ public void apply(@Nonnull Project project) {
211209
}
212210

213211
project.afterEvaluate(p -> {
214-
if ("official".equals(extension.getMappingChannel())) {
215-
String warning = "WARNING: This project is configured to use the official obfuscation mappings provided by Mojang. " + Utils.OFFICIAL_MAPPING_USAGE;
216-
logger.warn(warning);
217-
}
212+
MojangLicenseHelper.displayWarning(p, extension.getMappingChannel());
218213

219214
MinecraftUserRepo mcrepo = null;
220215
DeobfuscatingRepo deobfrepo = null;
@@ -229,7 +224,7 @@ public void apply(@Nonnull Project project) {
229224

230225
mcrepo = new MinecraftUserRepo(p, dep.getGroup(), dep.getName(), dep.getVersion(), extension.getAccessTransformers(), extension.getMappings());
231226
String newDep = mcrepo.getDependencyString();
232-
p.getLogger().lifecycle("New Dep: " + newDep);
227+
//p.getLogger().lifecycle("New Dep: " + newDep);
233228
ExternalModuleDependency ext = (ExternalModuleDependency) p.getDependencies().create(newDep);
234229
{
235230
if (MinecraftUserRepo.CHANGING_USERDEV)

0 commit comments

Comments
 (0)