Added Create command.
This commit is contained in:
parent
b0ce3a6854
commit
2c6b95003a
53
src/nl/Steffion/BlockHunt/Commands/CMDcreate.java
Normal file
53
src/nl/Steffion/BlockHunt/Commands/CMDcreate.java
Normal file
@ -0,0 +1,53 @@
|
||||
package nl.Steffion.BlockHunt.Commands;
|
||||
|
||||
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 CMDcreate extends DefaultCMD {
|
||||
|
||||
@Override
|
||||
public boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
if (PlayerM.hasPerm(player, PermsC.create, true)) {
|
||||
if (player != null) {
|
||||
if (args.length <= 1) {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_notEnoughArguments, true, "syntax-"
|
||||
+ CommandC.CREATE.usage);
|
||||
} else {
|
||||
if (W.pos1.get(player) != null
|
||||
&& W.pos2.get(player) != null) {
|
||||
if (W.pos1.get(player).getWorld()
|
||||
.equals(W.pos2.get(player).getWorld())) {
|
||||
W.arenas.getFile().set(args[1] + ".name", args[1]);
|
||||
W.arenas.getFile().set(args[1] + ".pos1",
|
||||
W.pos1.get(player));
|
||||
W.arenas.getFile().set(args[1] + ".pos2",
|
||||
W.pos2.get(player));
|
||||
W.arenas.save();
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.normal_createCreatedArena, true,
|
||||
"name-" + args[1]);
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_createNotSameWorld, true);
|
||||
}
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_createSelectionFirst, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
MessageM.sendFMessage(player, ConfigC.error_onlyIngame, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -50,6 +50,14 @@ public enum CommandC {
|
||||
ConfigC.help_wand,
|
||||
1,
|
||||
W.pluginName + " <wand|w>"),
|
||||
CREATE ("BlockHunt%create_",
|
||||
"BlockHunt%c_",
|
||||
new CMDcreate(),
|
||||
ConfigC.commandEnabled_create,
|
||||
PermsC.create,
|
||||
ConfigC.help_create,
|
||||
1,
|
||||
W.pluginName + " <create|c> <arenaname>"),
|
||||
NOT_FOUND ("%_",
|
||||
"%_",
|
||||
new CMDnotfound(),
|
||||
|
@ -19,6 +19,7 @@ public enum ConfigC {
|
||||
commandEnabled_help (true, W.config),
|
||||
commandEnabled_reload (true, W.config),
|
||||
commandEnabled_wand (true, W.config),
|
||||
commandEnabled_create (true, W.config),
|
||||
|
||||
wandID (280, W.config),
|
||||
wandName ("%A&l" + W.pluginName + "%N's selection wand", W.config),
|
||||
@ -38,11 +39,14 @@ public enum ConfigC {
|
||||
help_help ("%NShows a list of commands.", W.messages),
|
||||
help_reload ("%NReloads all configs.", W.messages),
|
||||
help_wand ("%NGives you the wand selection tool.", W.messages),
|
||||
help_create ("%NCreates an arena from your selection.", W.messages),
|
||||
|
||||
normal_reloadedConfigs ("&aReloaded all configs!", W.messages),
|
||||
normal_gaveWand ("%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),
|
||||
normal_setPosition ("%NSet position %A#%number%%N to location: %pos%.",
|
||||
normal_wandSetPosition ("%NSet position %A#%number%%N to location: %pos%.",
|
||||
W.messages),
|
||||
normal_createCreatedArena ("%NCreated an arena with the name %A%name%%N.",
|
||||
W.messages),
|
||||
|
||||
error_noPermission ("%EYou don't have the permissions to do that!",
|
||||
@ -53,7 +57,12 @@ public enum ConfigC {
|
||||
error_notEnoughArguments ("%EYou're missing arguments, correct syntax: %A/%syntax%",
|
||||
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_onlyIngame ("%EThis is an only in-game command!", 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);
|
||||
|
||||
Object value;
|
||||
ConfigM config;
|
||||
|
@ -25,6 +25,7 @@ public class W {
|
||||
public static HashMap<Player, LocationSerializable> pos2 = new HashMap<Player, LocationSerializable>();
|
||||
public static ConfigM config = new ConfigM("config", "");
|
||||
public static ConfigM messages = new ConfigM("messages", "");
|
||||
public static ConfigM arenas = new ConfigM("arenas", "");
|
||||
|
||||
public static void newFiles() {
|
||||
ConfigM.setDefaults();
|
||||
|
Loading…
x
Reference in New Issue
Block a user