mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-11-25 12:25:37 +01:00
Prepped logging for skull skin textures on Paper servers
This commit is contained in:
parent
dbd8723752
commit
4bf4f4eb92
@ -4,9 +4,9 @@ import java.sql.Statement;
|
|||||||
|
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
|
|
||||||
|
import net.coreprotect.config.ConfigHandler;
|
||||||
import net.coreprotect.database.statement.SkullStatement;
|
import net.coreprotect.database.statement.SkullStatement;
|
||||||
import net.coreprotect.utility.Util;
|
import net.coreprotect.utility.Util;
|
||||||
import net.coreprotect.config.ConfigHandler;
|
|
||||||
|
|
||||||
class SkullUpdateProcess {
|
class SkullUpdateProcess {
|
||||||
|
|
||||||
|
@ -28,10 +28,12 @@ public class SkullBreakLogger {
|
|||||||
int type = Util.getBlockId(block.getType().name(), true);
|
int type = Util.getBlockId(block.getType().name(), true);
|
||||||
Skull skull = (Skull) block;
|
Skull skull = (Skull) block;
|
||||||
String skullOwner = "";
|
String skullOwner = "";
|
||||||
|
String skullSkin = null;
|
||||||
int skullKey = 0;
|
int skullKey = 0;
|
||||||
if (skull.hasOwner()) {
|
if (skull.hasOwner()) {
|
||||||
skullOwner = PaperAdapter.ADAPTER.getSkullOwner(skull);
|
skullOwner = PaperAdapter.ADAPTER.getSkullOwner(skull);
|
||||||
ResultSet resultSet = SkullStatement.insert(preparedStmt2, time, skullOwner);
|
skullSkin = PaperAdapter.ADAPTER.getSkullSkin(skull);
|
||||||
|
ResultSet resultSet = SkullStatement.insert(preparedStmt2, time, skullOwner, skullSkin);
|
||||||
if (Database.hasReturningKeys()) {
|
if (Database.hasReturningKeys()) {
|
||||||
resultSet.next();
|
resultSet.next();
|
||||||
skullKey = resultSet.getInt(1);
|
skullKey = resultSet.getInt(1);
|
||||||
|
@ -31,9 +31,11 @@ public class SkullPlaceLogger {
|
|||||||
if (block instanceof Skull) {
|
if (block instanceof Skull) {
|
||||||
Skull skull = (Skull) block;
|
Skull skull = (Skull) block;
|
||||||
String skullOwner = "";
|
String skullOwner = "";
|
||||||
|
String skullSkin = null;
|
||||||
if (skull.hasOwner()) {
|
if (skull.hasOwner()) {
|
||||||
skullOwner = PaperAdapter.ADAPTER.getSkullOwner(skull);
|
skullOwner = PaperAdapter.ADAPTER.getSkullOwner(skull);
|
||||||
ResultSet resultSet = SkullStatement.insert(preparedStmt2, time, skullOwner);
|
skullSkin = PaperAdapter.ADAPTER.getSkullSkin(skull);
|
||||||
|
ResultSet resultSet = SkullStatement.insert(preparedStmt2, time, skullOwner, skullSkin);
|
||||||
if (Database.hasReturningKeys()) {
|
if (Database.hasReturningKeys()) {
|
||||||
resultSet.next();
|
resultSet.next();
|
||||||
skullKey = resultSet.getInt(1);
|
skullKey = resultSet.getInt(1);
|
||||||
|
@ -18,7 +18,7 @@ public class SkullStatement {
|
|||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResultSet insert(PreparedStatement preparedStmt, int time, String owner) {
|
public static ResultSet insert(PreparedStatement preparedStmt, int time, String owner, String skin) {
|
||||||
try {
|
try {
|
||||||
preparedStmt.setInt(1, time);
|
preparedStmt.setInt(1, time);
|
||||||
preparedStmt.setString(2, owner);
|
preparedStmt.setString(2, owner);
|
||||||
|
@ -86,4 +86,14 @@ public class PaperAdapter implements PaperInterface {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSkullSkin(Skull skull) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSkullSkin(Skull skull, String skin) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,10 @@ public interface PaperInterface {
|
|||||||
|
|
||||||
public String getSkullOwner(Skull skull);
|
public String getSkullOwner(Skull skull);
|
||||||
|
|
||||||
|
public String getSkullSkin(Skull skull);
|
||||||
|
|
||||||
public void setSkullOwner(Skull skull, String owner);
|
public void setSkullOwner(Skull skull, String owner);
|
||||||
|
|
||||||
|
public void setSkullSkin(Skull skull, String skin);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package net.coreprotect.paper;
|
package net.coreprotect.paper;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.block.Skull;
|
import org.bukkit.block.Skull;
|
||||||
@ -41,4 +44,24 @@ public class Paper_v1_20 extends Paper_v1_17 implements PaperInterface {
|
|||||||
skull.setPlayerProfile(Bukkit.createProfile(owner));
|
skull.setPlayerProfile(Bukkit.createProfile(owner));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSkullSkin(Skull skull) {
|
||||||
|
URL skin = skull.getPlayerProfile().getTextures().getSkin();
|
||||||
|
if (skin == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return skin.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSkullSkin(Skull skull, String skin) {
|
||||||
|
try {
|
||||||
|
skull.getPlayerProfile().getTextures().setSkin(URI.create(skin).toURL());
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
44
src/main/java/net/coreprotect/patch/script/__2_23_1.java
Normal file
44
src/main/java/net/coreprotect/patch/script/__2_23_1.java
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package net.coreprotect.patch.script;
|
||||||
|
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
import net.coreprotect.config.Config;
|
||||||
|
import net.coreprotect.config.ConfigHandler;
|
||||||
|
import net.coreprotect.language.Phrase;
|
||||||
|
import net.coreprotect.language.Selector;
|
||||||
|
import net.coreprotect.patch.Patch;
|
||||||
|
import net.coreprotect.utility.Chat;
|
||||||
|
|
||||||
|
public class __2_23_1 {
|
||||||
|
|
||||||
|
protected static boolean patch(Statement statement) {
|
||||||
|
try {
|
||||||
|
if (Config.getGlobal().MYSQL) {
|
||||||
|
try {
|
||||||
|
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "skull ADD COLUMN skin VARCHAR(255);");
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
Chat.console(Phrase.build(Phrase.PATCH_SKIP_UPDATE, ConfigHandler.prefix + "skull", Selector.FIRST, Selector.FIRST));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "skull ADD COLUMN skin TEXT;");
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
Chat.console(Phrase.build(Phrase.PATCH_SKIP_UPDATE, ConfigHandler.prefix + "skull", Selector.FIRST, Selector.FIRST));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Patch.continuePatch()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user