+ Added a start command.

This commit is contained in:
Steffion 2013-08-25 20:47:10 +02:00
parent 580afb014d
commit 537f03a899
4 changed files with 81 additions and 0 deletions

View File

@ -0,0 +1,68 @@
package nl.Steffion.BlockHunt.Commands;
import nl.Steffion.BlockHunt.Arena;
import nl.Steffion.BlockHunt.Arena.ArenaState;
import nl.Steffion.BlockHunt.W;
import nl.Steffion.BlockHunt.Managers.CommandC;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Managers.PlayerM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import org.bukkit.command.Command;
import org.bukkit.entity.Player;
public class CMDstart extends DefaultCMD {
@Override
public boolean exectue(Player player, Command cmd, String label,
String[] args) {
if (PlayerM.hasPerm(player, PermsC.start, true)) {
if (player != null) {
if (args.length <= 1) {
MessageM.sendFMessage(player,
ConfigC.error_notEnoughArguments, true, "syntax-"
+ CommandC.START.usage);
} else {
Arena arena = null;
for (Arena arena2 : W.arenaList) {
if (arena2.arenaName.equalsIgnoreCase(args[1])) {
arena = arena2;
}
}
if (arena != null) {
if (arena.gameState.equals(ArenaState.WAITING)) {
if (arena.playersInArena.size() >= 2) {
arena.timer = 10;
MessageM.sendFMessage(player,
ConfigC.normal_startForced, true,
"arenaname-" + arena.arenaName);
} else {
MessageM.sendFMessage(player,
ConfigC.warning_lobbyNeedAtleast, true,
"1-2");
}
} else if (arena.gameState.equals(ArenaState.STARTING)) {
if (arena.playersInArena.size() != arena.maxPlayers) {
arena.timer = 10;
} else {
arena.timer = 1;
}
MessageM.sendFMessage(player,
ConfigC.normal_startForced, true,
"arenaname-" + arena.arenaName);
}
} else {
MessageM.sendFMessage(player, ConfigC.error_noArena,
true, "name-" + args[1]);
}
}
} else {
MessageM.sendFMessage(player, ConfigC.error_onlyIngame, true);
}
}
return true;
}
}

View File

@ -58,6 +58,14 @@ public enum CommandC {
ConfigC.help_leave, ConfigC.help_leave,
1, 1,
W.pluginName + " <leave|l>"), W.pluginName + " <leave|l>"),
START ("BlockHunt%start_",
"BlockHunt%go_",
new CMDstart(),
ConfigC.commandEnabled_start,
PermsC.start,
ConfigC.help_start,
1,
W.pluginName + " <start|go> <arenaname>"),
WAND ("BlockHunt%wand_", WAND ("BlockHunt%wand_",
"BlockHunt%w_", "BlockHunt%w_",
new CMDwand(), new CMDwand(),

View File

@ -20,6 +20,7 @@ public enum ConfigC {
commandEnabled_reload (true, W.config), commandEnabled_reload (true, W.config),
commandEnabled_join (true, W.config), commandEnabled_join (true, W.config),
commandEnabled_leave (true, W.config), commandEnabled_leave (true, W.config),
commandEnabled_start (true, W.config),
commandEnabled_wand (true, W.config), commandEnabled_wand (true, W.config),
commandEnabled_create (true, W.config), commandEnabled_create (true, W.config),
commandEnabled_set (true, W.config), commandEnabled_set (true, W.config),
@ -59,6 +60,7 @@ public enum ConfigC {
help_reload ("%NReloads all configs.", W.messages), help_reload ("%NReloads all configs.", W.messages),
help_join ("%NJoins a " + W.pluginName + " game.", W.messages), help_join ("%NJoins a " + W.pluginName + " game.", W.messages),
help_leave ("%NLeave a " + W.pluginName + " game.", W.messages), help_leave ("%NLeave a " + W.pluginName + " game.", W.messages),
help_start ("%NForces an arena to start.", W.messages),
help_wand ("%NGives you the wand selection tool.", W.messages), help_wand ("%NGives you the wand selection tool.", W.messages),
help_create ("%NCreates an arena from your selection.", W.messages), help_create ("%NCreates an arena from your selection.", W.messages),
help_set ("%NOpens a panel to set settings.", W.messages), help_set ("%NOpens a panel to set settings.", W.messages),
@ -78,6 +80,8 @@ public enum ConfigC {
W.messages), W.messages),
normal_leaveLeftArena ("%A%playername%%N left your arena. (%A%1%%N/%A%2%%N)", normal_leaveLeftArena ("%A%playername%%N left your arena. (%A%1%%N/%A%2%%N)",
W.messages), W.messages),
normal_startForced ("%NYou forced to start arena '%A%arenaname%%N'!",
W.messages),
normal_wandGaveWand ("%NHere you go ;)! &o(Use the %A&o%type%%N&o!)", normal_wandGaveWand ("%NHere you go ;)! &o(Use the %A&o%type%%N&o!)",
W.messages), W.messages),
normal_wandSetPosition ("%NSet position %A#%number%%N to location: %pos%.", normal_wandSetPosition ("%NSet position %A#%number%%N to location: %pos%.",

View File

@ -23,6 +23,7 @@ public class PlayerM {
joinfull (main + "joinfull", PType.MODERATOR), joinfull (main + "joinfull", PType.MODERATOR),
joinsign (main + "joinsign", PType.PLAYER), joinsign (main + "joinsign", PType.PLAYER),
leave (main + "leave", PType.PLAYER), leave (main + "leave", PType.PLAYER),
start (main + "start", PType.MODERATOR),
create (main + "create", PType.ADMIN), create (main + "create", PType.ADMIN),
set (main + "set", PType.MODERATOR), set (main + "set", PType.MODERATOR),
setwarp (main + "setwarp", PType.MODERATOR), setwarp (main + "setwarp", PType.MODERATOR),