forked from xjboss/KCauldronX
Update forge to 1481
This commit is contained in:
parent
8c50b9899f
commit
eedf6789a0
@ -1,6 +1,7 @@
|
|||||||
import groovy.json.JsonSlurper
|
import groovy.json.JsonSlurper
|
||||||
import kcauldron.CreateChangelog
|
import kcauldron.CreateChangelog
|
||||||
import kcauldron.InstallBundle
|
import kcauldron.InstallBundle
|
||||||
|
import kcauldron.VersionParser
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
@ -96,7 +97,7 @@ def gitInfo(String key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext.mcVersion = "1.7.10"
|
ext.mcVersion = "1.7.10"
|
||||||
ext.forgeVersion = "1448"
|
ext.forgeVersion = "1481"
|
||||||
ext.revision = project.hasProperty('revision') ? project.getProperty('revision') : buildInfo('nextBuildNumber')
|
ext.revision = project.hasProperty('revision') ? project.getProperty('revision') : buildInfo('nextBuildNumber')
|
||||||
version = "${mcVersion}-${forgeVersion}.${revision}"
|
version = "${mcVersion}-${forgeVersion}.${revision}"
|
||||||
if (project.hasProperty('officialBuild')) println "Updated KCauldron version: ${version}"
|
if (project.hasProperty('officialBuild')) println "Updated KCauldron version: ${version}"
|
||||||
@ -114,7 +115,7 @@ configurations {
|
|||||||
dependencies {
|
dependencies {
|
||||||
bootstrap 'pw.prok:KBootstrap:0.0.10+'
|
bootstrap 'pw.prok:KBootstrap:0.0.10+'
|
||||||
|
|
||||||
libraries 'net.minecraft:launchwrapper:1.11'
|
libraries 'net.minecraft:launchwrapper:1.12@jar'
|
||||||
libraries 'org.ow2.asm:asm-all:5.0.3'
|
libraries 'org.ow2.asm:asm-all:5.0.3'
|
||||||
libraries 'com.typesafe.akka:akka-actor_2.11:2.3.3'
|
libraries 'com.typesafe.akka:akka-actor_2.11:2.3.3'
|
||||||
libraries 'com.typesafe:config:1.2.1'
|
libraries 'com.typesafe:config:1.2.1'
|
||||||
@ -178,7 +179,7 @@ def generateManifest(boolean legacy = false) {
|
|||||||
'Specification-Vendor' : 'Bukkit Team',
|
'Specification-Vendor' : 'Bukkit Team',
|
||||||
'Specification-Title' : 'Bukkit',
|
'Specification-Title' : 'Bukkit',
|
||||||
'Specification-Version' : '1.7.10-R0.1-SNAPSHOT',
|
'Specification-Version' : '1.7.10-R0.1-SNAPSHOT',
|
||||||
'Forge-Version' : '10.13.3.1448',
|
'Forge-Version' : VersionParser.parseForgeRevision(file('forge/src/main/java/net/minecraftforge/common/ForgeVersion.java'), file('src/main/resources/fmlversion.properties')),
|
||||||
'TweakClass' : 'cpw.mods.fml.common.launcher.FMLTweaker',
|
'TweakClass' : 'cpw.mods.fml.common.launcher.FMLTweaker',
|
||||||
'Main-Class' : 'cpw.mods.fml.relauncher.ServerLaunchWrapper',
|
'Main-Class' : 'cpw.mods.fml.relauncher.ServerLaunchWrapper',
|
||||||
'Class-Path' : generateClasspath(legacy)
|
'Class-Path' : generateClasspath(legacy)
|
||||||
|
@ -4,4 +4,3 @@ dependencies {
|
|||||||
compile gradleApi()
|
compile gradleApi()
|
||||||
compile localGroovy()
|
compile localGroovy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
21
buildSrc/src/main/groovy/kcauldron/VersionParser.groovy
Normal file
21
buildSrc/src/main/groovy/kcauldron/VersionParser.groovy
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package kcauldron
|
||||||
|
|
||||||
|
import java.util.regex.Matcher
|
||||||
|
|
||||||
|
class VersionParser {
|
||||||
|
public static String parseForgeRevision(File forgeFile, File propsFile) {
|
||||||
|
def forgeVersion = forgeFile.text
|
||||||
|
def int majorVersion = v(forgeVersion =~ /.+int majorVersion\s+=\s+(\d+);/)
|
||||||
|
def int minorVersion = v(forgeVersion =~ /.+int minorVersion\s+=\s+(\d+);/)
|
||||||
|
def int revisionVersion = v(forgeVersion =~ /.+int revisionVersion\s+=\s+(\d+);/)
|
||||||
|
def props = new Properties();
|
||||||
|
propsFile.withInputStream { props.load(it) }
|
||||||
|
def int buildVersion = props['fmlbuild.build.number'] as int
|
||||||
|
return "${majorVersion}.${minorVersion}.${revisionVersion}.${buildVersion}"
|
||||||
|
}
|
||||||
|
|
||||||
|
static int v(Matcher matcher) {
|
||||||
|
matcher.find()
|
||||||
|
matcher.group(1) as int
|
||||||
|
}
|
||||||
|
}
|
2
forge
2
forge
@ -1 +1 @@
|
|||||||
Subproject commit b3a1548cfaac77e9756168a8887270f8181487ad
|
Subproject commit 204cb16bc45e7f60a87aac2cdaa49816bb0e7d12
|
@ -1,29 +1,6 @@
|
|||||||
--- ../src-base/minecraft/cpw/mods/fml/relauncher/CoreModManager.java
|
--- ../src-base/minecraft/cpw/mods/fml/relauncher/CoreModManager.java
|
||||||
+++ ../src-work/minecraft/cpw/mods/fml/relauncher/CoreModManager.java
|
+++ ../src-work/minecraft/cpw/mods/fml/relauncher/CoreModManager.java
|
||||||
@@ -27,10 +27,14 @@
|
@@ -60,7 +60,7 @@
|
||||||
import java.util.Map;
|
|
||||||
import java.util.jar.Attributes;
|
|
||||||
import java.util.jar.JarFile;
|
|
||||||
+
|
|
||||||
+import kcauldron.KCauldronClassTransformer;
|
|
||||||
import net.minecraft.launchwrapper.ITweaker;
|
|
||||||
import net.minecraft.launchwrapper.Launch;
|
|
||||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
|
||||||
+
|
|
||||||
import org.apache.logging.log4j.Level;
|
|
||||||
+
|
|
||||||
import com.google.common.base.Strings;
|
|
||||||
import com.google.common.base.Throwables;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
@@ -38,6 +42,7 @@
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.google.common.collect.ObjectArrays;
|
|
||||||
import com.google.common.primitives.Ints;
|
|
||||||
+
|
|
||||||
import cpw.mods.fml.common.FMLLog;
|
|
||||||
import cpw.mods.fml.common.asm.transformers.ModAccessTransformer;
|
|
||||||
import cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker;
|
|
||||||
@@ -53,7 +58,7 @@
|
|
||||||
private static final Attributes.Name COREMODCONTAINSFMLMOD = new Attributes.Name("FMLCorePluginContainsFMLMod");
|
private static final Attributes.Name COREMODCONTAINSFMLMOD = new Attributes.Name("FMLCorePluginContainsFMLMod");
|
||||||
private static final Attributes.Name MODTYPE = new Attributes.Name("ModType");
|
private static final Attributes.Name MODTYPE = new Attributes.Name("ModType");
|
||||||
private static final Attributes.Name MODSIDE = new Attributes.Name("ModSide");
|
private static final Attributes.Name MODSIDE = new Attributes.Name("ModSide");
|
||||||
@ -32,7 +9,7 @@
|
|||||||
private static List<String> loadedCoremods = Lists.newArrayList();
|
private static List<String> loadedCoremods = Lists.newArrayList();
|
||||||
private static List<FMLPluginWrapper> loadPlugins;
|
private static List<FMLPluginWrapper> loadPlugins;
|
||||||
private static boolean deobfuscatedEnvironment;
|
private static boolean deobfuscatedEnvironment;
|
||||||
@@ -94,6 +99,7 @@
|
@@ -101,6 +101,7 @@
|
||||||
@Override
|
@Override
|
||||||
public void injectIntoClassLoader(LaunchClassLoader classLoader)
|
public void injectIntoClassLoader(LaunchClassLoader classLoader)
|
||||||
{
|
{
|
||||||
@ -40,7 +17,7 @@
|
|||||||
FMLRelaunchLog.fine("Injecting coremod %s {%s} class transformers", name, coreModInstance.getClass().getName());
|
FMLRelaunchLog.fine("Injecting coremod %s {%s} class transformers", name, coreModInstance.getClass().getName());
|
||||||
if (coreModInstance.getASMTransformerClass() != null) for (String transformer : coreModInstance.getASMTransformerClass())
|
if (coreModInstance.getASMTransformerClass() != null) for (String transformer : coreModInstance.getASMTransformerClass())
|
||||||
{
|
{
|
||||||
@@ -153,6 +159,9 @@
|
@@ -160,6 +161,9 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +27,7 @@
|
|||||||
public static void handleLaunch(File mcDir, LaunchClassLoader classLoader, FMLTweaker tweaker)
|
public static void handleLaunch(File mcDir, LaunchClassLoader classLoader, FMLTweaker tweaker)
|
||||||
{
|
{
|
||||||
CoreModManager.mcDir = mcDir;
|
CoreModManager.mcDir = mcDir;
|
||||||
@@ -212,6 +221,19 @@
|
@@ -219,6 +223,19 @@
|
||||||
loadCoreMod(classLoader, coreModClassName, null);
|
loadCoreMod(classLoader, coreModClassName, null);
|
||||||
}
|
}
|
||||||
discoverCoreMods(mcDir, classLoader);
|
discoverCoreMods(mcDir, classLoader);
|
||||||
@ -70,7 +47,7 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,6 +315,10 @@
|
@@ -336,6 +353,10 @@
|
||||||
String cascadedTweaker = mfAttributes.getValue("TweakClass");
|
String cascadedTweaker = mfAttributes.getValue("TweakClass");
|
||||||
if (cascadedTweaker != null)
|
if (cascadedTweaker != null)
|
||||||
{
|
{
|
||||||
@ -81,7 +58,7 @@
|
|||||||
FMLRelaunchLog.info("Loading tweaker %s from %s", cascadedTweaker, coreMod.getName());
|
FMLRelaunchLog.info("Loading tweaker %s from %s", cascadedTweaker, coreMod.getName());
|
||||||
Integer sortOrder = Ints.tryParse(Strings.nullToEmpty(mfAttributes.getValue("TweakOrder")));
|
Integer sortOrder = Ints.tryParse(Strings.nullToEmpty(mfAttributes.getValue("TweakOrder")));
|
||||||
sortOrder = (sortOrder == null ? Integer.valueOf(0) : sortOrder);
|
sortOrder = (sortOrder == null ? Integer.valueOf(0) : sortOrder);
|
||||||
@@ -322,6 +348,10 @@
|
@@ -365,6 +386,10 @@
|
||||||
FMLRelaunchLog.fine("Not found coremod data in %s", coreMod.getName());
|
FMLRelaunchLog.fine("Not found coremod data in %s", coreMod.getName());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -92,7 +69,7 @@
|
|||||||
// Support things that are mod jars, but not FML mod jars
|
// Support things that are mod jars, but not FML mod jars
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -424,8 +454,11 @@
|
@@ -467,8 +492,11 @@
|
||||||
MCVersion requiredMCVersion = coreModClazz.getAnnotation(IFMLLoadingPlugin.MCVersion.class);
|
MCVersion requiredMCVersion = coreModClazz.getAnnotation(IFMLLoadingPlugin.MCVersion.class);
|
||||||
if (!Arrays.asList(rootPlugins).contains(coreModClass) && (requiredMCVersion == null || Strings.isNullOrEmpty(requiredMCVersion.value())))
|
if (!Arrays.asList(rootPlugins).contains(coreModClass) && (requiredMCVersion == null || Strings.isNullOrEmpty(requiredMCVersion.value())))
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
public static final int revisionVersion = 4;
|
public static final int revisionVersion = 4;
|
||||||
//This number is incremented every time Jenkins builds Forge, and never reset. Should always be 0 in the repo code.
|
//This number is incremented every time Jenkins builds Forge, and never reset. Should always be 0 in the repo code.
|
||||||
- public static final int buildVersion = 0;
|
- public static final int buildVersion = 0;
|
||||||
+ public static final int buildVersion = 1448; // Cauldron
|
+ public static final int buildVersion = kcauldron.KCauldron.lookupForgeRevision(); // KCauldron
|
||||||
|
|
||||||
private static Status status = PENDING;
|
private static Status status = PENDING;
|
||||||
private static String target = null;
|
private static String target = null;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package kcauldron;
|
package kcauldron;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
@ -8,90 +9,92 @@ import java.util.Properties;
|
|||||||
|
|
||||||
import org.spigotmc.RestartCommand;
|
import org.spigotmc.RestartCommand;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
|
||||||
public class KCauldron {
|
public class KCauldron {
|
||||||
private static boolean sManifestParsed = false;
|
private static boolean sManifestParsed = false;
|
||||||
|
|
||||||
private static void parseManifest() {
|
private static void parseManifest() {
|
||||||
if (sManifestParsed)
|
if (sManifestParsed)
|
||||||
return;
|
return;
|
||||||
sManifestParsed = true;
|
sManifestParsed = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Enumeration<URL> resources = KCauldron.class.getClassLoader()
|
Enumeration<URL> resources = KCauldron.class.getClassLoader()
|
||||||
.getResources("META-INF/MANIFEST.MF");
|
.getResources("META-INF/MANIFEST.MF");
|
||||||
Properties manifest = new Properties();
|
Properties manifest = new Properties();
|
||||||
while (resources.hasMoreElements()) {
|
while (resources.hasMoreElements()) {
|
||||||
URL url = resources.nextElement();
|
URL url = resources.nextElement();
|
||||||
manifest.load(url.openStream());
|
manifest.load(url.openStream());
|
||||||
String version = manifest.getProperty("KCauldron-Version");
|
String version = manifest.getProperty("KCauldron-Version");
|
||||||
if (version != null) {
|
if (version != null) {
|
||||||
String path = url.getPath();
|
String path = url.getPath();
|
||||||
String jarFilePath = path.substring(path.indexOf(":") + 1,
|
String jarFilePath = path.substring(path.indexOf(":") + 1,
|
||||||
path.indexOf("!"));
|
path.indexOf("!"));
|
||||||
jarFilePath = URLDecoder.decode(jarFilePath, "UTF-8");
|
jarFilePath = URLDecoder.decode(jarFilePath, "UTF-8");
|
||||||
sServerLocation = new File(jarFilePath);
|
sServerLocation = new File(jarFilePath);
|
||||||
|
|
||||||
sCurrentVersion = version;
|
sCurrentVersion = version;
|
||||||
sGroup = manifest.getProperty("KCauldron-Group");
|
sGroup = manifest.getProperty("KCauldron-Group");
|
||||||
sBranch = manifest.getProperty("KCauldron-Branch");
|
sBranch = manifest.getProperty("KCauldron-Branch");
|
||||||
sChannel = manifest.getProperty("KCauldron-Channel");
|
sChannel = manifest.getProperty("KCauldron-Channel");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
manifest.clear();
|
manifest.clear();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String sCurrentVersion;
|
private static String sCurrentVersion;
|
||||||
|
|
||||||
public static String getCurrentVersion() {
|
public static String getCurrentVersion() {
|
||||||
parseManifest();
|
parseManifest();
|
||||||
return sCurrentVersion;
|
return sCurrentVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static File sServerLocation;
|
private static File sServerLocation;
|
||||||
|
|
||||||
public static File getServerLocation() {
|
public static File getServerLocation() {
|
||||||
parseManifest();
|
parseManifest();
|
||||||
return sServerLocation;
|
return sServerLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static File sServerHome;
|
private static File sServerHome;
|
||||||
|
|
||||||
public static File getServerHome() {
|
public static File getServerHome() {
|
||||||
if (sServerHome == null) {
|
if (sServerHome == null) {
|
||||||
String home = System.getenv("KCAULDRON_HOME");
|
String home = System.getenv("KCAULDRON_HOME");
|
||||||
if (home != null) {
|
if (home != null) {
|
||||||
sServerHome = new File(home);
|
sServerHome = new File(home);
|
||||||
} else {
|
} else {
|
||||||
parseManifest();
|
parseManifest();
|
||||||
sServerHome = sServerLocation.getParentFile();
|
sServerHome = sServerLocation.getParentFile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sServerHome;
|
return sServerHome;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String sGroup;
|
private static String sGroup;
|
||||||
|
|
||||||
public static String getGroup() {
|
public static String getGroup() {
|
||||||
parseManifest();
|
parseManifest();
|
||||||
return sGroup;
|
return sGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String sBranch;
|
private static String sBranch;
|
||||||
|
|
||||||
public static String getBranch() {
|
public static String getBranch() {
|
||||||
parseManifest();
|
parseManifest();
|
||||||
return sBranch;
|
return sBranch;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String sChannel;
|
private static String sChannel;
|
||||||
|
|
||||||
public static String getChannel() {
|
public static String getChannel() {
|
||||||
parseManifest();
|
parseManifest();
|
||||||
return sChannel;
|
return sChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File sNewServerLocation;
|
public static File sNewServerLocation;
|
||||||
@ -99,6 +102,26 @@ public class KCauldron {
|
|||||||
public static boolean sUpdateInProgress;
|
public static boolean sUpdateInProgress;
|
||||||
|
|
||||||
public static void restart() {
|
public static void restart() {
|
||||||
RestartCommand.restart(true);
|
RestartCommand.restart(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int sForgeRevision = 0;
|
||||||
|
|
||||||
|
public static int lookupForgeRevision() {
|
||||||
|
if (sForgeRevision != 0) return sForgeRevision;
|
||||||
|
int revision = 0;
|
||||||
|
try {
|
||||||
|
Properties p = new Properties();
|
||||||
|
p.load(KCauldron.class
|
||||||
|
.getResourceAsStream("/fmlversion.properties"));
|
||||||
|
revision = Integer.parseInt(String.valueOf(p.getOrDefault(
|
||||||
|
"fmlbuild.build.number", "0")));
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
if (revision == 0) {
|
||||||
|
KLog.get().warning("KCauldron: could not parse forge revision, critical error");
|
||||||
|
FMLCommonHandler.instance().exitJava(1, false);
|
||||||
|
}
|
||||||
|
return sForgeRevision = revision;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,26 +18,26 @@ import cpw.mods.fml.common.FMLLog;
|
|||||||
public class KCauldronClassTransformer implements Transformer {
|
public class KCauldronClassTransformer implements Transformer {
|
||||||
@Override
|
@Override
|
||||||
public void transform(final ImagineASM asm) {
|
public void transform(final ImagineASM asm) {
|
||||||
if (asm.is("climateControl.utils.ChunkGeneratorExtractor")) {
|
if (asm.is("climateControl.utils.ChunkGeneratorExtractor")) {
|
||||||
boolean undergroundBiomesInstalled = false;
|
boolean undergroundBiomesInstalled = false;
|
||||||
try {
|
try {
|
||||||
Class.forName("exterminatorJeff.undergroundBiomes.worldGen.ChunkProviderWrapper");
|
Class.forName("exterminatorJeff.undergroundBiomes.worldGen.ChunkProviderWrapper");
|
||||||
undergroundBiomesInstalled = true;
|
undergroundBiomesInstalled = true;
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
if (!undergroundBiomesInstalled) {
|
if (!undergroundBiomesInstalled) {
|
||||||
FMLLog.log(Level.INFO, "KCauldron: Patching " + asm.getActualName() + " for compatibility with Climate Control");
|
FMLLog.log(Level.INFO, "KCauldron: Patching " + asm.getActualName() + " for compatibility with Climate Control");
|
||||||
extractFrom(asm, asm.method("extractFrom",
|
extractFrom(asm, asm.method("extractFrom",
|
||||||
"(Lnet/minecraft/world/WorldServer;)Lnet/minecraft/world/chunk/IChunkProvider;").instructions());
|
"(Lnet/minecraft/world/WorldServer;)Lnet/minecraft/world/chunk/IChunkProvider;").instructions());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void extractFrom(ImagineASM asm, InsnList list) {
|
public void extractFrom(ImagineASM asm, InsnList list) {
|
||||||
//Pair<String, String> fieldChunkProvider = asm.field("net/minecraft/world/World", "chunkProvider");
|
//Pair<String, String> fieldChunkProvider = asm.field("net/minecraft/world/World", "chunkProvider");
|
||||||
list.clear();
|
list.clear();
|
||||||
list.add(new IntInsnNode(ALOAD, 1));
|
list.add(new IntInsnNode(ALOAD, 1));
|
||||||
list.add(new FieldInsnNode(GETFIELD, "ahb", "v", "Lapu;"));
|
list.add(new FieldInsnNode(GETFIELD, "ahb", "v", "Lapu;"));
|
||||||
list.add(new InsnNode(ARETURN));
|
list.add(new InsnNode(ARETURN));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,66 +15,66 @@ public class KCauldronCommand extends Command {
|
|||||||
public static final String RESTART = NAME + ".restart";
|
public static final String RESTART = NAME + ".restart";
|
||||||
|
|
||||||
public KCauldronCommand() {
|
public KCauldronCommand() {
|
||||||
super(NAME);
|
super(NAME);
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append(String.format("/%s check - Check to update\n", NAME));
|
builder.append(String.format("/%s check - Check to update\n", NAME));
|
||||||
builder.append(String
|
builder.append(String
|
||||||
.format("/%s update [version] - Update to specified or latest version\n",
|
.format("/%s update [version] - Update to specified or latest version\n",
|
||||||
NAME));
|
NAME));
|
||||||
builder.append(String.format("/%s restart - Restart server\n", NAME));
|
builder.append(String.format("/%s restart - Restart server\n", NAME));
|
||||||
setUsage(builder.toString());
|
setUsage(builder.toString());
|
||||||
|
|
||||||
setPermission("kcauldron");
|
setPermission("kcauldron");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean testPermission(CommandSender target, String permission) {
|
public boolean testPermission(CommandSender target, String permission) {
|
||||||
if (testPermissionSilent(target, permission)) {
|
if (testPermissionSilent(target, permission)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
target.sendMessage(ChatColor.RED
|
target.sendMessage(ChatColor.RED
|
||||||
+ "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error.");
|
+ "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean testPermissionSilent(CommandSender target, String permission) {
|
public boolean testPermissionSilent(CommandSender target, String permission) {
|
||||||
if (!super.testPermissionSilent(target)) {
|
if (!super.testPermissionSilent(target)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (String p : permission.split(";"))
|
for (String p : permission.split(";"))
|
||||||
if (target.hasPermission(p))
|
if (target.hasPermission(p))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(CommandSender sender, String commandLabel,
|
public boolean execute(CommandSender sender, String commandLabel,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
if (!testPermission(sender))
|
if (!testPermission(sender))
|
||||||
return true;
|
return true;
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Please specify action");
|
sender.sendMessage(ChatColor.YELLOW + "Please specify action");
|
||||||
sender.sendMessage(ChatColor.AQUA + usageMessage);
|
sender.sendMessage(ChatColor.AQUA + usageMessage);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String action = args[0];
|
String action = args[0];
|
||||||
if ("check".equals(action)) {
|
if ("check".equals(action)) {
|
||||||
if (!testPermission(sender, CHECK))
|
if (!testPermission(sender, CHECK))
|
||||||
return true;
|
return true;
|
||||||
sender.sendMessage(ChatColor.GREEN + "Initiated version check...");
|
sender.sendMessage(ChatColor.GREEN + "Initiated version check...");
|
||||||
KVersionRetriever.startServer(new CommandSenderUpdateCallback(
|
KVersionRetriever.startServer(new CommandSenderUpdateCallback(
|
||||||
sender), false);
|
sender), false);
|
||||||
} else if ("update".equals(action)) {
|
} else if ("update".equals(action)) {
|
||||||
KCauldronUpdater.initUpdate(sender, args.length > 1 ? args[1]
|
KCauldronUpdater.initUpdate(sender, args.length > 1 ? args[1]
|
||||||
: null);
|
: null);
|
||||||
} else if ("restart".equals(action)) {
|
} else if ("restart".equals(action)) {
|
||||||
if (!testPermission(sender, RESTART))
|
if (!testPermission(sender, RESTART))
|
||||||
return true;
|
return true;
|
||||||
KCauldron.restart();
|
KCauldron.restart();
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.RED + "Unknown action");
|
sender.sendMessage(ChatColor.RED + "Unknown action");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,70 +10,70 @@ import net.minecraftforge.cauldron.configuration.StringSetting;
|
|||||||
|
|
||||||
public class KCauldronConfig extends ConfigBase {
|
public class KCauldronConfig extends ConfigBase {
|
||||||
public BoolSetting commandEnable = new BoolSetting(this, "command.enable",
|
public BoolSetting commandEnable = new BoolSetting(this, "command.enable",
|
||||||
true, "Enable KCauldron command");
|
true, "Enable KCauldron command");
|
||||||
public BoolSetting updatecheckerEnable = new BoolSetting(this,
|
public BoolSetting updatecheckerEnable = new BoolSetting(this,
|
||||||
"updatechecker.enable", true, "Enable KCauldron update checker");
|
"updatechecker.enable", true, "Enable KCauldron update checker");
|
||||||
public StringSetting updatecheckerSymlinks = new StringSetting(this,
|
public StringSetting updatecheckerSymlinks = new StringSetting(this,
|
||||||
"updatechecker.symlinks", "KCauldron.jar", "(Re)create symlinks after update");
|
"updatechecker.symlinks", "KCauldron.jar", "(Re)create symlinks after update");
|
||||||
public BoolSetting updatecheckerAutoinstall = new BoolSetting(this,
|
public BoolSetting updatecheckerAutoinstall = new BoolSetting(this,
|
||||||
"updatechecker.autoinstall", false, "Install updates without confirming");
|
"updatechecker.autoinstall", false, "Install updates without confirming");
|
||||||
public BoolSetting updatecheckerAutorestart = new BoolSetting(this,
|
public BoolSetting updatecheckerAutorestart = new BoolSetting(this,
|
||||||
"updatechecker.autorestart", false, "Restart server after updating without confirming (set restart script in spigot.yml)");
|
"updatechecker.autorestart", false, "Restart server after updating without confirming (set restart script in spigot.yml)");
|
||||||
public BoolSetting updatecheckerQuite = new BoolSetting(this,
|
public BoolSetting updatecheckerQuite = new BoolSetting(this,
|
||||||
"updatechecker.quite", false, "Print less info during update");
|
"updatechecker.quite", false, "Print less info during update");
|
||||||
|
|
||||||
public BoolSetting loggingMaterialInjection = new BoolSetting(this,
|
public BoolSetting loggingMaterialInjection = new BoolSetting(this,
|
||||||
"logging.materialInjection", false, "Log material injection event");
|
"logging.materialInjection", false, "Log material injection event");
|
||||||
|
|
||||||
public KCauldronConfig() {
|
public KCauldronConfig() {
|
||||||
super("kcauldron.yml", "kc");
|
super("kcauldron.yml", "kc");
|
||||||
register(commandEnable);
|
register(commandEnable);
|
||||||
register(updatecheckerEnable);
|
register(updatecheckerEnable);
|
||||||
register(updatecheckerSymlinks);
|
register(updatecheckerSymlinks);
|
||||||
register(updatecheckerAutoinstall);
|
register(updatecheckerAutoinstall);
|
||||||
register(updatecheckerAutorestart);
|
register(updatecheckerAutorestart);
|
||||||
register(updatecheckerQuite);
|
register(updatecheckerQuite);
|
||||||
register(loggingMaterialInjection);
|
register(loggingMaterialInjection);
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void register(Setting<?> setting) {
|
private void register(Setting<?> setting) {
|
||||||
settings.put(setting.path, setting);
|
settings.put(setting.path, setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerCommands() {
|
public void registerCommands() {
|
||||||
if (commandEnable.getValue()) {
|
if (commandEnable.getValue()) {
|
||||||
super.registerCommands();
|
super.registerCommands();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addCommands() {
|
protected void addCommands() {
|
||||||
commands.put(commandName, new KCauldronCommand());
|
commands.put(commandName, new KCauldronCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void load() {
|
protected void load() {
|
||||||
try {
|
try {
|
||||||
config = YamlConfiguration.loadConfiguration(configFile);
|
config = YamlConfiguration.loadConfiguration(configFile);
|
||||||
String header = "";
|
String header = "";
|
||||||
for (Setting<?> toggle : settings.values()) {
|
for (Setting<?> toggle : settings.values()) {
|
||||||
if (!toggle.description.equals(""))
|
if (!toggle.description.equals(""))
|
||||||
header += "Setting: " + toggle.path + " Default: "
|
header += "Setting: " + toggle.path + " Default: "
|
||||||
+ toggle.def + " # " + toggle.description + "\n";
|
+ toggle.def + " # " + toggle.description + "\n";
|
||||||
|
|
||||||
config.addDefault(toggle.path, toggle.def);
|
config.addDefault(toggle.path, toggle.def);
|
||||||
settings.get(toggle.path).setValue(
|
settings.get(toggle.path).setValue(
|
||||||
config.getString(toggle.path));
|
config.getString(toggle.path));
|
||||||
}
|
}
|
||||||
config.options().header(header);
|
config.options().header(header);
|
||||||
config.options().copyDefaults(true);
|
config.options().copyDefaults(true);
|
||||||
save();
|
save();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
MinecraftServer.getServer().logSevere(
|
MinecraftServer.getServer().logSevere(
|
||||||
"Could not load " + this.configFile);
|
"Could not load " + this.configFile);
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,15 +5,15 @@ import net.md_5.specialsource.JarRemapper;
|
|||||||
|
|
||||||
public class KCauldronRemapper extends JarRemapper {
|
public class KCauldronRemapper extends JarRemapper {
|
||||||
public KCauldronRemapper(JarMapping jarMapping) {
|
public KCauldronRemapper(JarMapping jarMapping) {
|
||||||
super(jarMapping);
|
super(jarMapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String mapSignature(String signature, boolean typeSignature) {
|
public String mapSignature(String signature, boolean typeSignature) {
|
||||||
try {
|
try {
|
||||||
return super.mapSignature(signature, typeSignature);
|
return super.mapSignature(signature, typeSignature);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return signature;
|
return signature;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,45 +8,45 @@ public class KLog {
|
|||||||
private static final KLog DEFAULT_LOGGER = new KLog("KCauldron");
|
private static final KLog DEFAULT_LOGGER = new KLog("KCauldron");
|
||||||
|
|
||||||
public static KLog get() {
|
public static KLog get() {
|
||||||
return DEFAULT_LOGGER;
|
return DEFAULT_LOGGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KLog get(String tag) {
|
public static KLog get(String tag) {
|
||||||
return new KLog("KCauldron: " + tag);
|
return new KLog("KCauldron: " + tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String mTag;
|
private final String mTag;
|
||||||
|
|
||||||
public KLog(String tag) {
|
public KLog(String tag) {
|
||||||
mTag = tag;
|
mTag = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log(Level level, Throwable throwable, String message,
|
public void log(Level level, Throwable throwable, String message,
|
||||||
Object... args) {
|
Object... args) {
|
||||||
Throwable t = null;
|
Throwable t = null;
|
||||||
if (throwable != null) {
|
if (throwable != null) {
|
||||||
t = new Throwable();
|
t = new Throwable();
|
||||||
t.initCause(throwable);
|
t.initCause(throwable);
|
||||||
t.fillInStackTrace();
|
t.fillInStackTrace();
|
||||||
}
|
}
|
||||||
FMLLog.log(mTag, level, t, String.format(message, args));
|
FMLLog.log(mTag, level, t, String.format(message, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void warning(String message, Object... args) {
|
public void warning(String message, Object... args) {
|
||||||
log(Level.WARN, null, message, args);
|
log(Level.WARN, null, message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void warning(Throwable throwable, String message,
|
public void warning(Throwable throwable, String message,
|
||||||
Object... args) {
|
Object... args) {
|
||||||
log(Level.WARN, throwable, message, args);
|
log(Level.WARN, throwable, message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void info(String message, Object... args) {
|
public void info(String message, Object... args) {
|
||||||
log(Level.INFO, null, message, args);
|
log(Level.INFO, null, message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void info(Throwable throwable, String message,
|
public void info(Throwable throwable, String message,
|
||||||
Object... args) {
|
Object... args) {
|
||||||
log(Level.INFO, throwable, message, args);
|
log(Level.INFO, throwable, message, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,49 +13,49 @@ public class CommandSenderUpdateCallback implements IVersionCheckCallback {
|
|||||||
private Reference<CommandSender> mSender;
|
private Reference<CommandSender> mSender;
|
||||||
|
|
||||||
public CommandSenderUpdateCallback(CommandSender sender) {
|
public CommandSenderUpdateCallback(CommandSender sender) {
|
||||||
mSender = new WeakReference<CommandSender>(sender);
|
mSender = new WeakReference<CommandSender>(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CommandSender getSender() {
|
protected CommandSender getSender() {
|
||||||
return mSender.get();
|
return mSender.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void upToDate() {
|
public void upToDate() {
|
||||||
CommandSender sender = mSender.get();
|
CommandSender sender = mSender.get();
|
||||||
if (sender != null) {
|
if (sender != null) {
|
||||||
sender.sendMessage(ChatColor.GREEN
|
sender.sendMessage(ChatColor.GREEN
|
||||||
+ "Running version of KCauldron is up-to-date: "
|
+ "Running version of KCauldron is up-to-date: "
|
||||||
+ KCauldron.getCurrentVersion());
|
+ KCauldron.getCurrentVersion());
|
||||||
}
|
}
|
||||||
DefaultUpdateCallback.INSTANCE.upToDate();
|
DefaultUpdateCallback.INSTANCE.upToDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void newVersion(String newVersion) {
|
public void newVersion(String newVersion) {
|
||||||
CommandSender sender = mSender.get();
|
CommandSender sender = mSender.get();
|
||||||
if (sender != null) {
|
if (sender != null) {
|
||||||
newVersion(sender, KCauldron.getCurrentVersion(), newVersion);
|
newVersion(sender, KCauldron.getCurrentVersion(), newVersion);
|
||||||
}
|
}
|
||||||
DefaultUpdateCallback.INSTANCE.newVersion(newVersion);
|
DefaultUpdateCallback.INSTANCE.newVersion(newVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void newVersion(CommandSender sender, String currentVersion,
|
public static void newVersion(CommandSender sender, String currentVersion,
|
||||||
String newVersion) {
|
String newVersion) {
|
||||||
sender.sendMessage(new String[] {
|
sender.sendMessage(new String[] {
|
||||||
ChatColor.YELLOW + "Found new version of KCauldron: "
|
ChatColor.YELLOW + "Found new version of KCauldron: "
|
||||||
+ newVersion,
|
+ newVersion,
|
||||||
ChatColor.YELLOW + "Current is " + currentVersion,
|
ChatColor.YELLOW + "Current is " + currentVersion,
|
||||||
ChatColor.YELLOW + "Type '" + ChatColor.BLUE + "/kc update"
|
ChatColor.YELLOW + "Type '" + ChatColor.BLUE + "/kc update"
|
||||||
+ ChatColor.YELLOW + "' to update" });
|
+ ChatColor.YELLOW + "' to update" });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error(Throwable t) {
|
public void error(Throwable t) {
|
||||||
CommandSender sender = mSender.get();
|
CommandSender sender = mSender.get();
|
||||||
if (sender != null) {
|
if (sender != null) {
|
||||||
sender.sendMessage(ChatColor.RED
|
sender.sendMessage(ChatColor.RED
|
||||||
+ "Error ocurred durring version check, see details in server log");
|
+ "Error ocurred durring version check, see details in server log");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,23 +14,23 @@ public class DefaultUpdateCallback implements IVersionCheckCallback {
|
|||||||
public static DefaultUpdateCallback INSTANCE;
|
public static DefaultUpdateCallback INSTANCE;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
INSTANCE = new DefaultUpdateCallback();
|
INSTANCE = new DefaultUpdateCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (mHasUpdate && hasPermission(player)) {
|
if (mHasUpdate && hasPermission(player)) {
|
||||||
sendUpdate(player);
|
sendUpdate(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasPermission(CommandSender player) {
|
private boolean hasPermission(CommandSender player) {
|
||||||
return player.hasPermission(KCauldronCommand.UPDATE);
|
return player.hasPermission(KCauldronCommand.UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendUpdate(CommandSender player) {
|
private void sendUpdate(CommandSender player) {
|
||||||
CommandSenderUpdateCallback.newVersion(player, mCurrentVersion,
|
CommandSenderUpdateCallback.newVersion(player, mCurrentVersion,
|
||||||
mNewVersion);
|
mNewVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean mHasUpdate;
|
private boolean mHasUpdate;
|
||||||
@ -42,31 +42,31 @@ public class DefaultUpdateCallback implements IVersionCheckCallback {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void upToDate() {
|
public void upToDate() {
|
||||||
mHasUpdate = false;
|
mHasUpdate = false;
|
||||||
mCurrentVersion = KCauldron.getCurrentVersion();
|
mCurrentVersion = KCauldron.getCurrentVersion();
|
||||||
mNewVersion = null;
|
mNewVersion = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void newVersion(String newVersion) {
|
public void newVersion(String newVersion) {
|
||||||
mCurrentVersion = KCauldron.getCurrentVersion();
|
mCurrentVersion = KCauldron.getCurrentVersion();
|
||||||
mNewVersion = newVersion;
|
mNewVersion = newVersion;
|
||||||
if (!mHasUpdate) {
|
if (!mHasUpdate) {
|
||||||
Bukkit.getConsoleSender().sendMessage(
|
Bukkit.getConsoleSender().sendMessage(
|
||||||
"New version of KCauldron avaiable: " + newVersion);
|
"New version of KCauldron avaiable: " + newVersion);
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if (hasPermission(player)) {
|
if (hasPermission(player)) {
|
||||||
sendUpdate(player);
|
sendUpdate(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mHasUpdate = true;
|
mHasUpdate = true;
|
||||||
if (MinecraftServer.kcauldronConfig.updatecheckerAutoinstall.getValue()
|
if (MinecraftServer.kcauldronConfig.updatecheckerAutoinstall.getValue()
|
||||||
&& !mNewVersion.equals(KCauldron.sNewServerVersion)
|
&& !mNewVersion.equals(KCauldron.sNewServerVersion)
|
||||||
&& !KCauldron.sUpdateInProgress) {
|
&& !KCauldron.sUpdateInProgress) {
|
||||||
Bukkit.getConsoleSender().sendMessage("Triggering auto update");
|
Bukkit.getConsoleSender().sendMessage("Triggering auto update");
|
||||||
KCauldronUpdater.initUpdate(Bukkit.getConsoleSender(), newVersion);
|
KCauldronUpdater.initUpdate(Bukkit.getConsoleSender(), newVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,56 +27,56 @@ import com.google.common.base.Joiner;
|
|||||||
|
|
||||||
public class KCauldronUpdater implements Runnable, IVersionCheckCallback {
|
public class KCauldronUpdater implements Runnable, IVersionCheckCallback {
|
||||||
private static final class LatestVersionCallback extends
|
private static final class LatestVersionCallback extends
|
||||||
CommandSenderUpdateCallback {
|
CommandSenderUpdateCallback {
|
||||||
public LatestVersionCallback(CommandSender sender) {
|
public LatestVersionCallback(CommandSender sender) {
|
||||||
super(sender);
|
super(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void newVersion(String newVersion) {
|
public void newVersion(String newVersion) {
|
||||||
startUpdate(getSender(), newVersion);
|
startUpdate(getSender(), newVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void upToDate() {
|
public void upToDate() {
|
||||||
KCauldron.sUpdateInProgress = false;
|
KCauldron.sUpdateInProgress = false;
|
||||||
CommandSender sender = getSender();
|
CommandSender sender = getSender();
|
||||||
if (sender != null) {
|
if (sender != null) {
|
||||||
sender.sendMessage(ChatColor.DARK_PURPLE + "Current version ("
|
sender.sendMessage(ChatColor.DARK_PURPLE + "Current version ("
|
||||||
+ KCauldron.getCurrentVersion() + ") is up to date");
|
+ KCauldron.getCurrentVersion() + ") is up to date");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error(Throwable t) {
|
public void error(Throwable t) {
|
||||||
super.error(t);
|
super.error(t);
|
||||||
KCauldron.sUpdateInProgress = false;
|
KCauldron.sUpdateInProgress = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initUpdate(CommandSender sender, String version) {
|
public static void initUpdate(CommandSender sender, String version) {
|
||||||
if (KCauldron.sUpdateInProgress) {
|
if (KCauldron.sUpdateInProgress) {
|
||||||
sender.sendMessage(ChatColor.RED
|
sender.sendMessage(ChatColor.RED
|
||||||
+ "Update stopped: another update in progress");
|
+ "Update stopped: another update in progress");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
KCauldron.sUpdateInProgress = true;
|
KCauldron.sUpdateInProgress = true;
|
||||||
if (version == null) {
|
if (version == null) {
|
||||||
sender.sendMessage(ChatColor.DARK_PURPLE
|
sender.sendMessage(ChatColor.DARK_PURPLE
|
||||||
+ "Fetching latest version...");
|
+ "Fetching latest version...");
|
||||||
KVersionRetriever.startServer(new LatestVersionCallback(sender),
|
KVersionRetriever.startServer(new LatestVersionCallback(sender),
|
||||||
false);
|
false);
|
||||||
} else {
|
} else {
|
||||||
startUpdate(sender, version);
|
startUpdate(sender, version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void startUpdate(CommandSender sender, String version) {
|
private static void startUpdate(CommandSender sender, String version) {
|
||||||
if (sender != null) {
|
if (sender != null) {
|
||||||
sender.sendMessage(ChatColor.DARK_PURPLE + "Starting update to "
|
sender.sendMessage(ChatColor.DARK_PURPLE + "Starting update to "
|
||||||
+ version + "...");
|
+ version + "...");
|
||||||
}
|
}
|
||||||
new KCauldronUpdater(sender, version);
|
new KCauldronUpdater(sender, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final CommandSender mSender;
|
private final CommandSender mSender;
|
||||||
@ -84,21 +84,21 @@ public class KCauldronUpdater implements Runnable, IVersionCheckCallback {
|
|||||||
private final Thread mThread;
|
private final Thread mThread;
|
||||||
|
|
||||||
public KCauldronUpdater(CommandSender sender, String version) {
|
public KCauldronUpdater(CommandSender sender, String version) {
|
||||||
mSender = sender;
|
mSender = sender;
|
||||||
mVersion = version;
|
mVersion = version;
|
||||||
mThread = new Thread(this);
|
mThread = new Thread(this);
|
||||||
mThread.setName("KCauldron updater");
|
mThread.setName("KCauldron updater");
|
||||||
mThread.setPriority(Thread.MIN_PRIORITY);
|
mThread.setPriority(Thread.MIN_PRIORITY);
|
||||||
mThread.start();
|
mThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!MinecraftServer.kcauldronConfig.updatecheckerQuite.getValue()) {
|
if (!MinecraftServer.kcauldronConfig.updatecheckerQuite.getValue()) {
|
||||||
mSender.sendMessage(ChatColor.DARK_PURPLE
|
mSender.sendMessage(ChatColor.DARK_PURPLE
|
||||||
+ "Retrieving latest KBootstrap version...");
|
+ "Retrieving latest KBootstrap version...");
|
||||||
}
|
}
|
||||||
new KVersionRetriever(this, false, false, "pw.prok", "KBootstrap");
|
new KVersionRetriever(this, false, false, "pw.prok", "KBootstrap");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -108,99 +108,99 @@ public class KCauldronUpdater implements Runnable, IVersionCheckCallback {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void newVersion(String kbootstrapVersion) {
|
public void newVersion(String kbootstrapVersion) {
|
||||||
boolean quite = MinecraftServer.kcauldronConfig.updatecheckerQuite
|
boolean quite = MinecraftServer.kcauldronConfig.updatecheckerQuite
|
||||||
.getValue();
|
.getValue();
|
||||||
try {
|
try {
|
||||||
if (!quite) {
|
if (!quite) {
|
||||||
mSender.sendMessage(ChatColor.DARK_PURPLE
|
mSender.sendMessage(ChatColor.DARK_PURPLE
|
||||||
+ "Downloading KBootstrap " + kbootstrapVersion + "...");
|
+ "Downloading KBootstrap " + kbootstrapVersion + "...");
|
||||||
}
|
}
|
||||||
File kbootstrap = File.createTempFile("kbootstrap",
|
File kbootstrap = File.createTempFile("kbootstrap",
|
||||||
String.valueOf(System.currentTimeMillis()));
|
String.valueOf(System.currentTimeMillis()));
|
||||||
download(
|
download(
|
||||||
"https://api.prok.pw/repo/blob/pw.prok/KBootstrap/latest/app",
|
"https://api.prok.pw/repo/blob/pw.prok/KBootstrap/latest/app",
|
||||||
kbootstrap);
|
kbootstrap);
|
||||||
if (!quite) {
|
if (!quite) {
|
||||||
mSender.sendMessage(ChatColor.DARK_PURPLE
|
mSender.sendMessage(ChatColor.DARK_PURPLE
|
||||||
+ "Installing KCauldron " + mVersion
|
+ "Installing KCauldron " + mVersion
|
||||||
+ " via KBootstrap " + kbootstrapVersion + "...");
|
+ " via KBootstrap " + kbootstrapVersion + "...");
|
||||||
}
|
}
|
||||||
|
|
||||||
String javahome = System.getProperty("java.home");
|
String javahome = System.getProperty("java.home");
|
||||||
String javapath = javahome + "/bin/java";
|
String javapath = javahome + "/bin/java";
|
||||||
|
|
||||||
List<String> command = new ArrayList<String>();
|
List<String> command = new ArrayList<String>();
|
||||||
command.add(javapath);
|
command.add(javapath);
|
||||||
command.add("-jar");
|
command.add("-jar");
|
||||||
command.add(kbootstrap.getCanonicalPath());
|
command.add(kbootstrap.getCanonicalPath());
|
||||||
command.add("--serverDir");
|
command.add("--serverDir");
|
||||||
command.add(KCauldron.getServerHome().getCanonicalPath());
|
command.add(KCauldron.getServerHome().getCanonicalPath());
|
||||||
command.add("--installKCauldron");
|
command.add("--installKCauldron");
|
||||||
command.add(String.format("%s:%s:%s", KCauldron.getGroup(), KCauldron.getChannel(), mVersion));
|
command.add(String.format("%s:%s:%s", KCauldron.getGroup(), KCauldron.getChannel(), mVersion));
|
||||||
final String[] symlinks = MinecraftServer.kcauldronConfig.updatecheckerSymlinks
|
final String[] symlinks = MinecraftServer.kcauldronConfig.updatecheckerSymlinks
|
||||||
.getValue().trim().split(File.pathSeparator);
|
.getValue().trim().split(File.pathSeparator);
|
||||||
for (String symlink : symlinks) {
|
for (String symlink : symlinks) {
|
||||||
command.add("--serverSymlinks");
|
command.add("--serverSymlinks");
|
||||||
command.add(symlink);
|
command.add(symlink);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getConsoleSender().sendMessage(
|
Bukkit.getConsoleSender().sendMessage(
|
||||||
"Starting command: " + Joiner.on(' ').join(command));
|
"Starting command: " + Joiner.on(' ').join(command));
|
||||||
|
|
||||||
ProcessBuilder builder = new ProcessBuilder(command);
|
ProcessBuilder builder = new ProcessBuilder(command);
|
||||||
builder.environment().put("JAVA_HOME", javahome);
|
builder.environment().put("JAVA_HOME", javahome);
|
||||||
switch (builder.start().waitFor()) {
|
switch (builder.start().waitFor()) {
|
||||||
case 0:
|
case 0:
|
||||||
mSender.sendMessage(ChatColor.GREEN + "KCauldron " + mVersion
|
mSender.sendMessage(ChatColor.GREEN + "KCauldron " + mVersion
|
||||||
+ " installed");
|
+ " installed");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mSender.sendMessage(ChatColor.RED
|
mSender.sendMessage(ChatColor.RED
|
||||||
+ "Failed to install KCauldron " + mVersion);
|
+ "Failed to install KCauldron " + mVersion);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (!quite) {
|
if (!quite) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (mSender != null) {
|
if (mSender != null) {
|
||||||
mSender.sendMessage(ChatColor.RED + "Failed update to "
|
mSender.sendMessage(ChatColor.RED + "Failed update to "
|
||||||
+ mVersion);
|
+ mVersion);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
KCauldron.sUpdateInProgress = false;
|
KCauldron.sUpdateInProgress = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error(Throwable t) {
|
public void error(Throwable t) {
|
||||||
KCauldron.sUpdateInProgress = false;
|
KCauldron.sUpdateInProgress = false;
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void download(String url, File destination)
|
private static void download(String url, File destination)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
HttpUriRequest request = RequestBuilder
|
HttpUriRequest request = RequestBuilder
|
||||||
.get()
|
.get()
|
||||||
.setUri(url)
|
.setUri(url)
|
||||||
.addParameter("hostname",
|
.addParameter("hostname",
|
||||||
MinecraftServer.getServer().getHostname())
|
MinecraftServer.getServer().getHostname())
|
||||||
.addParameter("port",
|
.addParameter("port",
|
||||||
String.valueOf(MinecraftServer.getServer().getPort()))
|
String.valueOf(MinecraftServer.getServer().getPort()))
|
||||||
.build();
|
.build();
|
||||||
CloseableHttpClient client = HttpClientBuilder.create()
|
CloseableHttpClient client = HttpClientBuilder.create()
|
||||||
.setRedirectStrategy(new LaxRedirectStrategy())
|
.setRedirectStrategy(new LaxRedirectStrategy())
|
||||||
.setUserAgent("KCauldron Updater").build();
|
.setUserAgent("KCauldron Updater").build();
|
||||||
|
|
||||||
HttpResponse response = client.execute(request);
|
HttpResponse response = client.execute(request);
|
||||||
if (response.getStatusLine().getStatusCode() != 200) {
|
if (response.getStatusLine().getStatusCode() != 200) {
|
||||||
client.close();
|
client.close();
|
||||||
throw new IllegalStateException("Could not download " + url);
|
throw new IllegalStateException("Could not download " + url);
|
||||||
}
|
}
|
||||||
InputStream is = response.getEntity().getContent();
|
InputStream is = response.getEntity().getContent();
|
||||||
OutputStream os = new FileOutputStream(destination);
|
OutputStream os = new FileOutputStream(destination);
|
||||||
IOUtils.copy(is, os);
|
IOUtils.copy(is, os);
|
||||||
is.close();
|
is.close();
|
||||||
os.close();
|
os.close();
|
||||||
client.close();
|
client.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,22 +22,22 @@ public class KVersionRetriever implements Runnable, UncaughtExceptionHandler {
|
|||||||
private static MinecraftServer sServer;
|
private static MinecraftServer sServer;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
DEBUG = false;
|
DEBUG = false;
|
||||||
sLogger = KLog.get(KVersionRetriever.class.getSimpleName());
|
sLogger = KLog.get(KVersionRetriever.class.getSimpleName());
|
||||||
|
|
||||||
sParser = new JSONParser();
|
sParser = new JSONParser();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init(MinecraftServer server) {
|
public static void init(MinecraftServer server) {
|
||||||
sServer = server;
|
sServer = server;
|
||||||
if (MinecraftServer.kcauldronConfig.updatecheckerEnable.getValue()) {
|
if (MinecraftServer.kcauldronConfig.updatecheckerEnable.getValue()) {
|
||||||
startServer(DefaultUpdateCallback.INSTANCE, true);
|
startServer(DefaultUpdateCallback.INSTANCE, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void startServer(IVersionCheckCallback callback, boolean loop) {
|
public static void startServer(IVersionCheckCallback callback, boolean loop) {
|
||||||
new KVersionRetriever(callback, loop, true, KCauldron.getGroup(),
|
new KVersionRetriever(callback, loop, true, KCauldron.getGroup(),
|
||||||
KCauldron.getChannel());
|
KCauldron.getChannel());
|
||||||
}
|
}
|
||||||
|
|
||||||
private final IVersionCheckCallback mCallback;
|
private final IVersionCheckCallback mCallback;
|
||||||
@ -48,80 +48,80 @@ public class KVersionRetriever implements Runnable, UncaughtExceptionHandler {
|
|||||||
private final boolean mUpToDateSupport;
|
private final boolean mUpToDateSupport;
|
||||||
|
|
||||||
public KVersionRetriever(IVersionCheckCallback callback, boolean loop,
|
public KVersionRetriever(IVersionCheckCallback callback, boolean loop,
|
||||||
boolean upToDateSupport, String group, String name) {
|
boolean upToDateSupport, String group, String name) {
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
sLogger.info("Created new version retrivier");
|
sLogger.info("Created new version retrivier");
|
||||||
mCallback = callback;
|
mCallback = callback;
|
||||||
mLoop = loop;
|
mLoop = loop;
|
||||||
mUpToDateSupport = upToDateSupport;
|
mUpToDateSupport = upToDateSupport;
|
||||||
mGroup = group;
|
mGroup = group;
|
||||||
mName = name;
|
mName = name;
|
||||||
mThread = new Thread(this);
|
mThread = new Thread(this);
|
||||||
mThread.setName("KCauldron version retrievier");
|
mThread.setName("KCauldron version retrievier");
|
||||||
mThread.setPriority(Thread.MIN_PRIORITY);
|
mThread.setPriority(Thread.MIN_PRIORITY);
|
||||||
mThread.setDaemon(true);
|
mThread.setDaemon(true);
|
||||||
mThread.setUncaughtExceptionHandler(this);
|
mThread.setUncaughtExceptionHandler(this);
|
||||||
mThread.start();
|
mThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while (!mThread.isInterrupted()) {
|
while (!mThread.isInterrupted()) {
|
||||||
check();
|
check();
|
||||||
if (!mLoop)
|
if (!mLoop)
|
||||||
break;
|
break;
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000 * 60 * 10);// Sleep ten minutes
|
Thread.sleep(1000 * 60 * 10);// Sleep ten minutes
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void check() {
|
private void check() {
|
||||||
try {
|
try {
|
||||||
HttpUriRequest request = RequestBuilder
|
HttpUriRequest request = RequestBuilder
|
||||||
.get()
|
.get()
|
||||||
.setUri("https://api.prok.pw/repo/version/" + mGroup + "/"
|
.setUri("https://api.prok.pw/repo/version/" + mGroup + "/"
|
||||||
+ mName)
|
+ mName)
|
||||||
.addParameter("hostname", sServer.getHostname())
|
.addParameter("hostname", sServer.getHostname())
|
||||||
.addParameter("port", "" + sServer.getPort()).build();
|
.addParameter("port", "" + sServer.getPort()).build();
|
||||||
HttpResponse response = HttpClientBuilder.create()
|
HttpResponse response = HttpClientBuilder.create()
|
||||||
.setUserAgent("KCauldron Version Retriever")
|
.setUserAgent("KCauldron Version Retriever")
|
||||||
.setRedirectStrategy(new LaxRedirectStrategy()).build()
|
.setRedirectStrategy(new LaxRedirectStrategy()).build()
|
||||||
.execute(request);
|
.execute(request);
|
||||||
if (response.getStatusLine().getStatusCode() != 200) {
|
if (response.getStatusLine().getStatusCode() != 200) {
|
||||||
uncaughtException(mThread, new IllegalStateException(
|
uncaughtException(mThread, new IllegalStateException(
|
||||||
"Status code isn't OK"));
|
"Status code isn't OK"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSONObject json = (JSONObject) sParser.parse(new InputStreamReader(
|
JSONObject json = (JSONObject) sParser.parse(new InputStreamReader(
|
||||||
response.getEntity().getContent()));
|
response.getEntity().getContent()));
|
||||||
String version = (String) json.get("version");
|
String version = (String) json.get("version");
|
||||||
if (!mUpToDateSupport || KCauldron.getCurrentVersion() == null
|
if (!mUpToDateSupport || KCauldron.getCurrentVersion() == null
|
||||||
|| !version.equals(KCauldron.getCurrentVersion())) {
|
|| !version.equals(KCauldron.getCurrentVersion())) {
|
||||||
mCallback.newVersion(version);
|
mCallback.newVersion(version);
|
||||||
} else {
|
} else {
|
||||||
mCallback.upToDate();
|
mCallback.upToDate();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
uncaughtException(null, e);
|
uncaughtException(null, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void uncaughtException(Thread t, Throwable e) {
|
public void uncaughtException(Thread t, Throwable e) {
|
||||||
sLogger.warning(e, "Error occured during retriving version");
|
sLogger.warning(e, "Error occured during retriving version");
|
||||||
if (mCallback != null) {
|
if (mCallback != null) {
|
||||||
mCallback.error(e);
|
mCallback.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IVersionCheckCallback {
|
public interface IVersionCheckCallback {
|
||||||
void upToDate();
|
void upToDate();
|
||||||
|
|
||||||
void newVersion(String newVersion);
|
void newVersion(String newVersion);
|
||||||
|
|
||||||
void error(Throwable t);
|
void error(Throwable t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,33 +7,33 @@ public class LongHashMapTrove<T> extends LongHashMap {
|
|||||||
private final TLongObjectMap<T> mMap;
|
private final TLongObjectMap<T> mMap;
|
||||||
|
|
||||||
public LongHashMapTrove(TLongObjectMap<T> map) {
|
public LongHashMapTrove(TLongObjectMap<T> map) {
|
||||||
mMap = map;
|
mMap = map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void add(long key, Object value) {
|
public void add(long key, Object value) {
|
||||||
mMap.put(key, (T) value);
|
mMap.put(key, (T) value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNumHashElements() {
|
public int getNumHashElements() {
|
||||||
return mMap.size();
|
return mMap.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValueByKey(long key) {
|
public Object getValueByKey(long key) {
|
||||||
return mMap.get(key);
|
return mMap.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsItem(long key) {
|
public boolean containsItem(long key) {
|
||||||
return mMap.containsKey(key);
|
return mMap.containsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object remove(long key) {
|
public Object remove(long key) {
|
||||||
return mMap.remove(key);
|
return mMap.remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,30 +7,30 @@ import org.bukkit.craftbukkit.util.LongHash;
|
|||||||
|
|
||||||
public class VanillaChunkHashMap extends LongHashMapTrove<Chunk> {
|
public class VanillaChunkHashMap extends LongHashMapTrove<Chunk> {
|
||||||
public VanillaChunkHashMap(TLongObjectMap<Chunk> map) {
|
public VanillaChunkHashMap(TLongObjectMap<Chunk> map) {
|
||||||
super(map);
|
super(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long V2B(long key) {
|
private static long V2B(long key) {
|
||||||
return LongHash.toLong((int) (key & 0xFFFFFFFFL), (int) (key >>> 32));
|
return LongHash.toLong((int) (key & 0xFFFFFFFFL), (int) (key >>> 32));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(long key, Object value) {
|
public void add(long key, Object value) {
|
||||||
super.add(V2B(key), value);
|
super.add(V2B(key), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsItem(long key) {
|
public boolean containsItem(long key) {
|
||||||
return super.containsItem(V2B(key));
|
return super.containsItem(V2B(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValueByKey(long key) {
|
public Object getValueByKey(long key) {
|
||||||
return super.getValueByKey(V2B(key));
|
return super.getValueByKey(V2B(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object remove(long key) {
|
public Object remove(long key) {
|
||||||
return super.remove(V2B(key));
|
return super.remove(V2B(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
fmlbuild.major.number=7
|
fmlbuild.major.number=7
|
||||||
fmlbuild.minor.number=99
|
fmlbuild.minor.number=99
|
||||||
fmlbuild.revision.number=4
|
fmlbuild.revision.number=4
|
||||||
fmlbuild.build.number=1448
|
fmlbuild.build.number=1481
|
||||||
fmlbuild.mcversion=1.7.10
|
fmlbuild.mcversion=1.7.10
|
||||||
fmlbuild.mcpversion=9.05
|
fmlbuild.mcpversion=9.05
|
||||||
|
Loading…
Reference in New Issue
Block a user