Help me

Discussion in 'WIP and Development Status' started by Corndogoz, Jun 10, 2014.

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

    Corndogoz

    so my plugin for some reason always has the boolean start true, can someone please tell me why?
    Code:java
    1. /*
    2. * To change this license header, choose License Headers in Project Properties.
    3. * To change this template file, choose Tools | Templates
    4. * and open the template in the editor.
    5. */
    6. /*
    7.  * To change this license header, choose License Headers in Project Properties.
    8.  * To change this template file, choose Tools | Templates
    9.  * and open the template in the editor.
    10.  */
    11. package wizardsway;
    12.  
    13. import java.util.ArrayList;
    14. import java.util.HashMap;
    15. import java.util.Random;
    16. import java.util.UUID;
    17. import org.bukkit.Bukkit;
    18. import org.bukkit.ChatColor;
    19. import org.bukkit.Color;
    20. import org.bukkit.Location;
    21. import org.bukkit.Material;
    22. import org.bukkit.command.Command;
    23. import org.bukkit.command.CommandSender;
    24. import org.bukkit.entity.Player;
    25. import org.bukkit.inventory.ItemStack;
    26. import org.bukkit.inventory.meta.LeatherArmorMeta;
    27. import org.bukkit.plugin.java.JavaPlugin;
    28.  
    29. /**
    30.  *
    31.  * @author plankton
    32.  */
    33. public class WizardsWay extends JavaPlugin {
    34.  
    35. HashMap<String, Location> backlocation = new HashMap<String, Location>();
    36.  
    37. Random rand = new Random();
    38.  
    39. ArrayList<String> players = new ArrayList<String>();
    40. ArrayList<String> wizards = new ArrayList<String>();
    41.  
    42. boolean start = false;
    43.  
    44. public void onEnable() {
    45. new PlayerListener(this);
    46. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { //for the "plugin" variable, use "this" if you're running this from the main class
    47. public void run() {
    48. if (start = true && players.size() == 1) {
    49. start = false;
    50. for (String name : players) {
    51. Bukkit.getServer().broadcastMessage(ChatColor.DARK_PURPLE + "[Ww]" + ChatColor.YELLOW + name + " has won wizardsway!");
    52. players.remove(name);
    53. }
    54.  
    55. for (String name : wizards) {
    56. Player p = (Player) Bukkit.getServer().matchPlayer(name);
    57. p.getInventory().setHelmet(new ItemStack(Material.AIR));
    58. p.getInventory().setChestplate(new ItemStack(Material.AIR));
    59. p.getInventory().setLeggings(new ItemStack(Material.AIR));
    60. p.getInventory().setBoots(new ItemStack(Material.AIR));
    61. wizards.remove(p.getName());
    62. p.teleport(backlocation.get(p.getName()));
    63. }
    64. }
    65. }
    66. }, 0, 2); //The first number is the amount of ticks before the loop is started. And the second number is the number of ticks before it repeats. (there are usually ~20 ticks in a second)
    67.  
    68. }
    69.  
    70. public void onDisable() {
    71.  
    72. }
    73.  
    74. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    75. Player p = (Player) sender;
    76. if (cmd.getName().equalsIgnoreCase("ww")) {
    77. int length = args.length;
    78. if (length == 1) {
    79. if (args[0].equalsIgnoreCase("setspawn")) {
    80. getConfig().set("WizardsWay.Location", p.getLocation());
    81. saveConfig();
    82. Bukkit.broadcastMessage(ChatColor.DARK_PURPLE + "[Ww]" + ChatColor.YELLOW + "WizardsWay arena created, you may now use /ww join");
    83. }
    84. if (args[0].equalsIgnoreCase("join")) {
    85. if (start = false) {
    86. backlocation.put(p.getName(), p.getLocation());
    87. p.teleport((Location) getConfig().get("WizardsWay.Location"));
    88. int team = rand.nextInt(2);
    89. if (!players.contains(p.getName()) || !wizards.contains(p.getName())) {
    90. if (team == 0) {
    91. turnwizard(p);
    92. } else {
    93. players.add(p.getName());
    94. }
    95. } else {
    96. p.sendMessage(ChatColor.DARK_PURPLE + "[Ww]" + ChatColor.YELLOW + "You already joined the game");
    97. }
    98. } else {
    99. p.sendMessage(ChatColor.DARK_PURPLE + "[Ww]" + ChatColor.YELLOW + "Game already started");
    100. }
    101. }
    102. if (args[0].equalsIgnoreCase("start")) {
    103. if (wizards.size() > 0 && players.size() > 0) {
    104. for (String name : wizards) {
    105. Bukkit.getServer().getPlayer(name).getInventory().addItem(new ItemStack(Material.BLAZE_ROD));
    106. start = true;
    107. }
    108. } else {
    109. p.sendMessage(ChatColor.DARK_PURPLE + "[Ww]" + ChatColor.YELLOW + "Not enough players/wizards!");
    110. }
    111. }
    112. if (args[0].equalsIgnoreCase("leave")) {
    113. if (wizards.contains(p.getName()) || players.contains(p.getName())) {
    114. p.teleport(backlocation.get(p.getName()));
    115. if (wizards.contains(p.getName())) {
    116. wizards.remove(p.getName());
    117. } else if (players.contains(p.getName())) {
    118. players.remove(p.getName());
    119. }
    120. } else {
    121. p.sendMessage(ChatColor.DARK_PURPLE + "[Ww]" + ChatColor.YELLOW + "You are not in game!");
    122. }
    123. }
    124.  
    125. }
    126. }
    127. return false;
    128.  
    129. }
    130.  
    131. public void turnwizard(Player p) {
    132. ItemStack helm = new ItemStack(Material.LEATHER_HELMET);
    133. ItemStack chest = new ItemStack(Material.LEATHER_CHESTPLATE);
    134. ItemStack pants = new ItemStack(Material.LEATHER_LEGGINGS);
    135. ItemStack boots = new ItemStack(Material.LEATHER_BOOTS);
    136. LeatherArmorMeta hmeta = (LeatherArmorMeta) helm.getItemMeta();
    137. LeatherArmorMeta cmeta = (LeatherArmorMeta) chest.getItemMeta();
    138. LeatherArmorMeta pmeta = (LeatherArmorMeta) pants.getItemMeta();
    139. LeatherArmorMeta bmeta = (LeatherArmorMeta) boots.getItemMeta();
    140. hmeta.setColor(Color.YELLOW);
    141. cmeta.setColor(Color.PURPLE);
    142. pmeta.setColor(Color.YELLOW);
    143. bmeta.setColor(Color.PURPLE);
    144. helm.setItemMeta(hmeta);
    145. chest.setItemMeta(cmeta);
    146. pants.setItemMeta(pmeta);
    147. boots.setItemMeta(bmeta);
    148. p.getInventory().setHelmet(helm);
    149. p.getInventory().setChestplate(chest);
    150. p.getInventory().setLeggings(pants);
    151. p.getInventory().setBoots(boots);
    152. wizards.add(p.getName());
    153. }
    154. }
    155.  
    156.  
     
  2. Offline

    Necrodoom

  3. Offline

    Corndogoz

  4. Offline

    JaguarJo Retired Staff

    Locked. Dupe of http://forums.bukkit.org/threads/help-me.277856/

    Just a tip: if the edit option doesn't show your post when you hit it and everything is blank instead, then hit the "more options" button that is there after hitting "edit" to open up the full editor. That will make your post show up correctly and you can fix things from there.
     
Thread Status:
Not open for further replies.

Share This Page