CoreProtect partial support

This commit is contained in:
Fabrizio La Rosa 2020-06-21 18:56:22 +02:00
parent 41d850cdc1
commit 9af318ff58
5 changed files with 46 additions and 2 deletions

View File

@ -196,5 +196,11 @@
<scope>provided</scope>
<version>4.9.0.6</version>
</dependency>
<dependency>
<groupId>net</groupId>
<artifactId>coreprotect</artifactId>
<scope>provided</scope>
<version>2.18.2</version>
</dependency>
</dependencies>
</project>

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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: