Compare commits

...

4 Commits

Author SHA1 Message Date
A 0a3f593cb6
Merge ba071ec1ed into 6023c21ba9 2024-05-07 15:04:07 +12:00
Intelli 6023c21ba9 Fixed hopper pulls performing container validation on source block 2024-05-06 19:19:48 -06:00
Intelli 3e3496ad12 Corrected version references in API v10 documentation 2024-05-06 18:18:56 -06:00
Arasple ba071ec1ed Check for optional SkullOwner 2024-03-04 19:59:50 +08:00
4 changed files with 22 additions and 12 deletions

View File

@ -25,8 +25,8 @@ logRemoval(String user, BlockState blockState)
## Getting Started
Ensure you're using CoreProtect 21.0 or higher. Add it as an external jar to your plugin in your IDE.
Alternatively, if using Maven, you can add it via the repository [https://maven.playpro.com](https://maven.playpro.com) (net.coreprotect, 21.0).
Ensure you're using CoreProtect 23.0 or higher. Add it as an external jar to your plugin in your IDE.
Alternatively, if using Maven, you can add it via the repository [https://maven.playpro.com](https://maven.playpro.com) (net.coreprotect, 23.0).
The first thing you need to do is get access to CoreProtect. You can do this by using code similar to the following:
@ -49,7 +49,7 @@ private CoreProtectAPI getCoreProtect() {
}
// Check that a compatible version of the API is loaded
if (CoreProtect.APIVersion() < 9) {
if (CoreProtect.APIVersion() < 10) {
return null;
}

View File

@ -28,7 +28,7 @@ public final class HopperPullListener {
}
}
ItemStack[] sourceContainer = Util.getContainerState(sourceHolder.getInventory().getContents());
ItemStack[] destinationContainer = Util.getContainerState(destinationHolder.getInventory().getContents());
ItemStack movedItem = item.clone();
final long taskStarted = InventoryChangeListener.tasksStarted.incrementAndGet();
@ -39,7 +39,7 @@ public final class HopperPullListener {
}
boolean abort = false;
boolean addedInventory = Util.canAddContainer(sourceContainer, movedItem, sourceHolder.getInventory().getMaxStackSize());
boolean addedInventory = Util.canAddContainer(destinationContainer, movedItem, destinationHolder.getInventory().getMaxStackSize());
if (!addedInventory) {
abort = true;
}

View File

@ -1,6 +1,9 @@
package net.coreprotect.paper;
import net.coreprotect.bukkit.BukkitAdapter;
import net.coreprotect.config.ConfigHandler;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.block.Sign;
import org.bukkit.block.Skull;
@ -8,9 +11,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import net.coreprotect.bukkit.BukkitAdapter;
import net.coreprotect.config.ConfigHandler;
public class PaperAdapter implements PaperInterface {
public static PaperInterface ADAPTER;
@ -76,7 +76,12 @@ public class PaperAdapter implements PaperInterface {
@Override
public String getSkullOwner(Skull skull) {
return skull.getOwningPlayer().getUniqueId().toString();
OfflinePlayer owner = skull.getOwningPlayer();
if (owner != null) {
return owner.getUniqueId().toString();
} else {
return "";
}
}
@Override

View File

@ -1,12 +1,12 @@
package net.coreprotect.paper;
import com.destroystokyo.paper.profile.PlayerProfile;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.block.Sign;
import org.bukkit.block.Skull;
import org.bukkit.block.sign.Side;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
public class Paper_v1_20 extends Paper_v1_17 implements PaperInterface {
@Override
@ -22,7 +22,12 @@ public class Paper_v1_20 extends Paper_v1_17 implements PaperInterface {
@Override
public String getSkullOwner(Skull skull) {
return skull.getPlayerProfile().getName();
PlayerProfile profile = skull.getPlayerProfile();
if (profile == null) {
return "";
} else {
return profile.getName();
}
}
@Override