How to bypass cooldown?

Discussion in 'Plugin Development' started by Sean0402, Jul 24, 2014.

Thread Status:
Not open for further replies.
  1. How do I bypass cooldown time for my code?

    Code:java
    1. if (cooldown.contains(p)) {
    2. p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "PvPKits" + ChatColor.GRAY + "]" + ChatColor.RED + " You Cannot Get Another Kit At This Time!");
    3. return true;
     
  2. Offline

    _Filip

    Sean0402 Honestly if you can't figure this out you aren't fit to develop Bukkit plugins... Yet.
    Buy a book or two about Java, then once you figure out how everything works, you will gain a much better understanding of how to develop Bukkit plugins.

    Youtube has some good tutorials on Java, for example, search thenewboston.
     
  3. TheSpherret that really didn't help.. I'm still learning java?
     
  4. Offline

    _Filip

    Sean0402 Do you understand what if statements do?

    Also what code did you try so far.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  5. Offline

    stormneo7

  6. TheSpherret I'm coding a kitpvp kinda server and trying to bypass the cooldown this is main part of the code:
    Code:java
    1. if (cmd.getName().equalsIgnoreCase("pvp")) {
    2. p.setHealth(20);
    3. p.setFireTicks(0);
    4. p.setFoodLevel(20);
    5. if (cooldown.contains(p)) {
    6. p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "PvPKits" + ChatColor.GRAY + "]" + ChatColor.RED + " You Cannot Get Another Kit At This Time!");
    7. return true;
    8. }
    9. EconomyResponse r = econ.withdrawPlayer(p.getName(), 10);
    10. if (r.transactionSuccess()) {
    11. ItemStack sword = new ItemStack(Material.DIAMOND_SWORD, 1);
    12. ItemStack bow = new ItemStack(Material.BOW, 1);
    13. ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
    14. ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
    15. ItemStack leggings = new ItemStack(Material.DIAMOND_LEGGINGS);
    16. ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
    17. ItemStack item = new ItemStack(Material.POTION, 1);
    18.  
    19. sword.addEnchantment(Enchantment.DAMAGE_ALL, 5);
    20. sword.addEnchantment(Enchantment.FIRE_ASPECT, 2);
    21. ItemMeta swordmeta = sword.getItemMeta();
    22. swordmeta.setDisplayName(ChatColor.RED + "PainBringer!");
    23. List<String> lore = new ArrayList<String>();
    24. lore.add(ChatColor.GREEN + "This Amazing Sword");
    25. lore.add(ChatColor.GREEN + "Can Bring Pain!");
    26. swordmeta.setLore(lore);
    27. sword.setItemMeta(swordmeta);
    28. pi.addItem(sword);
    29. bow.addEnchantment(Enchantment.ARROW_FIRE, 1);
    30. bow.addEnchantment(Enchantment.ARROW_DAMAGE, 2);
    31. bow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
    32. pi.addItem(bow);
    33. helmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    34. chestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    35. leggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    36. boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    37.  
    38. pi.setArmorContents(null);
    39. pi.setHelmet(helmet);
    40. pi.setChestplate(chestplate);
    41. pi.setLeggings(leggings);
    42. pi.setBoots(boots);
    43. pi.addItem(new ItemStack(Material.ENDER_PEARL, 16));
    44. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    45. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    46. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    47. Potion potion = new Potion(PotionType.FIRE_RESISTANCE);
    48. pi.addItem(potion.toItemStack(1));
    49. Potion potion1 = new Potion(PotionType.STRENGTH);
    50. pi.addItem(potion1.toItemStack(1));
    51. Potion potion2 = new Potion(PotionType.SPEED);
    52. pi.addItem(potion2.toItemStack(1));
    53. pi.addItem(new ItemStack(Material.ARROW, 1));
    54. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    55. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    56. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    57. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    58. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    59. Potion pot = new Potion(1);
    60. pot.setType(PotionType.WEAKNESS);
    61. pot.setHasExtendedDuration(true);
    62. pot.setSplash(true);
    63. pot.apply(item);
    64. p.getInventory().addItem(item);
    65. Potion pot1 = new Potion(1);
    66. pot1.setType(PotionType.POISON);
    67. pot1.setHasExtendedDuration(true);
    68. pot1.setSplash(true);
    69. pot1.apply(item);
    70. p.getInventory().addItem(item);
    71. Potion pot2 = new Potion(1);
    72. pot2.setType(PotionType.POISON);
    73. pot2.setHasExtendedDuration(true);
    74. pot2.setSplash(true);
    75. pot2.apply(item);
    76. p.getInventory().addItem(item);
    77. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    78. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    79. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    80. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    81. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    82. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    83. Potion pot3 = new Potion(1);
    84. pot3.setType(PotionType.WEAKNESS);
    85. pot3.setHasExtendedDuration(true);
    86. pot3.setSplash(true);
    87. pot3.apply(item);
    88. p.getInventory().addItem(item);
    89. Potion pot4 = new Potion(1);
    90. pot4.setType(PotionType.WEAKNESS);
    91. pot4.setHasExtendedDuration(true);
    92. pot4.setSplash(true);
    93. pot4.apply(item);
    94. p.getInventory().addItem(item);
    95. Potion pot5 = new Potion(1);
    96. pot5.setType(PotionType.WEAKNESS);
    97. pot5.setHasExtendedDuration(true);
    98. pot5.setSplash(true);
    99. pot5.apply(item);
    100. p.getInventory().addItem(item);
    101. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    102. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    103. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    104. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    105. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    106. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    107. Potion potion21 = new Potion(PotionType.STRENGTH);
    108. pi.addItem(potion21.toItemStack(1));
    109. Potion potion211 = new Potion(PotionType.REGEN);
    110. pi.addItem(potion211.toItemStack(1));
    111. Potion potion2111 = new Potion(PotionType.SPEED);
    112. pi.addItem(potion2111.toItemStack(1));
    113. //p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 10000000, 0));
    114. //p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 100000000, 0));
    115. p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "Kits" + ChatColor.GRAY + "]" + ChatColor.RED + " You Got Your Kit!");
    116. cooldown.add(p);
    117. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
    118. public void run() {
    119. cooldown.remove(p);
    120. }
    121. }, 12000);
    122. return true;
    123. }
    124. else {
    125. p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "Kits" + ChatColor.GRAY + "]" + ChatColor.RED + " Please Wait 10 Minutes For This Kit!");
    126. return true;
    127. }
    128. }
     
  7. Offline

    stormneo7

    What do you mean bypass?...
     
  8. stormneo7 So it removes the oooldown I tried doing this:
    Code:java
    1. } if(!(p.hasPermission("cooldown.bypass"))) {
    2. cooldown.remove(p);
    3. }


    Didn't work
     
  9. Offline

    _Filip

    Sean0402 Just LOOK AT YOUR CODE.
    You inverted the boolean that returns true if the player has the permission to bypass the cooldown.......
     
  10. TheSpherret can you write the code I need to do? Possibly?
     
  11. Offline

    _Filip

    Sean0402 No? I can help you figure it out, I can't write the code for you.

    You're just lazy.
     
    AmateurChairSitter likes this.
  12. Offline

    stormneo7

    oh ma gaud
    Please read your code (Hint: Line 7) then think about what you should do.
    You're on the right track but... (Hint: Line 7) something's stopping you.
     
  13. Offline

    hankered

    This again.

    Don't store actual players, store their names/uuid.
     
  14. Offline

    stormneo7

    That isn't the problem though.
    At line 7, he preformed a return true; in the .contains(p); bracket.

    After doing so, he did his
    check.

    He stopped the code BEFORE checking for the cooldown.
     
  15. Offline

    hankered

  16. stormneo7 TheSpherret I removed "return true;" but now i'm stuck..

    Code:java
    1. if (cooldown.contains(p)) {
    2. p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "PvPKits" + ChatColor.GRAY + "]" + ChatColor.RED + " You Cannot Get Another Kit At This Time!");
    3. } else {
    4. if(!(p.hasPermission("cooldown.bypass"))) {
    5. cooldown.remove(p);
    6. }
     
  17. Offline

    stormneo7

    Read your code out loud. Tell me if it makes sense.
     
  18. Offline

    hankered

    ..

    Yeah, if the player doesn't have the permission, remove him from the cooldown.

    Remove the '!' and it should work.
     
  19. hankered Still don't work..
    Code:java
    1. if (cmd.getName().equalsIgnoreCase("pvp")) {
    2. p.setHealth(20);
    3. p.setFireTicks(0);
    4. p.setFoodLevel(20);
    5. if (cooldown.contains(p)) {
    6. p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "PvPKits" + ChatColor.GRAY + "]" + ChatColor.RED + " You Cannot Get Another Kit At This Time!");
    7. } else {
    8. if((p.hasPermission("cooldown.bypass"))) {
    9. cooldown.remove(p);
    10. }
     
  20. Offline

    hankered

    Sean0402
    Why don't you just not add the player to the list if they have permission?
    like
    if player has permission (cooldown perm) return;
     
  21. Offline

    DannyDog

    Sean0402
    Your code doesn't make sense.
    You're checking if they're in the list, and if they aren't check if they have the permission and then remove them from the list.
    But they aren't in the list in the first place so you will get an error.
     
  22. hankered DannyDog I cannot return true becuause I have my /pvp code below it and it stops it from working

    Code:java
    1. if (cmd.getName().equalsIgnoreCase("pvp")) {
    2. p.setHealth(20);
    3. p.setFireTicks(0);
    4. p.setFoodLevel(20);
    5. if (cooldown.contains(p)) {
    6. p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "PvPKits" + ChatColor.GRAY + "]" + ChatColor.RED + " You Cannot Get Another Kit At This Time!");
    7. } else {
    8. if((p.hasPermission("cooldown.bypass"))) {
    9.  
    10. }
    11. EconomyResponse r = econ.withdrawPlayer(p.getName(), 10);
    12. if (r.transactionSuccess()) {
    13. ItemStack sword = new ItemStack(Material.DIAMOND_SWORD, 1);
    14. ItemStack bow = new ItemStack(Material.BOW, 1);
    15. ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
    16. ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
    17. ItemStack leggings = new ItemStack(Material.DIAMOND_LEGGINGS);
    18. ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
    19. ItemStack item = new ItemStack(Material.POTION, 1);
    20.  
    21. sword.addEnchantment(Enchantment.DAMAGE_ALL, 5);
    22. sword.addEnchantment(Enchantment.FIRE_ASPECT, 2);
    23. ItemMeta swordmeta = sword.getItemMeta();
    24. swordmeta.setDisplayName(ChatColor.RED + "PainBringer!");
    25. List<String> lore = new ArrayList<String>();
    26. lore.add(ChatColor.GREEN + "This Amazing Sword");
    27. lore.add(ChatColor.GREEN + "Can Bring Pain!");
    28. swordmeta.setLore(lore);
    29. sword.setItemMeta(swordmeta);
    30. pi.addItem(sword);
    31. bow.addEnchantment(Enchantment.ARROW_FIRE, 1);
    32. bow.addEnchantment(Enchantment.ARROW_DAMAGE, 2);
    33. bow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
    34. pi.addItem(bow);
    35. helmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    36. chestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    37. leggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    38. boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    39.  
    40. pi.setArmorContents(null);
    41. pi.setHelmet(helmet);
    42. pi.setChestplate(chestplate);
    43. pi.setLeggings(leggings);
    44. pi.setBoots(boots);
    45. pi.addItem(new ItemStack(Material.ENDER_PEARL, 16));
    46. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    47. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    48. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    49. Potion potion = new Potion(PotionType.FIRE_RESISTANCE);
    50. pi.addItem(potion.toItemStack(1));
    51. Potion potion1 = new Potion(PotionType.STRENGTH);
    52. pi.addItem(potion1.toItemStack(1));
    53. Potion potion2 = new Potion(PotionType.SPEED);
    54. pi.addItem(potion2.toItemStack(1));
    55. pi.addItem(new ItemStack(Material.ARROW, 1));
    56. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    57. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    58. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    59. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    60. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    61. Potion pot = new Potion(1);
    62. pot.setType(PotionType.WEAKNESS);
    63. pot.setHasExtendedDuration(true);
    64. pot.setSplash(true);
    65. pot.apply(item);
    66. p.getInventory().addItem(item);
    67. Potion pot1 = new Potion(1);
    68. pot1.setType(PotionType.POISON);
    69. pot1.setHasExtendedDuration(true);
    70. pot1.setSplash(true);
    71. pot1.apply(item);
    72. p.getInventory().addItem(item);
    73. Potion pot2 = new Potion(1);
    74. pot2.setType(PotionType.POISON);
    75. pot2.setHasExtendedDuration(true);
    76. pot2.setSplash(true);
    77. pot2.apply(item);
    78. p.getInventory().addItem(item);
    79. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    80. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    81. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    82. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    83. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    84. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    85. Potion pot3 = new Potion(1);
    86. pot3.setType(PotionType.WEAKNESS);
    87. pot3.setHasExtendedDuration(true);
    88. pot3.setSplash(true);
    89. pot3.apply(item);
    90. p.getInventory().addItem(item);
    91. Potion pot4 = new Potion(1);
    92. pot4.setType(PotionType.WEAKNESS);
    93. pot4.setHasExtendedDuration(true);
    94. pot4.setSplash(true);
    95. pot4.apply(item);
    96. p.getInventory().addItem(item);
    97. Potion pot5 = new Potion(1);
    98. pot5.setType(PotionType.WEAKNESS);
    99. pot5.setHasExtendedDuration(true);
    100. pot5.setSplash(true);
    101. pot5.apply(item);
    102. p.getInventory().addItem(item);
    103. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    104. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    105. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    106. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    107. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    108. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    109. Potion potion21 = new Potion(PotionType.STRENGTH);
    110. pi.addItem(potion21.toItemStack(1));
    111. Potion potion211 = new Potion(PotionType.REGEN);
    112. pi.addItem(potion211.toItemStack(1));
    113. Potion potion2111 = new Potion(PotionType.SPEED);
    114. pi.addItem(potion2111.toItemStack(1));
    115. //p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 10000000, 0));
    116. //p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 100000000, 0));
    117. p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "Kits" + ChatColor.GRAY + "]" + ChatColor.RED + " You Got Your Kit!");
    118. cooldown.add(p);
    119. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
    120. public void run() {
    121. cooldown.remove(p);
    122. }
    123. }, 12000);
    124. return true;
    125. }
    126. else {
    127. p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "Kits" + ChatColor.GRAY + "]" + ChatColor.RED + " Please Wait 10 Minutes For This Kit!");
    128. return true;
    129. }
    130. }
    131. }
    132. return false;
    133. }
    134. }
     
  23. Offline

    hankered

    Don't add them to the cooldown if they have the permission.

    Then remove the check for the permission, and after the command stuff (cmd.get) check if they are in the cooldown, else do whatever.
     
  24. hankered can you explain what i'm editing, sorry for my little knowledge
     
  25. Offline

    hankered

    after the command do

    if(cooldown.contains(p))
    {
    //do whatever
    }
    else
    {
    //not in cooldown
    }
     
  26. Why dont you check if the player can bypass befor you add him to the array?
    Line 118: cooldown.add(p);
    Like this:
    Code:java
    1. if(p.hasPermission("cooldown.bypass")){
    2. return;
    3. }else{
    4. cooldown.add(p);
    5. }
    6.  
     
  27. @TheLegendOffPabi hankered This is my class now :
    Code:java
    1. package me.sean0402.kit;
    2.  
    3. import java.util.ArrayList;
    4. import java.util.HashMap;
    5. import java.util.List;
    6. import java.util.Random;
    7.  
    8. import net.milkbowl.vault.economy.Economy;
    9. import net.milkbowl.vault.economy.EconomyResponse;
    10. import net.minecraft.server.v1_7_R4.NBTTagList;
    11.  
    12. import org.bukkit.Bukkit;
    13. import org.bukkit.ChatColor;
    14. import org.bukkit.Material;
    15. import org.bukkit.Sound;
    16. import org.bukkit.command.Command;
    17. import org.bukkit.command.CommandSender;
    18. import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
    19. import org.bukkit.enchantments.Enchantment;
    20. import org.bukkit.entity.Player;
    21. import org.bukkit.event.EventHandler;
    22. import org.bukkit.event.Listener;
    23. import org.bukkit.event.block.Action;
    24. import org.bukkit.event.player.PlayerInteractEvent;
    25. import org.bukkit.event.player.PlayerJoinEvent;
    26. import org.bukkit.inventory.ItemStack;
    27. import org.bukkit.inventory.PlayerInventory;
    28. import org.bukkit.inventory.meta.ItemMeta;
    29. import org.bukkit.plugin.RegisteredServiceProvider;
    30. import org.bukkit.plugin.java.JavaPlugin;
    31. import org.bukkit.potion.Potion;
    32. import org.bukkit.potion.PotionEffect;
    33. import org.bukkit.potion.PotionEffectType;
    34. import org.bukkit.potion.PotionType;
    35. import org.bukkit.scheduler.BukkitRunnable;
    36.  
    37. public class Kit extends JavaPlugin implements Listener {
    38.  
    39. public static Economy econ = null;
    40.  
    41. public void onDisable() {
    42. Bukkit.getServer().getLogger()
    43. .info(ChatColor.AQUA + "[Kits] Disabling Kits By Sean0402");
    44. }
    45.  
    46. public void onEnable() {
    47. if (!setupEconomy()) {
    48. Bukkit.getServer().getPluginManager()
    49. .registerEvents(new NoFoodLoss(), this);
    50. Bukkit.getServer().getLogger()
    51. .info(ChatColor.AQUA + "[Kits] Loading Kits By Sean0402");
    52. getLogger().severe(
    53. ChatColor.RED
    54. + "Disabled due to no Vault dependency found!");
    55. getServer().getPluginManager().disablePlugin(this);
    56. return;
    57. }
    58. }
    59.  
    60. private boolean setupEconomy() {
    61. if (getServer().getPluginManager().getPlugin("Vault") == null) {
    62. return false;
    63. }
    64. RegisteredServiceProvider<Economy> rsp = getServer()
    65. .getServicesManager().getRegistration(Economy.class);
    66. if (rsp == null) {
    67. return false;
    68. }
    69. econ = rsp.getProvider();
    70. return econ != null;
    71. }
    72.  
    73. ArrayList<Player> cooldown = new ArrayList<Player>();
    74.  
    75. public boolean onCommand(CommandSender sender, Command cmd,
    76. String commandLabel, String[] args) {
    77. if (!(sender instanceof Player)) {
    78. sender.sendMessage(ChatColor.RED + "Only players can get kits!");
    79. return true;
    80. }
    81.  
    82. final Player p = (Player) sender;
    83. PlayerInventory pi = p.getInventory();
    84.  
    85. if (cmd.getName().equalsIgnoreCase("pvp")) {
    86. p.setHealth(20);
    87. p.setFireTicks(0);
    88. p.setFoodLevel(20);
    89. if (cooldown.contains(p)) {
    90. p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "PvPKits"
    91. + ChatColor.GRAY + "]" + ChatColor.RED
    92. + " You Must Wait Seconds!");
    93. } else {
    94. if ((p.hasPermission("cooldown.bypass"))) {
    95.  
    96. } else {
    97. cooldown.add(p);
    98. }
    99. EconomyResponse r = econ.withdrawPlayer(p.getName(), 10);
    100. if (r.transactionSuccess()) {
    101. ItemStack sword = new ItemStack(Material.DIAMOND_SWORD, 1);
    102. ItemStack bow = new ItemStack(Material.BOW, 1);
    103. ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
    104. ItemStack chestplate = new ItemStack(
    105. Material.DIAMOND_CHESTPLATE);
    106. ItemStack leggings = new ItemStack(
    107. Material.DIAMOND_LEGGINGS);
    108. ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
    109. ItemStack item = new ItemStack(Material.POTION, 1);
    110.  
    111. sword.addEnchantment(Enchantment.DAMAGE_ALL, 5);
    112. sword.addEnchantment(Enchantment.FIRE_ASPECT, 2);
    113. ItemMeta swordmeta = sword.getItemMeta();
    114. swordmeta.setDisplayName(ChatColor.RED + "PainBringer!");
    115. List<String> lore = new ArrayList<String>();
    116. lore.add(ChatColor.GREEN + "This Amazing Sword");
    117. lore.add(ChatColor.GREEN + "Can Bring Pain!");
    118. swordmeta.setLore(lore);
    119. sword.setItemMeta(swordmeta);
    120. pi.addItem(sword);
    121. bow.addEnchantment(Enchantment.ARROW_FIRE, 1);
    122. bow.addEnchantment(Enchantment.ARROW_DAMAGE, 2);
    123. bow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
    124. pi.addItem(bow);
    125. helmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,
    126. 4);
    127. chestplate.addEnchantment(
    128. Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    129. leggings.addEnchantment(
    130. Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    131. boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,
    132. 4);
    133.  
    134. pi.setArmorContents(null);
    135. pi.setHelmet(helmet);
    136. pi.setChestplate(chestplate);
    137. pi.setLeggings(leggings);
    138. pi.setBoots(boots);
    139. pi.addItem(new ItemStack(Material.ENDER_PEARL, 16));
    140. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    141. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    142. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    143. Potion potion = new Potion(PotionType.FIRE_RESISTANCE);
    144. pi.addItem(potion.toItemStack(1));
    145. Potion potion1 = new Potion(PotionType.STRENGTH);
    146. pi.addItem(potion1.toItemStack(1));
    147. Potion potion2 = new Potion(PotionType.SPEED);
    148. pi.addItem(potion2.toItemStack(1));
    149. pi.addItem(new ItemStack(Material.ARROW, 1));
    150. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    151. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    152. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    153. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    154. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    155. Potion pot = new Potion(1);
    156. pot.setType(PotionType.WEAKNESS);
    157. pot.setHasExtendedDuration(true);
    158. pot.setSplash(true);
    159. pot.apply(item);
    160. p.getInventory().addItem(item);
    161. Potion pot1 = new Potion(1);
    162. pot1.setType(PotionType.POISON);
    163. pot1.setHasExtendedDuration(true);
    164. pot1.setSplash(true);
    165. pot1.apply(item);
    166. p.getInventory().addItem(item);
    167. Potion pot2 = new Potion(1);
    168. pot2.setType(PotionType.POISON);
    169. pot2.setHasExtendedDuration(true);
    170. pot2.setSplash(true);
    171. pot2.apply(item);
    172. p.getInventory().addItem(item);
    173. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    174. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    175. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    176. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    177. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    178. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    179. Potion pot3 = new Potion(1);
    180. pot3.setType(PotionType.WEAKNESS);
    181. pot3.setHasExtendedDuration(true);
    182. pot3.setSplash(true);
    183. pot3.apply(item);
    184. p.getInventory().addItem(item);
    185. Potion pot4 = new Potion(1);
    186. pot4.setType(PotionType.WEAKNESS);
    187. pot4.setHasExtendedDuration(true);
    188. pot4.setSplash(true);
    189. pot4.apply(item);
    190. p.getInventory().addItem(item);
    191. Potion pot5 = new Potion(1);
    192. pot5.setType(PotionType.WEAKNESS);
    193. pot5.setHasExtendedDuration(true);
    194. pot5.setSplash(true);
    195. pot5.apply(item);
    196. p.getInventory().addItem(item);
    197. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    198. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    199. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    200. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    201. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    202. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    203. Potion potion21 = new Potion(PotionType.STRENGTH);
    204. pi.addItem(potion21.toItemStack(1));
    205. Potion potion211 = new Potion(PotionType.REGEN);
    206. pi.addItem(potion211.toItemStack(1));
    207. Potion potion2111 = new Potion(PotionType.SPEED);
    208. pi.addItem(potion2111.toItemStack(1));
    209. // p.addPotionEffect(new
    210. // PotionEffect(PotionEffectType.REGENERATION, 10000000,
    211. // 0));
    212. // p.addPotionEffect(new
    213. // PotionEffect(PotionEffectType.SPEED, 100000000, 0));
    214. p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD
    215. + "Kits" + ChatColor.GRAY + "]" + ChatColor.RED
    216. + " You Got Your Kit!");
    217. cooldown.add(p);
    218. Bukkit.getServer().getScheduler()
    219. .scheduleSyncDelayedTask(this, new Runnable() {
    220. public void run() {
    221. cooldown.remove(p);
    222. }
    223. }, 12000);
    224. return true;
    225. } else {
    226. p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD
    227. + "Kits" + ChatColor.GRAY + "]" + ChatColor.RED
    228. + " Please Wait 10 Minutes For This Kit!");
    229. return true;
    230. }
    231. }
    232. }
    233. return false;
    234. }
    235. }

    But I am just not sure how to make them not have the cooldown if they don't have the permission..
     
  28. I did only change what i did post uarlier.
    If it doesnt work im sorry.
    If i did copy or paste something wrong im sorry its 2 o clock in the night (My time) and i had a long day

    Code:java
    1. package me.sean0402.kit;
    2.  
    3. import java.util.ArrayList;
    4. import java.util.HashMap;
    5. import java.util.List;
    6. import java.util.Random;
    7.  
    8. import net.milkbowl.vault.economy.Economy;
    9. import net.milkbowl.vault.economy.EconomyResponse;
    10. import net.minecraft.server.v1_7_R4.NBTTagList;
    11.  
    12. import org.bukkit.Bukkit;
    13. import org.bukkit.ChatColor;
    14. import org.bukkit.Material;
    15. import org.bukkit.Sound;
    16. import org.bukkit.command.Command;
    17. import org.bukkit.command.CommandSender;
    18. import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
    19. import org.bukkit.enchantments.Enchantment;
    20. import org.bukkit.entity.Player;
    21. import org.bukkit.event.EventHandler;
    22. import org.bukkit.event.Listener;
    23. import org.bukkit.event.block.Action;
    24. import org.bukkit.event.player.PlayerInteractEvent;
    25. import org.bukkit.event.player.PlayerJoinEvent;
    26. import org.bukkit.inventory.ItemStack;
    27. import org.bukkit.inventory.PlayerInventory;
    28. import org.bukkit.inventory.meta.ItemMeta;
    29. import org.bukkit.plugin.RegisteredServiceProvider;
    30. import org.bukkit.plugin.java.JavaPlugin;
    31. import org.bukkit.potion.Potion;
    32. import org.bukkit.potion.PotionEffect;
    33. import org.bukkit.potion.PotionEffectType;
    34. import org.bukkit.potion.PotionType;
    35. import org.bukkit.scheduler.BukkitRunnable;
    36.  
    37. public class Kit extends JavaPlugin implements Listener {
    38.  
    39. public static Economy econ = null;
    40.  
    41. public void onDisable() {
    42. Bukkit.getServer().getLogger()
    43. .info(ChatColor.AQUA + "[Kits] Disabling Kits By Sean0402");
    44. }
    45.  
    46. public void onEnable() {
    47. if (!setupEconomy()) {
    48. Bukkit.getServer().getPluginManager()
    49. .registerEvents(new NoFoodLoss(), this);
    50. Bukkit.getServer().getLogger()
    51. .info(ChatColor.AQUA + "[Kits] Loading Kits By Sean0402");
    52. getLogger().severe(
    53. ChatColor.RED
    54. + "Disabled due to no Vault dependency found!");
    55. getServer().getPluginManager().disablePlugin(this);
    56. return;
    57. }
    58. }
    59.  
    60. private boolean setupEconomy() {
    61. if (getServer().getPluginManager().getPlugin("Vault") == null) {
    62. return false;
    63. }
    64. RegisteredServiceProvider<Economy> rsp = getServer()
    65. .getServicesManager().getRegistration(Economy.class);
    66. if (rsp == null) {
    67. return false;
    68. }
    69. econ = rsp.getProvider();
    70. return econ != null;
    71. }
    72.  
    73. ArrayList<Player> cooldown = new ArrayList<Player>();
    74.  
    75. public boolean onCommand(CommandSender sender, Command cmd,
    76. String commandLabel, String[] args) {
    77. if (!(sender instanceof Player)) {
    78. sender.sendMessage(ChatColor.RED + "Only players can get kits!");
    79. return true;
    80. }
    81.  
    82. final Player p = (Player) sender;
    83. PlayerInventory pi = p.getInventory();
    84.  
    85. if (cmd.getName().equalsIgnoreCase("pvp")) {
    86. p.setHealth(20);
    87. p.setFireTicks(0);
    88. p.setFoodLevel(20);
    89. if (cooldown.contains(p)) {
    90. p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "PvPKits"
    91. + ChatColor.GRAY + "]" + ChatColor.RED
    92. + " You Must Wait Seconds!");
    93. } else {
    94. EconomyResponse r = econ.withdrawPlayer(p.getName(), 10);
    95. if (r.transactionSuccess()) {
    96. ItemStack sword = new ItemStack(Material.DIAMOND_SWORD, 1);
    97. ItemStack bow = new ItemStack(Material.BOW, 1);
    98. ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
    99. ItemStack chestplate = new ItemStack(
    100. Material.DIAMOND_CHESTPLATE);
    101. ItemStack leggings = new ItemStack(
    102. Material.DIAMOND_LEGGINGS);
    103. ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
    104. ItemStack item = new ItemStack(Material.POTION, 1);
    105.  
    106. sword.addEnchantment(Enchantment.DAMAGE_ALL, 5);
    107. sword.addEnchantment(Enchantment.FIRE_ASPECT, 2);
    108. ItemMeta swordmeta = sword.getItemMeta();
    109. swordmeta.setDisplayName(ChatColor.RED + "PainBringer!");
    110. List<String> lore = new ArrayList<String>();
    111. lore.add(ChatColor.GREEN + "This Amazing Sword");
    112. lore.add(ChatColor.GREEN + "Can Bring Pain!");
    113. swordmeta.setLore(lore);
    114. sword.setItemMeta(swordmeta);
    115. pi.addItem(sword);
    116. bow.addEnchantment(Enchantment.ARROW_FIRE, 1);
    117. bow.addEnchantment(Enchantment.ARROW_DAMAGE, 2);
    118. bow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
    119. pi.addItem(bow);
    120. helmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,
    121. 4);
    122. chestplate.addEnchantment(
    123. Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    124. leggings.addEnchantment(
    125. Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    126. boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,
    127. 4);
    128.  
    129. pi.setArmorContents(null);
    130. pi.setHelmet(helmet);
    131. pi.setChestplate(chestplate);
    132. pi.setLeggings(leggings);
    133. pi.setBoots(boots);
    134. pi.addItem(new ItemStack(Material.ENDER_PEARL, 16));
    135. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    136. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    137. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    138. Potion potion = new Potion(PotionType.FIRE_RESISTANCE);
    139. pi.addItem(potion.toItemStack(1));
    140. Potion potion1 = new Potion(PotionType.STRENGTH);
    141. pi.addItem(potion1.toItemStack(1));
    142. Potion potion2 = new Potion(PotionType.SPEED);
    143. pi.addItem(potion2.toItemStack(1));
    144. pi.addItem(new ItemStack(Material.ARROW, 1));
    145. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    146. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    147. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    148. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    149. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    150. Potion pot = new Potion(1);
    151. pot.setType(PotionType.WEAKNESS);
    152. pot.setHasExtendedDuration(true);
    153. pot.setSplash(true);
    154. pot.apply(item);
    155. p.getInventory().addItem(item);
    156. Potion pot1 = new Potion(1);
    157. pot1.setType(PotionType.POISON);
    158. pot1.setHasExtendedDuration(true);
    159. pot1.setSplash(true);
    160. pot1.apply(item);
    161. p.getInventory().addItem(item);
    162. Potion pot2 = new Potion(1);
    163. pot2.setType(PotionType.POISON);
    164. pot2.setHasExtendedDuration(true);
    165. pot2.setSplash(true);
    166. pot2.apply(item);
    167. p.getInventory().addItem(item);
    168. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    169. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    170. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    171. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    172. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    173. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    174. Potion pot3 = new Potion(1);
    175. pot3.setType(PotionType.WEAKNESS);
    176. pot3.setHasExtendedDuration(true);
    177. pot3.setSplash(true);
    178. pot3.apply(item);
    179. p.getInventory().addItem(item);
    180. Potion pot4 = new Potion(1);
    181. pot4.setType(PotionType.WEAKNESS);
    182. pot4.setHasExtendedDuration(true);
    183. pot4.setSplash(true);
    184. pot4.apply(item);
    185. p.getInventory().addItem(item);
    186. Potion pot5 = new Potion(1);
    187. pot5.setType(PotionType.WEAKNESS);
    188. pot5.setHasExtendedDuration(true);
    189. pot5.setSplash(true);
    190. pot5.apply(item);
    191. p.getInventory().addItem(item);
    192. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    193. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    194. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    195. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    196. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    197. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    198. Potion potion21 = new Potion(PotionType.STRENGTH);
    199. pi.addItem(potion21.toItemStack(1));
    200. Potion potion211 = new Potion(PotionType.REGEN);
    201. pi.addItem(potion211.toItemStack(1));
    202. Potion potion2111 = new Potion(PotionType.SPEED);
    203. pi.addItem(potion2111.toItemStack(1));
    204. // p.addPotionEffect(new
    205. // PotionEffect(PotionEffectType.REGENERATION, 10000000,
    206. // 0));
    207. // p.addPotionEffect(new
    208. // PotionEffect(PotionEffectType.SPEED, 100000000, 0));
    209. p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD
    210. + "Kits" + ChatColor.GRAY + "]" + ChatColor.RED
    211. + " You Got Your Kit!");
    212. if (!(p.hasPermission("cooldown.bypass"))) {
    213. cooldown.add(p);
    214.  
    215. Bukkit.getServer().getScheduler()
    216. .scheduleSyncDelayedTask(this, new Runnable() {
    217. public void run() {
    218. cooldown.remove(p);
    219. }
    220. }, 12000);
    221. return true;
    222. } else {
    223. return;
    224. }
    225. } else {
    226. p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD
    227. + "Kits" + ChatColor.GRAY + "]" + ChatColor.RED
    228. + " Please Wait 10 Minutes For This Kit!");
    229. return true;
    230. }
    231. }
    232. }
    233. return false;
    234. }
    235. }
     
  29. Sean0402 In the code i did put above your post.
    It says this:
    Code:java
    1. if (!(p.hasPermission("cooldown.bypass"))) {
    2. cooldown.add(p);
    3.  
    4. Bukkit.getServer().getScheduler()
    5. .scheduleSyncDelayedTask(this, new Runnable() {
    6. public void run() {
    7. cooldown.remove(p);
    8. }
    9. }, 12000);
    10. return true;
    11. } else {
    12. return;
    13. }

    In words:
    If the user does not have permission "cooldown.bypass"
    Then it will add him to the cooldown.
    But if the player has the permission then it wont add him.

    And please READ what people are saying.
    And try to use your brains.
    If someone says 'Just dont add them'
    Think, and look for something that dont add them.
     
Thread Status:
Not open for further replies.

Share This Page