Trying to make plugin that regenerates block... Need Help!

Discussion in 'Spigot Plugin Help' started by angmusae2015, Feb 29, 2020.

  1. Code (Java):
    package com.gmail.angmusae2015.basicplugin.RegenBlock;

    import java.util.HashMap;

    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockBreakEvent;

    public class RegenBlock implements Listener {
        public static HashMap<Location, Material> regenBlockList = new HashMap<Location, Material>();
        public static HashMap<Player, Location> record = new HashMap<Player, Location>();

        @EventHandler
        public void BlockBreakAlarm(BlockBreakEvent event) {
            Player player = event.getPlayer();
            Location location = event.getBlock().getLocation();
            Material type = event.getBlock().getType();

            if(regenBlockList.containsKey(location)) {
                location.getBlock().setType(regenBlockList.get(location));
            }

            player.sendMessage("Block '" + type + "' on '" + location.toString() + "'.");
            player.sendMessage("Regen block : " + regenBlockList.containsKey(location));

            record.put(player, location);
        }
    and this is my code in event code.
    But,
    Code (Text):
    if(regenBlockList.containsKey(location)) {
                location.getBlock().setType(regenBlockList.get(location));
            }
    this part of the code won't work.
    Why is it doing nothing?
     
  2. May you provide us the part where you put a new entry in your HashMap?