Help with my plugin

Discussion in 'Plugin Development' started by spookyDHD, Jan 15, 2014.

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

    spookyDHD

    Can you help on my plugin?



    this is the class:

    Code:java
    1. package me.Ricardo.ClanZ;
    2.  
    3. /**
    4. * Created by Ricardo on 1/15/14.
    5. */
    6. import java.util.ArrayList;
    7.  
    8. import org.bukkit.Bukkit;
    9. import org.bukkit.ChatColor;
    10. import org.bukkit.DyeColor;
    11. import org.bukkit.GameMode;
    12. import org.bukkit.Location;
    13. import org.bukkit.Material;
    14. import org.bukkit.configuration.ConfigurationSection;
    15. import org.bukkit.entity.Player;
    16. import org.bukkit.inventory.ItemStack;
    17. import org.bukkit.material.Wool;
    18. import org.bukkit.scoreboard.Objective;
    19. import org.bukkit.scoreboard.Score;
    20. import org.bukkit.scoreboard.Scoreboard;
    21.  
    22.  
    23. public class Arena {
    24.  
    25. private int id;
    26. private boolean started = false;
    27. private boolean cd = false;
    28. private Location redspawn, bluespawn, blackspawn, purplespawn;
    29. private ArrayList<PlayerData> players = new ArrayList<PlayerData>();
    30.  
    31. private Scoreboard sb;
    32. private Objective o;
    33. private Score red, blue;
    34.  
    35. public Arena(int id) {
    36. this.id = id;
    37.  
    38. ConfigurationSection conf = SettingsManager.getInstance().get(id + "");
    39.  
    40. this.redspawn = getLocation(conf.getConfigurationSection("redspawn"));
    41. this.bluespawn = getLocation(conf.getConfigurationSection("bluespawn"));
    42.  
    43. sb = Bukkit.getServer().getScoreboardManager().getNewScoreboard();
    44. o = sb.registerNewObjective("Team Scores", "dummy");
    45. red = o.getScore(Bukkit.getServer().getOfflinePlayer(ChatColor.RED + "Red"));
    46. blue = o.getScore(Bukkit.getServer().getOfflinePlayer(ChatColor.BLUE + "Blue"));
    47. }
    48.  
    49. private Location getLocation(ConfigurationSection path) {
    50. return new Location(
    51. Bukkit.getServer().getWorld(path.getString("world")),
    52. path.getDouble("x"),
    53. path.getDouble("y"),
    54. path.getDouble("z")
    55. );
    56. }
    57.  
    58. public int getID() {
    59. return id;
    60. }
    61.  
    62. public boolean isStarted() {
    63. return started;
    64. }
    65.  
    66. public void setStarted(boolean started) {
    67. this.started = started;
    68. }
    69.  
    70. public Location getSpawn(ArenaManager.Team team) {
    71. switch(team) {
    72. case RED: return redspawn;
    73. case BLUE: return bluespawn;
    74. case BLACK: return blackspawn;
    75. case PURPLE: return purplespawn;
    76. default: return null;
    77. }
    78. }
    79.  
    80. public ArenaManager.Team getTeam(Player p) {
    81. return getData(p).getTeam();
    82. }
    83.  
    84. public void addPlayer(Player p) {
    85. //players.add(new PlayerData(p.getName(), getTeamWithLessPlayers(), p.getInventory().getContents(), p.getInventory().getArmorContents(), p.getLocation()));
    86. players.add(new PlayerData p.getName(), getTeamWithLessPlayers(),p.getInventory().getContents(), p.getInventory().getArmorContents(), p.getLocation()));
    87.  
    88. p.getInventory().clear();
    89. p.getInventory().addItem(new ItemStack(Material.SNOW_BALL, 1));
    90. p.getInventory().setHelmet(new Wool(DyeColor.valueOf(getData(p).getTeam().toString())).toItemStack(1));
    91. // Could add colored armor.
    92.  
    93. p.teleport(getSpawn(getData(p).getTeam()));
    94.  
    95. p.setScoreboard(sb);
    96.  
    97. p.setGameMode(GameMode.SURVIVAL);
    98. p.setFlying(false);
    99.  
    100. MessageManager.getInstance().info(p, "You have joined arena " + getID() + " and are on the " + ChatColor.valueOf(getData(p).getTeam().toString()) + getData(p).getTeam().toString().toLowerCase() + ChatColor.YELLOW + " team!");
    101.  
    102. if (players.size() >= 2 && !cd) start();
    103. }
    104.  
    105. public void removePlayer(Player p, boolean lost) {
    106. PlayerData pd = getData(p);
    107.  
    108. p.getInventory().clear();
    109. for (ItemStack i : pd.getContents()) if (i != null) p.getInventory().addItem(i);
    110. p.getInventory().setArmorContents(pd.getArmorContents());
    111.  
    112. p.teleport(pd.getLocation());
    113.  
    114. p.setScoreboard(null);
    115.  
    116. players.remove(pd);
    117.  
    118. if (lost) {
    119. MessageManager.getInstance().info(p, "You lost the game.");
    120. msg(p.getName() + " lost the game.");
    121. }
    122. }
    123.  
    124. public void start() {
    125. cd = true;
    126. msg("Game starting in 30 seconds!");
    127. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SettingsManager.getInstance().getPlugin(), new Runnable() {
    128. public void run() {
    129. Arena.this.started = true;
    130. Arena.this.cd = false;
    131. msg("Good luck!");
    132. }
    133. }, 30 * 20);
    134. }
    135.  
    136. public void stop(Player winner) {
    137. msg(winner != null ? winner.getName() + " won the game!" : "The game was ended.");
    138. for (PlayerData pd : players) {
    139. Player p = Bukkit.getServer().getPlayer(pd.getPlayerName());
    140. removePlayer(p, true);
    141. }
    142. }
    143.  
    144. public void addDeath(Player p) {
    145. ArenaManager.Team t = getTeam(p);
    146. if (t == ArenaManager.Team.RED) blue.setScore(blue.getScore() + 1);
    147. else red.setScore(red.getScore() + 1);
    148. }
    149.  
    150. private void msg(String msg) {
    151. for (PlayerData pd : players) {
    152. Player p = Bukkit.getServer().getPlayer(pd.getPlayerName());
    153. MessageManager.getInstance().info(p, msg);
    154. }
    155. }
    156.  
    157. private ArenaManager.Team getTeamWithLessPlayers() {
    158. int red = 0, blue = 0;
    159. for (PlayerData pd : players) {
    160. if (pd.getTeam() == ArenaManager.Team.RED) red++;
    161. else blue++;
    162. }
    163. if (red > blue) return ArenaManager.Team.BLUE;
    164. else return ArenaManager.Team.RED;
    165. }
    166.  
    167. public boolean containsPlayer(Player p) {
    168. return getData(p) != null;
    169. }
    170.  
    171. private PlayerData getData(Player p) {
    172. for (PlayerData pd : players) {
    173. if (pd.getPlayerName().equalsIgnoreCase(p.getName())) return pd;
    174. }
    175. return null;
    176. }
    177. }




    and the error on line 86:

    Code:java
    1. players.add(new PlayerData p.getName(), getTeamWithLessPlayers(),p.getInventory().getContents(), p.getInventory().getArmorContents(), p.getLocation()));
     
  2. Offline

    Stealth2800

    And the error is? Although that line seems to have invalid syntax.
    Code:java
    1. players.add(new PlayerData(p.getName(), getTeamWithLessPlayers(), p.getInventory().getContents(), p.getInventory().getArmorContents(), p.getLocation()));

    is a fixed version of it.
     
Thread Status:
Not open for further replies.

Share This Page