Solved Canceling fall will not work, no matter how hard I try

Discussion in 'Plugin Development' started by sgavster, Nov 12, 2013.

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

    1Rogue

    What class is the arraylist stored in? How are you accessing this arraylist?


    No real need for it, an ArrayList works fine here.
     
  2. Offline

    sgavster

    jimbo8 - It was a couple hours, and it's the next day; I thought it'd be okay.
    1Rogue - It's in the same class, heres all my code(ignore the super bad horrible non-safe laggy code)

    PHP:
    package me.sgavster.QuadularMC.commands;
     
    import java.util.ArrayList;
     
    import me.sgavster.QuadularMC.QuadularMC;
     
    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Item;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDamageEvent;
    import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.util.Vector;
     
    public class 
    CommandG2P implements CommandExecutorListener
    {
     
        public 
    ArrayList<String= new ArrayList<String>();
     
        public 
    boolean onCommand(CommandSender senderCommand cmdString commandLabelString[] args)
        {
            if(
    cmd.getName().equalsIgnoreCase("g2p"))
            {
                if(
    sender instanceof Player)
                {
                    if(
    Math.random() < 0.50)
                    {
                        
    Player p = (Playersender;
                        
    Bukkit.broadcastMessage("§9 * §2" p.getName() + " §8pees");
                    }
                    else
                    {
                        
    Bukkit.getScheduler().runTaskTimer(QuadularMC.getInstance(), new Poop(), 0L0L);
                        final 
    Player p = (Playersender;
                        
    Bukkit.broadcastMessage("§9 * §2" p.getName() + " §9poops!");
                        
    QuadularMC.getInstance().poop.add(p.getName());
                        if(!
    f.contains(p.getName()))
                        {
                            
    f.add(p.getName().toLowerCase());
                            
    Bukkit.broadcastMessage("added");
                        }
                        
    Bukkit.getScheduler().scheduleSyncDelayedTask(QuadularMC.getInstance(), new Runnable()
                        {
                            public 
    void run()
                            {
                                
    p.getWorld().createExplosion(p.getLocation(), 0L);
                                
    p.getWorld().createExplosion(p.getLocation(), 0L);
                                
    p.getWorld().createExplosion(p.getLocation(), 0L);
                                
    p.getWorld().createExplosion(p.getLocation(), 0L);
                                
    Vector v p.getVelocity();
                                
    p.setVelocity(new Vector(v.getX(), v.getY() + 10v.getZ()));
                                
    QuadularMC.getInstance().poop.remove(p.getName());
                            }
                        }, 
    500L);
                    }
                }
            }
            return 
    false;
        }
     
        @
    EventHandler
        
    public void onFall(EntityDamageEvent e)
        {
            
    Bukkit.broadcastMessage("test");
            if(
    e.getEntity() instanceof Player)
            {
                
    Bukkit.broadcastMessage("test2");
                if(
    e.getCause() == DamageCause.FALL)
                {
                    
    Bukkit.broadcastMessage("test3");
                    
    Player p = (Playere.getEntity();
                    
    Bukkit.broadcastMessage("test45");
                    if(
    f.contains(p.getName().toLowerCase()))
                    {
                        
    Bukkit.broadcastMessage("test4");
                        
    f.remove(p.getName().toLowerCase());
                        
    Bukkit.broadcastMessage("test5");
                        
    e.setDamage(0);
                        
    Bukkit.broadcastMessage("test6");
                    }
                }
            }
        }
     
        private class 
    Poop implements Runnable
        
    {
            public 
    void run()
            {
                for(
    Player p Bukkit.getOnlinePlayers())
                {
                    if(
    QuadularMC.getInstance().poop.contains(p.getName()))
                    {
                        
    Location l = new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY() + 1p.getLocation().getZ());
                        
    Item e p.getWorld().dropItemNaturally(p.getLocation(), new ItemStack(Material.INK_SACK1, (short)3));
                        
    Item z p.getWorld().dropItemNaturally(l, new ItemStack(Material.INK_SACK1, (short)3));
                        
    e.setPickupDelay(100000);
                        
    z.setPickupDelay(100000);
                        
    z.setTicksLived(5500);
                        
    e.setTicksLived(5500);
                    }
                }
            }
        }
    }
    And btw, the '.toLowerCase()' was testing, I've tried it the other way too.
     
    jimbo8 likes this.
  3. Offline

    maxben34

    Did you see my post?
     
  4. Offline

    sgavster

    maxben34 Your way would be a bit too complex in my opinion..
    I think this is possible, I just don't know why it wont work.
     
  5. Offline

    1Rogue

    Are you executing the command before you fall?
     
  6. Offline

    xize

    I didn't fully read the topics but however I recommend to use a HashSet instead of a ArrayList just because people could add duplicates.

    heres how I do it:
    Code:
    public static HashSet<String> players = new HashSet<String>();
    @EventHandler
    public void fallTest(EntityDamageEvent e) {
        if(e.getCause() == DamageCause.FALL) {
                if(e.getEntity() instanceof Player) {
                    Player p = (Player) e.getEntity();
                    if(players.contains(p.getName())) {
                              e.setCanceled(true);
                              players.remove(p.getName());
                    }
                }
        }
    }
    
    your problem might lays on how you use the ArrayList though.
    if your ArrayList is in a other class than in the listener class you need to use static in all cases because if you instance it as myArrayClass array = new myArrayClass(); you are also recreate the ArrayList as empty.

    edit
    also if you won't want to use static you can use getters and setters in the same class where your ArrayList is in.
     
  7. Offline

    1Rogue


    1) They're in the same class
    2) You do not need static for anything within this.
    3) A hashset could be good but if the ArrayList isn't even working in the first place a hashset wouldn't improve it at all.
     
  8. Offline

    maxben34

    I think that damage causes are buggy when it comes to certain damages. I don't know if this is something you can control easily, which is why I said that using. A move event and getting the fall distance would probably work better for you.
     
  9. Offline

    sgavster

    xize *sigh* not that one that matters.. the 'poop' one is in a different class. Not f.

    1Rogue yes, I am see(ignore the crappy quality, I am too lazy to edit atm):


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

    1Rogue

    Code:java
    1. public class External implements Listener, CommandExecutor {
    2.  
    3. private final List<String> players;
    4. private final TestingPlugin plugin;
    5. private final List<String> extlist;
    6.  
    7. public External(TestingPlugin plugin) {
    8. this.plugin = plugin;
    9. this.players = new ArrayList();
    10. this.extlist = new ArrayList();
    11. }
    12.  
    13. @EventHandler
    14. public void onFall(EntityDamageEvent e) {
    15. Bukkit.broadcastMessage("test");
    16. if (e.getEntity() instanceof Player) {
    17. Bukkit.broadcastMessage("test2");
    18. if (e.getCause() == DamageCause.FALL) {
    19. Bukkit.broadcastMessage("test3");
    20. Player p = (Player) e.getEntity();
    21. if (this.players.contains(p.getName())) {
    22. Bukkit.broadcastMessage("test4");
    23. this.players.remove(p.getName());
    24. Bukkit.broadcastMessage("test5");
    25. e.setDamage(0);
    26. Bukkit.broadcastMessage("test6");
    27. }
    28. }
    29. }
    30. }
    31.  
    32. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    33. if (cmd.getName().equalsIgnoreCase("test")) {
    34. if (sender instanceof Player) {
    35. if (Math.random() < 0.50) {
    36. Bukkit.broadcastMessage("hit math random block!");
    37. } else {
    38. final Player p = (Player) sender;
    39. Bukkit.broadcastMessage("§9 * §2" + p.getName() + " §9poops!");
    40. this.extlist.add(p.getName());
    41. Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() {
    42. public void run() {
    43. p.getWorld().createExplosion(p.getLocation(), 0L);
    44. p.getWorld().createExplosion(p.getLocation(), 0L);
    45. p.getWorld().createExplosion(p.getLocation(), 0L);
    46. p.getWorld().createExplosion(p.getLocation(), 0L);
    47. Vector v = p.getVelocity();
    48. if (!players.contains(p.getName())) {
    49. players.add(p.getName());
    50. Bukkit.broadcastMessage("added");
    51. }
    52. p.setVelocity(new Vector(v.getX(), v.getY() + 10, v.getZ()));
    53. extlist.remove(p.getName());
    54. }
    55. }, 500L);
    56. }
    57. }
    58. }
    59. return false;
    60. }
    61.  
    62. }


    I just tested this, and it works. You are probably having issues since you are using a static getter for your main class instance.
     
  11. Offline

    sgavster

    1Rogue I just removed all QuadularMC.getInstance();..
    Code:java
    1. public class CommandG2P implements CommandExecutor, Listener
    2. {
    3.  
    4. private final List<String> f;
    5. private final ArrayList<String> s;
    6.  
    7. public static QuadularMC plugin;
    8. public CommandG2P(QuadularMC instance)
    9. {
    10. this.f = new ArrayList<String>();
    11. this.s = new ArrayList<String>();
    12. plugin = instance;
    13. }
    14.  
    15. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
    16. {
    17. if(cmd.getName().equalsIgnoreCase("g2p"))
    18. {
    19. if(sender instanceof Player)
    20. {
    21. if(Math.random() < 0.50)
    22. {
    23. Player p = (Player) sender;
    24. Bukkit.broadcastMessage("§9 * §2" + p.getName() + " §8pees");
    25. }
    26. else
    27. {
    28. Bukkit.getScheduler().runTaskTimer(plugin, new Poop(), 0L, 0L);
    29. final Player p = (Player) sender;
    30. Bukkit.broadcastMessage("§9 * §2" + p.getName() + " §9poops!");
    31. s.add(p.getName());
    32. if(!this.f.contains(p.getName()))
    33. {
    34. this.f.add(p.getName());
    35. Bukkit.broadcastMessage("added");
    36. }
    37. Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
    38. {
    39. public void run()
    40. {
    41. p.getWorld().createExplosion(p.getLocation(), 0L);
    42. p.getWorld().createExplosion(p.getLocation(), 0L);
    43. p.getWorld().createExplosion(p.getLocation(), 0L);
    44. p.getWorld().createExplosion(p.getLocation(), 0L);
    45. Vector v = p.getVelocity();
    46. p.setVelocity(new Vector(v.getX(), v.getY() + 10, v.getZ()));
    47. s.remove(p.getName());
    48. }
    49. }, 500L);
    50. }
    51. }
    52. }
    53. return false;
    54. }
    55.  
    56. @EventHandler
    57. public void onFall(EntityDamageEvent e)
    58. {
    59. Bukkit.broadcastMessage("test");
    60. if(e.getEntity() instanceof Player)
    61. {
    62. Bukkit.broadcastMessage("test2");
    63. if(e.getCause() == DamageCause.FALL)
    64. {
    65. Bukkit.broadcastMessage("test3");
    66. Player p = (Player) e.getEntity();
    67. Bukkit.broadcastMessage("test45");
    68. if(this.f.contains(p.getName()))
    69. {
    70. Bukkit.broadcastMessage("test4");
    71. this.f.remove(p.getName());
    72. Bukkit.broadcastMessage("test5");
    73. e.setDamage(0);
    74. Bukkit.broadcastMessage("test6");
    75. }
    76. }
    77. }
    78. }

    Still doesn't work. Any idea why?
     
  12. Offline

    1Rogue

    get. rid. of. the. static.

    You have no reason to be having a public static variable in there. make it private final. Also, how are you initializing this class?
     
  13. Offline

    sgavster

    1Rogue What is static? I Don't see it!
    and:
    Code:java
    1. package me.sgavster.QuadularMC;
    2.  
    3. import java.util.ArrayList;
    4. import java.util.Arrays;
    5. import java.util.List;
    6. import java.util.logging.Logger;
    7.  
    8. import me.sgavster.QuadularMC.classes.commands.CommandClass;
    9. import me.sgavster.QuadularMC.commands.CommandAdmin;
    10. import me.sgavster.QuadularMC.commands.CommandAdminChat;
    11. import me.sgavster.QuadularMC.commands.CommandAir;
    12. import me.sgavster.QuadularMC.commands.CommandAlert;
    13. import me.sgavster.QuadularMC.commands.CommandCMC;
    14. import me.sgavster.QuadularMC.commands.CommandCoal;
    15. import me.sgavster.QuadularMC.commands.CommandDanger;
    16. import me.sgavster.QuadularMC.commands.CommandFM;
    17. import me.sgavster.QuadularMC.commands.CommandG2P;
    18. import me.sgavster.QuadularMC.commands.CommandHead;
    19. import me.sgavster.QuadularMC.commands.CommandKA;
    20. import me.sgavster.QuadularMC.commands.CommandLore;
    21. import me.sgavster.QuadularMC.commands.CommandMIR;
    22. import me.sgavster.QuadularMC.commands.CommandName;
    23. import me.sgavster.QuadularMC.commands.CommandPoll;
    24. import me.sgavster.QuadularMC.commands.CommandQRL;
    25. import me.sgavster.QuadularMC.commands.CommandSet;
    26. import me.sgavster.QuadularMC.commands.CommandTalkas;
    27. import me.sgavster.QuadularMC.commands.CommandVanish;
    28. import me.sgavster.QuadularMC.commands.CommandVote;
    29. import me.sgavster.QuadularMC.commands.CommandWarn;
    30. import me.sgavster.QuadularMC.listeners.AdminChatListener;
    31. import me.sgavster.QuadularMC.listeners.AntiCreativePvPListener;
    32. import me.sgavster.QuadularMC.listeners.AutoCropListener;
    33. import me.sgavster.QuadularMC.listeners.AutoRespawnListener;
    34. import me.sgavster.QuadularMC.listeners.BlowdartListener;
    35. import me.sgavster.QuadularMC.listeners.ChatLayoutListener;
    36. import me.sgavster.QuadularMC.listeners.CommandSpyListener;
    37. import me.sgavster.QuadularMC.listeners.DefaultConfigListener;
    38. import me.sgavster.QuadularMC.listeners.GraveListener;
    39. import me.sgavster.QuadularMC.listeners.HeadshotListener;
    40. import me.sgavster.QuadularMC.listeners.HeatAxeListener;
    41. import me.sgavster.QuadularMC.listeners.HeatPickaxeListener;
    42. import me.sgavster.QuadularMC.listeners.HeatShovelListener;
    43. import me.sgavster.QuadularMC.listeners.HeatSwordListener;
    44. import me.sgavster.QuadularMC.listeners.JetPackListener;
    45. import me.sgavster.QuadularMC.listeners.JoinMessageListener;
    46. import me.sgavster.QuadularMC.listeners.LambChopSmeltListener;
    47. import me.sgavster.QuadularMC.listeners.MentionListener;
    48. import me.sgavster.QuadularMC.listeners.MobSpawnerLootHandler;
    49. import me.sgavster.QuadularMC.listeners.OptionsListener;
    50. import me.sgavster.QuadularMC.listeners.ParticleAndSoundListener;
    51. import me.sgavster.QuadularMC.listeners.PlayerVoteListener;
    52. import me.sgavster.QuadularMC.listeners.PublicChestListener;
    53. import me.sgavster.QuadularMC.listeners.QuitMessageListener;
    54. import me.sgavster.QuadularMC.listeners.RandomTPListener;
    55. import me.sgavster.QuadularMC.listeners.ScoreboardGUIListener;
    56. import me.sgavster.QuadularMC.listeners.SheepLambChopListener;
    57. import me.sgavster.QuadularMC.listeners.SpongeJumpListener;
    58. import me.sgavster.QuadularMC.listeners.TNTRemoveListener;
    59. import me.sgavster.QuadularMC.listeners.TabLayoutListener;
    60. import me.sgavster.QuadularMC.listeners.VoidSpawnTeleportListener;
    61. import me.sgavster.QuadularMC.runnables.ClearAll;
    62. import me.sgavster.QuadularMC.shop.ShopHandler;
    63.  
    64. import org.bukkit.Bukkit;
    65. import org.bukkit.ChatColor;
    66. import org.bukkit.Material;
    67. import org.bukkit.enchantments.Enchantment;
    68. import org.bukkit.event.HandlerList;
    69. import org.bukkit.inventory.FurnaceRecipe;
    70. import org.bukkit.inventory.Inventory;
    71. import org.bukkit.inventory.ItemStack;
    72. import org.bukkit.inventory.ShapedRecipe;
    73. import org.bukkit.inventory.ShapelessRecipe;
    74. import org.bukkit.inventory.meta.ItemMeta;
    75. import org.bukkit.plugin.PluginManager;
    76. import org.bukkit.plugin.java.JavaPlugin;
    77.  
    78. public class QuadularMC extends JavaPlugin
    79. {
    80. private static final Logger log = Logger.getLogger("Minecraft");
    81.  
    82. public ArrayList<String> dangercd = new ArrayList<String>();
    83. public ArrayList<String> tpnf = new ArrayList<String>();
    84. public ArrayList<String> poop = new ArrayList<String>();
    85.  
    86. public static Inventory hatInventory;
    87.  
    88. public static QuadularMC plugin;
    89. public static QuadularMC instance;
    90.  
    91. String prefix = "§3[§4Quadular§6MC§3]";
    92. String noperms = "§4You do not have permission to do this!";
    93.  
    94. ShapedRecipe blowDart = new ShapedRecipe(new ItemStack(blowDart())).shape(" S ", "S S", " S ").setIngredient('S', Material.STICK);
    95. ShapedRecipe QMCDEgg = new ShapedRecipe(new ItemStack(dragonEgg())).shape("EGE", "GDG", "EGE").setIngredient('D', Material.DIAMOND).setIngredient('G', Material.GOLD_BLOCK).setIngredient('E', Material.ENDER_PEARL);
    96. ShapedRecipe HeatPick = new ShapedRecipe(new ItemStack(heatPick())).shape("DLD", " B ", " B ").setIngredient('D', Material.DIAMOND).setIngredient('L', Material.LAVA_BUCKET).setIngredient('B', Material.BLAZE_ROD);
    97. ShapedRecipe HeatShovel = new ShapedRecipe(new ItemStack(heatShovel())).shape(" D ", " L ", " B ").setIngredient('D', Material.DIAMOND).setIngredient('L', Material.LAVA_BUCKET).setIngredient('B', Material.BLAZE_ROD);
    98. ShapedRecipe HeatAxe = new ShapedRecipe(new ItemStack(heatAxe())).shape("DL ", "DB ", " B ").setIngredient('D', Material.DIAMOND).setIngredient('L', Material.LAVA_BUCKET).setIngredient('B', Material.BLAZE_ROD);
    99. ShapedRecipe HeatSword = new ShapedRecipe(new ItemStack(heatSword())).shape(" L ", " D ", " B ").setIngredient('D', Material.DIAMOND).setIngredient('L', Material.LAVA_BUCKET).setIngredient('B', Material.BLAZE_ROD);
    100. ShapedRecipe Saddle = new ShapedRecipe(setNameAndLore(Material.SADDLE, "&6Saddle", "&9Freshly", "&5Crafted")).shape("LL ", "LI ", " S").setIngredient('L', Material.LEATHER).setIngredient('I', Material.IRON_INGOT).setIngredient('S', Material.STRING);
    101. ShapelessRecipe CircleB = new ShapelessRecipe(new ItemStack(Material.SMOOTH_BRICK, 1, (short) 3)).addIngredient(Material.SMOOTH_BRICK).addIngredient(Material.SMOOTH_BRICK).addIngredient(Material.SMOOTH_BRICK).addIngredient(Material.SMOOTH_BRICK);
    102.  
    103. @Override
    104. public void onEnable()
    105. {
    106. log.info(this.prefix + "Private Plugin has been enabled!");
    107.  
    108. PluginManager pm = Bukkit.getPluginManager();
    109. pm.registerEvents(new HeadshotListener(this), this);
    110. pm.registerEvents(new JoinMessageListener(this), this);
    111. pm.registerEvents(new QuitMessageListener(this), this);
    112. pm.registerEvents(new MobSpawnerLootHandler(this), this);
    113. pm.registerEvents(new VoidSpawnTeleportListener(this), this);
    114. pm.registerEvents(new AntiCreativePvPListener(this), this);
    115. pm.registerEvents(new CommandSpyListener(this), this);
    116. pm.registerEvents(new HeatPickaxeListener(this), this);
    117. pm.registerEvents(new HeatShovelListener(this), this);
    118. pm.registerEvents(new HeatAxeListener(this), this);
    119. pm.registerEvents(new HeatSwordListener(this), this);
    120. pm.registerEvents(new ChatLayoutListener(this), this);
    121. pm.registerEvents(new SheepLambChopListener(this), this);
    122. pm.registerEvents(new LambChopSmeltListener(this), this);
    123. pm.registerEvents(new ParticleAndSoundListener(this), this);
    124. pm.registerEvents(new DefaultConfigListener(this), this);
    125. pm.registerEvents(new JetPackListener(this), this);
    126. pm.registerEvents(new SpongeJumpListener(this), this);
    127. pm.registerEvents(new ScoreboardGUIListener(this), this);
    128. pm.registerEvents(new MentionListener(this), this);
    129. pm.registerEvents(new ShopHandler(this), this);
    130. pm.registerEvents(new AdminChatListener(this), this);
    131. pm.registerEvents(new OptionsListener(this), this);
    132. pm.registerEvents(new BlowdartListener(this), this);
    133. pm.registerEvents(new PlayerVoteListener(this), this);
    134. pm.registerEvents(new PublicChestListener(this), this);
    135. pm.registerEvents(new AutoCropListener(this), this);
    136. pm.registerEvents(new GraveListener(this), this);
    137. pm.registerEvents(new AutoRespawnListener(this), this);
    138. pm.registerEvents(new RandomTPListener(this), this);
    139. pm.registerEvents(new TabLayoutListener(this), this);
    140. pm.registerEvents(new TNTRemoveListener(this), this);
    141.  
    142. pm.registerEvents(new CommandG2P(this), this);
    143. pm.registerEvents(new CommandVanish(), this);
    144.  
    145. getCommand("danger").setExecutor(new CommandDanger());
    146. getCommand("admin").setExecutor(new CommandAdmin());
    147. getCommand("air").setExecutor(new CommandAir());
    148. getCommand("coal").setExecutor(new CommandCoal());
    149. getCommand("cmc").setExecutor(new CommandCMC());
    150. getCommand("alert").setExecutor(new CommandAlert());
    151. getCommand("talkas").setExecutor(new CommandTalkas());
    152. getCommand("fm").setExecutor(new CommandFM());
    153. getCommand("set").setExecutor(new CommandSet(this));
    154. getCommand("name").setExecutor(new CommandName());
    155. getCommand("lore").setExecutor(new CommandLore());
    156. getCommand("head").setExecutor(new CommandHead());
    157. getCommand("adminchat").setExecutor(new CommandAdminChat());
    158. getCommand("ka").setExecutor(new CommandKA());
    159. getCommand("warn").setExecutor(new CommandWarn());
    160. getCommand("qrl").setExecutor(new CommandQRL(this));
    161. getCommand("vote").setExecutor(new CommandVote());
    162. getCommand("poll").setExecutor(new CommandPoll(this));
    163. getCommand("class").setExecutor(new CommandClass(this));
    164. getCommand("mir").setExecutor(new CommandMIR(this));
    165. getCommand("g2p").setExecutor(new CommandG2P(this));
    166. getCommand("vanish").setExecutor(new CommandVanish());
    167. getCommand("v").setExecutor(new CommandVanish());
    168.  
    169. getServer().addRecipe(QMCDEgg);
    170. getServer().addRecipe(HeatPick);
    171. getServer().addRecipe(HeatShovel);
    172. getServer().addRecipe(HeatAxe);
    173. getServer().addRecipe(HeatSword);
    174. getServer().addRecipe(CircleB);
    175. getServer().addRecipe(Saddle);
    176. getServer().addRecipe(blowDart);
    177.  
    178. getServer().addRecipe(new FurnaceRecipe(new ItemStack(Material.LEATHER), Material.ROTTEN_FLESH));
    179. getServer().addRecipe(new FurnaceRecipe(new ItemStack(bread()), Material.WHEAT));
    180.  
    181. this.saveDefaultConfig();
    182.  
    183. instance = this;
    184.  
    185. Bukkit.getScheduler().runTaskTimer(this, new ClearAll(), 0L, 21600000L);
    186. }
    187.  
    188. @Override
    189. public void onDisable()
    190. {
    191. log.info(this.prefix + "Private Plugin has been disabled!");
    192. getServer().clearRecipes();
    193. HandlerList.unregisterAll(this);
    194. }
    195.  
    196. public ItemStack dragonEgg()
    197. {
    198. ItemStack de = new ItemStack(Material.DRAGON_EGG);
    199. ItemMeta dim = de.getItemMeta();
    200. dim.setDisplayName("§3[§4Quadular§6MC§3] §6Quadular §4Dragon §6Egg");
    201. List<String> dl = new ArrayList<String>();
    202. dl.add("§9Specially crafted just for you!");
    203. dim.setLore(dl);
    204. de.setItemMeta(dim);
    205. return de;
    206. }
    207.  
    208. public ItemStack heatPick()
    209. {
    210. ItemStack hp = new ItemStack(Material.DIAMOND_PICKAXE);
    211. ItemMeta hpm = hp.getItemMeta();
    212. hpm.setDisplayName("§4Heat Pickaxe");
    213. hpm.addEnchant(Enchantment.DIG_SPEED, 2, false);
    214. hpm.addEnchant(Enchantment.DURABILITY, 2, false);
    215. List<String> hpl = new ArrayList<String>();
    216. hpl.add("§7Heat I");
    217. hpm.setLore(hpl);
    218. hp.setItemMeta(hpm);
    219. return hp;
    220. }
    221.  
    222. public ItemStack heatShovel()
    223. {
    224. ItemStack hp = new ItemStack(Material.DIAMOND_SPADE);
    225. ItemMeta hpm = hp.getItemMeta();
    226. hpm.setDisplayName("§4Heat Shovel");
    227. hpm.addEnchant(Enchantment.DIG_SPEED, 2, false);
    228. hpm.addEnchant(Enchantment.DURABILITY, 2, false);
    229. List<String> hpl = new ArrayList<String>();
    230. hpl.add("§7Heat I");
    231. hpm.setLore(hpl);
    232. hp.setItemMeta(hpm);
    233. return hp;
    234. }
    235.  
    236. public ItemStack heatAxe()
    237. {
    238. ItemStack hp = new ItemStack(Material.DIAMOND_AXE);
    239. ItemMeta hpm = hp.getItemMeta();
    240. hpm.setDisplayName("§4Heat Axe");
    241. hpm.addEnchant(Enchantment.DIG_SPEED, 2, false);
    242. hpm.addEnchant(Enchantment.DURABILITY, 2, false);
    243. List<String> hpl = new ArrayList<String>();
    244. hpl.add("§7Heat I");
    245. hpm.setLore(hpl);
    246. hp.setItemMeta(hpm);
    247. return hp;
    248. }
    249.  
    250. public ItemStack heatSword()
    251. {
    252. ItemStack hp = new ItemStack(Material.DIAMOND_SWORD);
    253. ItemMeta hpm = hp.getItemMeta();
    254. hpm.setDisplayName("§4Heat Sword");
    255. hpm.addEnchant(Enchantment.DIG_SPEED, 2, false);
    256. hpm.addEnchant(Enchantment.DURABILITY, 2, false);
    257. List<String> hpl = new ArrayList<String>();
    258. hpl.add("§7Heat I");
    259. hpm.setLore(hpl);
    260. hp.setItemMeta(hpm);
    261. return hp;
    262. }
    263.  
    264. public ItemStack blowDart()
    265. {
    266. ItemStack bd = new ItemStack(Material.STICK);
    267. ItemMeta im = bd.getItemMeta();
    268. im.setDisplayName("§4Blow Dart");
    269. im.setLore(Arrays.asList("§o§8Right click to use."));
    270. bd.setItemMeta(im);
    271. return bd;
    272. }
    273.  
    274. public ItemStack bread()
    275. {
    276. ItemStack b = new ItemStack(Material.BREAD);
    277. ItemMeta im = b.getItemMeta();
    278. im.setDisplayName("§fBread");
    279. im.setLore(Arrays.asList("§2§oFresh §8§ofrom the oven."));
    280. b.setItemMeta(im);
    281. return b;
    282. }
    283.  
    284. public ItemStack setName(ItemStack item, String name)
    285. {
    286. {
    287. ItemMeta meta = item.getItemMeta();
    288. meta.setDisplayName(name);
    289. item.setItemMeta(meta);
    290. return item;
    291. }
    292. }
    293.  
    294. public ItemStack setNameAndLore(Material material, String name, String... lore)
    295. {
    296. ItemStack item = new ItemStack(material);
    297. ItemMeta meta = item.getItemMeta();
    298. meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
    299. ArrayList<String> lorez = new ArrayList<String>();
    300. for(String mylores : lore)
    301. {
    302. lorez.add(ChatColor.translateAlternateColorCodes('&', mylores));
    303. }
    304. meta.setLore(lorez);
    305. item.setItemMeta(meta);
    306. return item;
    307. }
    308.  
    309. public static final QuadularMC getInstance()
    310. {
    311. return instance;
    312. }
    313. }
    314.  
     
  14. Offline

    1Rogue



    Code:java
    1. public static QuadularMC plugin;


    In your Command class
     
  15. Offline

    sgavster

    1Rogue I removed that.. Still doesn't work
     
  16. Offline

    1Rogue


    What exactly isn't working about it?
     
  17. Offline

    sgavster

    1Rogue When I fall, I die
     
  18. Offline

    CoderCloud

    I would try to use a HashSet instead of an ArrayList, it could be that ArrayLists dont recognize them as the same, another thing that you could do is using the String.toLowerCase() bevore storing it to the ArrayList, so you could manually enter tham by chat and capital letters would be ignored and possible errors prevented.

    I had a problem like this bevore when loading stuff from configs:
    loadedString == "Test" (false)
    loadedString.equals("Test") (true)

    Functions like toLowerCase usually prevent this so it would be possible that it fixes your problem.
     
  19. Offline

    1Rogue


    Neither one of those is the issue, and a HashSet wouldn't be better over an arraylist for nearly the reason you're thinking of.

    Where else are you handling with this same event? What other plugins are on the server?
     
  20. Offline

    sgavster

    1Rogue I have like 4 other plugins (all by me)
    And I have a couple other classes, but I don't see why that matters, because it works up to the arraylist
     
  21. Offline

    LazyLemons

    Try adding the static modifier to your lists, haven't looked through most of your code, but that could be the issue.
     
  22. Offline

    1Rogue


    Try running it without the other plugins on the server

    :|
    :||||||||||||||||||
     
    hawkfalcon likes this.
  23. Offline

    LazyLemons

    1Rogue I'm not going to rewrite his whole plugin for him and fix his instance issues...
     
  24. Offline

    1Rogue


    You don't need static in here. At all.

    In fact you hardly need static in any plugin.
     
  25. Offline

    drtshock

    Then why would you even suggest it? No advice > bad advice :\
     
  26. Offline

    LazyLemons

    Static works well for cross-plugin instance access.
     
  27. Offline

    drtshock

  28. Offline

    LazyLemons

    sgavster
    Debug by outputting the contents of the list when fall damage is taken.
     
  29. Offline

    1Rogue


    Code:java
    1. Bukkit.getPluginManager().getPlugin("PluginName");


    tada
     
  30. Offline

    LazyLemons

Thread Status:
Not open for further replies.

Share This Page