1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package me.Spiritwo.silktouch;

import java.util.ArrayList;
import java.util.logging.Logger;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

public class SilkTouch extends JavaPlugin
{

  public Logger log = Logger.getLogger("Minecraft");
  
  public ArrayList<String> activePlayers = new ArrayList<String>();
  
  public void onEnable()
  {
    PluginManager manager = this.getServer().getPluginManager();
    
    manager.registerEvents(new SilkTouchListeners(this), this);
    
        this.log.info("| ========================================== |");
    this.log.info("| * MACHISILK VERSION 1.1                    |");
    this.log.info("| *                                          |");
    this.log.info("| * Silk touch made easy.                    |");
    this.log.info("| *                                          |");
    this.log.info("| * Built by: Spiritwo & MachiDev            |");
    this.log.info("| * Copyright MachiDev 2012                  |");
    this.log.info("| ========================================== |");
  }
  
  public void onDisable()
  {

  }

  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
  {
    if(sender instanceof Player)
    {
      Player player = (Player) sender;
      String playerName = player.getName();
      
      if (cmd.getName().equalsIgnoreCase("silkon"))
      {
        if (args.length == 0)
        {
          if (player.hasPermission("MachiSilk.silktoggle") || player.isOp())
          {
            if (this.activePlayers.contains(playerName))
            {
              player.sendMessage(ChatColor.RED + "Silk Touch mode is already activated.");
                    System.out.println("1");
              return true;
            }
            
            this.activePlayers.add(playerName);
                  System.out.println("1");
            player.sendMessage(ChatColor.GREEN + "Silk Touch mode enabled. " + ChatColor.DARK_AQUA + "\nType " + ChatColor.YELLOW + "/silkoff" + ChatColor.DARK_AQUA + " to disable silk touch mode.");
            return true;
          }
          else
          {
                  System.out.println("1");
                  player.sendMessage(ChatColor.RED + "You do not have permission for this command.");
                  return true;
              }
        }
      }
        
      if (cmd.getName().equalsIgnoreCase("silkoff"))
      {
        if (args.length == 0)
        {
          if (player.hasPermission("MachiSilk.silktoggle") || player.isOp())
          {
            if (!this.activePlayers.contains(playerName))
            {
              player.sendMessage(ChatColor.RED + "Silk Touch mode isn't activated.");
              return true;
            }
            
            this.activePlayers.remove(playerName);
            player.sendMessage(ChatColor.GREEN + "Silk Touch mode disabled.");
            return true;
          }
          else
          {
            player.sendMessage(ChatColor.RED + "You do not have permission for this command.");
            return true;
          }
        }
      }
    }
    else
    {
      log.info("This command is only executable in-game");
      return true;
    }
      
  return false;
  }
}