Unresolved Compilation Problem

Discussion in 'Plugin Development' started by maxben34, Nov 4, 2013.

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

    maxben34

    I'm trying to make a plugin that uses command arguments (which is something I've never done before). When I run the server and perform the command ./song it gives me a Unresolved Compiliation Error on line 70... which happens to be a curly brace. Anybody know what's wrong?

    Thanks in advance.

    The code:

    Code:java
    1. package me.maxben34.music;
    2.  
    3. import java.util.ArrayList;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.Location;
    8. import org.bukkit.Material;
    9. import org.bukkit.World;
    10. import org.bukkit.command.Command;
    11. import org.bukkit.command.CommandSender;
    12. import org.bukkit.entity.Player;
    13. import org.bukkit.event.EventHandler;
    14. import org.bukkit.event.Listener;
    15. import org.bukkit.event.player.PlayerJoinEvent;
    16. import org.bukkit.event.player.PlayerQuitEvent;
    17. import org.bukkit.plugin.java.JavaPlugin;
    18.  
    19. public class music extends JavaPlugin implements Listener{
    20. ArrayList <Player> song1 = new ArrayList <Player>();
    21. ArrayList <Player> song2 = new ArrayList <Player>();
    22. ArrayList <Player> song3 = new ArrayList <Player>();
    23. ArrayList <Player> song4 = new ArrayList <Player>();
    24. ArrayList <Player> song5 = new ArrayList <Player>();
    25. ArrayList <Player> song6 = new ArrayList <Player>();
    26. ArrayList<Player> cooldown = new ArrayList <Player>();
    27.  
    28. public void onEnable() {
    29. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    30. voteStart();
    31. }
    32.  
    33. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    34. if(!(sender instanceof Player)){
    35. return true;
    36. }
    37. final Player p = (Player) sender;
    38. if (cmd.getName().equalsIgnoreCase("song")) {
    39. if (args.length == 0) {
    40. p.sendMessage(ChatColor.LIGHT_PURPLE + "Possible song choices are: ");
    41. p.sendMessage(ChatColor.LIGHT_PURPLE + "Song 1: /song sail");
    42. p.sendMessage(ChatColor.LIGHT_PURPLE + "Song 2: /song zelda");
    43. p.sendMessage(ChatColor.LIGHT_PURPLE + "Song 3: /song thriftshop");
    44. p.sendMessage(ChatColor.LIGHT_PURPLE + "Song 4: /song none");
    45. return true;
    46. }
    47. }
    48. if(args.length == 1){
    49. if(args[0].equalsIgnoreCase("sail")){
    50. if(cooldown.contains(p)){
    51. p.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "It is not time for you to vote!");
    52. return true;
    53. }
    54.  
    55. song1.add(p);
    56. cooldown.add(p);
    57. return true;
    58. }
    59. }
    60. if(args.length == 1){
    61. if(args[0].equalsIgnoreCase("zelda")){
    62. if(cooldown.contains(p)){
    63. p.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "It is not time for you to vote!");
    64. return true;
    65. }
    66. song2.add(p);
    67. cooldown.add(p);
    68. return true;
    69. }
    70. }
    71. if(args.length == 1){
    72. if(args[0].equalsIgnoreCase("thriftshop")){
    73. if(cooldown.contains(p)){
    74. p.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "It is not time for you to vote!");
    75. return true;
    76. }
    77. song3.add(p);
    78. cooldown.add(p);
    79. return true;
    80. }
    81. }
    82. if(args.length == 1){
    83. if(args[0].equalsIgnoreCase("none")){
    84. if(cooldown.contains(p)){
    85. p.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "It is not time for you to vote!");
    86. return true;
    87. }
    88. song4.add(p);
    89. cooldown.add(p);
    90. return true;
    91. }
    92. }
    93. return true;
    94. }
    95.  
    96. public void SongPick() {
    97. for (Player p : Bukkit.getServer().getOnlinePlayers()) {
    98. p.sendMessage(ChatColor.LIGHT_PURPLE + "Possible song choices are: ");
    99. p.sendMessage(ChatColor.LIGHT_PURPLE + "Song 1: /song sail");
    100. p.sendMessage(ChatColor.LIGHT_PURPLE + "Song 2: /song zelda");
    101. p.sendMessage(ChatColor.LIGHT_PURPLE + "Song 3: /song thriftshop");
    102. p.sendMessage(ChatColor.LIGHT_PURPLE + "Song 4: /song none");
    103. }
    104. }
    105.  
    106. @EventHandler
    107. public void onPlayerLeave(PlayerQuitEvent e) {
    108. Player p = e.getPlayer();
    109. cooldown.remove(p);
    110. }
    111.  
    112. @EventHandler
    113. public void onPlayerJoin(PlayerJoinEvent e) {
    114. Player p = e.getPlayer();
    115. cooldown.add(p);
    116. }
    117.  
    118. public void voteStart(){
    119. Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    120. public void run(){
    121. Bukkit.getServer().broadcastMessage(ChatColor.AQUA + "" + ChatColor.BOLD + "A new song vote is being offered! Type /song to vote!");
    122. SongPick();
    123. voteEnd();
    124. stopSong();
    125. for(Player p : Bukkit.getOnlinePlayers()){
    126. cooldown.remove(p);
    127. song1.remove(p);
    128. song2.remove(p);
    129. song3.remove(p);
    130. song4.remove(p);
    131. }
    132. }
    133. }, 1);
    134. }
    135. public void voteEnd(){
    136. World w = Bukkit.getWorld("world");
    137. double sx1 = -1;
    138. double sy1 = 67;
    139. double sz1 = 9;
    140. double sx2 = 0;
    141. double sx3 = 2;
    142.  
    143. final Location s1 = new Location(w,sx1,sy1,sz1);
    144. final Location s2 = new Location(w,sx2,sy1,sz1);
    145. final Location s3 = new Location(w,sx3,sy1,sz1);
    146. Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    147. public void run(){
    148. if(song1.size() > song2.size() && song1.size() > song3.size() && song1.size() > song4.size()){
    149. Bukkit.getServer().broadcastMessage(ChatColor.GREEN + ""+ ChatColor.BOLD + "Sail by Awolnation has won the vote with " + song1.size() + "votes!");
    150. Bukkit.getServer().broadcastMessage(ChatColor.BLUE + "Playing Sail!");
    151. s1.getBlock().setType(Material.REDSTONE_BLOCK);
    152. song1End();
    153. }
    154. if(song2.size() > song1.size() && song2.size() > song3.size() && song2.size() > song4.size()){
    155. Bukkit.getServer().broadcastMessage(ChatColor.GREEN + ""+ ChatColor.BOLD + "The Zelda Theme song has won the vote with " + song2.size() + "votes!");
    156. Bukkit.getServer().broadcastMessage(ChatColor.BLUE + "Playing Zelda Themesong");
    157. s2.getBlock().setType(Material.REDSTONE_BLOCK);
    158. song2End();
    159. }
    160. if(song3.size() > song1.size() && song3.size() > song2.size() && song3.size() > song4.size()){
    161. Bukkit.getServer().broadcastMessage(ChatColor.GREEN + ""+ ChatColor.BOLD + "Thrift Shop by Macklemore has won the vote with " + song3.size() + "votes!");
    162. Bukkit.getServer().broadcastMessage(ChatColor.BLUE + "Playing ThriftShop");
    163. s3.getBlock().setType(Material.REDSTONE_BLOCK);
    164. song3End();
    165. }
    166. if(song4.size() > song1.size() && song4.size() > song2.size() && song4.size() > song3.size()){
    167. Bukkit.getServer().broadcastMessage(ChatColor.GREEN + ""+ ChatColor.BOLD + "No song has won the vote with " + song4.size() + "votes!");
    168. song4End();
    169. }
    170. }
    171. }, 20*31);
    172. }
    173. public void stopSong(){
    174. World w = Bukkit.getWorld("world");
    175. double sx1 = -1;
    176. double sy1 = 67;
    177. double sz1 = 9;
    178. double sx2 = 0;
    179. double sx3 = 2;
    180.  
    181. final Location s1 = new Location(w,sx1,sy1,sz1);
    182. final Location s2 = new Location(w,sx2,sy1,sz1);
    183. final Location s3 = new Location(w,sx3,sy1,sz1);
    184. Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    185. public void run(){
    186. if(song1.size() > song2.size() && song1.size() > song3.size() && song1.size() > song4.size()){
    187.  
    188. s1.getBlock().setType(Material.AIR);
    189. }
    190. if(song2.size() > song1.size() && song2.size() > song3.size() && song2.size() > song4.size()){
    191.  
    192. s2.getBlock().setType(Material.AIR);
    193. }
    194. if(song3.size() > song1.size() && song3.size() > song2.size() && song3.size() > song4.size()){
    195.  
    196. s3.getBlock().setType(Material.AIR);
    197. }
    198. }
    199. }, 20*32);
    200. }
    201.  
    202. public void song1End(){
    203. Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    204. public void run(){
    205. if(song1.size() > song2.size() && song1.size() > song3.size() && song1.size() > song4.size()){
    206. voteStart();
    207. }
    208. }
    209. }, 180+45*20);
    210. }
    211. public void song2End(){
    212. Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    213. public void run(){
    214. if(song2.size() > song1.size() && song2.size() > song3.size() && song2.size() > song4.size()){
    215. voteStart();
    216. }
    217. }
    218. }, 45*20);
    219. }
    220. public void song3End(){
    221. Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    222. public void run(){
    223. if(song3.size() > song2.size() && song3.size() > song1.size() && song3.size() > song4.size()){
    224. voteStart();
    225. }
    226. }
    227. }, 80*20);
    228. }
    229. public void song4End(){
    230. Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    231. public void run(){
    232. if(song4.size() > song2.size() && song4.size() > song3.size() && song4.size() > song1.size()){
    233. voteStart();
    234. }
    235. }
    236. }, 120*20);
    237. }
    238. }
     
  2. Offline

    Blah1

    Why do you have 3 "if args.length == 1"? Put all of those in just one args.length == 1
     
  3. Quite a peculiar problem.

    I would first try condensing the code as Blah1 suggested. Although it probably won't fix the bug, it'll make reading the code a bit easier.

    Out of curiosity, does the problem go away if you get rid of the "return true" lines in each of the different song blocks?
     
  4. Offline

    maxben34

    Blah1 Someguyfromcrowd I listened to what both of you said and it's still not working. I thought the problem may have been related the fact that I was writing it with saros with a friend, but I ended the session and exported and the problem still occurred.

    It may be due to the fact that there is a red exclamation point on my project folder in my package explorer.
     

  5. Ooh, yes, that's probably the issue. Sounds like you may be missing an external library. Double-check that you have the Bukkit .jar file selected.

    Do you use Eclipse? If so, I can probably explain things in more detail.
     
    maxben34 likes this.
  6. Offline

    maxben34

    I did some research and found that the red exclamation point might have to do with the build path, and surely enough... when my friend used saros to make the plugin with me, he put his own craftbukkit jar in the build path but since I don't have the exact craftbukkit jar that he imported, so it returned an error.
     
Thread Status:
Not open for further replies.

Share This Page