From d55c0affe2e05f3651f2b655de911d097062792a Mon Sep 17 00:00:00 2001 From: Indyuce Date: Sun, 4 Oct 2020 16:03:53 +0200 Subject: [PATCH] !Fixed custom block chains --- dependency-reduced-pom.xml | 370 +++++++++--------- .../mmocore/listener/BlockListener.java | 16 +- .../mmocore/manager/CustomBlockManager.java | 38 +- 3 files changed, 215 insertions(+), 209 deletions(-) diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index fb7756df..a9e93cf1 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -1,185 +1,185 @@ - - - 4.0.0 - net.Indyuce - MMOCore - MMOCore - 1.4.7 - Offer your players a brand new RPG experience. - - - - true - ${basedir}/src/main/resources/ - - - ${project.name}-${project.version} - - - maven-compiler-plugin - - 1.8 - 1.8 - junit:junit - UTF-8 - UTF-8 - UTF-8 - -ea -Dfile.encoding=UTF-8 - - - - maven-shade-plugin - 3.2.4 - - - package - - shade - - - - - - - io.papermc.lib - net.indyuce.mmocore.shaded.paperlib - - - - - - - - - jitpack.io - https://jitpack.io - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - sk89q-repo - https://maven.enginehub.org/repo/ - - - papermc - https://papermc.io/repo/repository/maven-public/ - - - - - org.jetbrains - annotations - 19.0.0 - provided - - - com.github.MilkBowl - VaultAPI - 1.7 - provided - - - com.sk89q.worldguard - worldguard-bukkit - 7.0.2-SNAPSHOT - provided - - - org.projectlombok - lombok - 1.18.12 - provided - - - net.Indyuce - mmoitems - 6.1.2 - system - ${basedir}/lib/MMOItems.jar - - - net.Indyuce - MMOLib - 1.3 - system - ${basedir}/lib/MMOLib.jar - - - org.spigotmc - spigot-api - 1.12-R1-1.16-R2 - system - ${basedir}/lib/spigot.jar - - - com.bekvon.bukkit - Residence - 4.8.7.2 - system - ${basedir}/lib/Residence.jar - - - com.Zrips - CMI - 8.6.5.0 - system - ${basedir}/lib/CMI.jar - - - com.sainttx.holograms - holograms - 2.9.1 - system - ${basedir}/lib/Holograms.jar - - - com.gmail.filoghost - HolographicDisplays - 6.9.1 - system - ${basedir}/lib/HolographicDisplays.jar - - - io.lumine.xikage - MythicMobs - 4.8.0 - system - ${basedir}/lib/MythicMobs.jar - - - net.citizensnpcs - citizens - 2.0.25-SNAPSHOT - system - ${basedir}/lib/Citizens.jar - - - me.clip - placeholderapi - 2.10.7 - system - ${basedir}/lib/PlaceholderAPI.jar - - - - - nexus - Lumine Releases - http://mvn.lumine.io/repository/maven-releases/ - - - nexus - Lumine Snapshots - http://mvn.lumine.io/repository/maven-snapshots/ - - - - false - false - UTF-8 - SNAPSHOT - UTF-8 - - + + + 4.0.0 + net.Indyuce + MMOCore + MMOCore + 1.4.7 + Offer your players a brand new RPG experience. + + + + true + ${basedir}/src/main/resources/ + + + ${project.name}-${project.version} + + + maven-compiler-plugin + + 1.8 + 1.8 + junit:junit + UTF-8 + UTF-8 + UTF-8 + -ea -Dfile.encoding=UTF-8 + + + + maven-shade-plugin + 3.2.4 + + + package + + shade + + + + + + + io.papermc.lib + net.indyuce.mmocore.shaded.paperlib + + + + + + + + + jitpack.io + https://jitpack.io + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + sk89q-repo + https://maven.enginehub.org/repo/ + + + papermc + https://papermc.io/repo/repository/maven-public/ + + + + + org.jetbrains + annotations + 19.0.0 + provided + + + com.github.MilkBowl + VaultAPI + 1.7 + provided + + + com.sk89q.worldguard + worldguard-bukkit + 7.0.2-SNAPSHOT + provided + + + org.projectlombok + lombok + 1.18.12 + provided + + + net.Indyuce + mmoitems + 6.1.2 + system + ${basedir}/lib/MMOItems.jar + + + net.Indyuce + MMOLib + 1.3 + system + ${basedir}/lib/MMOLib.jar + + + org.spigotmc + spigot-api + 1.12-R1-1.16-R2 + system + ${basedir}/lib/spigot.jar + + + com.bekvon.bukkit + Residence + 4.8.7.2 + system + ${basedir}/lib/Residence.jar + + + com.Zrips + CMI + 8.6.5.0 + system + ${basedir}/lib/CMI.jar + + + com.sainttx.holograms + holograms + 2.9.1 + system + ${basedir}/lib/Holograms.jar + + + com.gmail.filoghost + HolographicDisplays + 6.9.1 + system + ${basedir}/lib/HolographicDisplays.jar + + + io.lumine.xikage + MythicMobs + 4.8.0 + system + ${basedir}/lib/MythicMobs.jar + + + net.citizensnpcs + citizens + 2.0.25-SNAPSHOT + system + ${basedir}/lib/Citizens.jar + + + me.clip + placeholderapi + 2.10.7 + system + ${basedir}/lib/PlaceholderAPI.jar + + + + + nexus + Lumine Releases + http://mvn.lumine.io/repository/maven-releases/ + + + nexus + Lumine Snapshots + http://mvn.lumine.io/repository/maven-snapshots/ + + + + false + false + UTF-8 + SNAPSHOT + UTF-8 + + diff --git a/src/main/java/net/Indyuce/mmocore/listener/BlockListener.java b/src/main/java/net/Indyuce/mmocore/listener/BlockListener.java index 22778600..7ba15027 100644 --- a/src/main/java/net/Indyuce/mmocore/listener/BlockListener.java +++ b/src/main/java/net/Indyuce/mmocore/listener/BlockListener.java @@ -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) diff --git a/src/main/java/net/Indyuce/mmocore/manager/CustomBlockManager.java b/src/main/java/net/Indyuce/mmocore/manager/CustomBlockManager.java index 8652e550..71b0f08d 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/CustomBlockManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/CustomBlockManager.java @@ -30,22 +30,24 @@ import net.mmogroup.mmolib.api.MMOLineConfig; public class CustomBlockManager extends MMOManager { - /* - * registered block infos + /** + * Registered block infos */ private final Map 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 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 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>> 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); }