Added enter command

This commit is contained in:
Daniel Saukel 2016-04-28 22:41:14 +02:00
parent 1cdc78dda3
commit 2d4e870d65
4 changed files with 97 additions and 1 deletions

View File

@ -307,6 +307,7 @@ public class DungeonsXL extends BRPlugin {
new GameCommand(), new GameCommand(),
new GroupCommand(), new GroupCommand(),
new InviteCommand(), new InviteCommand(),
new EnterCommand(),
new LeaveCommand(), new LeaveCommand(),
new ListCommand(), new ListCommand(),
new LivesCommand(), new LivesCommand(),

View File

@ -0,0 +1,89 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.commons.command.BRCommand;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.MessageConfig;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
/**
* @author Daniel Saukel
*/
public class EnterCommand extends BRCommand {
protected static DungeonsXL plugin = DungeonsXL.getInstance();
protected static MessageConfig messageConfig = plugin.getMessageConfig();
public EnterCommand() {
setMinArgs(1);
setMaxArgs(2);
setCommand("enter");
setHelp(messageConfig.getMessage(MessageConfig.Messages.HELP_CMD_ENTER));
setPermission("dxl.enter");
setPlayerCommand(true);
}
@Override
public void onExecute(String[] args, CommandSender sender) {
Player captain = (Player) sender;
String targetName = args.length == 3 ? args[2] : args[1];
DGroup joining = args.length == 3 ? DGroup.getByName(args[1]) : DGroup.getByPlayer(captain);
DGroup target = DGroup.getByName(targetName);
if (target == null) {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_NO_SUCH_GROUP, targetName));
return;
}
Game game = Game.getByDGroup(target);
if (game == null) {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_NOT_IN_GAME, targetName));
return;
}
if (Game.getByDGroup(joining) != null) {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_LEAVE_GAME));
return;
}
if (joining == null) {
joining = new DGroup(captain, game.getWorld().getMapName(), game.getDungeon() != null);
}
if (joining.getCaptain() != captain && !sender.hasPermission("dxl.bypass")) {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_NOT_CAPTAIN));
return;
}
joining.setGameWorld(game.getWorld());
game.addDGroup(joining);
joining.sendMessage(messageConfig.getMessage(Messages.CMD_ENTER_SUCCESS, joining.getName(), targetName));
for (Player player : joining.getPlayers()) {
new DPlayer(player, game.getWorld()).ready();
}
}
}

View File

