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