mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2025-01-23 08:31:24 +01:00
GameType: TEST
This commit is contained in:
parent
7dc26d5805
commit
8b35d91f75
@ -1,10 +1,8 @@
|
||||
package io.github.dre2n.dungeonsxl.command;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
|
||||
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
||||
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
||||
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
|
||||
import io.github.dre2n.dungeonsxl.game.Game;
|
||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||
@ -17,8 +15,8 @@ public class TestCommand extends DCommand {
|
||||
|
||||
public TestCommand() {
|
||||
setCommand("test");
|
||||
setMinArgs(1);
|
||||
setMaxArgs(2);
|
||||
setMinArgs(0);
|
||||
setMaxArgs(0);
|
||||
setHelp(messageConfig.getMessage(Messages.HELP_CMD_TEST));
|
||||
setPermission("dxl.test");
|
||||
setPlayerCommand(true);
|
||||
@ -27,104 +25,32 @@ public class TestCommand extends DCommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DPlayer dplayer = DPlayer.getByPlayer(player);
|
||||
|
||||
if (dplayer != null) {
|
||||
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_LEAVE_DUNGEON));
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !(args.length >= 2 && args.length <= 3)) {
|
||||
displayHelp(player);
|
||||
return;
|
||||
}
|
||||
|
||||
String identifier = args[1];
|
||||
|
||||
boolean multiFloor = false;
|
||||
if (args.length == 3) {
|
||||
identifier = args[2];
|
||||
if (args[1].equalsIgnoreCase("dungeon") || args[1].equalsIgnoreCase("d")) {
|
||||
Dungeon dungeon = plugin.getDungeons().getDungeon(args[2]);
|
||||
if (dungeon != null) {
|
||||
multiFloor = true;
|
||||
} else {
|
||||
displayHelp(player);
|
||||
return;
|
||||
}
|
||||
|
||||
} else if (args[1].equalsIgnoreCase("map") || args[1].equalsIgnoreCase("m")) {
|
||||
identifier = args[2];
|
||||
}
|
||||
}
|
||||
|
||||
if ( !multiFloor && !EditWorld.exists(identifier)) {
|
||||
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, identifier));
|
||||
return;
|
||||
}
|
||||
|
||||
DGroup dGroup = DGroup.getByPlayer(player);
|
||||
|
||||
if (dGroup != null) {
|
||||
if ( !dGroup.getCaptain().equals(player) && !player.hasPermission("dxl.bypass")) {
|
||||
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_NOT_CAPTAIN));
|
||||
}
|
||||
|
||||
if (dGroup.getMapName() == null) {
|
||||
if ( !multiFloor) {
|
||||
dGroup.setMapName(identifier);
|
||||
|
||||
} else {
|
||||
dGroup.setDungeonName(identifier);
|
||||
Dungeon dungeon = plugin.getDungeons().getDungeon(identifier);
|
||||
|
||||
if (dungeon != null) {
|
||||
DungeonConfig config = dungeon.getConfig();
|
||||
|
||||
if (config != null) {
|
||||
dGroup.setMapName(config.getStartFloor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_LEAVE_GROUP));
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
dGroup = new DGroup(player, identifier, multiFloor);
|
||||
}
|
||||
|
||||
DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.COMMAND);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
plugin.getDGroups().remove(dGroup);
|
||||
dGroup = null;
|
||||
}
|
||||
|
||||
if (dGroup == null) {
|
||||
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_JOIN_GROUP));
|
||||
return;
|
||||
}
|
||||
|
||||
if (dGroup.getGameWorld() == null) {
|
||||
dGroup.setGameWorld(GameWorld.load(DGroup.getByPlayer(player).getMapName()));
|
||||
}
|
||||
|
||||
if (dGroup.getGameWorld() == null) {
|
||||
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_NOT_SAVED, DGroup.getByPlayer(player).getMapName()));
|
||||
dGroup.remove();
|
||||
if ( !dGroup.getCaptain().equals(player)) {
|
||||
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_NOT_CAPTAIN));
|
||||
return;
|
||||
}
|
||||
if (dGroup.getGameWorld().getLocLobby() == null) {
|
||||
for (Player groupPlayer : dGroup.getPlayers()) {
|
||||
new DPlayer(groupPlayer, dGroup.getGameWorld().getWorld(), dGroup.getGameWorld().getWorld().getSpawnLocation(), false).setInTestMode(true);
|
||||
}
|
||||
|
||||
} else {
|
||||
for (Player groupPlayer : dGroup.getPlayers()) {
|
||||
new DPlayer(groupPlayer, dGroup.getGameWorld().getWorld(), dGroup.getGameWorld().getLocLobby(), false).setInTestMode(true);
|
||||
}
|
||||
|
||||
GameWorld gameWorld = dGroup.getGameWorld();
|
||||
if (gameWorld == null) {
|
||||
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_NOT_IN_DUNGEON));
|
||||
return;
|
||||
}
|
||||
|
||||
Game game = gameWorld.getGame();
|
||||
if (game != null) {
|
||||
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_LEAVE_DUNGEON));
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player groupPlayer : dGroup.getPlayers()) {
|
||||
DPlayer.getByPlayer(groupPlayer).ready(GameTypeDefault.TEST);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ public class MessageConfig {
|
||||
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_SAVE("Help_Cmd_Save", "/dxl save - Saves the current dungeon"),
|
||||
HELP_CMD_TEST("Help_Cmd_Test", "/dxl test ([dungeon|map]) [name] - Tests a dungeon"),
|
||||
HELP_CMD_TEST("Help_Cmd_Test", "/dxl test - Starts the game in test mode"),
|
||||
HELP_CMD_UNINVITE("Help_Cmd_Uninvite", "/dxl uninvite <player> <dungeon> - Uninvite a player to edit a dungeon"),
|
||||
|
||||
REQUIREMENT_FEE("Requirement_Fee", "&6You have been charged &4&v1 &6for entering the dungeon."),
|
||||
|
@ -14,6 +14,7 @@ import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
|
||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerUpdateEvent;
|
||||
import io.github.dre2n.dungeonsxl.game.Game;
|
||||
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.reward.Reward;
|
||||
import io.github.dre2n.dungeonsxl.trigger.DistanceTrigger;
|
||||
@ -54,7 +55,6 @@ public class DPlayer {
|
||||
|
||||
private DSavePlayer savePlayer;
|
||||
|
||||
private boolean inTestMode = false;
|
||||
private boolean editing;
|
||||
private boolean inDungeonChat = false;
|
||||
private boolean ready = false;
|
||||
@ -170,15 +170,27 @@ public class DPlayer {
|
||||
* @return if the player is in test mode
|
||||
*/
|
||||
public boolean isInTestMode() {
|
||||
return inTestMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param inTestMode
|
||||
* if the player is in test mode
|
||||
*/
|
||||
public void setInTestMode(boolean inTestMode) {
|
||||
this.inTestMode = inTestMode;
|
||||
DGroup dGroup = DGroup.getByPlayer(player);
|
||||
if (dGroup == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GameWorld gameWorld = dGroup.getGameWorld();
|
||||
if (gameWorld == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Game game = gameWorld.getGame();
|
||||
if (game == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GameType gameType = game.getType();
|
||||
if (gameType == GameTypeDefault.TEST) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -509,7 +521,7 @@ public class DPlayer {
|
||||
}
|
||||
|
||||
// Belohnung
|
||||
if ( !inTestMode) {// Nur wenn man nicht am Testen ist
|
||||
if ( !isInTestMode()) {// Nur wenn man nicht am Testen ist
|
||||
if (finished) {
|
||||
for (Reward reward : gameWorld.getConfig().getRewards()) {
|
||||
reward.giveTo(player);
|
||||
@ -582,7 +594,6 @@ public class DPlayer {
|
||||
// ...*flies away*
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user