Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public final Logger logger = Logger.getLogger("Minecraft");
- PluginDescriptionFile pdf = this.getDescription();
- public void onEnable() {
- this.logger.info(pdf.getName() + "v" + pdf.getVersion() + " has been enabled!");
- this.saveDefaultConfig();
- if(!getDataFolder().exists())
- getDataFolder().mkdir();
- if(getConfig() == null)
- saveDefaultConfig();
- new BT2ArenaManager(this);
- BT2ArenaManager.getManager().loadGames();
- this.getServer().getPluginManager().registerEvents(new BT2GameListener(this), this);
- }
- public void onDisable() {
- this.logger.info(pdf.getName() + "v" + pdf.getVersion() + " has been disabled!");
- this.saveConfig();
- }
- public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
- Player p = (Player) s;
- if (c.getName().equalsIgnoreCase("bowthrow")) {
- if (!(s instanceof Player)) {
- return true;
- }
- if (args.length > 2) {
- p.sendMessage(ChatColor.RED + "Invalid command! Do /bowthrow for help!");
- return true;
- }
- else if (args.length == 0) {
- if (p.hasPermission("bowthrow.help")) {
- p.sendMessage(ChatColor.BLUE + "BowThrow " + ChatColor.GREEN + "v" + pdf.getVersion() + ChatColor.BLUE + " by " + ChatColor.GREEN + "GiraffeKnee" + ChatColor.BLUE + "!");
- p.sendMessage(ChatColor.GREEN + "/" + ChatColor.BLUE + "bowthrow create" + ChatColor.GREEN + " - " + ChatColor.BLUE + "create an arena!");
- p.sendMessage(ChatColor.GREEN + "/" + ChatColor.BLUE + "bowthrow remove <arena#>" + ChatColor.GREEN + " - " + ChatColor.BLUE + "remove <arena#>!");
- p.sendMessage(ChatColor.GREEN + "/" + ChatColor.BLUE + "bowthrow join <arena#>" + ChatColor.GREEN + " - " + ChatColor.BLUE + "join <arena#>!");
- p.sendMessage(ChatColor.GREEN + "/" + ChatColor.BLUE + "bowthrow leave" + ChatColor.GREEN + " - " + ChatColor.BLUE + "leave the arena!");
- p.sendMessage(ChatColor.GREEN + "/" + ChatColor.BLUE + "bowthrow list" + ChatColor.GREEN + " - " + ChatColor.BLUE + "lists all arenas!");
- p.sendMessage(ChatColor.GREEN + "/" + ChatColor.BLUE + "bowthrow reload" + ChatColor.GREEN + " - " + ChatColor.BLUE + "reloads the config!");
- return true;
- }
- else {
- p.sendMessage(ChatColor.RED + "You don't have permission!");
- return true;
- }
- }
- else if (args.length == 1) {
- if (args[0].equalsIgnoreCase("create")) {
- if (p.hasPermission("bowthrow.create")) {
- Location loc = p.getLocation();
- BT2ArenaManager.getManager().createBT2Arena(loc);
- p.sendMessage(ChatColor.BLUE + "Created a new arena!");
- return true;
- }
- else {
- p.sendMessage(ChatColor.RED + "You don't have permission!");
- return true;
- }
- }
- else if (args[0].equalsIgnoreCase("leave")) {
- if (p.hasPermission("bowthrow.leave")) {
- BT2ArenaManager.getManager().removePlayer(p);
- if (BT2ArenaManager.getManager().isInGame(p)) {
- p.sendMessage(ChatColor.RED + "You left the arena!");
- Bukkit.broadcastMessage(ChatColor.BLUE + p.getName() + ChatColor.RED +" left the BowThrow arena!");
- return true;
- }
- return true;
- }
- else {
- p.sendMessage(ChatColor.RED + "You don't have permission!");
- return true;
- }
- }
- else if (args[0].equalsIgnoreCase("list")) {
- if (p.hasPermission("bowthrow.list")) {
- p.sendMessage(ChatColor.GREEN + "Arenas: ");
- String arenas = this.getConfig().getIntegerList("BT2Arenas.BT2Arenas").toString();
- p.sendMessage(ChatColor.BLUE + arenas);
- return true;
- }
- else {
- p.sendMessage(ChatColor.RED + "You don't have permission!");
- return true;
- }
- }
- else if (args[0].equalsIgnoreCase("reload")) {
- if (p.hasPermission("bowthrow.reload")) {
- this.reloadConfig();
- p.sendMessage(ChatColor.GREEN + "BowThrow config reloaded!");
- return true;
- }
- else {
- p.sendMessage(ChatColor.RED + "You don't have permission!");
- return true;
- }
- }
- else {
- p.sendMessage(ChatColor.RED + "Invalid command!");
- return true;
- }
- }
- else if (args.length == 2) {
- if (args[0].equalsIgnoreCase("remove")) {
- if (p.hasPermission("bowthrow.remove")) {
- int numb = 0;
- try{
- numb = Integer.parseInt(args[1]);
- }catch(NumberFormatException e){
- p.sendMessage(ChatColor.RED + "Invalid arena ID");
- return true;
- }
- numb = Integer.parseInt(args[1]);
- if (BT2ArenaManager.getManager().getBT2Arena(numb) == null) {
- p.sendMessage(ChatColor.RED + "That arena is null (probably doesn't exist!)");
- return true;
- }
- BT2ArenaManager.getManager().removeBT2Arena(numb);
- List<Integer> l = this.getConfig().getIntegerList("BT2Arenas.BT2Arenas");
- l.remove(numb);
- this.getConfig().set("BT2Arenas.BT2Arenas", l);
- p.sendMessage(ChatColor.GREEN + "Arena " + numb + " was removed!");
- this.saveConfig();
- return true;
- }
- else {
- p.sendMessage(ChatColor.RED + "You don't have permission!");
- return true;
- }
- }
- else if (args[0].equalsIgnoreCase("join")) {
- if (p.hasPermission("bowthrow.join")) {
- int num = 0;
- try{
- num = Integer.parseInt(args[1]);
- }catch(NumberFormatException e){
- p.sendMessage(ChatColor.RED + "Invalid arena ID");
- return true;
- }
- BT2ArenaManager.getManager().addPlayer(p, num);
- return true;
- }
- else {
- p.sendMessage(ChatColor.RED + "You don't have permission!");
- return true;
- }
- }
- else {
- p.sendMessage(ChatColor.RED + "Invalid command!");
- return true;
- }
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement