diff --git a/pom.xml b/pom.xml
index a53bd0c3..d44936c7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -196,5 +196,11 @@
provided
4.9.0.6
+
+ net
+ coreprotect
+ provided
+ 2.18.2
+
diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java
index 5f86e20b..6c8f5ece 100644
--- a/src/main/java/com/songoda/skyblock/SkyBlock.java
+++ b/src/main/java/com/songoda/skyblock/SkyBlock.java
@@ -45,10 +45,13 @@ import com.songoda.skyblock.visit.VisitManager;
import com.songoda.skyblock.visit.VisitTask;
import com.songoda.skyblock.world.WorldManager;
import com.songoda.skyblock.world.generator.VoidGenerator;
+import net.coreprotect.CoreProtect;
+import net.coreprotect.CoreProtectAPI;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.HandlerList;
import org.bukkit.generator.ChunkGenerator;
+import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import java.io.File;
@@ -88,6 +91,8 @@ public class SkyBlock extends SongodaPlugin {
private BankManager bankManager;
private PermissionManager permissionManager;
+ private CoreProtectAPI coreProtectAPI;
+
private final GuiManager guiManager = new GuiManager(this);
public static SkyBlock getInstance() {
@@ -196,6 +201,8 @@ public class SkyBlock extends SongodaPlugin {
this.getCommand("skyblock").setExecutor(new SkyBlockCommand());
+ this.coreProtectAPI = loadCoreProtect();
+
SkyBlockAPI.setImplementation(INSTANCE);
}
@@ -240,6 +247,24 @@ public class SkyBlock extends SongodaPlugin {
HandlerList.unregisterAll(this);
}
+ private CoreProtectAPI loadCoreProtect() {
+ Plugin plugin = getServer().getPluginManager().getPlugin("CoreProtect");
+
+
+ if (plugin != null) { // Check before loading classes
+ if (plugin instanceof CoreProtect) { // Check that CoreProtect is loaded
+ CoreProtectAPI CoreProtect = ((CoreProtect) plugin).getAPI();
+ if (CoreProtect.isEnabled()) { // Check that the API is enabled
+ if (CoreProtect.APIVersion() >= 6) { // Check that a compatible version of the API is loaded
+ return CoreProtect;
+ }
+ }
+ }
+ }
+ return null;
+
+ }
+
@Override
public void onConfigReload() {
@@ -386,4 +411,8 @@ public class SkyBlock extends SongodaPlugin {
public GuiManager getGuiManager() {
return guiManager;
}
+
+ public CoreProtectAPI getCoreProtectAPI() {
+ return coreProtectAPI;
+ }
}
diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java
index ce16ea0d..b3a687cf 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Block.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Block.java
@@ -78,7 +78,7 @@ public class Block implements Listener {
CompatibleMaterial material = CompatibleMaterial.getMaterial(block);
byte data = block.getData();
- int droppedAmount = 0;
+ int droppedAmount;
if (event.getPlayer().isSneaking()) {
Location dropLoc = blockLocation.clone().add(0.5, 0.5, 0.5);
int count = stackable.getSize();
@@ -96,6 +96,10 @@ public class Block implements Listener {
droppedAmount = 1;
}
+ if(skyblock.getCoreProtectAPI() != null) {
+ skyblock.getCoreProtectAPI().logRemoval(player.getName(), block.getLocation(), material.getMaterial(), null);
+ }
+
if (stackable.getSize() <= 1) {
stackableManager.removeStack(stackable);
}
diff --git a/src/main/java/com/songoda/skyblock/listeners/Interact.java b/src/main/java/com/songoda/skyblock/listeners/Interact.java
index 0e053b5b..53244d01 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Interact.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Interact.java
@@ -236,6 +236,10 @@ public class Interact implements Listener {
event.setCancelled(true);
}
+ if(skyblock.getCoreProtectAPI() != null && material != null) {
+ skyblock.getCoreProtectAPI().logPlacement(player.getName(), location, material.getMaterial(), null);
+ }
+
if (player.getGameMode() != GameMode.CREATIVE)
ItemUtils.takeActiveItem(player, CompatibleHand.getHand(event), itemAmount);
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 2932d356..0f607091 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -5,7 +5,8 @@ api-version: 1.13
description: A unique SkyBlock plugin
author: Songoda
authors: [Fabrimat]
-softdepend: [HolographicDisplays, Holograms, CMI, PlaceholderAPI, MVdWPlaceholderAPI, Vault, Reserve, LeaderHeads, EpicSpawners, WildStacker, UltimateStacker, WorldEdit, Residence]
+softdepend: [HolographicDisplays, Holograms, CMI, PlaceholderAPI, MVdWPlaceholderAPI, Vault, Reserve, LeaderHeads,
+ EpicSpawners, WildStacker, UltimateStacker, WorldEdit, Residence, CoreProtect]
loadbefore: [Multiverse-Core, ProtocolLib]
commands:
island: