forked from Upstream/mmocore
!Fixed custom block chains
This commit is contained in:
parent
8cf6f057d2
commit
d55c0affe2
@ -46,7 +46,9 @@ public class BlockListener implements Listener {
|
||||
/*
|
||||
* If the block is a temporary block, immediately cancel the break event
|
||||
*/
|
||||
if (MMOCore.plugin.mineManager.isTemporaryBlock(block)) {
|
||||
BlockInfo info = MMOCore.plugin.mineManager.getInfo(block);
|
||||
boolean temporaryBlock = MMOCore.plugin.mineManager.isTemporaryBlock(block);
|
||||
if (temporaryBlock && info == null) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -54,7 +56,6 @@ public class BlockListener implements Listener {
|
||||
/*
|
||||
* Check if the block has exp or drop tables
|
||||
*/
|
||||
BlockInfo info = MMOCore.plugin.mineManager.getInfo(block);
|
||||
if (info == null) {
|
||||
|
||||
/*
|
||||
@ -109,15 +110,6 @@ public class BlockListener implements Listener {
|
||||
if (info.hasTriggers() && !block.hasMetadata("player_placed")) {
|
||||
PlayerData playerData = PlayerData.get(player);
|
||||
info.getTriggers().forEach(trigger -> trigger.apply(playerData));
|
||||
/**
|
||||
* if (!block.hasMetadata("player_placed") && info.hasExperience()
|
||||
* && MMOCore.plugin.hasHolograms())
|
||||
* MMOCore.plugin.hologramSupport.displayIndicator(block.getLocation().add(.5,
|
||||
* 1.5, .5),
|
||||
* MMOCore.plugin.configManager.getSimpleMessage("exp-hologram",
|
||||
* "exp", "" + called.getGainedExperience().getValue()).message(),
|
||||
* player);
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
@ -135,7 +127,7 @@ public class BlockListener implements Listener {
|
||||
* Finally enable block regen.
|
||||
*/
|
||||
if (info.hasRegen())
|
||||
MMOCore.plugin.mineManager.initialize(info.startRegeneration(Bukkit.createBlockData(savedData), block.getLocation()));
|
||||
MMOCore.plugin.mineManager.initialize(info.startRegeneration(Bukkit.createBlockData(savedData), block.getLocation()), !temporaryBlock);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
|
@ -30,22 +30,24 @@ import net.mmogroup.mmolib.api.MMOLineConfig;
|
||||
|
||||
public class CustomBlockManager extends MMOManager {
|
||||
|
||||
/*
|
||||
* registered block infos
|
||||
/**
|
||||
* Registered block infos
|
||||
*/
|
||||
private final Map<String, BlockInfo> map = new HashMap<>();
|
||||
|
||||
/*
|
||||
* blocks that are regenerating and that must be refreshed whenever the
|
||||
/**
|
||||
* Blocks that are regenerating and that must be refreshed whenever the
|
||||
* server reloads or shuts down not to hurt the world map
|
||||
*/
|
||||
private final Set<RegeneratingBlock> active = new HashSet<>();
|
||||
|
||||
/* list in which both block regen and block permissions are enabled. */
|
||||
/**
|
||||
* Stores conditions which must be met to apply custom mining
|
||||
*/
|
||||
private final List<Condition> customMineConditions = new ArrayList<>();
|
||||
|
||||
/*
|
||||
* list of functions which let MMOCore recognize what block a player is
|
||||
/**
|
||||
* List of functions which let MMOCore recognize what block a player is
|
||||
* currently breaking
|
||||
*/
|
||||
private final List<Function<Block, Optional<BlockType>>> blockTypes = new ArrayList<>();
|
||||
@ -78,11 +80,23 @@ public class CustomBlockManager extends MMOManager {
|
||||
return new VanillaBlockType(block);
|
||||
}
|
||||
|
||||
public void initialize(RegeneratingBlock info) {
|
||||
// if (schedule) {
|
||||
active.add(info);
|
||||
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> regen(info, false), info.getRegeneratingBlock().getRegenerationInfo().getTime());
|
||||
// }
|
||||
/**
|
||||
* Used when a block is being broken and MMOCore needs to regen it after X
|
||||
* seconds. Also places the temporary block at the block location
|
||||
*
|
||||
* @param info
|
||||
* Block info
|
||||
* @param scheduleRegen
|
||||
* If block regeneration should be scheduled or not. If the block
|
||||
* broken is a temporary block and is part of a "block chain", no
|
||||
* regen should be scheduled as there is already one
|
||||
*/
|
||||
public void initialize(RegeneratingBlock info, boolean scheduleRegen) {
|
||||
if (scheduleRegen) {
|
||||
active.add(info);
|
||||
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> regen(info, false), info.getRegeneratingBlock().getRegenerationInfo().getTime());
|
||||
}
|
||||
|
||||
if (info.getRegeneratingBlock().getRegenerationInfo().hasTemporaryBlock())
|
||||
info.getRegeneratingBlock().getRegenerationInfo().getTemporaryBlock().place(info.getLocation(), info);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user