forked from mirror/BlueMap
Merge branch 'feature/forge' into mc/1.13
This commit is contained in:
commit
9e6dcb7849
50
BlueMapForge/build.gradle
Normal file
50
BlueMapForge/build.gradle
Normal file
@ -0,0 +1,50 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
maven { url = 'https://files.minecraftforge.net/maven/' }
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
|
||||
minecraft {
|
||||
mappings channel: 'snapshot', version: '20190719-1.14.3'
|
||||
}
|
||||
|
||||
configurations {
|
||||
compile.extendsFrom include
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft 'net.minecraftforge:forge:1.15.2-31.1.0'
|
||||
include project(':BlueMapCommon')
|
||||
}
|
||||
|
||||
build.dependsOn shadowJar {
|
||||
destinationDir = file '../build/release'
|
||||
archiveFileName = "BlueMap-${version}-forge.jar"
|
||||
|
||||
configurations = [project.configurations.include]
|
||||
|
||||
relocate 'com.google', 'de.bluecolored.bluemap.google'
|
||||
relocate 'com.flowpowered', 'de.bluecolored.bluemap.flowpowered'
|
||||
relocate 'com.typesafe', 'de.bluecolored.bluemap.typesafe'
|
||||
relocate 'net.querz', 'de.bluecolored.bluemap.querz'
|
||||
relocate 'ninja', 'de.bluecolored.bluemap.ninja'
|
||||
relocate 'org.apache', 'de.bluecolored.bluemap.apache'
|
||||
relocate 'org.yaml', 'de.bluecolored.bluemap.yaml'
|
||||
}
|
||||
|
||||
processResources {
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
|
||||
expand (
|
||||
version: project.version
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
package de.bluecolored.bluemap.forge;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import de.bluecolored.bluemap.common.plugin.Plugin;
|
||||
import de.bluecolored.bluemap.common.plugin.serverinterface.ServerEventListener;
|
||||
import de.bluecolored.bluemap.common.plugin.serverinterface.ServerInterface;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
|
||||
|
||||
@Mod(Plugin.PLUGIN_ID)
|
||||
public class ForgeMod implements ServerInterface {
|
||||
|
||||
private Plugin bluemap;
|
||||
|
||||
private MinecraftServer server;
|
||||
private Map<String, UUID> worldUUIDs;
|
||||
|
||||
public ForgeMod() {
|
||||
Logger.global = new Log4jLogger(LogManager.getLogger());
|
||||
|
||||
this.bluemap = new Plugin("forge", this);
|
||||
this.worldUUIDs = new HashMap<>();
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerStarting(FMLServerStartingEvent event) {
|
||||
this.server = event.getServer();
|
||||
this.worldUUIDs.clear();
|
||||
|
||||
for (ServerWorld world : event.getServer().getWorlds()) {
|
||||
try {
|
||||
world.save(null, false, false);
|
||||
} catch (Throwable t) {
|
||||
Logger.global.logError("Failed to save world: " + world.getProviderName(), t);
|
||||
}
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Logger.global.logInfo("Loading...");
|
||||
bluemap.load();
|
||||
if (bluemap.isLoaded()) Logger.global.logInfo("Loaded!");
|
||||
} catch (Throwable t) {
|
||||
Logger.global.logError("Failed to load!", t);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerStopping(FMLServerStoppingEvent event) {
|
||||
Logger.global.logInfo("Stopping...");
|
||||
bluemap.unload();
|
||||
Logger.global.logInfo("Saved and stopped!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerListener(ServerEventListener listener) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterAllListeners() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUIDForWorld(File worldFolder) throws IOException {
|
||||
|
||||
|
||||
worldFolder = worldFolder.getCanonicalFile();
|
||||
|
||||
for (ServerWorld world : server.getWorlds()) {
|
||||
if (worldFolder.equals(world.getSaveHandler().getWorldDirectory().getCanonicalFile())) return getUUIDForWorld(world);
|
||||
}
|
||||
|
||||
throw new IOException("There is no world with this folder loaded: " + worldFolder.getPath());
|
||||
}
|
||||
|
||||
public UUID getUUIDForWorld(World world) {
|
||||
synchronized (worldUUIDs) {
|
||||
String key = world.getWorldInfo().getWorldName();
|
||||
|
||||
UUID uuid = worldUUIDs.get(key);
|
||||
if (uuid == null) {
|
||||
uuid = UUID.randomUUID();
|
||||
worldUUIDs.put(key, uuid);
|
||||
}
|
||||
|
||||
return uuid;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getConfigFolder() {
|
||||
//TODO
|
||||
return new File(server.getDataDirectory(), "config");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* This file is part of BlueMapSponge, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package de.bluecolored.bluemap.forge;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import de.bluecolored.bluemap.core.logger.AbstractLogger;
|
||||
|
||||
public class Log4jLogger extends AbstractLogger {
|
||||
|
||||
private Logger out;
|
||||
|
||||
public Log4jLogger(Logger out) {
|
||||
this.out = out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logError(String message, Throwable throwable) {
|
||||
out.error(message, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logWarning(String message) {
|
||||
out.warn(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logInfo(String message) {
|
||||
out.info(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logDebug(String message) {
|
||||
if (out.isDebugEnabled()) out.debug(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noFloodDebug(String message) {
|
||||
if (out.isDebugEnabled()) super.noFloodDebug(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noFloodDebug(String key, String message) {
|
||||
if (out.isDebugEnabled()) super.noFloodDebug(key, message);
|
||||
}
|
||||
|
||||
}
|
14
BlueMapForge/src/main/resources/mcmod.info
Normal file
14
BlueMapForge/src/main/resources/mcmod.info
Normal file
@ -0,0 +1,14 @@
|
||||
[
|
||||
{
|
||||
"modid": "bluemap",
|
||||
"name": "BlueMap",
|
||||
"version": "${version}",
|
||||
"description": "A 3d-map of your Minecraft worlds view-able in your browser using three.js (WebGL)",
|
||||
"url": "https://github.com/BlueMap-Minecraft",
|
||||
"authorList": [
|
||||
"Blue (TBlueF, Lukas Rieger)"
|
||||
],
|
||||
"dependencies": [],
|
||||
"requiredMods": []
|
||||
}
|
||||
]
|
@ -5,18 +5,22 @@ plugins {
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
maven {
|
||||
url 'https://jitpack.io'
|
||||
}
|
||||
maven {
|
||||
name 'sponge'
|
||||
url 'http://repo.spongepowered.org/maven'
|
||||
url 'http://repo.spongepowered.org/maven/'
|
||||
}
|
||||
maven {
|
||||
name 'CodeMC'
|
||||
url 'https://repo.codemc.org/repository/maven-public'
|
||||
url 'https://repo.codemc.org/repository/maven-public/'
|
||||
}
|
||||
maven {
|
||||
url = 'https://files.minecraftforge.net/maven/'
|
||||
}
|
||||
}
|
||||
|
||||
compileJava.options.compilerArgs.add '-parameters'
|
||||
|
2
gradle.properties
Normal file
2
gradle.properties
Normal file
@ -0,0 +1,2 @@
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
@ -4,9 +4,11 @@ include ':BlueMapCLI'
|
||||
include ':BlueMapCommon'
|
||||
include ':BlueMapSponge'
|
||||
include ':BlueMapBukkit'
|
||||
include ':BlueMapForge'
|
||||
|
||||
project(':BlueMapCore').projectDir = "$rootDir/BlueMapCore" as File
|
||||
project(':BlueMapCLI').projectDir = "$rootDir/BlueMapCLI" as File
|
||||
project(':BlueMapCommon').projectDir = "$rootDir/BlueMapCommon" as File
|
||||
project(':BlueMapSponge').projectDir = "$rootDir/BlueMapSponge" as File
|
||||
project(':BlueMapBukkit').projectDir = "$rootDir/BlueMapBukkit" as File
|
||||
project(':BlueMapBukkit').projectDir = "$rootDir/BlueMapBukkit" as File
|
||||
project(':BlueMapForge').projectDir = "$rootDir/BlueMapForge" as File
|
Loading…
Reference in New Issue
Block a user