mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-26 20:45:55 +01:00
New block place/break system for better performance
This commit is contained in:
parent
a707f8a991
commit
748d4fae86
BIN
libs/CMILib1.5.0.2.jar
Normal file
BIN
libs/CMILib1.5.0.2.jar
Normal file
Binary file not shown.
28
pom.xml
28
pom.xml
@ -5,7 +5,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>Jobs</groupId>
|
<groupId>Jobs</groupId>
|
||||||
<artifactId>jobs</artifactId>
|
<artifactId>jobs</artifactId>
|
||||||
<version>5.2.3.0</version>
|
<version>5.2.4.0</version>
|
||||||
<name>Jobs</name>
|
<name>Jobs</name>
|
||||||
<url>http://maven.apache.org</url>
|
<url>http://maven.apache.org</url>
|
||||||
|
|
||||||
@ -150,11 +150,11 @@
|
|||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- CMILib -->
|
<!-- CMILib -->
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>com.github.Zrips</groupId>
|
<!-- <groupId>com.github.Zrips</groupId>-->
|
||||||
<artifactId>CMILib</artifactId>
|
<!-- <artifactId>CMILib</artifactId>-->
|
||||||
<version>1.4.7.4</version>
|
<!-- <version>1.4.7.4</version>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
<!-- WildStacker -->
|
<!-- WildStacker -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.bgsoftware</groupId>
|
<groupId>com.bgsoftware</groupId>
|
||||||
@ -184,6 +184,14 @@
|
|||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${basedir}/libs/PyroFishingPro-4.9.1.jar</systemPath>
|
<systemPath>${basedir}/libs/PyroFishingPro-4.9.1.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- CMILib -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.Zrips</groupId>
|
||||||
|
<artifactId>CMILib</artifactId>
|
||||||
|
<version>1.5.0.2</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${basedir}/libs/CMILib1.5.0.2.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
@ -248,14 +256,6 @@
|
|||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
|
||||||
<version>2.3.1</version>
|
|
||||||
<configuration>
|
|
||||||
<outputDirectory>D:\MC\Server 1.20.5\plugins\</outputDirectory>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
@ -50,6 +50,7 @@ import com.gamingmesh.jobs.commands.JobsCommands;
|
|||||||
import com.gamingmesh.jobs.config.BlockProtectionManager;
|
import com.gamingmesh.jobs.config.BlockProtectionManager;
|
||||||
import com.gamingmesh.jobs.config.BossBarManager;
|
import com.gamingmesh.jobs.config.BossBarManager;
|
||||||
import com.gamingmesh.jobs.config.ConfigManager;
|
import com.gamingmesh.jobs.config.ConfigManager;
|
||||||
|
import com.gamingmesh.jobs.config.ExploitProtectionManager;
|
||||||
import com.gamingmesh.jobs.config.ExploreManager;
|
import com.gamingmesh.jobs.config.ExploreManager;
|
||||||
import com.gamingmesh.jobs.config.GeneralConfigManager;
|
import com.gamingmesh.jobs.config.GeneralConfigManager;
|
||||||
import com.gamingmesh.jobs.config.LanguageManager;
|
import com.gamingmesh.jobs.config.LanguageManager;
|
||||||
@ -139,6 +140,7 @@ public final class Jobs extends JavaPlugin {
|
|||||||
private static ShopManager shopManager;
|
private static ShopManager shopManager;
|
||||||
private static Loging loging;
|
private static Loging loging;
|
||||||
private static BlockProtectionManager bpManager;
|
private static BlockProtectionManager bpManager;
|
||||||
|
private static ExploitProtectionManager exploitManager;
|
||||||
private static JobsManager dbManager;
|
private static JobsManager dbManager;
|
||||||
private static ConfigManager configManager;
|
private static ConfigManager configManager;
|
||||||
private static GeneralConfigManager gConfigManager;
|
private static GeneralConfigManager gConfigManager;
|
||||||
@ -294,6 +296,12 @@ public final class Jobs extends JavaPlugin {
|
|||||||
return bpManager;
|
return bpManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ExploitProtectionManager getExploitManager() {
|
||||||
|
if (exploitManager == null)
|
||||||
|
exploitManager = new ExploitProtectionManager();
|
||||||
|
return exploitManager;
|
||||||
|
}
|
||||||
|
|
||||||
public static JobsManager getDBManager() {
|
public static JobsManager getDBManager() {
|
||||||
if (dbManager == null)
|
if (dbManager == null)
|
||||||
dbManager = new JobsManager(getInstance());
|
dbManager = new JobsManager(getInstance());
|
||||||
@ -1020,8 +1028,10 @@ public final class Jobs extends JavaPlugin {
|
|||||||
List<JobProgression> progression = jPlayer.getJobProgression();
|
List<JobProgression> progression = jPlayer.getJobProgression();
|
||||||
int numjobs = progression.size();
|
int numjobs = progression.size();
|
||||||
|
|
||||||
if (!Jobs.getGCManager().useBlockProtectionBlockTracker && !isBpOk(jPlayer, info, block, true))
|
CMIDebug.it();
|
||||||
|
if (!Jobs.getGCManager().useBlockProtectionBlockTracker && !Jobs.getExploitManager().isProtectionValidAddIfNotExists(jPlayer, info, block, true))
|
||||||
return;
|
return;
|
||||||
|
CMIDebug.d(CMIDebug.getIT(), "ms");
|
||||||
|
|
||||||
// no job
|
// no job
|
||||||
if (numjobs == 0) {
|
if (numjobs == 0) {
|
||||||
@ -1100,8 +1110,12 @@ public final class Jobs extends JavaPlugin {
|
|||||||
if (income == 0D && pointAmount == 0D)
|
if (income == 0D && pointAmount == 0D)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (info.getType() == ActionType.BREAK && block != null)
|
if (info.getType() == ActionType.BREAK && block != null) {
|
||||||
|
if (getGCManager().useNewBlockProtection)
|
||||||
|
getExploitManager().remove(block);
|
||||||
|
else
|
||||||
getBpManager().remove(block);
|
getBpManager().remove(block);
|
||||||
|
}
|
||||||
|
|
||||||
if (pointAmount != 0D) {
|
if (pointAmount != 0D) {
|
||||||
jPlayer.setSaved(false);
|
jPlayer.setSaved(false);
|
||||||
@ -1309,7 +1323,11 @@ public final class Jobs extends JavaPlugin {
|
|||||||
|
|
||||||
//need to update bp
|
//need to update bp
|
||||||
if (block != null && !Jobs.getGCManager().useBlockProtectionBlockTracker) {
|
if (block != null && !Jobs.getGCManager().useBlockProtectionBlockTracker) {
|
||||||
BlockProtection bp = getBpManager().getBp(block.getLocation());
|
BlockProtection bp = null;
|
||||||
|
if (Jobs.getGCManager().useNewBlockProtection) {
|
||||||
|
getExploitManager().setPaid(block, true);
|
||||||
|
} else
|
||||||
|
bp = getBpManager().getBp(block.getLocation());
|
||||||
if (bp != null)
|
if (bp != null)
|
||||||
bp.setPaid(true);
|
bp.setPaid(true);
|
||||||
}
|
}
|
||||||
@ -1318,83 +1336,6 @@ public final class Jobs extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isBpOk(JobsPlayer player, ActionInfo info, Block block, boolean inform) {
|
|
||||||
if (block == null || !gConfigManager.useBlockProtection)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (info.getType() == ActionType.BREAK) {
|
|
||||||
if (block.hasMetadata("JobsExploit")) {
|
|
||||||
//player.sendMessage("This block is protected using Rukes' system!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockProtection bp = getBpManager().getBp(block.getLocation());
|
|
||||||
if (bp != null) {
|
|
||||||
long time = bp.getTime();
|
|
||||||
Integer cd = getBpManager().getBlockDelayTime(block);
|
|
||||||
|
|
||||||
if (time == -1L) {
|
|
||||||
getBpManager().remove(block);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (time < System.currentTimeMillis() && bp.getAction() != DBAction.DELETE) {
|
|
||||||
getBpManager().remove(block);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((time > System.currentTimeMillis() || bp.isPaid()) && bp.getAction() != DBAction.DELETE) {
|
|
||||||
if (inform && player.canGetPaid(info)) {
|
|
||||||
int sec = Math.round((time - System.currentTimeMillis()) / 1000L);
|
|
||||||
CMIActionBar.send(player.getPlayer(), lManager.getMessage("message.blocktimer", "[time]", sec));
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
getBpManager().add(block, cd);
|
|
||||||
|
|
||||||
if ((cd == null || cd == 0) && gConfigManager.useGlobalTimer) {
|
|
||||||
getBpManager().add(block, gConfigManager.globalblocktimer);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (gConfigManager.useGlobalTimer) {
|
|
||||||
getBpManager().add(block, gConfigManager.globalblocktimer);
|
|
||||||
}
|
|
||||||
} else if (info.getType() == ActionType.PLACE) {
|
|
||||||
BlockProtection bp = getBpManager().getBp(block.getLocation());
|
|
||||||
if (bp != null) {
|
|
||||||
Long time = bp.getTime();
|
|
||||||
Integer cd = getBpManager().getBlockDelayTime(block);
|
|
||||||
if (time != -1L) {
|
|
||||||
if (time < System.currentTimeMillis() && bp.getAction() != DBAction.DELETE) {
|
|
||||||
getBpManager().add(block, cd);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((time > System.currentTimeMillis() || bp.isPaid()) && bp.getAction() != DBAction.DELETE) {
|
|
||||||
if (inform && player.canGetPaid(info)) {
|
|
||||||
int sec = Math.round((time - System.currentTimeMillis()) / 1000L);
|
|
||||||
CMIActionBar.send(player.getPlayer(), lManager.getMessage("message.blocktimer", "[time]", sec));
|
|
||||||
}
|
|
||||||
|
|
||||||
getBpManager().add(block, cd);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lets add protection in any case
|
|
||||||
getBpManager().add(block, cd);
|
|
||||||
} else if (bp.isPaid() && bp.getTime() == -1L && cd != null && cd == -1) {
|
|
||||||
getBpManager().add(block, cd);
|
|
||||||
return false;
|
|
||||||
} else
|
|
||||||
getBpManager().add(block, cd);
|
|
||||||
} else
|
|
||||||
getBpManager().add(block, getBpManager().getBlockDelayTime(block));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int getPlayerExperience(Player player) {
|
private static int getPlayerExperience(Player player) {
|
||||||
return (expToLevel(player.getLevel()) + Math.round(deltaLevelToExp(player.getLevel()) * player.getExp()));
|
return (expToLevel(player.getLevel()) + Math.round(deltaLevelToExp(player.getLevel()) * player.getExp()));
|
||||||
|
@ -327,6 +327,7 @@ public class PlayerManager {
|
|||||||
|
|
||||||
playersUUID.values().removeIf(jPlayer -> jPlayer.isSaved() && !jPlayer.isOnline());
|
playersUUID.values().removeIf(jPlayer -> jPlayer.isSaved() && !jPlayer.isOnline());
|
||||||
|
|
||||||
|
if (!Jobs.getGCManager().useNewBlockProtection)
|
||||||
Jobs.getBpManager().saveCache();
|
Jobs.getBpManager().saveCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,35 @@ public class bp implements Cmd {
|
|||||||
|
|
||||||
final List<Block> changedBlocks = new ArrayList<>();
|
final List<Block> changedBlocks = new ArrayList<>();
|
||||||
|
|
||||||
|
if (Jobs.getGCManager().useNewBlockProtection) {
|
||||||
|
for (int x = -10; x < 10; x++) {
|
||||||
|
for (int y = -10; y < 10; y++) {
|
||||||
|
for (int z = -10; z < 10; z++) {
|
||||||
|
Location l = loc.clone().add(x, y, z);
|
||||||
|
Long time = Jobs.getExploitManager().getTime(l.getBlock());
|
||||||
|
if (time == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!all && time != -1 && time < System.currentTimeMillis()) {
|
||||||
|
Jobs.getExploitManager().remove(l.getBlock());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
changedBlocks.add(l.getBlock());
|
||||||
|
|
||||||
|
if (Version.isCurrentEqualOrHigher(Version.v1_15_R1)) {
|
||||||
|
player.sendBlockChange(l, (time == -1 ? CMIMaterial.BLACK_STAINED_GLASS : CMIMaterial.WHITE_STAINED_GLASS)
|
||||||
|
.getMaterial().createBlockData());
|
||||||
|
} else {
|
||||||
|
if (time == -1)
|
||||||
|
player.sendBlockChange(l, CMIMaterial.RED_STAINED_GLASS.getMaterial(), (byte) 15);
|
||||||
|
else
|
||||||
|
player.sendBlockChange(l, CMIMaterial.RED_STAINED_GLASS.getMaterial(), (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
for (int x = -10; x < 10; x++) {
|
for (int x = -10; x < 10; x++) {
|
||||||
for (int y = -10; y < 10; y++) {
|
for (int y = -10; y < 10; y++) {
|
||||||
for (int z = -10; z < 10; z++) {
|
for (int z = -10; z < 10; z++) {
|
||||||
@ -59,7 +88,8 @@ public class bp implements Cmd {
|
|||||||
changedBlocks.add(l.getBlock());
|
changedBlocks.add(l.getBlock());
|
||||||
|
|
||||||
if (Version.isCurrentEqualOrHigher(Version.v1_15_R1)) {
|
if (Version.isCurrentEqualOrHigher(Version.v1_15_R1)) {
|
||||||
player.sendBlockChange(l, (bp.getAction() == DBAction.DELETE ? CMIMaterial.RED_STAINED_GLASS : time == -1 ? CMIMaterial.BLACK_STAINED_GLASS : CMIMaterial.WHITE_STAINED_GLASS)
|
player.sendBlockChange(l, (bp.getAction() == DBAction.DELETE ? CMIMaterial.RED_STAINED_GLASS : time == -1 ? CMIMaterial.BLACK_STAINED_GLASS
|
||||||
|
: CMIMaterial.WHITE_STAINED_GLASS)
|
||||||
.getMaterial().createBlockData());
|
.getMaterial().createBlockData());
|
||||||
} else {
|
} else {
|
||||||
if (bp.getAction() == DBAction.DELETE)
|
if (bp.getAction() == DBAction.DELETE)
|
||||||
|
@ -9,9 +9,13 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.container.ActionInfo;
|
||||||
|
import com.gamingmesh.jobs.container.ActionType;
|
||||||
import com.gamingmesh.jobs.container.BlockProtection;
|
import com.gamingmesh.jobs.container.BlockProtection;
|
||||||
import com.gamingmesh.jobs.container.DBAction;
|
import com.gamingmesh.jobs.container.DBAction;
|
||||||
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
|
|
||||||
|
import net.Zrips.CMILib.ActionBar.CMIActionBar;
|
||||||
import net.Zrips.CMILib.Container.CMIBlock;
|
import net.Zrips.CMILib.Container.CMIBlock;
|
||||||
import net.Zrips.CMILib.Container.CMIBlock.Bisect;
|
import net.Zrips.CMILib.Container.CMIBlock.Bisect;
|
||||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||||
@ -22,7 +26,7 @@ public class BlockProtectionManager {
|
|||||||
private final HashMap<World, HashMap<String, HashMap<String, HashMap<String, BlockProtection>>>> map = new HashMap<>();
|
private final HashMap<World, HashMap<String, HashMap<String, HashMap<String, BlockProtection>>>> map = new HashMap<>();
|
||||||
private final ConcurrentHashMap<World, ConcurrentHashMap<String, BlockProtection>> tempCache = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<World, ConcurrentHashMap<String, BlockProtection>> tempCache = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public HashMap<World, HashMap<String, HashMap<String, HashMap<String, BlockProtection>>>> getMap() {
|
public HashMap<World, HashMap<String, HashMap<String, HashMap<String, BlockProtection>>>> getMap2() {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,9 +110,7 @@ public class BlockProtectionManager {
|
|||||||
|
|
||||||
// If timer is under 2 hours, we can run scheduler to remove it when time comes
|
// If timer is under 2 hours, we can run scheduler to remove it when time comes
|
||||||
if (time > -1 && (time - System.currentTimeMillis()) / 1000 < 60 * 60 * 2)
|
if (time > -1 && (time - System.currentTimeMillis()) / 1000 < 60 * 60 * 2)
|
||||||
Bp.setScheduler(CMIScheduler.get().runAtLocationLater(loc, () -> {
|
Bp.setScheduler(CMIScheduler.runAtLocationLater(loc, () -> remove(loc), (time - System.currentTimeMillis()) / 50));
|
||||||
remove(loc);
|
|
||||||
}, (time - System.currentTimeMillis()) / 50));
|
|
||||||
|
|
||||||
Bpm.put(v, Bp);
|
Bpm.put(v, Bp);
|
||||||
chunks.put(chunk, Bpm);
|
chunks.put(chunk, Bpm);
|
||||||
@ -231,4 +233,83 @@ public class BlockProtectionManager {
|
|||||||
public boolean isInBp(Block block) {
|
public boolean isInBp(Block block) {
|
||||||
return Jobs.getRestrictedBlockManager().restrictedBlocksTimer.containsKey(CMIMaterial.get(block));
|
return Jobs.getRestrictedBlockManager().restrictedBlocksTimer.containsKey(CMIMaterial.get(block));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isBpOk(JobsPlayer player, ActionInfo info, Block block, boolean inform) {
|
||||||
|
if (block == null || !Jobs.getGCManager().useBlockProtection)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (info.getType() == ActionType.BREAK) {
|
||||||
|
if (block.hasMetadata("JobsExploit")) {
|
||||||
|
//player.sendMessage("This block is protected using Rukes' system!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockProtection bp = getBp(block.getLocation());
|
||||||
|
if (bp != null) {
|
||||||
|
long time = bp.getTime();
|
||||||
|
Integer cd = getBlockDelayTime(block);
|
||||||
|
|
||||||
|
if (time == -1L) {
|
||||||
|
remove(block);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (time < System.currentTimeMillis() && bp.getAction() != DBAction.DELETE) {
|
||||||
|
remove(block);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((time > System.currentTimeMillis() || bp.isPaid()) && bp.getAction() != DBAction.DELETE) {
|
||||||
|
if (inform && player.canGetPaid(info)) {
|
||||||
|
int sec = Math.round((time - System.currentTimeMillis()) / 1000L);
|
||||||
|
CMIActionBar.send(player.getPlayer(), Jobs.getLanguage().getMessage("message.blocktimer", "[time]", sec));
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
add(block, cd);
|
||||||
|
|
||||||
|
if ((cd == null || cd == 0) && Jobs.getGCManager().useGlobalTimer) {
|
||||||
|
add(block, Jobs.getGCManager().globalblocktimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (Jobs.getGCManager().useGlobalTimer) {
|
||||||
|
add(block, Jobs.getGCManager().globalblocktimer);
|
||||||
|
}
|
||||||
|
} else if (info.getType() == ActionType.PLACE) {
|
||||||
|
BlockProtection bp = getBp(block.getLocation());
|
||||||
|
if (bp != null) {
|
||||||
|
Long time = bp.getTime();
|
||||||
|
Integer cd = getBlockDelayTime(block);
|
||||||
|
if (time != -1L) {
|
||||||
|
if (time < System.currentTimeMillis() && bp.getAction() != DBAction.DELETE) {
|
||||||
|
add(block, cd);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((time > System.currentTimeMillis() || bp.isPaid()) && bp.getAction() != DBAction.DELETE) {
|
||||||
|
if (inform && player.canGetPaid(info)) {
|
||||||
|
int sec = Math.round((time - System.currentTimeMillis()) / 1000L);
|
||||||
|
CMIActionBar.send(player.getPlayer(), Jobs.getLanguage().getMessage("message.blocktimer", "[time]", sec));
|
||||||
|
}
|
||||||
|
|
||||||
|
add(block, cd);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lets add protection in any case
|
||||||
|
add(block, cd);
|
||||||
|
} else if (bp.isPaid() && bp.getTime() == -1L && cd != null && cd == -1) {
|
||||||
|
add(block, cd);
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
add(block, cd);
|
||||||
|
} else
|
||||||
|
add(block, getBlockDelayTime(block));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,9 +140,7 @@ public class BossBarManager {
|
|||||||
bar.setVisible(true);
|
bar.setVisible(true);
|
||||||
|
|
||||||
if (oldOne != null)
|
if (oldOne != null)
|
||||||
oldOne.setScheduler(CMIScheduler.get().runTaskLater(new Runnable() {
|
oldOne.setScheduler(CMIScheduler.runTaskLater(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
for (BossBarInfo one : player.getBossBarInfo()) {
|
for (BossBarInfo one : player.getBossBarInfo()) {
|
||||||
if (!one.getPlayerName().equalsIgnoreCase(player.getName()))
|
if (!one.getPlayerName().equalsIgnoreCase(player.getName()))
|
||||||
continue;
|
continue;
|
||||||
@ -154,7 +152,6 @@ public class BossBarManager {
|
|||||||
tempBar.setVisible(false);
|
tempBar.setVisible(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, Jobs.getGCManager().BossBarTimer * 20L));
|
}, Jobs.getGCManager().BossBarTimer * 20L));
|
||||||
|
|
||||||
jobProg.setLastExperience(0D);
|
jobProg.setLastExperience(0D);
|
||||||
|
@ -0,0 +1,225 @@
|
|||||||
|
package com.gamingmesh.jobs.config;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.container.ActionInfo;
|
||||||
|
import com.gamingmesh.jobs.container.ActionType;
|
||||||
|
import com.gamingmesh.jobs.container.BlockProtection;
|
||||||
|
import com.gamingmesh.jobs.container.ExploitProtection;
|
||||||
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
|
|
||||||
|
import net.Zrips.CMILib.ActionBar.CMIActionBar;
|
||||||
|
import net.Zrips.CMILib.Container.CMIBlock;
|
||||||
|
import net.Zrips.CMILib.Container.CMIBlock.Bisect;
|
||||||
|
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||||
|
import net.Zrips.CMILib.PersistentData.CMIBlockPersistentDataContainer;
|
||||||
|
|
||||||
|
public class ExploitProtectionManager {
|
||||||
|
|
||||||
|
private static final String NAMEGENERAL = "JobsExploitProtection";
|
||||||
|
private static final String NAMEPAID = "JobsPaidProtection";
|
||||||
|
|
||||||
|
public void addProtection(Block block, Integer cd) {
|
||||||
|
|
||||||
|
if (cd == null || cd == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Assuming that block is bottom part of flower we will add top part to the record too
|
||||||
|
switch (CMIMaterial.get(block)) {
|
||||||
|
case LILAC:
|
||||||
|
case SUNFLOWER:
|
||||||
|
case ROSE_BUSH:
|
||||||
|
case PEONY:
|
||||||
|
CMIBlock cmb = new CMIBlock(block);
|
||||||
|
// We are only interested in this being bottom block as this should never trigger for top part of placed block
|
||||||
|
if (cmb.getBisect().equals(Bisect.BOTTOM))
|
||||||
|
addProtection(block.getLocation().clone().add(0, 1, 0).getBlock(), cd, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
addProtection(block, cd, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addProtection(Block block, Integer cd, boolean paid) {
|
||||||
|
if (cd == null || cd == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
addProtection(block, cd != -1 ? System.currentTimeMillis() + (cd * 1000) : -1, paid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExploitProtection addProtection(Block block, Long protectedUntil, boolean paid) {
|
||||||
|
|
||||||
|
if (!Jobs.getGCManager().useNewBlockProtection) {
|
||||||
|
BlockProtection protection = Jobs.getBpManager().addP(block.getLocation(), protectedUntil, paid, true);
|
||||||
|
|
||||||
|
ExploitProtection ep = new ExploitProtection(block.getLocation().toVector());
|
||||||
|
ep.setPaid(protection.isPaid());
|
||||||
|
ep.setProtectedUntil(protection.getTime());
|
||||||
|
return ep;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (protectedUntil == null || protectedUntil == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
CMIBlockPersistentDataContainer pdc = new CMIBlockPersistentDataContainer(block);
|
||||||
|
pdc.set(NAMEGENERAL, protectedUntil);
|
||||||
|
pdc.set(NAMEPAID, paid);
|
||||||
|
pdc.save();
|
||||||
|
|
||||||
|
ExploitProtection ep = new ExploitProtection(block.getLocation().toVector());
|
||||||
|
ep.setPaid(paid);
|
||||||
|
ep.setProtectedUntil(protectedUntil);
|
||||||
|
|
||||||
|
return ep;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(Block block) {
|
||||||
|
|
||||||
|
// In case double plant was destroyed we should remove both blocks from records
|
||||||
|
CMIMaterial cmat = CMIMaterial.get(block);
|
||||||
|
switch (cmat) {
|
||||||
|
case LILAC:
|
||||||
|
case SUNFLOWER:
|
||||||
|
case ROSE_BUSH:
|
||||||
|
case PEONY:
|
||||||
|
CMIBlock cmb = new CMIBlock(block);
|
||||||
|
if (cmb.getBisect().equals(Bisect.BOTTOM)) {
|
||||||
|
block = block.getLocation().clone().add(0, 1, 0).getBlock();
|
||||||
|
} else {
|
||||||
|
block = block.getLocation().clone().add(0, -1, 0).getBlock();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CMIBlockPersistentDataContainer pdc = new CMIBlockPersistentDataContainer(block);
|
||||||
|
pdc.remove(NAMEGENERAL);
|
||||||
|
pdc.remove(NAMEPAID);
|
||||||
|
pdc.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getTime(Block block) {
|
||||||
|
|
||||||
|
if (!Jobs.getGCManager().useNewBlockProtection)
|
||||||
|
return Jobs.getBpManager().getTime(block);
|
||||||
|
|
||||||
|
CMIBlockPersistentDataContainer pdc = new CMIBlockPersistentDataContainer(block);
|
||||||
|
return pdc.getLong(NAMEGENERAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getTime(Location loc) {
|
||||||
|
return getTime(loc.getBlock());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getBlockProtectionTime(Block block) {
|
||||||
|
Integer time = Jobs.getRestrictedBlockManager().restrictedBlocksTimer.get(CMIMaterial.get(block));
|
||||||
|
if (time == null && Jobs.getGCManager().useGlobalTimer) {
|
||||||
|
time = Jobs.getGCManager().globalblocktimer;
|
||||||
|
}
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInProtection(Block block) {
|
||||||
|
return Jobs.getRestrictedBlockManager().restrictedBlocksTimer.containsKey(CMIMaterial.get(block));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPaid(Block block, boolean paid) {
|
||||||
|
CMIBlockPersistentDataContainer pdc = new CMIBlockPersistentDataContainer(block);
|
||||||
|
pdc.set(NAMEPAID, paid);
|
||||||
|
pdc.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ExploitProtection getProtection(Block block) {
|
||||||
|
|
||||||
|
ExploitProtection ep = new ExploitProtection(block.getLocation().toVector());
|
||||||
|
|
||||||
|
CMIBlockPersistentDataContainer pdc = new CMIBlockPersistentDataContainer(block);
|
||||||
|
|
||||||
|
ep.setPaid(pdc.getBoolean(NAMEPAID));
|
||||||
|
ep.setProtectedUntil(pdc.getLong(NAMEGENERAL));
|
||||||
|
|
||||||
|
return ep;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isProtectionValidAddIfNotExists(JobsPlayer player, ActionInfo info, Block block, boolean inform) {
|
||||||
|
|
||||||
|
if (!Jobs.getGCManager().useNewBlockProtection)
|
||||||
|
return Jobs.getBpManager().isBpOk(player, info, block, inform);
|
||||||
|
|
||||||
|
if (block == null || !Jobs.getGCManager().useBlockProtection)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (info.getType() == ActionType.BREAK) {
|
||||||
|
if (block.hasMetadata("JobsExploit")) {
|
||||||
|
//player.sendMessage("This block is protected using Rukes' system!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExploitProtection exploitProtection = getProtection(block);
|
||||||
|
if (exploitProtection.getProtectedUntil() != 0) {
|
||||||
|
long time = exploitProtection.getProtectedUntil();
|
||||||
|
|
||||||
|
if (time == -1L) {
|
||||||
|
remove(block);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (time < System.currentTimeMillis()) {
|
||||||
|
remove(block);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (time > System.currentTimeMillis() || exploitProtection.isPaid()) {
|
||||||
|
if (inform && player.canGetPaid(info))
|
||||||
|
CMIActionBar.send(player.getPlayer(), Jobs.getLanguage().getMessage("message.blocktimer", "[time]", Math.round((time - System.currentTimeMillis()) / 1000L)));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer cd = getBlockProtectionTime(block);
|
||||||
|
|
||||||
|
if ((cd == null || cd == 0) && Jobs.getGCManager().useGlobalTimer) {
|
||||||
|
addProtection(block, Jobs.getGCManager().globalblocktimer);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
addProtection(block, cd);
|
||||||
|
|
||||||
|
} else if (Jobs.getGCManager().useGlobalTimer) {
|
||||||
|
addProtection(block, Jobs.getGCManager().globalblocktimer);
|
||||||
|
}
|
||||||
|
} else if (info.getType() == ActionType.PLACE) {
|
||||||
|
ExploitProtection exploitProtection = getProtection(block);
|
||||||
|
if (exploitProtection.getProtectedUntil() != 0) {
|
||||||
|
|
||||||
|
long time = exploitProtection.getProtectedUntil();
|
||||||
|
|
||||||
|
Integer cd = getBlockProtectionTime(block);
|
||||||
|
if (time != -1L) {
|
||||||
|
if (time < System.currentTimeMillis()) {
|
||||||
|
addProtection(block, cd);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((time > System.currentTimeMillis() || exploitProtection.isPaid())) {
|
||||||
|
if (inform && player.canGetPaid(info))
|
||||||
|
CMIActionBar.send(player.getPlayer(), Jobs.getLanguage().getMessage("message.blocktimer", "[time]", Math.round((time - System.currentTimeMillis()) / 1000L)));
|
||||||
|
addProtection(block, cd);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lets add protection in any case
|
||||||
|
addProtection(block, cd);
|
||||||
|
} else if (exploitProtection.isPaid() && exploitProtection.getProtectedUntil() == -1L && cd != null && cd == -1) {
|
||||||
|
addProtection(block, cd);
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
addProtection(block, cd);
|
||||||
|
} else
|
||||||
|
addProtection(block, getBlockProtectionTime(block));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -93,7 +93,7 @@ public class GeneralConfigManager {
|
|||||||
|
|
||||||
private FireworkEffect fireworkEffect;
|
private FireworkEffect fireworkEffect;
|
||||||
|
|
||||||
public boolean ignoreOreGenerators, useBlockProtection, useBlockProtectionBlockTracker, enableSchedule, PayForRenaming, PayForEnchantingOnAnvil, PayForEachCraft, SignsEnabled,
|
public boolean ignoreOreGenerators, useBlockProtection, useNewBlockProtection, useBlockProtectionBlockTracker, enableSchedule, PayForRenaming, PayForEnchantingOnAnvil, PayForEachCraft, SignsEnabled,
|
||||||
SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useSilkTouchProtection, UseCustomNames,
|
SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useSilkTouchProtection, UseCustomNames,
|
||||||
PreventSlimeSplit, PreventMagmaCubeSplit, PreventHopperFillUps, PreventBrewingStandFillUps, informOnPaymentDisable,
|
PreventSlimeSplit, PreventMagmaCubeSplit, PreventHopperFillUps, PreventBrewingStandFillUps, informOnPaymentDisable,
|
||||||
BrowseUseNewLook, payExploringWhenGliding = false, resetExploringData = false, disablePaymentIfMaxLevelReached, disablePaymentIfRiding,
|
BrowseUseNewLook, payExploringWhenGliding = false, resetExploringData = false, disablePaymentIfMaxLevelReached, disablePaymentIfRiding,
|
||||||
@ -885,6 +885,13 @@ public class GeneralConfigManager {
|
|||||||
"Modify restrictedBlocks.yml for blocks you want to protect");
|
"Modify restrictedBlocks.yml for blocks you want to protect");
|
||||||
useBlockProtection = c.get("ExploitProtections.General.PlaceAndBreak.Enabled", c.getC().getBoolean("ExploitProtections.General.PlaceAndBreakProtection", true));
|
useBlockProtection = c.get("ExploitProtections.General.PlaceAndBreak.Enabled", c.getC().getBoolean("ExploitProtections.General.PlaceAndBreakProtection", true));
|
||||||
|
|
||||||
|
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) {
|
||||||
|
c.addComment("ExploitProtections.General.PlaceAndBreak.NewMethod",
|
||||||
|
"Should we use new block protection method", "In most cases this is more efficient way to check for break/place protection and doesn't involve any cache or data saving into database",
|
||||||
|
"Only works with 1.14+ servers");
|
||||||
|
useNewBlockProtection = c.get("ExploitProtections.General.PlaceAndBreak.NewMethod", true);
|
||||||
|
}
|
||||||
|
|
||||||
c.addComment("ExploitProtections.General.PlaceAndBreak.BlockTracker.Enabled",
|
c.addComment("ExploitProtections.General.PlaceAndBreak.BlockTracker.Enabled",
|
||||||
"Should we use BlockTracker plugin instead of built in block tracker");
|
"Should we use BlockTracker plugin instead of built in block tracker");
|
||||||
useBlockProtectionBlockTracker = c.get("ExploitProtections.General.PlaceAndBreak.BlockTracker.Enabled", false);
|
useBlockProtectionBlockTracker = c.get("ExploitProtections.General.PlaceAndBreak.BlockTracker.Enabled", false);
|
||||||
@ -894,6 +901,7 @@ public class GeneralConfigManager {
|
|||||||
ignoreOreGenerators = c.get("ExploitProtections.General.PlaceAndBreak.IgnoreOreGenerators", true);
|
ignoreOreGenerators = c.get("ExploitProtections.General.PlaceAndBreak.IgnoreOreGenerators", true);
|
||||||
|
|
||||||
c.addComment("ExploitProtections.General.PlaceAndBreak.KeepDataFor",
|
c.addComment("ExploitProtections.General.PlaceAndBreak.KeepDataFor",
|
||||||
|
"Only applies when old method is used",
|
||||||
"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",
|
"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");
|
"Data base cleanup will be performed on each server startup", "This cant be more then 14 days");
|
||||||
BlockProtectionDays = c.get("ExploitProtections.General.PlaceAndBreak.KeepDataFor", c.getC().getInt("ExploitProtections.General.KeepDataFor", 14));
|
BlockProtectionDays = c.get("ExploitProtections.General.PlaceAndBreak.KeepDataFor", c.getC().getInt("ExploitProtections.General.KeepDataFor", 14));
|
||||||
@ -903,15 +911,15 @@ public class GeneralConfigManager {
|
|||||||
+ " once you have broken the block in one place.");
|
+ " once you have broken the block in one place.");
|
||||||
allowBreakPaymentForOreGenerators = c.get("ExploitProtections.General.AllowBreakPaymentForOreGenerators", false);*/
|
allowBreakPaymentForOreGenerators = c.get("ExploitProtections.General.AllowBreakPaymentForOreGenerators", false);*/
|
||||||
|
|
||||||
c.addComment("ExploitProtections.General.PlaceAndBreak.GlobalBlockTimer", "All blocks will be protected X sec after player places it on ground.");
|
c.addComment("ExploitProtections.General.PlaceAndBreak.GlobalBlockTimer", "All blocks will be protected X seconds after player places/breaks it");
|
||||||
useGlobalTimer = c.get("ExploitProtections.General.PlaceAndBreak.GlobalBlockTimer.Use", c.getC().getBoolean("ExploitProtections.General.GlobalBlockTimer.use", true));
|
useGlobalTimer = c.get("ExploitProtections.General.PlaceAndBreak.GlobalBlockTimer.Use", true);
|
||||||
c.addComment("ExploitProtections.General.PlaceAndBreak.GlobalBlockTimer.Timer", "Time in seconds. This can only be positive number");
|
c.addComment("ExploitProtections.General.PlaceAndBreak.GlobalBlockTimer.Timer", "Time in seconds. This can only be positive number");
|
||||||
globalblocktimer = c.get("ExploitProtections.General.PlaceAndBreak.GlobalBlockTimer.Timer", c.getC().getInt("ExploitProtections.General.GlobalBlockTimer.timer", 3));
|
globalblocktimer = c.get("ExploitProtections.General.PlaceAndBreak.GlobalBlockTimer.Timer", 3);
|
||||||
globalblocktimer = CMINumber.clamp(globalblocktimer, 1, 99999);
|
globalblocktimer = CMINumber.clamp(globalblocktimer, 1, 99999);
|
||||||
|
|
||||||
c.addComment("ExploitProtections.General.PlaceAndBreak.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.");
|
"With this enabled players wont get paid for broken blocks from restrictedblocks list with silk touch tool.");
|
||||||
useSilkTouchProtection = c.get("ExploitProtections.General.PlaceAndBreak.SilkTouchProtection", c.getC().getBoolean("ExploitProtections.General.SilkTouchProtection", false));
|
useSilkTouchProtection = c.get("ExploitProtections.General.PlaceAndBreak.SilkTouchProtection", false);
|
||||||
|
|
||||||
c.addComment("ExploitProtections.General.MonsterDamage.Use", "This section controls how much damage player should do to monster for player to get paid",
|
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");
|
"This prevents from killing monsters in one hit when they suffer in example fall damage");
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
package com.gamingmesh.jobs.container;
|
||||||
|
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
public class ExploitProtection {
|
||||||
|
|
||||||
|
private long protectedUntil = -1;
|
||||||
|
private boolean paid = false;
|
||||||
|
private int x = 0;
|
||||||
|
private short y = 0;
|
||||||
|
private int z = 0;
|
||||||
|
|
||||||
|
public ExploitProtection(Vector pos) {
|
||||||
|
this(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExploitProtection(Vector pos, boolean paid, long protectedUntil) {
|
||||||
|
this(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||||
|
this.paid = paid;
|
||||||
|
this.protectedUntil = protectedUntil;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExploitProtection(int x, int y, int z) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = (short) y;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getProtectedUntil() {
|
||||||
|
return protectedUntil;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProtectedUntil(Long time) {
|
||||||
|
this.protectedUntil = time == null ? 0 : time < 0 ? -1 : time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPaid() {
|
||||||
|
return paid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPaid(Boolean paid) {
|
||||||
|
this.paid = paid == null ? false : paid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getZ() {
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
}
|
@ -2465,6 +2465,9 @@ public abstract class JobsDAO {
|
|||||||
* @param jobBlockProtection - the information getting saved
|
* @param jobBlockProtection - the information getting saved
|
||||||
*/
|
*/
|
||||||
public void loadBlockProtection() {
|
public void loadBlockProtection() {
|
||||||
|
if (Jobs.getGCManager().useNewBlockProtection)
|
||||||
|
return;
|
||||||
|
|
||||||
JobsConnection conn = getConnection();
|
JobsConnection conn = getConnection();
|
||||||
if (conn == null)
|
if (conn == null)
|
||||||
return;
|
return;
|
||||||
|
@ -127,6 +127,10 @@ public class JobsListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld()))
|
if (!Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (Jobs.getGCManager().useNewBlockProtection)
|
||||||
|
Jobs.getExploitManager().remove(event.getToBlock());
|
||||||
|
else
|
||||||
Jobs.getBpManager().remove(event.getToBlock());
|
Jobs.getBpManager().remove(event.getToBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,14 +405,24 @@ public class JobsListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onCropGrown(final BlockGrowEvent event) {
|
public void onCropGrown(final BlockGrowEvent event) {
|
||||||
if (Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) {
|
if (Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) {
|
||||||
CMIScheduler.get().runAtLocationLater(event.getBlock().getLocation(), () -> Jobs.getBpManager().remove(event.getBlock()), 1L);
|
CMIScheduler.runAtLocationLater(event.getBlock().getLocation(), () -> {
|
||||||
|
if (Jobs.getGCManager().useNewBlockProtection)
|
||||||
|
Jobs.getExploitManager().remove(event.getBlock());
|
||||||
|
else
|
||||||
|
Jobs.getBpManager().remove(event.getBlock());
|
||||||
|
}, 1L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onTreeGrown(final StructureGrowEvent event) {
|
public void onTreeGrown(final StructureGrowEvent event) {
|
||||||
if (!event.getBlocks().isEmpty() && Jobs.getGCManager().canPerformActionInWorld(event.getBlocks().get(0).getWorld())) {
|
if (!event.getBlocks().isEmpty() && Jobs.getGCManager().canPerformActionInWorld(event.getBlocks().get(0).getWorld())) {
|
||||||
CMIScheduler.get().runAtLocationLater(event.getBlocks().get(0).getLocation(), () -> event.getBlocks().forEach(blockState -> Jobs.getBpManager().remove(blockState.getBlock())), 1L);
|
CMIScheduler.runAtLocationLater(event.getBlocks().get(0).getLocation(), () -> event.getBlocks().forEach(blockState -> {
|
||||||
|
if (Jobs.getGCManager().useNewBlockProtection)
|
||||||
|
Jobs.getExploitManager().remove(blockState.getBlock());
|
||||||
|
else
|
||||||
|
Jobs.getBpManager().remove(blockState.getBlock());
|
||||||
|
}), 1L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,7 +473,7 @@ public final class JobsPaymentListener implements Listener {
|
|||||||
if (Jobs.getGCManager().useSilkTouchProtection) {
|
if (Jobs.getGCManager().useSilkTouchProtection) {
|
||||||
ItemStack item = CMIItemStack.getItemInMainHand(player);
|
ItemStack item = CMIItemStack.getItemInMainHand(player);
|
||||||
|
|
||||||
if (item.getType() != Material.AIR && Jobs.getBpManager().isInBp(block)) {
|
if (item.getType() != Material.AIR && Jobs.getExploitManager().isInProtection(block)) {
|
||||||
for (Enchantment one : item.getEnchantments().keySet()) {
|
for (Enchantment one : item.getEnchantments().keySet()) {
|
||||||
CMIEnchantment enchant = CMIEnchantment.get(one);
|
CMIEnchantment enchant = CMIEnchantment.get(one);
|
||||||
if (enchant != null && enchant.equalEnum(CMIEnchantEnum.SILK_TOUCH)) {
|
if (enchant != null && enchant.equalEnum(CMIEnchantEnum.SILK_TOUCH)) {
|
||||||
|
@ -26,11 +26,11 @@ public class PistonProtectionListener implements Listener {
|
|||||||
for (int i = event.getBlocks().size() - 1; i >= 0; i--) {
|
for (int i = event.getBlocks().size() - 1; i >= 0; i--) {
|
||||||
Location oldLoc = event.getBlocks().get(i).getLocation();
|
Location oldLoc = event.getBlocks().get(i).getLocation();
|
||||||
Location newLoc = oldLoc.clone().add(dir.getModX(), dir.getModY(), dir.getModZ());
|
Location newLoc = oldLoc.clone().add(dir.getModX(), dir.getModY(), dir.getModZ());
|
||||||
Long bp = Jobs.getBpManager().getTime(oldLoc);
|
Long bp = Jobs.getExploitManager().getTime(event.getBlocks().get(i));
|
||||||
|
|
||||||
if (bp == null)
|
if (bp == null)
|
||||||
continue;
|
continue;
|
||||||
Jobs.getBpManager().addP(newLoc, bp, false, true);
|
Jobs.getExploitManager().addProtection(newLoc.getBlock(), bp, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,10 +45,10 @@ public class PistonProtectionListener implements Listener {
|
|||||||
for (int i = blocks.size() - 1; i >= 0; i--) {
|
for (int i = blocks.size() - 1; i >= 0; i--) {
|
||||||
Location oldLoc = blocks.get(i).getLocation();
|
Location oldLoc = blocks.get(i).getLocation();
|
||||||
Location newLoc = oldLoc.clone().add(dir.getModX(), dir.getModY(), dir.getModZ());
|
Location newLoc = oldLoc.clone().add(dir.getModX(), dir.getModY(), dir.getModZ());
|
||||||
Long bp = Jobs.getBpManager().getTime(oldLoc);
|
Long bp = Jobs.getExploitManager().getTime(blocks.get(i));
|
||||||
if (bp == null)
|
if (bp == null)
|
||||||
continue;
|
continue;
|
||||||
Jobs.getBpManager().addP(newLoc, bp, false, true);
|
Jobs.getExploitManager().addProtection(newLoc.getBlock(), bp, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user