mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 13:36:33 +01:00
/dxl escape: leave without saving
This commit is contained in:
parent
800e97adc1
commit
f97db1ed19
@ -102,6 +102,11 @@ public class DPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
public void escape() {
|
||||
remove(this);
|
||||
this.savePlayer.reset();
|
||||
}
|
||||
|
||||
public void leave() {
|
||||
remove(this);
|
||||
|
||||
|
@ -105,6 +105,20 @@ public class EditWorld {
|
||||
p.removeDirectory(dir);
|
||||
}
|
||||
|
||||
public void deleteNoSave() {
|
||||
eworlds.remove(this);
|
||||
for (Player player : this.world.getPlayers()) {
|
||||
DPlayer dplayer = DPlayer.get(player);
|
||||
dplayer.leave();
|
||||
}
|
||||
|
||||
File dir = new File("DXL_Edit_" + this.id);
|
||||
p.copyDirectory(dir, new File(p.getDataFolder(), "/dungeons/" + this.dungeonname));
|
||||
p.deletenotusingfiles(new File(p.getDataFolder(), "/dungeons/" + this.dungeonname));
|
||||
p.getServer().unloadWorld(this.world, true);
|
||||
p.removeDirectory(dir);
|
||||
}
|
||||
|
||||
// Static
|
||||
public static EditWorld get(World world) {
|
||||
for (EditWorld eworld : eworlds) {
|
||||
|
@ -115,6 +115,7 @@ public class LanguageReader {
|
||||
defaults.put("Help_Cmd_Help", "/dxl help - Zeigt die Hilfeseite an");
|
||||
defaults.put("Help_Cmd_Invite", "/dxl invite <player> <dungeon> - Ladet einen Spieler dazu ein den Dungeon zu editieren");
|
||||
defaults.put("Help_Cmd_Leave", "/dxl leave - Verlässt den aktuellen Dungeon");
|
||||
defaults.put("Help_Cmd_Escape", "/dxl escape - Verlässt den Dungeon, ohne ihn zu speichern");
|
||||
defaults.put("Help_Cmd_List", "/dxl list - Zeigt alle Dungeons an");
|
||||
defaults.put("Help_Cmd_Msg", "/dxl msg <id> '[msg]' - Zeigt oder editiert eine Nachricht");
|
||||
defaults.put("Help_Cmd_Portal", "/dxl portal - Erstellt ein Portal welches in Dungeons führt");
|
||||
|
49
src/com/dre/dungeonsxl/commands/CMDEscape.java
Normal file
49
src/com/dre/dungeonsxl/commands/CMDEscape.java
Normal file
@ -0,0 +1,49 @@
|
||||
package com.dre.dungeonsxl.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.dre.dungeonsxl.DGroup;
|
||||
import com.dre.dungeonsxl.DPlayer;
|
||||
import com.dre.dungeonsxl.EditWorld;
|
||||
|
||||
public class CMDEscape extends DCommand {
|
||||
|
||||
public CMDEscape() {
|
||||
this.command = "escape";
|
||||
this.args = 0;
|
||||
this.help = p.language.get("Help_Cmd_Escape");
|
||||
this.isPlayerCommand = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DPlayer dplayer = DPlayer.get(player);
|
||||
if (dplayer != null) {
|
||||
|
||||
if (dplayer.isEditing) {
|
||||
dplayer.escape();
|
||||
|
||||
EditWorld eworld = EditWorld.get(dplayer.world);
|
||||
if (eworld != null) {
|
||||
if (eworld.world.getPlayers().isEmpty()) {
|
||||
eworld.deleteNoSave();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
p.msg(player, p.language.get("Error_LeaveDungeon"));
|
||||
}
|
||||
|
||||
return;
|
||||
} else {
|
||||
DGroup dgroup = DGroup.get(player);
|
||||
if (dgroup != null) {
|
||||
dgroup.removePlayer(player);
|
||||
p.msg(player, p.language.get("Cmd_Leave_Success"));
|
||||
return;
|
||||
}
|
||||
p.msg(player, p.language.get("Error_NotInDungeon"));
|
||||
}
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ public class DCommandRoot {
|
||||
public CMDCreate cmdCreate = new CMDCreate();
|
||||
public CMDSave cmdSave = new CMDSave();
|
||||
public CMDLeave cmdLeave = new CMDLeave();
|
||||
public CMDEscape cmdEscape = new CMDEscape();
|
||||
public CMDEdit cmdEdit = new CMDEdit();
|
||||
public CMDPortal cmdPortal = new CMDPortal();
|
||||
public CMDDeletePortal cmdDeletePortal = new CMDDeletePortal();
|
||||
@ -33,6 +34,7 @@ public class DCommandRoot {
|
||||
this.commands.add(cmdCreate);
|
||||
this.commands.add(cmdSave);
|
||||
this.commands.add(cmdLeave);
|
||||
this.commands.add(cmdEscape);
|
||||
this.commands.add(cmdEdit);
|
||||
this.commands.add(cmdPortal);
|
||||
this.commands.add(cmdDeletePortal);
|
||||
|
Loading…
Reference in New Issue
Block a user