Improve play command

Added requirements
This commit is contained in:
Daniel Saukel 2015-08-11 19:34:27 +02:00
parent 5be72ab941
commit 77baa789e6

View File

@ -1,11 +1,15 @@
package com.dre.dungeonsxl.commands;
import java.io.File;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.dre.dungeonsxl.DConfig;
import com.dre.dungeonsxl.DGroup;
import com.dre.dungeonsxl.DPlayer;
import com.dre.dungeonsxl.EditWorld;
import com.dre.dungeonsxl.P;
import com.dre.dungeonsxl.game.GameWorld;
public class CMDPlay extends DCommand {
@ -29,6 +33,8 @@ public class CMDPlay extends DCommand {
dungeonname = args[1];
if (EditWorld.exist(dungeonname)) {
if (GameWorld.canPlayDungeon(dungeonname, player)) {
if (GameWorld.checkRequirements(dungeonname, player)) {
if (DGroup.get(player) == null) {
DGroup dgroup = new DGroup(player, dungeonname);
if (dgroup != null) {
@ -44,6 +50,18 @@ public class CMDPlay extends DCommand {
} else {
p.msg(player, p.language.get("Error_LeaveGroup"));
}
} else {
P.p.msg(player, P.p.language.get("Error_Requirements"));
}
} else {
File file = new File(p.getDataFolder() + "/dungeons/" + dungeonname + "/config.yml");
if (file != null) {
DConfig confReader = new DConfig(file);
if (confReader != null) {
P.p.msg(player, P.p.language.get("Error_Cooldown", "" + confReader.getTimeToNextPlay()));
}
}
}
} else {
p.msg(player, p.language.get("Error_DungeonNotExist", dungeonname));
}