@ -32,6 +32,7 @@ public class MessageConfig {
GROUP_CREATED("Group_Created", "&4&v1&6 created the group &4&v2&6!"), GROUP_CREATED("Group_Created", "&4&v1&6 created the group &4&v2&6!"),
GROUP_DISBANDED("Group_Disbanded", "&4&v1&6 disbanded the group &4&v2&6."), GROUP_DISBANDED("Group_Disbanded", "&4&v1&6 disbanded the group &4&v2&6."),
GROUP_INVITED_PLAYER("Group_InvitedPlayer", "&4&v1&6 invited the player &4&v2&6 to the group &4&v3&6."), GROUP_INVITED_PLAYER("Group_InvitedPlayer", "&4&v1&6 invited the player &4&v2&6 to the group &4&v3&6."),
GROUP_JOINED_GAME("Group_JoinedGame", "&6Your group successfully joined the game."),
GROUP_UNINVITED_PLAYER("Group_UninvitedPlayer", "&4&v1&6 took back the invitation for &4&v2&6 to the group &4&v3&6."), GROUP_UNINVITED_PLAYER("Group_UninvitedPlayer", "&4&v1&6 took back the invitation for &4&v2&6 to the group &4&v3&6."),
GROUP_KICKED_PLAYER("Group_KickedPlayer", "&4&v1&6 kicked the player &4&v2&6 from the group &4&v3&6."), GROUP_KICKED_PLAYER("Group_KickedPlayer", "&4&v1&6 kicked the player &4&v2&6 from the group &4&v3&6."),
GROUP_PLAYER_JOINED("Group_PlayerJoined", "&6Player &4&v1&6 has joined the group!"), GROUP_PLAYER_JOINED("Group_PlayerJoined", "&6Player &4&v1&6 has joined the group!"),
@ -78,6 +79,7 @@ public class MessageConfig {
CMD_CHAT_NORMAL_CHAT("Cmd_Chat_NormalChat", "&6You are now in the public chat"), CMD_CHAT_NORMAL_CHAT("Cmd_Chat_NormalChat", "&6You are now in the public chat"),
CMD_CHATSPY_STOPPED("Cmd_Chatspy_Stopped", "&6You stopped spying the DXL-chat!"), CMD_CHATSPY_STOPPED("Cmd_Chatspy_Stopped", "&6You stopped spying the DXL-chat!"),
CMD_CHATSPY_START("Cmd_Chatspy_Start", "&You started spying the DXL-chat!"), CMD_CHATSPY_START("Cmd_Chatspy_Start", "&You started spying the DXL-chat!"),
CMD_ENTER_SUCCESS("Cmd_Enter", "&6The group &4&v1 &6successfully entered the game of the group &4&v2&6."),
CMD_INVITE_SUCCESS("Cmd_Invite_Success", "&6Player &4&v1&6 was successfully invited to edit the Dungeon &4&v2&6!"), CMD_INVITE_SUCCESS("Cmd_Invite_Success", "&6Player &4&v1&6 was successfully invited to edit the Dungeon &4&v2&6!"),
CMD_LEAVE_SUCCESS("Cmd_Leave_Success", "&6You have successfully left your group!"), CMD_LEAVE_SUCCESS("Cmd_Leave_Success", "&6You have successfully left your group!"),
CMD_LIVES("Cmd_Lives", "&4v1&6 has &4v2 &6lives left."), CMD_LIVES("Cmd_Lives", "&4v1&6 has &4v2 &6lives left."),
@ -121,6 +123,7 @@ public class MessageConfig {
ERROR_NO_SUCH_PLAYER("Error_NoSuchPlayer", "&4The player &6&v1&4 does not exist!"), ERROR_NO_SUCH_PLAYER("Error_NoSuchPlayer", "&4The player &6&v1&4 does not exist!"),
ERROR_NOT_CAPTAIN("Error_NotCaptain", "&4You are not the captain of your group!"), ERROR_NOT_CAPTAIN("Error_NotCaptain", "&4You are not the captain of your group!"),
ERROR_NOT_IN_DUNGEON("Error_NotInDungeon", "&4You are not in a dungeon!"), ERROR_NOT_IN_DUNGEON("Error_NotInDungeon", "&4You are not in a dungeon!"),
ERROR_NOT_IN_GAME("Error_NotInGame", "&4The group &6&v1&4 is not member of a game."),
ERROR_NOT_IN_GROUP("Error_NotInGroup", "&4The player &6&v1&4 is not member of the group &6&v2&v4."), ERROR_NOT_IN_GROUP("Error_NotInGroup", "&4The player &6&v1&4 is not member of the group &6&v2&v4."),
ERROR_NOT_INVITED("Error_NotInvited", "&4You are not invited to the group &6&v1&4."), ERROR_NOT_INVITED("Error_NotInvited", "&4You are not invited to the group &6&v1&4."),
ERROR_NOT_SAVED("Error_NotSaved", "&4The map &6&v1&4 has not been saved to the &6DungeonsXL/maps/ &4folder yet!"), ERROR_NOT_SAVED("Error_NotSaved", "&4The map &6&v1&4 has not been saved to the &6DungeonsXL/maps/ &4folder yet!"),
@ -146,12 +149,13 @@ public class MessageConfig {
HELP_CMD_GROUP_SHOW("Help_Cmd_GroupShow", "/dxl group show [group] - Shows a group"), HELP_CMD_GROUP_SHOW("Help_Cmd_GroupShow", "/dxl group show [group] - Shows a group"),
HELP_CMD_HELP("Help_Cmd_Help", "/dxl help <page> - Shows the help page"), HELP_CMD_HELP("Help_Cmd_Help", "/dxl help <page> - Shows the help page"),
HELP_CMD_INVITE("Help_Cmd_Invite", "/dxl invite <player> <dungeon> - Invite a player to edit a dungeon"), HELP_CMD_INVITE("Help_Cmd_Invite", "/dxl invite <player> <dungeon> - Invite a player to edit a dungeon"),
HELP_CMD_ENTER("Help_Cmd_Enter", "/dxl enter ([joining group]) [target group] - Let the joining group enter the game of the target group"),
HELP_CMD_LEAVE("Help_Cmd_Leave", "/dxl leave - Leaves the current dungeon"), HELP_CMD_LEAVE("Help_Cmd_Leave", "/dxl leave - Leaves the current dungeon"),
HELP_CMD_LIST("Help_Cmd_List", "/dxl list ([dungeon|map|loaded]) ([dungeon]) - Lists all dungeons"), HELP_CMD_LIST("Help_Cmd_List", "/dxl list ([dungeon|map|loaded]) ([dungeon]) - Lists all dungeons"),
HELP_CMD_LIVES("Help_Cmd_Lives", "/dxl lives <player> - Shows the lives a player has left"), HELP_CMD_LIVES("Help_Cmd_Lives", "/dxl lives <player> - Shows the lives a player has left"),
HELP_CMD_MAIN("Help_Cmd_Main", "/dxl - General status information"), HELP_CMD_MAIN("Help_Cmd_Main", "/dxl - General status information"),
HELP_CMD_MSG("Help_Cmd_Msg", "/dxl msg <id> '[msg]' - Show or edit a message"), HELP_CMD_MSG("Help_Cmd_Msg", "/dxl msg <id> '[msg]' - Show or edit a message"),
HELP_CMD_PLAY("Help_Cmd_Play", "/dxl play ([dungeon|map]) [name] - Allows the player to join a game without a portal"), HELP_CMD_PLAY("Help_Cmd_Play", "/dxl play ([dungeon|map]) [name] - Allows the player to play a dungeon without a portal"),
HELP_CMD_PORTAL("Help_Cmd_Portal", "/dxl portal - Creates a portal that leads into a dungeon"), HELP_CMD_PORTAL("Help_Cmd_Portal", "/dxl portal - Creates a portal that leads into a dungeon"),
HELP_CMD_RELOAD("Help_Cmd_Reload", "/dxl reload - Reloads the plugin"), HELP_CMD_RELOAD("Help_Cmd_Reload", "/dxl reload - Reloads the plugin"),
HELP_CMD_SAVE("Help_Cmd_Save", "/dxl save - Saves the current dungeon"), HELP_CMD_SAVE("Help_Cmd_Save", "/dxl save - Saves the current dungeon"),

View File

@ -20,6 +20,8 @@ permissions:
default: op default: op
dxl.edit: dxl.edit:
default: op default: op
dxl.enter:
default: op
dxl.escape: dxl.escape:
default: true default: true
dxl.game: dxl.game: