Added new "should-cobblestone-generators-give-exp" config option to config.yml, regenerate your config or add this option manually.

This commit is contained in:
Joshua 2021-01-19 13:04:27 -06:00
parent 7143313138
commit f2f6dd7659
3 changed files with 25 additions and 24 deletions

View File

@ -174,11 +174,20 @@ public class BlockListener implements Listener {
* Allows to mark cobblestone generated by cobblestone generators so that
* exp is not gained by these blocks
*/
private boolean protect;
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void cobblestoneGeneratorHandling(BlockFormEvent event) {
if (event.getBlock().getType() == Material.WATER || event.getBlock().getType() == Material.LAVA)
if (event.getNewState().getType() == Material.COBBLESTONE || event.getNewState().getType() == Material.OBSIDIAN)
event.getNewState().setMetadata("player_placed", new FixedMetadataValue(MMOCore.plugin, true));
if(MMOCore.plugin.getConfig().contains("should-cobblestone-generators-give-exp")) {
this.protect = MMOCore.plugin.getConfig().getBoolean("should-cobblestone-generators-give-exp");
} else{ this.protect = false; }
if(!protect) {
if (event.getBlock().getType() == Material.WATER || event.getBlock().getType() == Material.LAVA)
if (event.getNewState().getType() == Material.COBBLESTONE || event.getNewState().getType() == Material.OBSIDIAN)
event.getNewState().setMetadata("player_placed", new FixedMetadataValue(MMOCore.plugin, true));
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)

View File

@ -1,23 +1,5 @@
package net.Indyuce.mmocore.manager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.logging.Level;
import javax.annotation.Nullable;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Entity;
import io.papermc.lib.PaperLib;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.block.BlockInfo;
@ -29,6 +11,16 @@ import net.Indyuce.mmocore.api.droptable.condition.Condition;
import net.Indyuce.mmocore.api.droptable.condition.ConditionInstance;
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.mmogroup.mmolib.api.MMOLineConfig;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Entity;
import javax.annotation.Nullable;
import java.util.*;
import java.util.function.Function;
import java.util.logging.Level;
public class CustomBlockManager extends MMOManager {
@ -188,8 +180,6 @@ public class CustomBlockManager extends MMOManager {
public void reload() {
customMineConditions.clear();
this.protect = MMOCore.plugin.getConfig().getBoolean("protect-custom-mine");
for (String key : MMOCore.plugin.getConfig().getStringList("custom-mine-conditions"))
try {
customMineConditions.add(MMOCore.plugin.loadManager.loadCondition(new MMOLineConfig(key)));

View File

@ -8,7 +8,7 @@
# a Spigot Plugin by Team Requiem
# DO NOT TOUCH
config-version: 6
config-version: 7
# Auto-Save feature automatically saves playerdata
# (class, level, etc.) and guild data
@ -58,6 +58,8 @@ custom-mine-conditions:
# broken when custom mining conditions are met
protect-custom-mine: false
should-cobblestone-generators-give-exp: false
loot-chests:
# Time in seconds it takes for a loot chest to