Added join command.
This commit is contained in:
parent
1ae55cabf8
commit
39e1f134a6
66
src/nl/Steffion/BlockHunt/Commands/CMDjoin.java
Normal file
66
src/nl/Steffion/BlockHunt/Commands/CMDjoin.java
Normal file
@ -0,0 +1,66 @@
|
||||
package nl.Steffion.BlockHunt.Commands;
|
||||
|
||||
import nl.Steffion.BlockHunt.Arena;
|
||||
import nl.Steffion.BlockHunt.ArenaHandler;
|
||||
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 CMDjoin extends DefaultCMD {
|
||||
|
||||
@Override
|
||||
public boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
if (PlayerM.hasPerm(player, PermsC.join, true)) {
|
||||
if (player != null) {
|
||||
if (args.length <= 1) {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_notEnoughArguments, true, "syntax-"
|
||||
+ CommandC.JOIN.usage);
|
||||
} else {
|
||||
boolean found = false;
|
||||
boolean alreadyJoined = false;
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena != null) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
alreadyJoined = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!alreadyJoined) {
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.arenaName.equalsIgnoreCase(args[1])) {
|
||||
found = true;
|
||||
arena.playersInArena.add(player);
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_joinJoinedArena, true,
|
||||
"playername-" + player.getName(), "1-"
|
||||
+ arena.playersInArena.size(),
|
||||
"2-" + arena.maxPlayers);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_joinAlreadyJoined, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
MessageM.sendFMessage(player, ConfigC.error_noArena,
|
||||
true, "name-" + args[1]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
MessageM.sendFMessage(player, ConfigC.error_onlyIngame, true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -42,6 +42,14 @@ public enum CommandC {
|
||||
ConfigC.help_reload,
|
||||
1,
|
||||
W.pluginName + " <reload|r>"),
|
||||
JOIN ("BlockHunt%join_",
|
||||
"BlockHunt%j_",
|
||||
new CMDjoin(),
|
||||
ConfigC.commandEnabled_join,
|
||||
PermsC.join,
|
||||
ConfigC.help_join,
|
||||
1,
|
||||
W.pluginName + " <join|j> <arenaname>"),
|
||||
WAND ("BlockHunt%wand_",
|
||||
"BlockHunt%w_",
|
||||
new CMDwand(),
|
||||
|
@ -18,6 +18,7 @@ public enum ConfigC {
|
||||
commandEnabled_info (true, W.config),
|
||||
commandEnabled_help (true, W.config),
|
||||
commandEnabled_reload (true, W.config),
|
||||
commandEnabled_join (true, W.config),
|
||||
commandEnabled_wand (true, W.config),
|
||||
commandEnabled_create (true, W.config),
|
||||
commandEnabled_set (true, W.config),
|
||||
@ -39,6 +40,7 @@ public enum ConfigC {
|
||||
help_info ("%NDisplays the plugin's info.", W.messages),
|
||||
help_help ("%NShows a list of commands.", W.messages),
|
||||
help_reload ("%NReloads all configs.", W.messages),
|
||||
help_join ("%NJoins a " + W.pluginName + " game.", W.messages),
|
||||
help_wand ("%NGives you the wand selection tool.", W.messages),
|
||||
help_create ("%NCreates an arena from your selection.", W.messages),
|
||||
help_set ("%NOpens a panel to set settings.", W.messages),
|
||||
@ -50,6 +52,8 @@ public enum ConfigC {
|
||||
button_remove2 ("Remove", W.messages),
|
||||
|
||||
normal_reloadedConfigs ("&aReloaded all configs!", W.messages),
|
||||
normal_joinJoinedArena ("%A%playername%%N joined your arena. (%A%1%%N/%A%2%%N)",
|
||||
W.messages),
|
||||
normal_wandGaveWand ("%NHere you go ;)! &o(Use the %A&o%type%%N&o!)",
|
||||
W.messages),
|
||||
normal_wandSetPosition ("%NSet position %A#%number%%N to location: %pos%.",
|
||||
@ -66,18 +70,19 @@ public enum ConfigC {
|
||||
W.messages),
|
||||
error_noArena ("%ENo arena found with the name '%A%name%%E'.", W.messages),
|
||||
error_onlyIngame ("%EThis is an only in-game command!", W.messages),
|
||||
error_joinAlreadyJoined ("%EYou've already joined an arena!", W.messages),
|
||||
error_createSelectionFirst ("%EMake a selection first. Use the wand command: %A/"
|
||||
+ W.pluginName + " <wand|w>%E.",
|
||||
W.messages),
|
||||
error_createNotSameWorld ("%EMake your selection points in the same world!",
|
||||
W.messages),
|
||||
error_tooHighNumber ("%EThat amount is too high! Max amount is: %A%max%%E.",
|
||||
error_setTooHighNumber ("%EThat amount is too high! Max amount is: %A%max%%E.",
|
||||
W.messages),
|
||||
error_tooLowNumber ("%EThat amount is too low! Minimal amount is: %A%min%%E.",
|
||||
error_setTooLowNumber ("%EThat amount is too low! Minimal amount is: %A%min%%E.",
|
||||
W.messages);
|
||||
|
||||
Object value;
|
||||
ConfigM config;
|
||||
public Object value;
|
||||
public ConfigM config;
|
||||
|
||||
private ConfigC (Object value, ConfigM config) {
|
||||
this.value = value;
|
||||
|
@ -20,7 +20,8 @@ public class PlayerM {
|
||||
help (main + "help", PType.ALL),
|
||||
reload (main + "reload", PType.MODERATOR),
|
||||
create (main + "create", PType.ADMIN),
|
||||
set (main + "set", PType.MODERATOR);
|
||||
set (main + "set", PType.MODERATOR),
|
||||
join (main + "join", PType.PLAYER);
|
||||
|
||||
public String perm;
|
||||
public PType type;
|
||||
|
Loading…
x
Reference in New Issue
Block a user