1
0
Fork 0

增加配置文件自定义路径功能

kcx-1614
聪聪 2017-07-18 18:17:26 +08:00
parent e5f30f532d
commit d06c424b1f
6 changed files with 169 additions and 110 deletions

View File

@ -1,6 +1,18 @@
--- ../src-base/minecraft/net/minecraft/network/NetworkSystem.java
+++ ../src-work/minecraft/net/minecraft/network/NetworkSystem.java
@@ -139,6 +139,14 @@
@@ -129,7 +129,10 @@
while (iterator.hasNext())
{
ChannelFuture channelfuture = (ChannelFuture)iterator.next();
- channelfuture.channel().close().syncUninterruptibly();
+ ChannelFuture close=channelfuture.channel().close();
+// if(channelfuture.channel().isOpen()){
+// close.syncUninterruptibly();
+// }
}
}
@@ -139,6 +142,14 @@
synchronized (this.networkManagers)
{

View File

@ -1,25 +1,75 @@
--- ../src-base/minecraft/net/minecraft/server/MinecraftServer.java
+++ ../src-work/minecraft/net/minecraft/server/MinecraftServer.java
@@ -16,6 +16,7 @@
import io.netty.buffer.ByteBufOutputStream;
import io.netty.buffer.Unpooled;
import io.netty.handler.codec.base64.Base64;
+
@@ -1,21 +1,5 @@
package net.minecraft.server;
-import com.google.common.base.Charsets;
-import com.mojang.authlib.GameProfile;
-import com.mojang.authlib.GameProfileRepository;
-import com.mojang.authlib.minecraft.MinecraftSessionService;
-import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
-
-import cpw.mods.fml.common.FMLCommonHandler;
-import cpw.mods.fml.common.Loader;
-import cpw.mods.fml.common.LoaderState;
-import cpw.mods.fml.common.StartupQuery;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.ByteBufOutputStream;
-import io.netty.buffer.Unpooled;
-import io.netty.handler.codec.base64.Base64;
import java.awt.GraphicsEnvironment;
import java.awt.image.BufferedImage;
import java.io.File;
@@ -33,7 +34,10 @@
@@ -33,10 +17,45 @@
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.Callable;
+import java.util.logging.Level;
+
import javax.imageio.ImageIO;
-import net.minecraft.command.CommandBase;
+
import net.minecraft.command.CommandBase;
+import org.apache.commons.lang3.Validate;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.bukkit.World.Environment;
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
+import org.bukkit.craftbukkit.block.CraftBlock;
+// Cauldron end
+import org.bukkit.craftbukkit.util.Waitable;
+import org.bukkit.event.server.RemoteServerCommandEvent;
+import org.bukkit.event.world.WorldSaveEvent;
+
+import com.google.common.base.Charsets;
+import com.mojang.authlib.GameProfile;
+import com.mojang.authlib.GameProfileRepository;
+import com.mojang.authlib.minecraft.MinecraftSessionService;
+import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
+
+import cpw.mods.fml.common.FMLCommonHandler;
+import cpw.mods.fml.common.Loader;
+import cpw.mods.fml.common.LoaderState;
+import cpw.mods.fml.common.StartupQuery;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufOutputStream;
+import io.netty.buffer.Unpooled;
+import io.netty.handler.codec.base64.Base64;
+import jline.console.ConsoleReader;
+import joptsimple.OptionParser;
+import joptsimple.OptionSet;
+import kcauldron.KCauldronConfig;
import net.minecraft.command.ICommandManager;
import net.minecraft.command.ICommandSender;
@@ -50,6 +54,7 @@
+import net.minecraft.command.ServerCommand;
import net.minecraft.command.ServerCommandManager;
import net.minecraft.crash.CrashReport;
import net.minecraft.entity.player.EntityPlayer;
@@ -50,9 +69,11 @@
import net.minecraft.profiler.PlayerUsageSnooper;
import net.minecraft.profiler.Profiler;
import net.minecraft.server.dedicated.DedicatedServer;
@ -27,57 +77,37 @@
import net.minecraft.server.gui.IUpdatePlayerListBox;
import net.minecraft.server.management.PlayerProfileCache;
import net.minecraft.server.management.ServerConfigurationManager;
@@ -72,6 +77,7 @@
import net.minecraft.world.storage.ISaveFormat;
import net.minecraft.world.storage.ISaveHandler;
import net.minecraft.world.storage.WorldInfo;
+
import org.apache.commons.lang3.Validate;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -80,18 +86,55 @@
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent;
+
+// CraftBukkit start
+import java.io.IOException;
+
+import jline.console.ConsoleReader;
+import joptsimple.OptionSet;
+import net.minecraft.world.chunk.storage.AnvilSaveHandler;
+
+import org.bukkit.World.Environment;
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
+import org.bukkit.craftbukkit.util.Waitable;
+import org.bukkit.event.server.RemoteServerCommandEvent;
+import org.bukkit.event.world.WorldSaveEvent;
+
+// CraftBukkit end
+// Cauldron start
+import java.util.Map;
+import java.lang.reflect.Constructor;
+
+import joptsimple.OptionParser;
+import kcauldron.KCauldronConfig;
+import cpw.mods.fml.common.asm.transformers.SideTransformer;
+import net.minecraft.command.ServerCommand;
+import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.IChatComponent;
@@ -63,19 +84,20 @@
import net.minecraft.world.MinecraftException;
import net.minecraft.world.World;
import net.minecraft.world.WorldManager;
+import net.minecraft.world.WorldProvider;
import net.minecraft.world.WorldServer;
import net.minecraft.world.WorldServerMulti;
import net.minecraft.world.WorldSettings;
import net.minecraft.world.WorldType;
import net.minecraft.world.chunk.storage.AnvilSaveConverter;
+import net.minecraft.world.chunk.storage.AnvilSaveHandler;
import net.minecraft.world.demo.DemoWorldServer;
import net.minecraft.world.storage.ISaveFormat;
-import net.minecraft.world.storage.ISaveHandler;
import net.minecraft.world.storage.WorldInfo;
-import org.apache.commons.lang3.Validate;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
+import net.minecraftforge.cauldron.CauldronUtils;
+import net.minecraftforge.cauldron.configuration.CauldronConfig;
+import net.minecraftforge.cauldron.configuration.EntityConfig;
+import net.minecraftforge.cauldron.configuration.TileEntityConfig;
+import net.minecraftforge.common.util.EnumHelper;
+
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.block.CraftBlock;
+// Cauldron end
+
public abstract class MinecraftServer implements ICommandSender, Runnable, IPlayerUsage
{
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent;
@@ -85,13 +107,13 @@
private static final Logger logger = LogManager.getLogger();
public static final File field_152367_a = new File("usercache.json");
private static MinecraftServer mcServer;
@ -94,7 +124,7 @@
private final ServerStatusResponse field_147147_p = new ServerStatusResponse();
private final Random field_147146_q = new Random();
@SideOnly(Side.SERVER)
@@ -135,8 +178,41 @@
@@ -135,8 +157,42 @@
private long field_147142_T = 0L;
private final GameProfileRepository field_152365_W;
private final PlayerProfileCache field_152366_X;
@ -124,6 +154,7 @@
+ public static YamlConfiguration commandsConfiguration;
+ public static File configFile;
+ public static File commandFile;
+ public static File serverConfigDir=new File(".");
+ public static double currentTps = 0;
+ public static boolean useJline = true;
+ public static boolean useConsole = true;
@ -136,7 +167,7 @@
public MinecraftServer(File p_i45281_1_, Proxy p_i45281_2_)
{
this.field_152366_X = new PlayerProfileCache(this, field_152367_a);
@@ -149,10 +225,72 @@
@@ -149,10 +205,72 @@
this.field_152364_T = new YggdrasilAuthenticationService(p_i45281_2_, UUID.randomUUID().toString());
this.field_147143_S = this.field_152364_T.createMinecraftSessionService();
this.field_152365_W = this.field_152364_T.createProfileRepository();
@ -151,7 +182,7 @@
- protected abstract boolean startServer() throws IOException;
+ public MinecraftServer(OptionSet options, Proxy proxy) // CraftBukkit - signature file -> OptionSet
+ {
+ this.field_152366_X = new PlayerProfileCache(this, field_152367_a);
+ this.field_152366_X = new PlayerProfileCache(this, new File(MinecraftServer.serverConfigDir,field_152367_a.getName()));
+ mcServer = this;
+ this.serverProxy = proxy;
+ // this.anvilFile = p_i45281_1_; // CraftBukkit
@ -210,7 +241,7 @@
protected void convertMapIfNeeded(String p_71237_1_)
{
if (this.getActiveAnvilConverter().isOldMapFormat(p_71237_1_))
@@ -172,6 +310,7 @@
@@ -172,6 +290,7 @@
MinecraftServer.logger.info("Converting... " + p_73718_1_ + "%");
}
}
@ -218,7 +249,7 @@
@SideOnly(Side.CLIENT)
public void resetProgressAndMessage(String p_73721_1_) {}
@SideOnly(Side.CLIENT)
@@ -195,10 +334,17 @@
@@ -195,10 +314,17 @@
protected void loadAllWorlds(String p_71247_1_, String p_71247_2_, long p_71247_3_, WorldType p_71247_5_, String p_71247_6_)
{
@ -238,7 +269,7 @@
WorldSettings worldsettings;
if (worldinfo == null)
@@ -215,11 +361,79 @@
@@ -215,11 +341,79 @@
{
worldsettings.enableBonusChest();
}
@ -321,7 +352,7 @@
world.addWorldAccess(new WorldManager(this, world));
if (!this.isSinglePlayer())
@@ -227,12 +441,14 @@
@@ -227,12 +421,14 @@
world.getWorldInfo().setGameType(this.getGameType());
}
@ -339,7 +370,7 @@
}
protected void initialWorldChunkLoad()
@@ -244,9 +460,12 @@
@@ -244,9 +440,12 @@
int i = 0;
this.setUserMessage("menu.generatingTerrain");
byte b0 = 0;
@ -352,7 +383,7 @@
long j = getSystemTimeMillis();
for (int k = -192; k <= 192 && this.isServerRunning(); k += 16)
@@ -265,7 +484,8 @@
@@ -265,7 +464,8 @@
worldserver.theChunkProviderServer.loadChunk(chunkcoordinates.posX + k >> 4, chunkcoordinates.posZ + l >> 4);
}
}
@ -362,7 +393,7 @@
this.clearCurrentTask();
}
@@ -292,19 +512,17 @@
@@ -292,19 +492,17 @@
{
this.currentTask = null;
this.percentDone = 0;
@ -387,7 +418,7 @@
if (worldserver != null)
{
@@ -313,25 +531,41 @@
@@ -313,25 +511,41 @@
logger.info("Saving chunks for level \'" + worldserver.getWorldInfo().getWorldName() + "\'/" + worldserver.provider.getDimensionName());
}
@ -434,7 +465,7 @@
if (this.func_147137_ag() != null)
{
this.func_147137_ag().terminateEndpoints();
@@ -347,7 +581,14 @@
@@ -347,7 +561,14 @@
if (this.worldServers != null)
{
logger.info("Saving worlds");
@ -450,7 +481,7 @@
for (int i = 0; i < this.worldServers.length; ++i)
{
@@ -380,6 +621,13 @@
@@ -380,6 +601,13 @@
this.serverRunning = false;
}
@ -464,7 +495,7 @@
public void run()
{
try
@@ -392,45 +640,41 @@
@@ -392,45 +620,41 @@
this.field_147147_p.func_151315_a(new ChatComponentText(this.motd));
this.field_147147_p.func_151321_a(new ServerStatusResponse.MinecraftProtocolVersionIdentifier("1.7.10", 5));
this.func_147138_a(this.field_147147_p);
@ -531,7 +562,7 @@
FMLCommonHandler.instance().handleServerStopping();
FMLCommonHandler.instance().expectServerStopped(); // has to come before finalTick to avoid race conditions
}
@@ -448,6 +692,14 @@
@@ -448,6 +672,14 @@
catch (Throwable throwable1)
{
logger.error("Encountered an unexpected exception", throwable1);
@ -546,7 +577,7 @@
CrashReport crashreport = null;
if (throwable1 instanceof ReportedException)
@@ -477,6 +729,7 @@
@@ -477,6 +709,7 @@
{
try
{
@ -554,7 +585,7 @@
this.stopServer();
this.serverStopped = true;
}
@@ -486,6 +739,16 @@
@@ -486,6 +719,16 @@
}
finally
{
@ -571,7 +602,7 @@
FMLCommonHandler.instance().handleServerStopped();
this.serverStopped = true;
this.systemExitNow();
@@ -532,8 +795,11 @@
@@ -532,8 +775,11 @@
public void tick()
{
@ -583,7 +614,7 @@
++this.tickCounter;
if (this.startProfiling)
@@ -562,12 +828,21 @@
@@ -562,12 +808,21 @@
this.field_147147_p.func_151318_b().func_151330_a(agameprofile);
}
@ -607,7 +638,7 @@
}
this.theProfiler.startSection("tallying");
@@ -575,25 +850,57 @@
@@ -575,25 +830,57 @@
this.theProfiler.endSection();
this.theProfiler.startSection("snooper");
@ -667,7 +698,7 @@
int i;
Integer[] ids = DimensionManager.getIDs(this.tickCounter % 200 == 0);
@@ -602,19 +909,21 @@
@@ -602,19 +889,21 @@
int id = ids[x];
long j = System.nanoTime();
@ -692,7 +723,7 @@
this.theProfiler.startSection("tick");
FMLCommonHandler.instance().onPreWorldTick(worldserver);
@@ -622,22 +931,46 @@
@@ -622,22 +911,46 @@
try
{
@ -741,7 +772,7 @@
worldserver.addWorldInfoToCrashReport(crashreport);
throw new ReportedException(crashreport);
}
@@ -645,10 +978,13 @@
@@ -645,10 +958,13 @@
FMLCommonHandler.instance().onPostWorldTick(worldserver);
this.theProfiler.endSection();
this.theProfiler.startSection("tracker");
@ -756,7 +787,7 @@
worldTickTimes.get(id)[this.tickCounter % 100] = System.nanoTime() - j;
}
@@ -656,15 +992,21 @@
@@ -656,15 +972,21 @@
this.theProfiler.endStartSection("dim_unloading");
DimensionManager.unloadWorlds(worldTickTimes);
this.theProfiler.endStartSection("connection");
@ -778,7 +809,7 @@
this.theProfiler.endSection();
}
@@ -699,6 +1041,13 @@
@@ -699,6 +1021,13 @@
public WorldServer worldServerForDimension(int p_71218_1_)
{
@ -792,7 +823,7 @@
WorldServer ret = DimensionManager.getWorld(p_71218_1_);
if (ret == null)
{
@@ -784,13 +1133,14 @@
@@ -784,13 +1113,14 @@
public List getPossibleCompletions(ICommandSender p_71248_1_, String p_71248_2_)
{
@ -811,7 +842,7 @@
if (list != null)
{
@@ -798,40 +1148,25 @@
@@ -798,40 +1128,25 @@
while (iterator.hasNext())
{
@ -860,7 +891,7 @@
}
public static MinecraftServer getServer()
@@ -1034,7 +1369,7 @@
@@ -1034,7 +1349,7 @@
public boolean isServerInOnlineMode()
{
@ -869,7 +900,7 @@
}
public void setOnlineMode(boolean p_71229_1_)
@@ -1124,7 +1459,7 @@
@@ -1124,7 +1439,7 @@
public NetworkSystem func_147137_ag()
{
@ -878,7 +909,7 @@
}
@SideOnly(Side.CLIENT)
@@ -1259,8 +1594,11 @@
@@ -1259,8 +1574,11 @@
{
Bootstrap.func_151354_b();
@ -890,7 +921,7 @@
boolean flag = true;
String s = null;
String s1 = ".";
@@ -1356,16 +1694,34 @@
@@ -1356,16 +1674,34 @@
{
dedicatedserver.setGuiEnabled();
}
@ -931,7 +962,7 @@
}
catch (Exception exception)
{
@@ -1400,15 +1756,70 @@
@@ -1400,15 +1736,70 @@
@SideOnly(Side.SERVER)
public String getPlugins()
{
@ -1007,7 +1038,7 @@
}
@SideOnly(Side.SERVER)
@@ -1455,9 +1866,213 @@
@@ -1455,9 +1846,220 @@
return this.serverStopped;
}
@ -1016,6 +1047,12 @@
+ {
+ acceptsAll(Arrays.asList("?", "help"), "Show the help");
+
+ acceptsAll(Arrays.asList("SCD", "ServerConfigDir"), "server config dir")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("."))
+ .describedAs("server config dir");
+
+ acceptsAll(Arrays.asList("c", "config"), "Properties file to use")
+ .withRequiredArg()
+ .ofType(File.class)
@ -1148,6 +1185,7 @@
+ useConsole = false;
+ }
+ // Cauldron start - initialize config
+ serverConfigDir = (File) options.valueOf("ServerConfigDir");
+ configFile = (File) options.valueOf("bukkit-settings");
+ commandFile = (File)options.valueOf("commands-settings");
+ configuration = YamlConfiguration.loadConfiguration(configFile);

View File

@ -0,0 +1,19 @@
--- ../src-base/minecraft/net/minecraftforge/common/UsernameCache.java
+++ ../src-work/minecraft/net/minecraftforge/common/UsernameCache.java
@@ -24,6 +24,7 @@
import com.google.gson.JsonSyntaxException;
import cpw.mods.fml.relauncher.FMLInjectionData;
+import net.minecraft.server.MinecraftServer;
/**
* Caches player's last known usernames
@@ -39,7 +40,7 @@
private static final Charset charset = Charsets.UTF_8;
- private static final File saveFile = new File( /* The minecraft dir */(File) FMLInjectionData.data()[6], "usernamecache.json");
+ private static final File saveFile = new File( MinecraftServer.serverConfigDir, "usernamecache.json");
private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
private static final Logger log = LogManager.getLogger(UsernameCache.class);

View File

@ -2,28 +2,15 @@ package net.minecraftforge.cauldron.configuration;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.WorldServer;
import net.minecraftforge.cauldron.CauldronHooks;
import net.minecraftforge.cauldron.TileEntityCache;
import net.minecraftforge.cauldron.command.CauldronCommand;
import net.minecraftforge.common.DimensionManager;
import org.apache.commons.lang.BooleanUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.configuration.file.YamlConfiguration;
import com.google.common.base.Throwables;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.WorldServer;
public abstract class ConfigBase
{
@ -41,7 +28,7 @@ public abstract class ConfigBase
public ConfigBase(String fileName, String commandName)
{
this.configFile = new File(fileName);
this.configFile=new File(MinecraftServer.serverConfigDir,fileName);
this.config = YamlConfiguration.loadConfiguration(configFile);
this.commandName = commandName;
this.commands = new HashMap<String, Command>();

View File

@ -8,6 +8,8 @@ import org.bukkit.help.HelpTopic;
import com.google.common.base.Charsets;
import net.minecraft.server.MinecraftServer;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
@ -27,7 +29,7 @@ public class HelpYamlReader {
public HelpYamlReader(Server server) {
this.server = server;
File helpYamlFile = new File("help.yml");
File helpYamlFile = new File(MinecraftServer.serverConfigDir,"help.yml");
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("configurations/help.yml"), Charsets.UTF_8));
try {

View File

@ -1,29 +1,30 @@
package org.spigotmc;
import com.google.common.base.Throwables;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import gnu.trove.map.hash.TObjectIntHashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import com.google.common.base.Throwables;
import gnu.trove.map.hash.TObjectIntHashMap;
import net.minecraft.server.MinecraftServer;
public class SpigotConfig
{
private static final File CONFIG_FILE = new File( "spigot.yml" );
private static final File CONFIG_FILE = new File(MinecraftServer.serverConfigDir, "spigot.yml" );
private static final String HEADER = "This is the main configuration file for Spigot.\n"
+ "As you can see, there's tons to configure. Some options may impact gameplay, so use\n"
+ "with caution, and make sure you know what each option does before configuring.\n"