2015-06-26 22:46:47 +02:00
|
|
|
package techreborn.compat.ee3;
|
|
|
|
|
|
|
|
import com.pahimar.ee3.command.CommandSyncEnergyValues;
|
|
|
|
import com.pahimar.ee3.exchange.DynamicEnergyValueInitThread;
|
|
|
|
import com.pahimar.ee3.exchange.EnergyValueRegistry;
|
|
|
|
import com.pahimar.ee3.reference.Reference;
|
2015-11-23 15:40:30 +01:00
|
|
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
2015-06-26 22:46:47 +02:00
|
|
|
import net.minecraft.command.CommandBase;
|
|
|
|
import net.minecraft.command.ICommandSender;
|
|
|
|
import net.minecraft.util.ChatComponentText;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
public class CommandRegen extends CommandBase {
|
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
public static final String EE3_ENERGYVALUES_DIR =
|
|
|
|
FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler().getWorldDirectory()
|
|
|
|
+ File.separator + "data" + File.separator
|
|
|
|
+ Reference.LOWERCASE_MOD_ID + File.separator
|
|
|
|
+ "energyvalues";
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getCommandName() {
|
|
|
|
return "eeregen";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getRequiredPermissionLevel() {
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getCommandUsage(ICommandSender commandSender) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void processCommand(ICommandSender commandSender, String[] args) {
|
|
|
|
commandSender.addChatMessage(new ChatComponentText("Regening EMC Values..."));
|
|
|
|
File energyValuesDirectory = new File(EE3_ENERGYVALUES_DIR);
|
|
|
|
|
|
|
|
if (energyValuesDirectory.exists() && energyValuesDirectory.isDirectory()) {
|
|
|
|
File[] files = energyValuesDirectory.listFiles();
|
|
|
|
for (File f : files) {
|
|
|
|
if (f.getName().toLowerCase().contains(".gz")) {
|
|
|
|
f.delete();
|
|
|
|
commandSender.addChatMessage(new ChatComponentText("Deleted " + f.getName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
commandSender.addChatMessage(new ChatComponentText("Regening EMC Values"));
|
|
|
|
DynamicEnergyValueInitThread.initEnergyValueRegistry();
|
|
|
|
EnergyValueRegistry.getInstance().setShouldRegenNextRestart(false);
|
|
|
|
EnergyValueRegistry.getInstance().save();
|
|
|
|
commandSender.addChatMessage(new ChatComponentText("Syncing all EMC Values"));
|
|
|
|
new CommandSyncEnergyValues().processCommand(commandSender, args);
|
|
|
|
}
|
2015-06-26 22:46:47 +02:00
|
|
|
}
|