From 2b7cf84e8964ebdcfecb30bcac2da4f6ca2eb41c Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Mon, 3 Aug 2015 17:18:41 +0200 Subject: [PATCH] Added /dxl play command --- src/com/dre/dungeonsxl/LanguageReader.java | 4 +- src/com/dre/dungeonsxl/commands/CMDPlay.java | 59 +++++++++++++++++++ .../dre/dungeonsxl/commands/DCommandRoot.java | 6 +- 3 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 src/com/dre/dungeonsxl/commands/CMDPlay.java diff --git a/src/com/dre/dungeonsxl/LanguageReader.java b/src/com/dre/dungeonsxl/LanguageReader.java index effccac8..29a00caf 100644 --- a/src/com/dre/dungeonsxl/LanguageReader.java +++ b/src/com/dre/dungeonsxl/LanguageReader.java @@ -122,10 +122,10 @@ public class LanguageReader { defaults.put("Help_Cmd_DeletePortal", "/dxl deleteportal - Deletes the portal you are looking at"); defaults.put("Help_Cmd_Reload", "/dxl reload - Reloads the plugin"); defaults.put("Help_Cmd_Save", "/dxl save - Saves the current dungeon"); + defaults.put("Help_Cmd_Play", "/dxl play [dungeon]"); defaults.put("Help_Cmd_Test", "/dxl test [dungeon] - Tests a dungeon"); + defaults.put("Help_Cmd_Lives", "/dxl lives - Shows the lives a player has left"); defaults.put("Help_Cmd_Uninvite", "/dxl uninvite - Uninvite a player to edit a dungeon"); - defaults.put("Help_Cmd_Lives", "/dxl lives - show the lives a player has left"); - } private void check() { diff --git a/src/com/dre/dungeonsxl/commands/CMDPlay.java b/src/com/dre/dungeonsxl/commands/CMDPlay.java new file mode 100644 index 00000000..3ac3a0ab --- /dev/null +++ b/src/com/dre/dungeonsxl/commands/CMDPlay.java @@ -0,0 +1,59 @@ +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; +import com.dre.dungeonsxl.game.GameWorld; + +public class CMDPlay extends DCommand { + + public CMDPlay() { + this.command = "play"; + this.args = -1; + this.help = p.language.get("Help_Cmd_Play"); + this.permissions = "dxl.play"; + this.isPlayerCommand = true; + } + + @Override + public void onExecute(String[] args, CommandSender sender) { + Player player = (Player) sender; + DPlayer dplayer = DPlayer.get(player); + String dungeonname; + + if (dplayer == null) { + if (args.length > 1) { + dungeonname = args[1]; + + if (EditWorld.exist(dungeonname)) { + if (DGroup.get(player) == null) { + DGroup dgroup = new DGroup(player, dungeonname); + if (dgroup != null) { + if (dgroup.getGworld() == null) { + dgroup.setGworld(GameWorld.load(DGroup.get(player).getDungeonname())); + } + if (dgroup.getGworld().locLobby == null) { + new DPlayer(player, dgroup.getGworld().world, dgroup.getGworld().world.getSpawnLocation(), false); + } else { + new DPlayer(player, dgroup.getGworld().world, dgroup.getGworld().locLobby, false); + } + } + } else { + p.msg(player, p.language.get("Error_LeaveGroup")); + } + } else { + p.msg(player, p.language.get("Error_DungeonNotExist", dungeonname)); + } + } else { + this.displayHelp(player); + } + } else { + p.msg(player, p.language.get("Error_LeaveDungeon")); + } + + } + +} diff --git a/src/com/dre/dungeonsxl/commands/DCommandRoot.java b/src/com/dre/dungeonsxl/commands/DCommandRoot.java index 928b0170..2b0e61f7 100644 --- a/src/com/dre/dungeonsxl/commands/DCommandRoot.java +++ b/src/com/dre/dungeonsxl/commands/DCommandRoot.java @@ -18,14 +18,15 @@ public class DCommandRoot { public CMDDeletePortal cmdDeletePortal = new CMDDeletePortal(); public CMDChat cmdChat = new CMDChat(); public CMDChatSpy cmdChatSpy = new CMDChatSpy(); + public CMDLives cmdLives = new CMDLives(); public CMDList cmdList = new CMDList(); public CMDUninvite cmdUninvite = new CMDUninvite(); public CMDInvite cmdInvite = new CMDInvite(); public CMDMsg cmdMsg = new CMDMsg(); + public CMDPlay cmdPlay = new CMDPlay(); public CMDTest cmdTest = new CMDTest(); public CMDHelp cmdHelp = new CMDHelp(); public CMDReload cmdReload = new CMDReload(); - public CMDLives cmdLives = new CMDLives(); // Methods public DCommandRoot() { @@ -41,13 +42,14 @@ public class DCommandRoot { this.commands.add(cmdDeletePortal); this.commands.add(cmdChat); this.commands.add(cmdChatSpy); + this.commands.add(cmdLives); this.commands.add(cmdList); this.commands.add(cmdUninvite); this.commands.add(cmdInvite); this.commands.add(cmdMsg); + this.commands.add(cmdPlay); this.commands.add(cmdTest); this.commands.add(cmdHelp); this.commands.add(cmdReload); - this.commands.add(cmdLives); } }