+ Added remove command.
This commit is contained in:
		
							
								
								
									
										72
									
								
								src/nl/Steffion/BlockHunt/Commands/CMDremove.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								src/nl/Steffion/BlockHunt/Commands/CMDremove.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,72 @@
 | 
			
		||||
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 nl.Steffion.BlockHunt.Serializables.LocationSerializable;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.Effect;
 | 
			
		||||
import org.bukkit.Location;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.Sound;
 | 
			
		||||
import org.bukkit.command.Command;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
 | 
			
		||||
public class CMDremove extends DefaultCMD {
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean exectue(Player player, Command cmd, String label,
 | 
			
		||||
			String[] args) {
 | 
			
		||||
		if (PlayerM.hasPerm(player, PermsC.remove, true)) {
 | 
			
		||||
			if (player != null) {
 | 
			
		||||
				if (args.length <= 1) {
 | 
			
		||||
					MessageM.sendFMessage(player,
 | 
			
		||||
							ConfigC.error_notEnoughArguments, true, "syntax-"
 | 
			
		||||
									+ CommandC.REMOVE.usage);
 | 
			
		||||
				} else {
 | 
			
		||||
					for (Arena arena : W.arenaList) {
 | 
			
		||||
						if (args[1].equalsIgnoreCase(arena.arenaName)) {
 | 
			
		||||
							MessageM.sendFMessage(player,
 | 
			
		||||
									ConfigC.normal_removeRemovedArena, true,
 | 
			
		||||
									"name-" + args[1]);
 | 
			
		||||
							W.arenas.getFile().set(args[1], null);
 | 
			
		||||
							for (String sign : W.signs.getFile().getKeys(false)) {
 | 
			
		||||
								if (W.signs.getFile().get(sign + ".arenaName")
 | 
			
		||||
										.toString().equalsIgnoreCase(args[1])) {
 | 
			
		||||
									LocationSerializable signLoc = new LocationSerializable(
 | 
			
		||||
											(Location) W.signs.getFile().get(
 | 
			
		||||
													sign + ".location"));
 | 
			
		||||
									signLoc.getBlock().setType(Material.AIR);
 | 
			
		||||
									signLoc.getWorld().playEffect(signLoc,
 | 
			
		||||
											Effect.MOBSPAWNER_FLAMES, 0);
 | 
			
		||||
									signLoc.getWorld().playSound(signLoc,
 | 
			
		||||
											Sound.ENDERDRAGON_WINGS, 1, 1);
 | 
			
		||||
									W.signs.getFile().set(sign, null);
 | 
			
		||||
								}
 | 
			
		||||
							}
 | 
			
		||||
 | 
			
		||||
							W.arenas.save();
 | 
			
		||||
							W.signs.load();
 | 
			
		||||
							for (Arena arena2 : W.arenaList) {
 | 
			
		||||
								ArenaHandler.stopArena(arena2);
 | 
			
		||||
							}
 | 
			
		||||
							ArenaHandler.loadArenas();
 | 
			
		||||
							return true;
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					MessageM.sendFMessage(player, ConfigC.error_noArena, true,
 | 
			
		||||
							"name-" + args[1]);
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				MessageM.sendFMessage(player, ConfigC.error_onlyIngame, true);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -90,6 +90,14 @@ public enum CommandC {
 | 
			
		||||
			ConfigC.help_setwarp,
 | 
			
		||||
			1,
 | 
			
		||||
			W.pluginName + " <setwarp|sw> <lobby|hiders|seekers> <arenaname>"),
 | 
			
		||||
	REMOVE ("BlockHunt%remove_",
 | 
			
		||||
			"BlockHunt%delete_",
 | 
			
		||||
			new CMDremove(),
 | 
			
		||||
			ConfigC.commandEnabled_remove,
 | 
			
		||||
			PermsC.remove,
 | 
			
		||||
			ConfigC.help_remove,
 | 
			
		||||
			1,
 | 
			
		||||
			W.pluginName + " <remove|delete> <arenaname>"),
 | 
			
		||||
	NOT_FOUND ("%_",
 | 
			
		||||
			"%_",
 | 
			
		||||
			new CMDnotfound(),
 | 
			
		||||
 
 | 
			
		||||
@@ -24,6 +24,7 @@ public enum ConfigC {
 | 
			
		||||
	commandEnabled_create (true, W.config),
 | 
			
		||||
	commandEnabled_set (true, W.config),
 | 
			
		||||
	commandEnabled_setwarp (true, W.config),
 | 
			
		||||
	commandEnabled_remove (true, W.config),
 | 
			
		||||
 | 
			
		||||
	wandID (280, W.config),
 | 
			
		||||
	wandName ("%A&l" + W.pluginName + "%N's selection wand", W.config),
 | 
			
		||||
@@ -42,7 +43,7 @@ public enum ConfigC {
 | 
			
		||||
			"%A%arenaname%", "%A%players%%N/%A%maxplayers%",
 | 
			
		||||
			"&2Start: %A%timeleft%" }, W.config),
 | 
			
		||||
	sign_INGAME (new String[] { "%H[" + W.pluginName + "%H]", "%A%arenaname%",
 | 
			
		||||
			"%A%players%%N/%A%maxplayers%", "%EIn-game: %A%timeleft%" },
 | 
			
		||||
			"%A%players%%N/%A%maxplayers%", "%EIngame: %A%timeleft%" },
 | 
			
		||||
			W.config),
 | 
			
		||||
 | 
			
		||||
	log_Enabled ("%N%name%&a&k + %N%version% is now Enabled. Made by %A%autors%%N.",
 | 
			
		||||
@@ -59,6 +60,7 @@ public enum ConfigC {
 | 
			
		||||
	help_create ("%NCreates an arena from your selection.", W.messages),
 | 
			
		||||
	help_set ("%NOpens a panel to set settings.", W.messages),
 | 
			
		||||
	help_setwarp ("%NSets warps for your arena.", W.messages),
 | 
			
		||||
	help_remove ("%NDeletes an Arena.", W.messages),
 | 
			
		||||
 | 
			
		||||
	button_add ("%NAdd %A%1%%N to %A%2%%N", W.messages),
 | 
			
		||||
	button_add2 ("Add", W.messages),
 | 
			
		||||
@@ -97,6 +99,7 @@ public enum ConfigC {
 | 
			
		||||
	normal_winHiders ("%NThe %AHIDERS%N have won!", W.messages),
 | 
			
		||||
	normal_setwarpWarpSet ("%NSet warp '%A%warp%%N' to your location!",
 | 
			
		||||
			W.messages),
 | 
			
		||||
	normal_removeRemovedArena ("%NRemoved arena '%A%name%%N'!", W.messages),
 | 
			
		||||
	normal_ingameNowSolid ("%NYou're now a solid '%A%block%%N' block!",
 | 
			
		||||
			W.messages),
 | 
			
		||||
	normal_ingameNoMoreSolid ("%NYou're no longer a solid block!", W.messages),
 | 
			
		||||
@@ -109,6 +112,7 @@ public enum ConfigC {
 | 
			
		||||
			W.messages),
 | 
			
		||||
	warning_ingameNoSolidPlace ("%WThat's not a valid place to become solid!",
 | 
			
		||||
			W.messages),
 | 
			
		||||
	warning_arenaStopped ("%WThe arena has been forced to stop!", W.messages),
 | 
			
		||||
 | 
			
		||||
	error_noPermission ("%EYou don't have the permissions to do that!",
 | 
			
		||||
			W.messages),
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,8 @@ public class PlayerM {
 | 
			
		||||
		create (main + "create", PType.ADMIN),
 | 
			
		||||
		set (main + "set", PType.MODERATOR),
 | 
			
		||||
		setwarp (main + "setwarp", PType.MODERATOR),
 | 
			
		||||
		signcreate (main + "signcreate", PType.MODERATOR);
 | 
			
		||||
		signcreate (main + "signcreate", PType.MODERATOR),
 | 
			
		||||
		remove (main + "remove", PType.ADMIN);
 | 
			
		||||
 | 
			
		||||
		public String perm;
 | 
			
		||||
		public PType type;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user