Fixed NullPointerException when rolling back player heads (fixes #473)
This commit is contained in:
parent
1c57ba52aa
commit
ba6a55fff6
6 changed files with 37 additions and 3 deletions
|
|
@ -10,6 +10,7 @@ import org.bukkit.block.Skull;
|
|||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.Database;
|
||||
import net.coreprotect.database.statement.SkullStatement;
|
||||
import net.coreprotect.paper.PaperAdapter;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class SkullBreakLogger {
|
||||
|
|
@ -29,7 +30,7 @@ public class SkullBreakLogger {
|
|||
String skullOwner = "";
|
||||
int skullKey = 0;
|
||||
if (skull.hasOwner()) {
|
||||
skullOwner = skull.getOwningPlayer().getUniqueId().toString();
|
||||
skullOwner = PaperAdapter.ADAPTER.getSkullOwner(skull);
|
||||
ResultSet resultSet = SkullStatement.insert(preparedStmt2, time, skullOwner);
|
||||
if (Database.hasReturningKeys()) {
|
||||
resultSet.next();
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import org.bukkit.block.Skull;
|
|||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.Database;
|
||||
import net.coreprotect.database.statement.SkullStatement;
|
||||
import net.coreprotect.paper.PaperAdapter;
|
||||
|
||||
public class SkullPlaceLogger {
|
||||
|
||||
|
|
@ -31,7 +32,7 @@ public class SkullPlaceLogger {
|
|||
Skull skull = (Skull) block;
|
||||
String skullOwner = "";
|
||||
if (skull.hasOwner()) {
|
||||
skullOwner = skull.getOwningPlayer().getUniqueId().toString();
|
||||
skullOwner = PaperAdapter.ADAPTER.getSkullOwner(skull);
|
||||
ResultSet resultSet = SkullStatement.insert(preparedStmt2, time, skullOwner);
|
||||
if (Database.hasReturningKeys()) {
|
||||
resultSet.next();
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import org.bukkit.block.BlockState;
|
|||
import org.bukkit.block.Skull;
|
||||
|
||||
import net.coreprotect.database.Database;
|
||||
import net.coreprotect.paper.PaperAdapter;
|
||||
|
||||
public class SkullStatement {
|
||||
|
||||
|
|
@ -46,9 +47,12 @@ public class SkullStatement {
|
|||
|
||||
while (resultSet.next()) {
|
||||
String owner = resultSet.getString("owner");
|
||||
if (owner != null && owner.length() >= 32) {
|
||||
if (owner != null && owner.length() >= 32 && owner.contains("-")) {
|
||||
skull.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(owner)));
|
||||
}
|
||||
else if (owner != null && owner.length() > 1) {
|
||||
PaperAdapter.ADAPTER.setSkullOwner(skull, owner);
|
||||
}
|
||||
}
|
||||
|
||||
resultSet.close();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue