added delete player data option in backup menu

This commit is contained in:
LAX1DUDE 2022-08-23 21:21:29 -07:00
parent 17bf3bcbc4
commit ede386dd79
12 changed files with 32281 additions and 32144 deletions

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -157,6 +157,11 @@ selectWorld.backup.export=Export World Backup
selectWorld.backup.export.tooltip=Download this world as a compressed backup file
selectWorld.backup.vanilla=Convert to Vanilla
selectWorld.backup.vanilla.tooltip=Download this world as a vanilla 1.5.2 world
selectWorld.backup.clearPlayerData=Delete Player Data
selectWorld.backup.clearPlayerData.tooltip=Clears the inventories of all players except the owner
selectWorld.backup.clearPlayerData.warning1=Are you sure you want to delete all player data?
selectWorld.backup.clearPlayerData.warning2=All players in '$world$' will lose their inventories (besides $player$)
selectWorld.create.title=What do you wanna do?
selectWorld.create.create=Create New World

View file

@ -0,0 +1,40 @@
package net.lax1dude.eaglercraft.sp.ipc;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
public class IPCPacket18ClearPlayers implements IPCPacketBase {
public static final int ID = 0x18;
public String worldName = null;
public IPCPacket18ClearPlayers(String worldName) {
this.worldName = worldName;
}
public IPCPacket18ClearPlayers() {
}
@Override
public void deserialize(DataInput bin) throws IOException {
worldName = bin.readUTF();
}
@Override
public void serialize(DataOutput bin) throws IOException {
bin.writeUTF(worldName);
}
@Override
public int id() {
return ID;
}
@Override
public int size() {
return IPCPacketBase.strLen(worldName);
}
}

View file

@ -39,6 +39,7 @@ public class IPCPacketManager {
mappings.put(IPCPacket15ThrowException.ID, () -> new IPCPacket15ThrowException());
mappings.put(IPCPacket16NBTList.ID, () -> new IPCPacket16NBTList());
mappings.put(IPCPacket17ConfigureLAN.ID, () -> new IPCPacket17ConfigureLAN());
mappings.put(IPCPacket18ClearPlayers.ID, () -> new IPCPacket18ClearPlayers());
mappings.put(IPCPacketFFProcessKeepAlive.ID, () -> new IPCPacketFFProcessKeepAlive());
}

View file

@ -659,10 +659,15 @@ public class IntegratedServer {
}
break;
case IPCPacket17ConfigureLAN.ID: {
IPCPacket17ConfigureLAN pkt = (IPCPacket17ConfigureLAN)packet;
currentProcess.getConfigurationManager().configureLAN(pkt.gamemode, pkt.cheats, pkt.iceServers);
}
break;
IPCPacket17ConfigureLAN pkt = (IPCPacket17ConfigureLAN)packet;
currentProcess.getConfigurationManager().configureLAN(pkt.gamemode, pkt.cheats, pkt.iceServers);
}
break;
case IPCPacket18ClearPlayers.ID: {
SYS.VFS.deleteFiles("worlds/" + ((IPCPacket18ClearPlayers)packet).worldName + "/player");
sendIPCPacket(new IPCPacketFFProcessKeepAlive(IPCPacket18ClearPlayers.ID));
}
break;
default:
System.err.println("IPC packet type 0x" + Integer.toHexString(id) + " class '" + packet.getClass().getSimpleName() + "' was not handled");
sendTaskFailed();

View file

@ -5,6 +5,7 @@ import net.minecraft.src.GuiButton;
import net.minecraft.src.GuiCreateWorld;
import net.minecraft.src.GuiRenameWorld;
import net.minecraft.src.GuiScreen;
import net.minecraft.src.GuiYesNo;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.StringTranslate;
import net.minecraft.src.WorldInfo;
@ -17,6 +18,7 @@ public class GuiScreenBackupWorld extends GuiScreen {
private GuiButton worldDuplicate = null;
private GuiButton worldExport = null;
private GuiButton worldConvert = null;
private GuiButton worldBackup = null;
private long worldSeed;
private NBTTagCompound levelDat;
@ -31,29 +33,32 @@ public class GuiScreenBackupWorld extends GuiScreen {
public void initGui() {
StringTranslate var1 = StringTranslate.getInstance();
this.buttonList.add(worldRecreate = new GuiButton(1, this.width / 2 - 100, this.height / 5 + 40, var1.translateKey("selectWorld.backup.recreate")));
this.buttonList.add(worldDuplicate = new GuiButton(2, this.width / 2 - 100, this.height / 5 + 65, var1.translateKey("selectWorld.backup.duplicate")));
this.buttonList.add(worldExport = new GuiButton(3, this.width / 2 - 100, this.height / 5 + 115, var1.translateKey("selectWorld.backup.export")));
this.buttonList.add(worldConvert = new GuiButton(4, this.width / 2 - 100, this.height / 5 + 140, var1.translateKey("selectWorld.backup.vanilla")));
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 160, var1.translateKey("gui.cancel")));
this.buttonList.add(worldRecreate = new GuiButton(1, this.width / 2 - 100, this.height / 5 + 15, var1.translateKey("selectWorld.backup.recreate")));
this.buttonList.add(worldDuplicate = new GuiButton(2, this.width / 2 - 100, this.height / 5 + 40, var1.translateKey("selectWorld.backup.duplicate")));
this.buttonList.add(worldExport = new GuiButton(3, this.width / 2 - 100, this.height / 5 + 90, var1.translateKey("selectWorld.backup.export")));
this.buttonList.add(worldConvert = new GuiButton(4, this.width / 2 - 100, this.height / 5 + 115, var1.translateKey("selectWorld.backup.vanilla")));
this.buttonList.add(worldBackup = new GuiButton(5, this.width / 2 - 100, this.height / 5 + 146, var1.translateKey("selectWorld.backup.clearPlayerData")));
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 165, var1.translateKey("gui.cancel")));
}
public void drawScreen(int par1, int par2, float par3) {
StringTranslate var4 = StringTranslate.getInstance();
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, var4.translateKey("selectWorld.backup.title") + " '" + worldName + "'", this.width / 2, this.height / 5, 16777215);
this.drawCenteredString(this.fontRenderer, var4.translateKey("selectWorld.backup.seed") + " " + worldSeed, this.width / 2, this.height / 5 + 97, 0xAAAAFF);
this.drawCenteredString(this.fontRenderer, var4.translateKey("selectWorld.backup.title") + " '" + worldName + "'", this.width / 2, this.height / 5 - 25, 16777215);
this.drawCenteredString(this.fontRenderer, var4.translateKey("selectWorld.backup.seed") + " " + worldSeed, this.width / 2, this.height / 5 + 72, 0xAAAAFF);
int toolTipColor = 0xDDDDAA;
if(worldRecreate.func_82252_a()) {
this.drawCenteredString(this.fontRenderer, var4.translateKey("selectWorld.backup.recreate.tooltip"), this.width / 2, this.height / 5 + 20, toolTipColor);
this.drawCenteredString(this.fontRenderer, var4.translateKey("selectWorld.backup.recreate.tooltip"), this.width / 2, this.height / 5 - 2, toolTipColor);
}else if(worldDuplicate.func_82252_a()) {
this.drawCenteredString(this.fontRenderer, var4.translateKey("selectWorld.backup.duplicate.tooltip"), this.width / 2, this.height / 5 + 20, toolTipColor);
this.drawCenteredString(this.fontRenderer, var4.translateKey("selectWorld.backup.duplicate.tooltip"), this.width / 2, this.height / 5 - 2, toolTipColor);
}else if(worldExport.func_82252_a()) {
this.drawCenteredString(this.fontRenderer, var4.translateKey("selectWorld.backup.export.tooltip"), this.width / 2, this.height / 5 + 20, toolTipColor);
this.drawCenteredString(this.fontRenderer, var4.translateKey("selectWorld.backup.export.tooltip"), this.width / 2, this.height / 5 - 2, toolTipColor);
}else if(worldConvert.func_82252_a()) {
this.drawCenteredString(this.fontRenderer, var4.translateKey("selectWorld.backup.vanilla.tooltip"), this.width / 2, this.height / 5 + 20, toolTipColor);
this.drawCenteredString(this.fontRenderer, var4.translateKey("selectWorld.backup.vanilla.tooltip"), this.width / 2, this.height / 5 - 2, toolTipColor);
}else if(worldBackup.func_82252_a()) {
this.drawCenteredString(this.fontRenderer, var4.translateKey("selectWorld.backup.clearPlayerData.tooltip"), this.width / 2, this.height / 5 - 2, toolTipColor);
}
super.drawScreen(par1, par2, par3);
@ -88,6 +93,17 @@ public class GuiScreenBackupWorld extends GuiScreen {
}
return false;
}));
}else if(par1GuiButton.id == 5) {
StringTranslate var4 = StringTranslate.getInstance();
this.mc.displayGuiScreen(new GuiYesNo(this, var4.translateKey("selectWorld.backup.clearPlayerData.warning1"),
var4.translateKey("selectWorld.backup.clearPlayerData.warning2").replace("$world$", worldName).replace("$player$", EaglerProfile.username), 0));
}
}
public void confirmClicked(boolean par1, int par2) {
if(par1) {
IntegratedServer.clearPlayerData(worldName);
}
mc.displayGuiScreen(this);
}
}

