Will this run?

Discussion in 'Plugin Development' started by TaiSmoove, Jun 27, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    TaiSmoove

    Code:java
    1. package me.taismoove.lists;
    2.  
    3. import java.util.ArrayList;
    4. import java.util.List;
    5. import java.util.logging.Logger;
    6.  
    7. import me.taismoove.main.Main;
    8.  
    9. import org.bukkit.ChatColor;
    10. import org.bukkit.GameMode;
    11. import org.bukkit.Location;
    12. import org.bukkit.Material;
    13. import org.bukkit.command.Command;
    14. import org.bukkit.command.CommandExecutor;
    15. import org.bukkit.command.CommandSender;
    16. import org.bukkit.entity.Player;
    17. import org.bukkit.inventory.ItemStack;
    18. import org.bukkit.inventory.PlayerInventory;
    19. import org.bukkit.plugin.PluginDescriptionFile;
    20.  
    21. public class CodeCommandExecutor implements CommandExecutor {
    22. public static Main plugin;
    23.  
    24. Logger l = Logger.getLogger("CodeCraft_Plugin");
    25.  
    26. public final String cPrefix = ChatColor.RED + "[" + ChatColor.BLUE
    27. + "CodeCraft" + ChatColor.RED + "]";
    28. public final String noPerms = cPrefix + " " + ChatColor.BLUE
    29. + "Insufficient permissions!";
    30.  
    31. public int GM = 0;
    32. public int ID = 0;
    33. public int Amount = 0;
    34. public boolean isEnabled = false;
    35.  
    36. List<Player> enabledUsers = new ArrayList<Player>();
    37.  
    38. public CodeCommandExecutor(Main main) {
    39. main = plugin;
    40. }
    41.  
    42. public boolean onCommand(CommandSender se, Command cmd, String cmdl,
    43. String[] args) {
    44. Player pl = (Player) se;
    45. if (cmd.getName().equalsIgnoreCase("gme")) {
    46. if (se.hasPermission(new Permissions().gme)) {
    47. if (se instanceof Player) {
    48. if (args.length == 0) {
    49. se.sendMessage(cPrefix + " " + ChatColor.BLUE
    50. + "[0 (Survival):1 (Creative):2 (Adventure)]");
    51. } else if (args.length == 1) {
    52. GM = Integer.parseInt(args[0]);
    53. pl.setGameMode(GameMode.getByValue(GM));
    54. pl.sendMessage(cPrefix + " " + ChatColor.BLUE
    55. + "You are now: " + ChatColor.RED + GM);
    56. } else if (args.length == 2) {
    57. Player target = pl.getServer().getPlayer(args[0]);
    58. target.setGameMode(GameMode.getByValue(GM));
    59. target.sendMessage(cPrefix + " " + ChatColor.BLUE
    60. + "You are now: " + ChatColor.RED + GM);
    61. } else if (args.length > 2) {
    62. se.sendMessage(cPrefix + " " + ChatColor.BLUE
    63. + "Usage: /gme [0:1:2] <Player>");
    64. }
    65. } else {
    66. PluginDescriptionFile p = plugin.getDescription();
    67. l.info("[" + p.getName() + "]" + " "
    68. + "You must be a player to perform that command!");
    69. }
    70. } else {
    71. se.sendMessage(noPerms);
    72. }
    73. }
    74. if (cmd.getName().equalsIgnoreCase("fme")) {
    75. if (se.hasPermission(new Permissions().fme)) {
    76. if (se instanceof Player) {
    77. if (args.length == 0) {
    78. if (!isEnabled) {
    79. isEnabled = true;
    80. enabledUsers.add(pl);
    81. pl.setAllowFlight(true);
    82. pl.sendMessage(cPrefix + " " + ChatColor.BLUE
    83. + "Flight has been enabled!");
    84. } else {
    85. isEnabled = false;
    86. enabledUsers.remove(pl);
    87. pl.setAllowFlight(false);
    88. pl.sendMessage(cPrefix + " " + ChatColor.BLUE
    89. + "Flight has been disabled!");
    90. }
    91. } else if (args.length == 1) {
    92. Player target = pl.getServer().getPlayer(args[0]);
    93. if (!isEnabled) {
    94. isEnabled = true;
    95. enabledUsers.add(target);
    96. target.setAllowFlight(true);
    97. target.sendMessage(cPrefix + " " + ChatColor.BLUE
    98. + "Flight has been enabled!");
    99. } else {
    100. isEnabled = false;
    101. enabledUsers.remove(target);
    102. target.setAllowFlight(false);
    103. target.sendMessage(cPrefix + " " + ChatColor.BLUE
    104. + "Flight has been disabled!");
    105. }
    106. }
    107. } else {
    108. PluginDescriptionFile pdf = plugin.getDescription();
    109. l.info("[" + pdf.getName() + "]" + " "
    110. + "You must bea player to perform that command!");
    111. }
    112. } else {
    113. se.sendMessage(noPerms);
    114. }
    115. }
    116. if (cmd.getName().equalsIgnoreCase("t")
    117. || cmd.getName().equalsIgnoreCase("tele")) {
    118. if (se.hasPermission(new Permissions().tele)) {
    119. if (se instanceof Player) {
    120. if (args.length == 0) {
    121. se.sendMessage(cPrefix + " " + ChatColor.BLUE
    122. + "Usage: /t <Player> or /t <Player> <Player>");
    123. } else if (args.length == 1) {
    124. Player target = pl.getServer().getPlayer(args[0]);
    125. Location targetLocation = target.getLocation();
    126. pl.teleport(targetLocation);
    127. se.sendMessage(cPrefix + " " + ChatColor.BLUE
    128. + "Whoosh!");
    129. } else if (args.length == 2) {
    130. Player target1 = pl.getServer().getPlayer(args[1]);
    131. Player target2 = pl.getServer().getPlayer(args[1]);
    132. Location target2Location = target2.getLocation();
    133. target1.teleport(target2Location);
    134. target1.sendMessage(cPrefix + " " + ChatColor.BLUE
    135. + "Whoosh!");
    136. }
    137. } else {
    138. PluginDescriptionFile p = plugin.getDescription();
    139. l.info("[" + p.getName() + "]" + " "
    140. + "You must be a player to perfrom this command!");
    141. }
    142. } else {
    143. se.sendMessage(noPerms);
    144. }
    145. }
    146. if (cmd.getName().equalsIgnoreCase("c")
    147. || cmd.getName().equalsIgnoreCase("cookie")) {
    148. if (se.hasPermission(new Permissions().cookie)) {
    149. if (se instanceof Player) {
    150. if (args.length == 0) {
    151. se.sendMessage(cPrefix + " " + ChatColor.BLUE
    152. + "Usage: /c <Amount> or /c <Amount> <Player>");
    153. } else if (args.length == 1) {
    154. Amount = Integer.parseInt(args[0]);
    155. ItemStack cookie = new ItemStack(Material.COOKIE,
    156. Amount);
    157. ItemStack milk = new ItemStack(Material.MILK_BUCKET, 1);
    158. PlayerInventory pi = pl.getInventory();
    159. pi.addItem(cookie);
    160. pi.addItem(milk);
    161. pl.sendMessage(cPrefix + " " + ChatColor.BLUE
    162. + "Here is your Milk and Cookie(s)!");
    163. } else if (args.length == 2) {
    164. ItemStack cookie = new ItemStack(Material.COOKIE,
    165. Amount);
    166. ItemStack milk = new ItemStack(Material.MILK_BUCKET, 1);
    167. Player target = pl.getServer().getPlayer(args[1]);
    168. PlayerInventory ti = target.getInventory();
    169. ti.addItem(cookie);
    170. ti.addItem(milk);
    171. target.sendMessage(cPrefix + " " + ChatColor.BLUE
    172. + "Here is Milk and Cookie(s)!");
    173. }
    174. } else {
    175. PluginDescriptionFile p = plugin.getDescription();
    176. l.info("[" + p.getName() + "]" + " "
    177. + "You must be a player to perform this command!");
    178. }
    179. } else {
    180. se.sendMessage(noPerms);
    181. }
    182. }
    183. if (cmd.getName().equalsIgnoreCase("co")
    184. || cmd.getName().equalsIgnoreCase("coords")) {
    185. if (se.hasPermission(new Permissions().coords)) {
    186. if (se instanceof Player) {
    187. if (args.length == 0) {
    188. int x = pl.getLocation().getBlockX();
    189. int y = pl.getLocation().getBlockY();
    190. int z = pl.getLocation().getBlockZ();
    191. pl.sendMessage(cPrefix + " " + ChatColor.BLUE
    192. + "You coords are: " + ChatColor.RED + "["
    193. + ChatColor.YELLOW + "X: " + ChatColor.BLUE + x
    194. + ChatColor.RED + ": " + ChatColor.YELLOW
    195. + "Y: " + ChatColor.BLUE + y + ChatColor.RED
    196. + ": " + ChatColor.YELLOW + "Z: "
    197. + ChatColor.BLUE + z);
    198. } else if (args.length == 1) {
    199. Player target = pl.getServer().getPlayer(args[0]);
    200. int xt = target.getLocation().getBlockX();
    201. int yt = target.getLocation().getBlockY();
    202. int zt = target.getLocation().getBlockZ();
    203. pl.sendMessage(cPrefix + " " + ChatColor.BLUE
    204. + target.getName() + "'s coords are: "
    205. + ChatColor.RED + "[" + ChatColor.YELLOW
    206. + "X: " + ChatColor.BLUE + xt + ChatColor.RED
    207. + ": " + ChatColor.YELLOW + "Y: "
    208. + ChatColor.BLUE + yt + ChatColor.RED + ": "
    209. + ChatColor.YELLOW + "Z: " + ChatColor.BLUE
    210. + zt);
    211. }
    212. } else {
    213. PluginDescriptionFile p = plugin.getDescription();
    214. l.info("[" + p.getName() + "]" + " "
    215. + "You must be a player to perform this command!");
    216. }
    217. } else {
    218. se.sendMessage(noPerms);
    219. }
    220. }
    221. return false;
    222. }
    223. }


    Just wondering : )
     
  2. Offline

    Rocoty

    You've got the code. Can't you test?
     
Thread Status:
Not open for further replies.

Share This Page