1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-30 21:07:48 +01:00

Option to ignore ore generators

Some config rearrangements for block protection
This commit is contained in:
Zrips 2021-07-15 16:39:19 +03:00
parent bf470202f4
commit c92c9fe95d
3 changed files with 27 additions and 12 deletions

View File

@ -23,12 +23,10 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.WeakHashMap;
import java.util.concurrent.CompletableFuture;

View File

@ -85,7 +85,7 @@ public class GeneralConfigManager {
private FireworkEffect fireworkEffect;
public boolean useBlockProtection, enableSchedule, PayForRenaming, PayForEnchantingOnAnvil, PayForEachCraft, SignsEnabled,
public boolean ignoreOreGenerators, useBlockProtection, enableSchedule, PayForRenaming, PayForEnchantingOnAnvil, PayForEachCraft, SignsEnabled,
SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useSilkTouchProtection, UseCustomNames,
PreventSlimeSplit, PreventMagmaCubeSplit, PreventHopperFillUps, PreventBrewingStandFillUps,
BrowseUseNewLook, payExploringWhenGliding = false, disablePaymentIfMaxLevelReached, disablePaymentIfRiding,
@ -785,28 +785,32 @@ public class GeneralConfigManager {
"This can be overridden with jobs.maxbrewingstands.[amount] permission node");
BrewingStandsMaxDefault = c.get("ExploitProtections.BrewingStands.MaxDefaultAvailable", 20);
c.addComment("ExploitProtections.General.PlaceAndBreakProtection",
c.addComment("ExploitProtections.General.PlaceAndBreak.Enabled",
"Enable blocks protection, like ore, from exploiting by placing and destroying same block again and again.",
"Modify restrictedBlocks.yml for blocks you want to protect");
useBlockProtection = c.get("ExploitProtections.General.PlaceAndBreakProtection", true);
useBlockProtection = c.get("ExploitProtections.General.PlaceAndBreak.Enabled", c.getC().getBoolean("ExploitProtections.General.PlaceAndBreakProtection", true));
c.addComment("ExploitProtections.General.KeepDataFor",
c.addComment("ExploitProtections.General.PlaceAndBreak.IgnoreOreGenerators",
"Enabling this we will ignore blocks generated in ore generators, liko stone, coublestone and obsidian. You can still use timer on player placed obsidian block");
ignoreOreGenerators = c.get("ExploitProtections.General.PlaceAndBreak.IgnoreOreGenerators", true);
c.addComment("ExploitProtections.General.PlaceAndBreak.KeepDataFor",
"For how long in days to keep block protection data in data base", "This will clean block data which ones have -1 as cooldown value",
"Data base cleanup will be performed on each server startup", "This cant be more then 14 days");
BlockProtectionDays = c.get("ExploitProtections.General.KeepDataFor", 14);
BlockProtectionDays = c.get("ExploitProtections.General.PlaceAndBreak.KeepDataFor", c.getC().getInt("ExploitProtections.General.KeepDataFor", 14));
BlockProtectionDays = BlockProtectionDays > 14 ? 14 : BlockProtectionDays;
/*c.addComment("ExploitProtections.General.AllowBreakPaymentForOreGenerators", "It allows you to pay for ore generator plugins continuously"
+ " once you have broken the block in one place.");
allowBreakPaymentForOreGenerators = c.get("ExploitProtections.General.AllowBreakPaymentForOreGenerators", false);*/
c.addComment("ExploitProtections.General.GlobalBlockTimer", "All blocks will be protected X sec after player places it on ground.");
useGlobalTimer = c.get("ExploitProtections.General.GlobalBlockTimer.use", true);
globalblocktimer = c.get("ExploitProtections.General.GlobalBlockTimer.timer", 3);
c.addComment("ExploitProtections.General.PlaceAndBreak.GlobalBlockTimer", "All blocks will be protected X sec after player places it on ground.");
useGlobalTimer = c.get("ExploitProtections.General.PlaceAndBreak.GlobalBlockTimer.Use", c.getC().getBoolean("ExploitProtections.General.GlobalBlockTimer.use", true));
globalblocktimer = c.get("ExploitProtections.General.PlaceAndBreak.GlobalBlockTimer.Timer", c.getC().getInt("ExploitProtections.General.GlobalBlockTimer.timer", 3));
c.addComment("ExploitProtections.General.SilkTouchProtection", "Enable silk touch protection.",
c.addComment("ExploitProtections.General.PlaceAndBreak.SilkTouchProtection", "Enable silk touch protection.",
"With this enabled players wont get paid for broken blocks from restrictedblocks list with silk touch tool.");
useSilkTouchProtection = c.get("ExploitProtections.General.SilkTouchProtection", false);
useSilkTouchProtection = c.get("ExploitProtections.General.PlaceAndBreak.SilkTouchProtection", c.getC().getBoolean("ExploitProtections.General.SilkTouchProtection", false));
c.addComment("ExploitProtections.General.MonsterDamage.Use", "This section controls how much damage player should do to monster for player to get paid",
"This prevents from killing monsters in one hit when they suffer in example fall damage");

View File

@ -42,6 +42,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDispenseEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.inventory.ClickType;
@ -107,6 +108,18 @@ public class JobsListener implements Listener {
return time > 100;
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockFromToEvent(BlockFromToEvent event) {
if (!Jobs.getGCManager().useBlockProtection)
return;
if (!Jobs.getGCManager().ignoreOreGenerators)
return;
if (!Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld()))
return;
Jobs.getBpManager().remove(event.getToBlock());
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onJoin(PlayerJoinEvent event) {
if (Jobs.getGCManager().isShowNewVersion() && event.getPlayer().hasPermission("jobs.versioncheck"))