Mirror von
https://github.com/Moulberry/AxiomPaperPlugin.git
synchronisiert 2024-11-14 04:00:05 +01:00
Clean up CoreProtect integration
Dieser Commit ist enthalten in:
Ursprung
15deea9c0c
Commit
1769394481
@ -10,51 +10,20 @@ public class CoreProtectIntegration {
|
|||||||
return CoreProtectIntegrationImpl.isEnabled();
|
return CoreProtectIntegrationImpl.isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean logPlacement(String name, BlockState blockState, CraftWorld world, BlockPos pos) {
|
public static void logPlacement(String name, BlockState blockState, CraftWorld world, BlockPos pos) {
|
||||||
if (!CoreProtectIntegrationImpl.isEnabled()) {
|
if (!CoreProtectIntegrationImpl.isEnabled()) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CoreProtectIntegrationImpl.logPlacement(name, blockState, world, pos);
|
CoreProtectIntegrationImpl.logPlacement(name, blockState, world, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean logPlacement(String name, BlockState blockState, CraftWorld world, int x, int y, int z) {
|
public static void logRemoval(String name, BlockState blockState, CraftWorld world, BlockPos pos) {
|
||||||
if (!CoreProtectIntegrationImpl.isEnabled()) {
|
if (!CoreProtectIntegrationImpl.isEnabled()) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CoreProtectIntegrationImpl.logPlacement(name, blockState, world, x, y, z);
|
CoreProtectIntegrationImpl.logRemoval(name, blockState, world, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean logPlacement(String name, Level level, CraftWorld world, BlockPos pos) {
|
|
||||||
if (!CoreProtectIntegrationImpl.isEnabled()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return CoreProtectIntegrationImpl.logPlacement(name, level, world, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean logRemoval(String name, BlockState blockState, CraftWorld world, BlockPos pos) {
|
|
||||||
if (!CoreProtectIntegrationImpl.isEnabled()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return CoreProtectIntegrationImpl.logRemoval(name, blockState, world, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean logRemoval(String name, BlockState blockState, CraftWorld world, int x, int y, int z) {
|
|
||||||
if (!CoreProtectIntegrationImpl.isEnabled()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return CoreProtectIntegrationImpl.logRemoval(name, blockState, world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean logRemoval(String name, Level level, CraftWorld world, BlockPos pos) {
|
|
||||||
if (!CoreProtectIntegrationImpl.isEnabled()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return CoreProtectIntegrationImpl.logRemoval(name, level, world, pos);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -4,7 +4,6 @@ import com.moulberry.axiom.AxiomPaper;
|
|||||||
import net.coreprotect.CoreProtect;
|
import net.coreprotect.CoreProtect;
|
||||||
import net.coreprotect.CoreProtectAPI;
|
import net.coreprotect.CoreProtectAPI;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -40,12 +39,12 @@ public class CoreProtectIntegrationImpl {
|
|||||||
private static CoreProtectAPI getCoreProtect() {
|
private static CoreProtectAPI getCoreProtect() {
|
||||||
Plugin plugin = Bukkit.getPluginManager().getPlugin("CoreProtect");
|
Plugin plugin = Bukkit.getPluginManager().getPlugin("CoreProtect");
|
||||||
|
|
||||||
if (plugin == null || !(plugin instanceof CoreProtect)) {
|
if (!(plugin instanceof CoreProtect)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreProtectAPI coreProtect = ((CoreProtect) plugin).getAPI();
|
CoreProtectAPI coreProtect = ((CoreProtect) plugin).getAPI();
|
||||||
if (coreProtect.isEnabled() == false) {
|
if (!coreProtect.isEnabled()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +57,7 @@ public class CoreProtectIntegrationImpl {
|
|||||||
|
|
||||||
private static CraftBlockState createCraftBlockState(World world, BlockPos pos, BlockState blockState) {
|
private static CraftBlockState createCraftBlockState(World world, BlockPos pos, BlockState blockState) {
|
||||||
try {
|
try {
|
||||||
return (CraftBlockState) CRAFT_BLOCK_STATE_CONSTRUCTOR.newInstance(world, pos, blockState);
|
return CRAFT_BLOCK_STATE_CONSTRUCTOR.newInstance(world, pos, blockState);
|
||||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||||
AxiomPaper.PLUGIN.getLogger().warning("Failed to create CraftBlockState for CoreProtect: " + e);
|
AxiomPaper.PLUGIN.getLogger().warning("Failed to create CraftBlockState for CoreProtect: " + e);
|
||||||
return null;
|
return null;
|
||||||
@ -69,31 +68,16 @@ public class CoreProtectIntegrationImpl {
|
|||||||
return COREPROTECT_ENABLED;
|
return COREPROTECT_ENABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean logPlacement(String name, BlockState blockState, CraftWorld world, BlockPos pos) {
|
static void logPlacement(String name, BlockState blockState, CraftWorld world, BlockPos pos) {
|
||||||
if (blockState.isAir()) {
|
if (blockState.isAir()) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return COREPROTECT_API.logPlacement(name, createCraftBlockState(world, pos, blockState));
|
COREPROTECT_API.logPlacement(name, createCraftBlockState(world, pos, blockState));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean logPlacement(String name, BlockState blockState, CraftWorld world, int x, int y, int z) {
|
static void logRemoval(String name, BlockState blockState, CraftWorld world, BlockPos pos) {
|
||||||
return logPlacement(name, blockState, world, new BlockPos(x, y, z));
|
COREPROTECT_API.logRemoval(name, createCraftBlockState(world, pos, blockState));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean logPlacement(String name, Level level, CraftWorld world, BlockPos pos) {
|
|
||||||
return logPlacement(name, level.getBlockState(pos), world, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean logRemoval(String name, BlockState blockState, CraftWorld world, BlockPos pos) {
|
|
||||||
return COREPROTECT_API.logRemoval(name, createCraftBlockState(world, pos, blockState));
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean logRemoval(String name, BlockState blockState, CraftWorld world, int x, int y, int z) {
|
|
||||||
return logRemoval(name, blockState, world, new BlockPos(x, y, z));
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean logRemoval(String name, Level level, CraftWorld world, BlockPos pos) {
|
|
||||||
return logRemoval(name, level.getBlockState(pos), world, pos);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -221,9 +221,6 @@ public class SetBlockBufferPacketListener {
|
|||||||
|
|
||||||
BlockState old = section.setBlockState(x, y, z, blockState, true);
|
BlockState old = section.setBlockState(x, y, z, blockState, true);
|
||||||
if (blockState != old) {
|
if (blockState != old) {
|
||||||
CoreProtectIntegration.logRemoval(player.getBukkitEntity().getName(), old, world.getWorld(), bx, by, bz);
|
|
||||||
CoreProtectIntegration.logPlacement(player.getBukkitEntity().getName(), blockState, world.getWorld(), bx, by, bz);
|
|
||||||
|
|
||||||
sectionChanged = true;
|
sectionChanged = true;
|
||||||
blockPos.set(bx, by, bz);
|
blockPos.set(bx, by, bz);
|
||||||
|
|
||||||
@ -291,6 +288,14 @@ public class SetBlockBufferPacketListener {
|
|||||||
} else if (old.hasBlockEntity()) {
|
} else if (old.hasBlockEntity()) {
|
||||||
chunk.removeBlockEntity(blockPos);
|
chunk.removeBlockEntity(blockPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CoreProtectIntegration.isEnabled() && old != blockState) {
|
||||||
|
String changedBy = player.getBukkitEntity().getName();
|
||||||
|
BlockPos changedPos = new BlockPos(bx, by, bz);
|
||||||
|
|
||||||
|
CoreProtectIntegration.logRemoval(changedBy, old, world.getWorld(), changedPos);
|
||||||
|
CoreProtectIntegration.logPlacement(changedBy, blockState, world.getWorld(), changedPos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,10 @@ public class SetBlockPacketListener implements PluginMessageListener {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreProtectIntegration.logRemoval(bukkitPlayer.getName(), player.level(), world, blockPos);
|
if (CoreProtectIntegration.isEnabled()) {
|
||||||
|
BlockState old = player.level().getBlockState(blockPos);
|
||||||
|
CoreProtectIntegration.logRemoval(bukkitPlayer.getName(), old, world, blockPos);
|
||||||
|
}
|
||||||
|
|
||||||
// Place block
|
// Place block
|
||||||
player.level().setBlock(blockPos, blockState, 3);
|
player.level().setBlock(blockPos, blockState, 3);
|
||||||
@ -225,9 +228,6 @@ public class SetBlockPacketListener implements PluginMessageListener {
|
|||||||
|
|
||||||
BlockState old = section.setBlockState(x, y, z, blockState, true);
|
BlockState old = section.setBlockState(x, y, z, blockState, true);
|
||||||
if (blockState != old) {
|
if (blockState != old) {
|
||||||
CoreProtectIntegration.logRemoval(bukkitPlayer.getName(), old, world, blockPos);
|
|
||||||
CoreProtectIntegration.logPlacement(bukkitPlayer.getName(), blockState, world, blockPos);
|
|
||||||
|
|
||||||
Block block = blockState.getBlock();
|
Block block = blockState.getBlock();
|
||||||
motionBlocking.update(x, by, z, blockState);
|
motionBlocking.update(x, by, z, blockState);
|
||||||
motionBlockingNoLeaves.update(x, by, z, blockState);
|
motionBlockingNoLeaves.update(x, by, z, blockState);
|
||||||
@ -284,6 +284,14 @@ public class SetBlockPacketListener implements PluginMessageListener {
|
|||||||
if (oldPoi.isPresent()) level.getPoiManager().remove(blockPos);
|
if (oldPoi.isPresent()) level.getPoiManager().remove(blockPos);
|
||||||
if (newPoi.isPresent()) level.getPoiManager().add(blockPos, newPoi.get());
|
if (newPoi.isPresent()) level.getPoiManager().add(blockPos, newPoi.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CoreProtectIntegration.isEnabled()) {
|
||||||
|
String changedBy = player.getBukkitEntity().getName();
|
||||||
|
BlockPos changedPos = new BlockPos(bx, by, bz);
|
||||||
|
|
||||||
|
CoreProtectIntegration.logRemoval(changedBy, old, world, changedPos);
|
||||||
|
CoreProtectIntegration.logPlacement(changedBy, blockState, world, changedPos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean nowHasOnlyAir = section.hasOnlyAir();
|
boolean nowHasOnlyAir = section.hasOnlyAir();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren