Forever Burning Furnace

Discussion in 'Plugin Development' started by ChrisixStudios, Oct 25, 2012.

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

    Milkywayz

    Creating a scheduler for every furnace would be hell, I think it would better to add the furnace block to a List<Furnace> then have one scheduler update them all with a for loop.

    EDIT: I quickly coded this up, it's crude but just for educational purpose:
    Code:
    import java.util.ArrayList;
    import java.util.List;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.block.Furnace;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.event.block.BlockPlaceEvent;
     
    public class ForeverFurnace implements Listener {
        private List<Furnace> foreverfurnaces = new ArrayList<Furnace>();
     
        public void startScheduler() {
            Bukkit.getScheduler().scheduleSyncRepeatingTask(//Main class, new Runnable() {
                @Override
                public void run() {
                    update();
                }
            }, 0L, 1200L);
        }
     
        public void update() {
            for (Furnace f : foreverfurnaces) {
                f.setCookTime((short) 10000);
            }
        }
     
        @EventHandler
        public void onblockplace(BlockPlaceEvent e) {
            if (e.getBlock().getType() == Material.FURNACE) {
                if (!foreverfurnaces.contains(e.getBlock())) {
                    foreverfurnaces.add((Furnace) e.getBlock());
                    e.getPlayer().sendMessage(
                            ChatColor.GREEN + "You placed a forever furnace!");
                }
            }
        }
     
        public void onblockbreak(BlockBreakEvent e) {
            if (e.getBlock().getType() == Material.FURNACE) {
                if (foreverfurnaces.contains(e.getBlock())) {
                    foreverfurnaces.remove(e.getBlock());
                    e.getPlayer().sendMessage(
                            ChatColor.GREEN + "You broke a forever furnace!");
                }
            }
        }
    }
     
  2. Offline

    CorrieKay

    mmh, thats what i said :p
     
  3. Offline

    Milkywayz

    Oh, sorry I didn't mean to jack your idea. I was primarily looking at the flame posts then decided to try and help the OP.
     
  4. Offline

    CorrieKay

    No worries!
     
  5. Offline

    cman1885

    It doesn't burn but creates light? Good point?
     
  6. Offline

    CorrieKay

    Thats not the point of the OP. he wanted a functionally burning furnace.
     
  7. Offline

    Unscrewed

    Not trying to get involved, but can you two just stop responding on eachother's posts?
    This isn't about trying to win a stupid discussion, this is about helping the @OP.
    Please continue through PM's if you really feel like discussing this.
     
    kroltan likes this.
  8. Offline

    CorrieKay

    I dont mean to sound rude, but please dont backseat moderate. I can understand if we were taking it off topic, but i actually am genuinely interested in cman's code, to see what he is talking about. This isnt about some "stupid discussion". At least its on topic.
     
    cman1885 likes this.
  9. Offline

    Unscrewed

    Now don't get me wrong, I am not backseat moderating. I don't really care what the conversation is about either, but it's completely off-topic and not helping the OP. And it obviously was a pretty pointless discussion since cman's method was proven to be faulty. And this too isn't helping the OP, so I won't respond anymore.

    Please, understand the difference between trying to help others and backseat moderating, though.

    Sincerely,
    Unscrewed
     
  10. Offline

    CorrieKay

    Talking about cman's method, and how it is incorrect or not (as i was only telling him he was wrong, and asking him to prove his method right) were not off topic in the slightest. As i said before, I am not off topic because I am trying to figure out what cman means when he thinks he isnt incorrect. If he had not posted any more after the last time he posted, it would most likely have been the end of it. If not, we would have progressed the conversation until one of us was proven correct. Still on topic, because it was regarding the situation the OP had brought up. Let alone that he had his answer.

    You on the other hand, are off topic, trying to tell me not to defend my point.
     
  11. Offline

    kroltan

    Well you just went offtopic with that reply. Just wait for the OP to test or leave it alone!

    As previously said, use a repeating scheduler and ArrayLists to store furnaces, on every scheduler run set the burning time of each furnace in the AL.
     
  12. Offline

    CorrieKay

    so its my fault. Okay, sure.

    Fuck it, im done with this thread.
     
  13. Offline

    cman1885

    I realized that I misjudged what the OP wanted and left. It's done. Quit.
     
  14. Offline

    MYCRAFTisbest

    I think this turned into a pointless debate about someone who was wrong.

    The person who started this form hasn't replied in a while so i assume it was completed/solved by now.
     
  15. Offline

    cman1885

    Ok shut up it's done
     
  16. Offline

    MYCRAFTisbest

    I am not saying your bad at coding, just misinterpreted a simple thing that isn't worth arguing over.
     
    Unscrewed likes this.
Thread Status:
Not open for further replies.

Share This Page