View file

@ -312,6 +312,7 @@ public class IntegratedServer {
case IPCPacket07ImportWorld.ID:
case IPCPacket12FileWrite.ID:
case IPCPacket13FileCopyMove.ID:
case IPCPacket18ClearPlayers.ID:
statusState = IntegratedState.WORLD_NONE;
break;
default:
@ -441,5 +442,11 @@ public class IntegratedServer {
public static void configureLAN(EnumGameType enumGameType, boolean allowCommands) {
sendIPCPacket(new IPCPacket17ConfigureLAN(enumGameType.getID(), allowCommands, IntegratedServerLAN.currentICEServers));
}
public static void clearPlayerData(String worldName) {
ensureReady();
statusState = IntegratedState.WORLD_CLEAR_PLAYERS;
sendIPCPacket(new IPCPacket18ClearPlayers(worldName));
}
}

View file

@ -25,6 +25,7 @@ public class IntegratedState {
public static final int WORLD_FILE_WRITE = 17;
public static final int WORLD_FILE_MOVE = 18;
public static final int WORLD_FILE_COPY = 19;
public static final int WORLD_CLEAR_PLAYERS = 20;
public static String getStateName(int i) {
switch(i) {
@ -48,6 +49,7 @@ public class IntegratedState {
case WORLD_FILE_WRITE: return "WORLD_FILE_WRITE";
case WORLD_FILE_MOVE: return "WORLD_FILE_MOVE";
case WORLD_FILE_COPY: return "WORLD_FILE_COPY";
case WORLD_CLEAR_PLAYERS: return "WORLD_CLEAR_PLAYERS";
default: return "INVALID";
}
}
@ -63,6 +65,7 @@ public class IntegratedState {
case IPCPacket0BPause.ID: return (state == WORLD_SAVING || state == WORLD_PAUSED);
case IPCPacket12FileWrite.ID: return state == WORLD_FILE_WRITE;
case IPCPacket13FileCopyMove.ID: return (state == WORLD_FILE_MOVE || state == WORLD_FILE_COPY);
case IPCPacket18ClearPlayers.ID: return state == WORLD_CLEAR_PLAYERS;
default: return false;
}
}