Added List command.
Shows a list of avaible arenas.
This commit is contained in:
parent
c9dfa4e8bc
commit
670f8cb872
69
src/nl/Steffion/BlockHunt/Commands/CMDlist.java
Normal file
69
src/nl/Steffion/BlockHunt/Commands/CMDlist.java
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
package nl.Steffion.BlockHunt.Commands;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import nl.Steffion.BlockHunt.W;
|
||||||
|
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 CMDlist extends DefaultCMD {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean exectue(Player player, Command cmd, String label,
|
||||||
|
String[] args) {
|
||||||
|
if (PlayerM.hasPerm(player, PermsC.list, true)) {
|
||||||
|
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, false,
|
||||||
|
"header-" + W.pluginName);
|
||||||
|
File arenaworldFolder = new File("plugins/" + W.pluginName
|
||||||
|
+ "/defaultArenas/");
|
||||||
|
ArrayList<String> arenas = new ArrayList<String>();
|
||||||
|
for (String file : arenaworldFolder.list()) {
|
||||||
|
File arenaCheck = new File(arenaworldFolder, file);
|
||||||
|
if (arenaCheck.isDirectory()) {
|
||||||
|
arenas.add(arenaCheck.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (arenas.size() >= 1) {
|
||||||
|
for (String arena : arenas) {
|
||||||
|
MessageM.sendMessage(player, "%A" + arena, false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
MessageM.sendMessage(player, "&7&oNo arenas available...",
|
||||||
|
false);
|
||||||
|
MessageM.sendMessage(player, "&7&oAdd arenas in the '"
|
||||||
|
+ W.pluginName + "/defaultArenas/' folder.", false);
|
||||||
|
MessageM.sendMessage(
|
||||||
|
player,
|
||||||
|
"&7&oWhile adding maps, be sure you REMOVE the uid.dat file. To prevent crashes.",
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, false,
|
||||||
|
"header-&oArenas list");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isAnArena(String worldname) {
|
||||||
|
File arenaworldFolder = new File("plugins/" + W.pluginName
|
||||||
|
+ "/defaultArenas/");
|
||||||
|
|
||||||
|
ArrayList<String> arenas = new ArrayList<String>();
|
||||||
|
for (String file : arenaworldFolder.list()) {
|
||||||
|
File arenaCheck = new File(arenaworldFolder, file);
|
||||||
|
if (arenaCheck.isDirectory()) {
|
||||||
|
arenas.add(arenaCheck.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arenas.contains(worldname)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -9,24 +9,24 @@ public enum CommandC {
|
|||||||
* Made by @author Steffion, © 2013.
|
* Made by @author Steffion, © 2013.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
INFO ("SteffionDefault%_",
|
INFO ("BlockHunt%_",
|
||||||
"SteffionDefault%_",
|
"BlockHunt%_",
|
||||||
new CMDinfo(),
|
new CMDinfo(),
|
||||||
ConfigC.commandEnabled_info,
|
ConfigC.commandEnabled_info,
|
||||||
PermsC.info,
|
PermsC.info,
|
||||||
ConfigC.help_info,
|
ConfigC.help_info,
|
||||||
0,
|
0,
|
||||||
"-"),
|
"-"),
|
||||||
INFO2 ("SteffionDefault%info_",
|
INFO2 ("BlockHunt%info_",
|
||||||
"SteffionDefault%i_",
|
"BlockHunt%i_",
|
||||||
new CMDinfo(),
|
new CMDinfo(),
|
||||||
ConfigC.commandEnabled_info,
|
ConfigC.commandEnabled_info,
|
||||||
PermsC.info,
|
PermsC.info,
|
||||||
ConfigC.help_info,
|
ConfigC.help_info,
|
||||||
1,
|
1,
|
||||||
W.pluginName + " [info|i]"),
|
W.pluginName + " [info|i]"),
|
||||||
HELP ("SteffionDefault%help_",
|
HELP ("BlockHunt%help_",
|
||||||
"SteffionDefault%h_",
|
"BlockHunt%h_",
|
||||||
new CMDhelp(),
|
new CMDhelp(),
|
||||||
|
|
||||||
ConfigC.commandEnabled_help,
|
ConfigC.commandEnabled_help,
|
||||||
@ -34,14 +34,22 @@ public enum CommandC {
|
|||||||
ConfigC.help_help,
|
ConfigC.help_help,
|
||||||
1,
|
1,
|
||||||
W.pluginName + " <help|h> [pagenumber]"),
|
W.pluginName + " <help|h> [pagenumber]"),
|
||||||
RELOAD ("SteffionDefault%reload_",
|
RELOAD ("BlockHunt%reload_",
|
||||||
"SteffionDefault%r_",
|
"BlockHunt%r_",
|
||||||
new CMDreload(),
|
new CMDreload(),
|
||||||
ConfigC.commandEnabled_reload,
|
ConfigC.commandEnabled_reload,
|
||||||
PermsC.reload,
|
PermsC.reload,
|
||||||
ConfigC.help_reload,
|
ConfigC.help_reload,
|
||||||
1,
|
1,
|
||||||
W.pluginName + " <reload|r>"),
|
W.pluginName + " <reload|r>"),
|
||||||
|
LIST ("BlockHunt%list_",
|
||||||
|
"BlockHunt%l_",
|
||||||
|
new CMDlist(),
|
||||||
|
ConfigC.commandEnabled_list,
|
||||||
|
PermsC.list,
|
||||||
|
ConfigC.help_list,
|
||||||
|
1,
|
||||||
|
W.pluginName + " <list|l>"),
|
||||||
NOT_FOUND ("%_",
|
NOT_FOUND ("%_",
|
||||||
"%_",
|
"%_",
|
||||||
new CMDnotfound(),
|
new CMDnotfound(),
|
||||||
|
@ -18,6 +18,7 @@ public enum ConfigC {
|
|||||||
commandEnabled_info (true, W.config),
|
commandEnabled_info (true, W.config),
|
||||||
commandEnabled_help (true, W.config),
|
commandEnabled_help (true, W.config),
|
||||||
commandEnabled_reload (true, W.config),
|
commandEnabled_reload (true, W.config),
|
||||||
|
commandEnabled_list (true, W.config),
|
||||||
|
|
||||||
log_Enabled ("%N%name%&a&k + %N%version% is now Enabled. Made by %A%autors%%N.",
|
log_Enabled ("%N%name%&a&k + %N%version% is now Enabled. Made by %A%autors%%N.",
|
||||||
W.messages),
|
W.messages),
|
||||||
@ -27,6 +28,7 @@ public enum ConfigC {
|
|||||||
help_info ("%NDisplays the plugin's info.", W.messages),
|
help_info ("%NDisplays the plugin's info.", W.messages),
|
||||||
help_help ("%NShows a list of commands.", W.messages),
|
help_help ("%NShows a list of commands.", W.messages),
|
||||||
help_reload ("%NReloads all configs.", W.messages),
|
help_reload ("%NReloads all configs.", W.messages),
|
||||||
|
help_list ("%NDisplays a list of available arenas.", W.messages),
|
||||||
|
|
||||||
normal_reloadedConfigs ("&aReloaded all configs!", W.messages),
|
normal_reloadedConfigs ("&aReloaded all configs!", W.messages),
|
||||||
|
|
||||||
|
@ -18,7 +18,8 @@ public class PlayerM {
|
|||||||
public enum PermsC {
|
public enum PermsC {
|
||||||
info (main + "info", PType.ALL),
|
info (main + "info", PType.ALL),
|
||||||
help (main + "help", PType.ALL),
|
help (main + "help", PType.ALL),
|
||||||
reload (main + "reload", PType.MODERATOR);
|
reload (main + "reload", PType.MODERATOR),
|
||||||
|
list (main + "list", PType.MODERATOR);
|
||||||
|
|
||||||
public String perm;
|
public String perm;
|
||||||
public PType type;
|
public PType type;
|
||||||
|
@ -19,6 +19,8 @@ public class W {
|
|||||||
public static ArrayList<String> newFiles = new ArrayList<String>();
|
public static ArrayList<String> newFiles = new ArrayList<String>();
|
||||||
public static ConfigM config = new ConfigM("config", "");
|
public static ConfigM config = new ConfigM("config", "");
|
||||||
public static ConfigM messages = new ConfigM("messages", "");
|
public static ConfigM messages = new ConfigM("messages", "");
|
||||||
|
public static ConfigM note1 = new ConfigM("PLACE WORLD FOLDERS HERE!",
|
||||||
|
"defaultArenas/");
|
||||||
|
|
||||||
public static void newFiles() {
|
public static void newFiles() {
|
||||||
ConfigM.setDefaults();
|
ConfigM.setDefaults();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user