Skip to content

Commit 9e6dcb7

Browse files
committed
Merge branch 'feature/forge' into mc/1.13
2 parents 323cb1b + 00c28f1 commit 9e6dcb7

File tree

7 files changed

+261
-3
lines changed

7 files changed

+261
-3
lines changed

BlueMapForge/build.gradle

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
buildscript {
2+
repositories {
3+
maven { url = 'https://files.minecraftforge.net/maven/' }
4+
jcenter()
5+
mavenCentral()
6+
}
7+
dependencies {
8+
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
9+
}
10+
}
11+
12+
apply plugin: 'net.minecraftforge.gradle'
13+
14+
minecraft {
15+
mappings channel: 'snapshot', version: '20190719-1.14.3'
16+
}
17+
18+
configurations {
19+
compile.extendsFrom include
20+
}
21+
22+
dependencies {
23+
minecraft 'net.minecraftforge:forge:1.15.2-31.1.0'
24+
include project(':BlueMapCommon')
25+
}
26+
27+
build.dependsOn shadowJar {
28+
destinationDir = file '../build/release'
29+
archiveFileName = "BlueMap-${version}-forge.jar"
30+
31+
configurations = [project.configurations.include]
32+
33+
relocate 'com.google', 'de.bluecolored.bluemap.google'
34+
relocate 'com.flowpowered', 'de.bluecolored.bluemap.flowpowered'
35+
relocate 'com.typesafe', 'de.bluecolored.bluemap.typesafe'
36+
relocate 'net.querz', 'de.bluecolored.bluemap.querz'
37+
relocate 'ninja', 'de.bluecolored.bluemap.ninja'
38+
relocate 'org.apache', 'de.bluecolored.bluemap.apache'
39+
relocate 'org.yaml', 'de.bluecolored.bluemap.yaml'
40+
}
41+
42+
processResources {
43+
from(sourceSets.main.resources.srcDirs) {
44+
include 'mcmod.info'
45+
46+
expand (
47+
version: project.version
48+
)
49+
}
50+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package de.bluecolored.bluemap.forge;
2+
3+
import java.io.File;
4+
import java.io.IOException;
5+
import java.util.HashMap;
6+
import java.util.Map;
7+
import java.util.UUID;
8+
9+
import org.apache.logging.log4j.LogManager;
10+
11+
import de.bluecolored.bluemap.common.plugin.Plugin;
12+
import de.bluecolored.bluemap.common.plugin.serverinterface.ServerEventListener;
13+
import de.bluecolored.bluemap.common.plugin.serverinterface.ServerInterface;
14+
import de.bluecolored.bluemap.core.logger.Logger;
15+
import net.minecraft.server.MinecraftServer;
16+
import net.minecraft.world.World;
17+
import net.minecraft.world.server.ServerWorld;
18+
import net.minecraftforge.common.MinecraftForge;
19+
import net.minecraftforge.eventbus.api.SubscribeEvent;
20+
import net.minecraftforge.fml.common.Mod;
21+
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
22+
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
23+
24+
@Mod(Plugin.PLUGIN_ID)
25+
public class ForgeMod implements ServerInterface {
26+
27+
private Plugin bluemap;
28+
29+
private MinecraftServer server;
30+
private Map<String, UUID> worldUUIDs;
31+
32+
public ForgeMod() {
33+
Logger.global = new Log4jLogger(LogManager.getLogger());
34+
35+
this.bluemap = new Plugin("forge", this);
36+
this.worldUUIDs = new HashMap<>();
37+
38+
MinecraftForge.EVENT_BUS.register(this);
39+
}
40+
41+
@SubscribeEvent
42+
public void onServerStarting(FMLServerStartingEvent event) {
43+
this.server = event.getServer();
44+
this.worldUUIDs.clear();
45+
46+
for (ServerWorld world : event.getServer().getWorlds()) {
47+
try {
48+
world.save(null, false, false);
49+
} catch (Throwable t) {
50+
Logger.global.logError("Failed to save world: " + world.getProviderName(), t);
51+
}
52+
}
53+
54+
new Thread(() -> {
55+
try {
56+
Logger.global.logInfo("Loading...");
57+
bluemap.load();
58+
if (bluemap.isLoaded()) Logger.global.logInfo("Loaded!");
59+
} catch (Throwable t) {
60+
Logger.global.logError("Failed to load!", t);
61+
}
62+
}).start();
63+
}
64+
65+
@SubscribeEvent
66+
public void onServerStopping(FMLServerStoppingEvent event) {
67+
Logger.global.logInfo("Stopping...");
68+
bluemap.unload();
69+
Logger.global.logInfo("Saved and stopped!");
70+
}
71+
72+
@Override
73+
public void registerListener(ServerEventListener listener) {
74+
// TODO Auto-generated method stub
75+
76+
}
77+
78+
@Override
79+
public void unregisterAllListeners() {
80+
// TODO Auto-generated method stub
81+
82+
}
83+
84+
@Override
85+
public UUID getUUIDForWorld(File worldFolder) throws IOException {
86+
87+
88+
worldFolder = worldFolder.getCanonicalFile();
89+
90+
for (ServerWorld world : server.getWorlds()) {
91+
if (worldFolder.equals(world.getSaveHandler().getWorldDirectory().getCanonicalFile())) return getUUIDForWorld(world);
92+
}
93+
94+
throw new IOException("There is no world with this folder loaded: " + worldFolder.getPath());
95+
}
96+
97+
public UUID getUUIDForWorld(World world) {
98+
synchronized (worldUUIDs) {
99+
String key = world.getWorldInfo().getWorldName();
100+
101+
UUID uuid = worldUUIDs.get(key);
102+
if (uuid == null) {
103+
uuid = UUID.randomUUID();
104+
worldUUIDs.put(key, uuid);
105+
}
106+
107+
return uuid;
108+
}
109+
}
110+
111+
@Override
112+
public File getConfigFolder() {
113+
//TODO
114+
return new File(server.getDataDirectory(), "config");
115+
}
116+
117+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* This file is part of BlueMapSponge, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package de.bluecolored.bluemap.forge;
26+
27+
import org.apache.logging.log4j.Logger;
28+
29+
import de.bluecolored.bluemap.core.logger.AbstractLogger;
30+
31+
public class Log4jLogger extends AbstractLogger {
32+
33+
private Logger out;
34+
35+
public Log4jLogger(Logger out) {
36+
this.out = out;
37+
}
38+
39+
@Override
40+
public void logError(String message, Throwable throwable) {
41+
out.error(message, throwable);
42+
}
43+
44+
@Override
45+
public void logWarning(String message) {
46+
out.warn(message);
47+
}
48+
49+
@Override
50+
public void logInfo(String message) {
51+
out.info(message);
52+
}
53+
54+
@Override
55+
public void logDebug(String message) {
56+
if (out.isDebugEnabled()) out.debug(message);
57+
}
58+
59+
@Override
60+
public void noFloodDebug(String message) {
61+
if (out.isDebugEnabled()) super.noFloodDebug(message);
62+
}
63+
64+
@Override
65+
public void noFloodDebug(String key, String message) {
66+
if (out.isDebugEnabled()) super.noFloodDebug(key, message);
67+
}
68+
69+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
{
3+
"modid": "bluemap",
4+
"name": "BlueMap",
5+
"version": "${version}",
6+
"description": "A 3d-map of your Minecraft worlds view-able in your browser using three.js (WebGL)",
7+
"url": "https://github.com/BlueMap-Minecraft",
8+
"authorList": [
9+
"Blue (TBlueF, Lukas Rieger)"
10+
],
11+
"dependencies": [],
12+
"requiredMods": []
13+
}
14+
]

build.gradle

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,22 @@ plugins {
55

66
allprojects {
77
repositories {
8+
jcenter()
89
mavenCentral()
910
maven {
1011
url 'https://jitpack.io'
1112
}
1213
maven {
1314
name 'sponge'
14-
url 'http://repo.spongepowered.org/maven'
15+
url 'http://repo.spongepowered.org/maven/'
1516
}
1617
maven {
1718
name 'CodeMC'
18-
url 'https://repo.codemc.org/repository/maven-public'
19+
url 'https://repo.codemc.org/repository/maven-public/'
1920
}
21+
maven {
22+
url = 'https://files.minecraftforge.net/maven/'
23+
}
2024
}
2125

2226
compileJava.options.compilerArgs.add '-parameters'

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
org.gradle.jvmargs=-Xmx3G
2+
org.gradle.daemon=false

settings.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ include ':BlueMapCLI'
44
include ':BlueMapCommon'
55
include ':BlueMapSponge'
66
include ':BlueMapBukkit'
7+
include ':BlueMapForge'
78

89
project(':BlueMapCore').projectDir = "$rootDir/BlueMapCore" as File
910
project(':BlueMapCLI').projectDir = "$rootDir/BlueMapCLI" as File
1011
project(':BlueMapCommon').projectDir = "$rootDir/BlueMapCommon" as File
1112
project(':BlueMapSponge').projectDir = "$rootDir/BlueMapSponge" as File
12-
project(':BlueMapBukkit').projectDir = "$rootDir/BlueMapBukkit" as File
13+
project(':BlueMapBukkit').projectDir = "$rootDir/BlueMapBukkit" as File
14+
project(':BlueMapForge').projectDir = "$rootDir/BlueMapForge" as File

0 commit comments

Comments
 (0)