17 Commits
Author SHA1 Message Date
Intelli 8fd41ac231 CoreProtect v21.2 release 2022-03-21 16:45:42 -06:00
Intelli 703d52bcc7 Changed inventory lookups to always require a username 2022-03-21 16:42:30 -06:00
Intelli aea0c82fd7 Fixed typos in API documentation 2022-03-21 15:19:16 -06:00
Intelli 01ed2e9f97 Fixed NullPointerException when logging player projectile data 2022-03-21 15:12:58 -06:00
Intelli 5861570f8a Added post-rollback sorting for player inventories 2022-03-20 17:34:24 -06:00
Intelli 840eb3b4ee Added hidden "disable-wal" database option (default: false) 2022-03-20 16:37:20 -06:00
Intelli 92e030f3e8 Fixed WAL checkpointing not running on some systems 2022-03-20 16:29:51 -06:00
Intelli d97f5482ee Fixed rollbacks/restores not correctly updating all blocks (#175) 2022-03-20 16:03:54 -06:00
Intelli 2763952dc6 Fixed deprecated display width warnings for MySQL databases 2022-03-11 18:16:16 -07:00
Intelli 3011aece46 Fixed inventory rollbacks not modifying player equipment slots (#170) 2022-03-11 17:20:52 -07:00
Intelli dedba3c57f Added command example to blacklist documentation 2022-03-10 16:42:13 -07:00
Intelli 75f66bf212 CoreProtect v21.1 release 2022-03-10 16:41:54 -07:00
Intelli 64106e2d64 Fixed "user not found" error when performing inventory lookups/rollbacks 2022-03-09 15:32:18 -07:00
Intelli 975a030ebe Fixed NullPointerException when trading with wandering traders 2022-03-08 13:59:19 -07:00
Intelli 829f4e95d5 Fixed exploited end crystals logging phantom fire data (#164) 2022-03-08 11:59:39 -07:00
Intelli 96292c82c3 Added example inventory lookup/rollback commands to docs 2022-03-08 11:10:36 -07:00
Intelli dad51fc900 Removed deprecated item durability and art ID method usage 2022-03-08 08:42:06 -07:00
28 changed files with 224 additions and 100 deletions

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@ plugins {
}
group = 'net.coreprotect'
String projectVersion = '21.0'
String projectVersion = '21.2'
String projectBranch = ''
version = projectVersion // `version` might be modified, we don't always want that (e.g. plugin.yml)
description = 'Provides block protection for your server.'
+1 -1
View File
@@ -392,7 +392,7 @@ if (CoreProtect!=null){ //Ensure we have access to the API
List<String[]> lookup = CoreProtect.blockLookup(block, 60);
if (lookup!=null){
for (String[] result : lookup){
ParseResult parseResult = CoreProtect.parseResult(value);
ParseResult parseResult = CoreProtect.parseResult(result);
int x = parseResult.getX();
int y = parseResult.getY();
int z = parseResult.getZ();
+1 -1
View File
@@ -392,7 +392,7 @@ if (CoreProtect!=null){ //Ensure we have access to the API
List<String[]> lookup = CoreProtect.blockLookup(block, 60);
if (lookup!=null){
for (String[] result : lookup){
ParseResult parseResult = CoreProtect.parseResult(value);
ParseResult parseResult = CoreProtect.parseResult(result);
int x = parseResult.getX();
int y = parseResult.getY();
int z = parseResult.getZ();
+5 -3
View File
@@ -89,6 +89,8 @@ List<String[]> blockLookup(Block block, int time)
List<String[]> sessionLookup(String user, int time)
List<String[]> queueLookup(Block block)
ParseResult parseResult(String[] result)
boolean logChat(Player player, String message)
@@ -404,7 +406,7 @@ if (CoreProtect != null){ // Ensure we have access to the API
if (!hasPlaced){
List<String[]> lookup = CoreProtect.queueLookup(block);
for (String[] result : lookup){
ParseResult parseResult = CoreProtect.parseResult(value);
ParseResult parseResult = CoreProtect.parseResult(result);
if (parseResult.getActionId()==1 && parseResult.getPlayer().equals("Notch")){
hasPlaced = true;
break;
@@ -423,7 +425,7 @@ if (CoreProtect != null){ // Ensure we have access to the API
List<String[]> lookup = CoreProtect.blockLookup(block, 60);
if (lookup != null){
for (String[] result : lookup){
ParseResult parseResult = CoreProtect.parseResult(value);
ParseResult parseResult = CoreProtect.parseResult(result);
int x = parseResult.getX();
int y = parseResult.getY();
int z = parseResult.getZ();
@@ -442,7 +444,7 @@ if (CoreProtect != null){ // Ensure we have access to the API
List<String[]> lookup = CoreProtect.sessionLookup("Notch", (24 * 60 * 60));
if (lookup != null){
for (String[] result : lookup){
ParseResult parseResult = CoreProtect.parseResult(value);
ParseResult parseResult = CoreProtect.parseResult(result);
int x = parseResult.getX();
int y = parseResult.getY();
int z = parseResult.getZ();
+4
View File
@@ -245,6 +245,8 @@ By default, if no radius is specified, a radius of 10 will be applied, restricti
*(rollback griefing Notch did in the last hour that is within 20 blocks of you)*
* `/co rollback u:Notch t:1h r:#nether`
*(rollback griefing Notch did in the last hour ONLY in the Nether)*
* `/co rollback u:Notch t:5m a:inventory`
*(rollback inventory transactions by Notch in the last 5 minutes)*
* `/co rollback t:15m r:30`
*(rollback everything done in the last 15 minutes by anyone within 30 blocks of you)*
* `/co rollback t:15m r:#worldedit`
@@ -260,6 +262,8 @@ Lookup commands are generally the same as rollback commands. The primary differe
*(lookup all diamond ore mined in the last hour)*
* `/co lookup u:Notch t:30m a:chat`
*(lookup chat messages sent by Notch in the last 30 minutes)*
* `/co lookup u:Notch t:3d a:inventory`
*(lookup inventory transactions by Notch in the last 3 days)*
* `/co lookup u:Notch a:login`
*(lookup all logins ever done by Notch)*
* `/co lookup u:Notch a:login`
+2 -1
View File
@@ -24,8 +24,9 @@ To disable logging for specific users or commands, simply do the following:
2. Enter the names of the users (or commands) you'd like to disable logging for (each username on a new line).
3. Either restart your server, or type "/co reload" in-game.
This can be used to disable logging for non-player users, such as "#tnt". For example, if you'd like to disable logging for the user "Notch" and for TNT explosions, the blacklist.txt file would look like this:
This can be used to disable logging for non-player users, such as "#tnt". For example, if you'd like to disable logging for the user "Notch", TNT explosions, and the "/help" command, the blacklist.txt file would look like this:
```text
Notch
#tnt
/help
```
+1 -1
View File
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.coreprotect</groupId>
<artifactId>CoreProtect</artifactId>
<version>21.0</version>
<version>21.2</version>
<properties>
<project.branch></project.branch>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -267,6 +267,11 @@ public class LookupCommand {
}
if (argAction.contains(4) && argAction.contains(11)) { // a:inventory
if (argUsers.size() == 0) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.MISSING_ACTION_USER));
return;
}
argExclude.put(Material.FIRE, false);
argExclude.put(Material.WATER, false);
argExclude.put(Material.FARMLAND, false);
@@ -572,6 +577,13 @@ public class LookupCommand {
}
}
c++;
if (argAction.contains(4) && argAction.contains(11)) {
if (ruser.startsWith("#")) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.INVALID_USERNAME, ruser));
return;
}
}
}
long timeStart = -1;
@@ -749,14 +761,14 @@ public class LookupCommand {
}
if (exists) {
for (String check : euserlist) {
if (!check.equals("#global")) {
if (!check.equals("#global") && !check.equals("#hopper")) {
exists = PlayerLookup.playerExists(connection, check);
if (!exists) {
baduser = check;
break;
}
}
else {
else if (check.equals("#global")) {
baduser = "#global";
exists = false;
}
@@ -368,14 +368,14 @@ public class RollbackRestoreCommand {
}
if (exists) {
for (String check : euserlist) {
if (!check.equals("#global")) {
if (!check.equals("#global") && !check.equals("#hopper")) {
exists = PlayerLookup.playerExists(connection, check);
if (!exists) {
baduser = check;
break;
}
}
else {
else if (check.equals("#global")) {
baduser = "#global";
exists = false;
}
@@ -42,6 +42,7 @@ public class Config extends Language {
public String MYSQL_PASSWORD;
public String LANGUAGE;
public boolean ENABLE_AWE;
public boolean DISABLE_WAL;
public boolean HOVER_EVENTS;
public boolean DATABASE_LOCK;
public boolean LOG_CANCELLED_CHAT;
@@ -182,6 +183,7 @@ public class Config extends Language {
private void readValues() {
this.ENABLE_AWE = this.getBoolean("enable-awe", false);
this.DISABLE_WAL = this.getBoolean("disable-wal", false);
this.HOVER_EVENTS = this.getBoolean("hover-events", true);
this.DATABASE_LOCK = this.getBoolean("database-lock", true);
this.LOG_CANCELLED_CHAT = this.getBoolean("log-cancelled-chat", true);
@@ -11,7 +11,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
@@ -118,7 +117,7 @@ public class ConfigHandler extends Queue {
public static Map<Integer, String> playerIdCacheReversed = syncMap();
public static Map<String, List<Object>> lastRollback = syncMap();
public static Map<String, Boolean> activeRollbacks = syncMap();
public static Map<UUID, Object[]> entityBlockMapper = syncMap();
public static Map<String, Object[]> entityBlockMapper = syncMap();
public static ConcurrentHashMap<Long, Long> populatedChunks = new ConcurrentHashMap<>();
public static ConcurrentHashMap<String, String> language = new ConcurrentHashMap<>();
public static List<String> databaseTables = new ArrayList<>();
@@ -73,8 +73,10 @@ public class Process {
return;
}
Consumer.isPaused = true;
Statement statement = connection.createStatement();
Database.performCheckpoint(statement);
Consumer.isPaused = true;
ArrayList<Object[]> consumerData = Consumer.consumer.get(processId);
Map<Integer, String[]> users = Consumer.consumerUsers.get(processId);
Map<Integer, Object> consumerObject = Consumer.consumerObjects.get(processId);
@@ -115,7 +115,7 @@ public class ContainerRollback extends Queue {
action = 1;
}
ItemStack itemstack = new ItemStack(rowType, rowAmount, (short) rowData);
ItemStack itemstack = new ItemStack(rowType, rowAmount);
Object[] populatedStack = Rollback.populateItemStack(itemstack, rowMetadata);
int slot = (Integer) populatedStack[0];
String faceData = (String) populatedStack[1];
@@ -4,6 +4,7 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
@@ -88,6 +89,12 @@ public class Database extends Queue {
}
}
public static void performCheckpoint(Statement statement) throws SQLException {
if (!Config.getGlobal().MYSQL) {
statement.executeUpdate("PRAGMA wal_checkpoint(TRUNCATE)");
}
}
public static void setMultiInt(PreparedStatement statement, int value, int count) {
try {
for (int i = 1; i <= count; i++) {
@@ -295,7 +302,12 @@ public class Database extends Queue {
private static void initializeTables(String prefix, Statement statement) {
try {
if (!Config.getGlobal().MYSQL) {
statement.executeUpdate("PRAGMA journal_mode=WAL;");
if (!Config.getGlobal().DISABLE_WAL) {
statement.executeUpdate("PRAGMA journal_mode=WAL;");
}
else {
statement.executeUpdate("PRAGMA journal_mode=DELETE;");
}
}
boolean lockInitialized = false;
@@ -328,37 +340,37 @@ public class Database extends Queue {
String index = "";
Statement statement = connection.createStatement();
index = ", INDEX(id)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "art_map(rowid int(8) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),id int(8),art varchar(255)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "art_map(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),id int,art varchar(255)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(wid,x,z,time), INDEX(user,time), INDEX(type,time)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "block(rowid bigint(20) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int(10), user int(8), wid int(4), x int(8), y int(3), z int(8), type int(6), data int(8), meta mediumblob, blockdata blob, action int(2), rolled_back tinyint(1)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "block(rowid bigint NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, user int, wid int, x int, y int, z int, type int, data int, meta mediumblob, blockdata blob, action tinyint, rolled_back tinyint" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(time), INDEX(user,time), INDEX(wid,x,z,time)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "chat(rowid int(8) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int(10), user int(8), wid int(4), x int(8), y int (3), z int(8), message varchar(16000)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "chat(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int, user int, wid int, x int, y int (3), z int, message varchar(16000)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(time), INDEX(user,time), INDEX(wid,x,z,time)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "command(rowid int(8) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int(10), user int(8), wid int(4), x int(8), y int (3), z int(8), message varchar(16000)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "command(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int, user int, wid int, x int, y int (3), z int, message varchar(16000)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(wid,x,z,time), INDEX(user,time), INDEX(type,time)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "container(rowid int(10) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int(10), user int(8), wid int(4), x int(8), y int(3), z int(8), type int(6), data int(6), amount int(4), metadata blob, action int(2), rolled_back tinyint(1)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "container(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, user int, wid int, x int, y int, z int, type int, data int, amount int, metadata blob, action tinyint, rolled_back tinyint" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(wid,x,z,time), INDEX(user,time), INDEX(type,time)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "item(rowid int(10) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int(10), user int(8), wid int(4), x int(8), y int(3), z int(8), type int(6), data blob, amount int(4), action tinyint(1), rolled_back tinyint(1)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "database_lock(rowid int(8) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),status tinyint(1),time int(10)) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "entity(rowid int(8) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int(10), data blob) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "item(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, user int, wid int, x int, y int, z int, type int, data blob, amount int, action tinyint, rolled_back tinyint" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "database_lock(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),status tinyint,time int) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "entity(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, data blob) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(id)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "entity_map(rowid int(8) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),id int(8),entity varchar(255)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "entity_map(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),id int,entity varchar(255)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(id)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "material_map(rowid int(8) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),id int(8),material varchar(255)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "material_map(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),id int,material varchar(255)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(id)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "blockdata_map(rowid int(8) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),id int(8),data varchar(255)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "blockdata_map(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),id int,data varchar(255)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(wid,x,z,time), INDEX(action,time), INDEX(user,time), INDEX(time)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "session(rowid int(8) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int(10), user int(8), wid int(4), x int(8), y int (3), z int(8), action int(1)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "session(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int, user int, wid int, x int, y int (3), z int, action tinyint" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(wid,x,z,time), INDEX(user,time), INDEX(time)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "sign(rowid int(8) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int(10), user int(8), wid int(4), x int(8), y int(3), z int(8), action tinyint(1), color int(8), data tinyint(1), line_1 varchar(100), line_2 varchar(100), line_3 varchar(100), line_4 varchar(100)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "skull(rowid int(8) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int(10), owner varchar(64)) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "sign(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int, user int, wid int, x int, y int, z int, action tinyint, color int, data tinyint, line_1 varchar(100), line_2 varchar(100), line_3 varchar(100), line_4 varchar(100)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "skull(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, owner varchar(64)) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(user), INDEX(uuid)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "user(rowid int(8) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int(10),user varchar(100),uuid varchar(64)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "user(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int,user varchar(100),uuid varchar(64)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(uuid,user)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "username_log(rowid int(8) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int(10),uuid varchar(64),user varchar(100)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "version(rowid int(8) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int(10),version varchar(16)) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "username_log(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int,uuid varchar(64),user varchar(100)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "version(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int,version varchar(16)) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(id)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "world(rowid int(8) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),id int(8),world varchar(255)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "world(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),id int,world varchar(255)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
if (!purge) {
initializeTables(prefix, statement);
}
@@ -62,6 +62,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.BannerMeta;
import org.bukkit.inventory.meta.BlockStateMeta;
import org.bukkit.inventory.meta.CrossbowMeta;
@@ -525,16 +526,24 @@ public class Rollback extends Queue {
boolean countBlock = true;
Material changeType = block.getType();
BlockData changeBlockData = block.getBlockData();
BlockData pendingChangeData = chunkChanges.get(block);
Material pendingChangeType = changeType;
if (pendingChangeData != null) {
pendingChangeType = pendingChangeData.getMaterial();
}
else {
pendingChangeData = changeBlockData;
}
if (rowRolledBack == 1 && rollbackType == 0) { // rollback
countBlock = false;
}
if ((rowType == changeType) && ((!BukkitAdapter.ADAPTER.isItemFrame(oldTypeMaterial)) && (oldTypeMaterial != Material.PAINTING) && (oldTypeMaterial != Material.ARMOR_STAND)) && (oldTypeMaterial != Material.END_CRYSTAL)) {
if ((rowType == pendingChangeType) && ((!BukkitAdapter.ADAPTER.isItemFrame(oldTypeMaterial)) && (oldTypeMaterial != Material.PAINTING) && (oldTypeMaterial != Material.ARMOR_STAND)) && (oldTypeMaterial != Material.END_CRYSTAL)) {
// block is already changed!
BlockData checkData = rowType == Material.AIR ? blockData : rawBlockData;
if (checkData != null) {
if (checkData.getAsString().equals(changeBlockData.getAsString()) || checkData instanceof MultipleFacing || checkData instanceof Stairs || checkData instanceof RedstoneWire) {
if (checkData.getAsString().equals(pendingChangeData.getAsString()) || checkData instanceof MultipleFacing || checkData instanceof Stairs || checkData instanceof RedstoneWire) {
if (rowType != Material.CHEST && rowType != Material.TRAPPED_CHEST) { // always update double chests
changeBlock = false;
}
@@ -546,11 +555,11 @@ public class Rollback extends Queue {
countBlock = false;
}
else if ((changeType != Material.AIR) && (changeType != Material.CAVE_AIR)) {
else if ((pendingChangeType != Material.AIR) && (pendingChangeType != Material.CAVE_AIR)) {
countBlock = true;
}
if ((changeType == Material.WATER) && (rowType != Material.AIR) && (rowType != Material.CAVE_AIR) && blockData != null) {
if ((pendingChangeType == Material.WATER) && (rowType != Material.AIR) && (rowType != Material.CAVE_AIR) && blockData != null) {
if (blockData instanceof Waterlogged) {
if (Material.WATER.createBlockData().equals(block.getBlockData())) {
Waterlogged waterlogged = (Waterlogged) blockData;
@@ -627,11 +636,10 @@ public class Rollback extends Queue {
}
}
else if ((rowType == Material.AIR) && ((oldTypeMaterial == Material.WATER))) {
BlockData existingBlockData = block.getBlockData();
if (existingBlockData instanceof Waterlogged) {
Waterlogged waterlogged = (Waterlogged) existingBlockData;
if (pendingChangeData instanceof Waterlogged) {
Waterlogged waterlogged = (Waterlogged) pendingChangeData;
waterlogged.setWaterlogged(false);
block.setBlockData(waterlogged);
Util.prepareTypeAndData(chunkChanges, block, null, waterlogged, false);
}
else {
Util.prepareTypeAndData(chunkChanges, block, rowType, blockData, true);
@@ -692,16 +700,14 @@ public class Rollback extends Queue {
boolean remove = true;
if ((rowType == Material.AIR)) {
BlockData currentBlockData = block.getBlockData();
if (currentBlockData instanceof Waterlogged) {
Waterlogged waterlogged = (Waterlogged) currentBlockData;
if (pendingChangeData instanceof Waterlogged) {
Waterlogged waterlogged = (Waterlogged) pendingChangeData;
if (waterlogged.isWaterlogged()) {
boolean physics = (changeBlockData instanceof Chest);
Util.prepareTypeAndData(chunkChanges, block, Material.WATER, Material.WATER.createBlockData(), physics);
Util.prepareTypeAndData(chunkChanges, block, Material.WATER, Material.WATER.createBlockData(), true);
remove = false;
}
}
else if ((changeType == Material.WATER)) {
else if ((pendingChangeType == Material.WATER)) {
if (rawBlockData instanceof Waterlogged) {
Waterlogged waterlogged = (Waterlogged) rawBlockData;
if (waterlogged.isWaterlogged()) {
@@ -818,11 +824,10 @@ public class Rollback extends Queue {
}
}
else if ((rowType == Material.WATER)) {
BlockData existingBlockData = block.getBlockData();
if (existingBlockData instanceof Waterlogged) {
Waterlogged waterlogged = (Waterlogged) existingBlockData;
if (pendingChangeData instanceof Waterlogged) {
Waterlogged waterlogged = (Waterlogged) pendingChangeData;
waterlogged.setWaterlogged(true);
block.setBlockData(waterlogged);
Util.prepareTypeAndData(chunkChanges, block, null, waterlogged, false);
}
else {
Util.prepareTypeAndData(chunkChanges, block, rowType, blockData, false);
@@ -1033,6 +1038,7 @@ public class Rollback extends Queue {
}
chunkChanges.clear();
Map<Player, List<Integer>> sortPlayers = new HashMap<>();
Object container = null;
Material containerType = null;
boolean containerInit = false;
@@ -1091,12 +1097,19 @@ public class Rollback extends Queue {
}
int action = rollbackType == 0 ? (inventoryAction ^ 1) : inventoryAction;
ItemStack itemstack = new ItemStack(inventoryItem, rowAmount, (short) rowData);
ItemStack itemstack = new ItemStack(inventoryItem, rowAmount);
Object[] populatedStack = populateItemStack(itemstack, rowMetadata);
if (rowAction == ItemLogger.ITEM_REMOVE_ENDER || rowAction == ItemLogger.ITEM_ADD_ENDER) {
modifyContainerItems(containerType, player.getEnderChest(), (Integer) populatedStack[0], ((ItemStack) populatedStack[2]).clone(), action ^ 1);
}
modifyContainerItems(containerType, player.getInventory(), (Integer) populatedStack[0], (ItemStack) populatedStack[2], action);
int modifiedArmor = modifyContainerItems(containerType, player.getInventory(), (Integer) populatedStack[0], (ItemStack) populatedStack[2], action);
if (modifiedArmor > -1) {
List<Integer> currentSortList = sortPlayers.getOrDefault(player, new ArrayList<>());
if (!currentSortList.contains(modifiedArmor)) {
currentSortList.add(modifiedArmor);
}
sortPlayers.put(player, currentSortList);
}
itemCount1 = itemCount1 + rowAmount;
ConfigHandler.rollbackHash.put(finalUserString, new int[] { itemCount1, blockCount1, entityCount1, 0 });
@@ -1108,7 +1121,7 @@ public class Rollback extends Queue {
}
if ((rollbackType == 0 && rowRolledBack == 0) || (rollbackType == 1 && rowRolledBack == 1)) {
ItemStack itemstack = new ItemStack(rowType, rowAmount, (short) rowData);
ItemStack itemstack = new ItemStack(rowType, rowAmount);
Object[] populatedStack = populateItemStack(itemstack, rowMetadata);
String faceData = (String) populatedStack[1];
@@ -1181,6 +1194,11 @@ public class Rollback extends Queue {
}
itemData.clear();
for (Entry<Player, List<Integer>> sortEntry : sortPlayers.entrySet()) {
sortContainerItems(sortEntry.getKey().getInventory(), sortEntry.getValue());
}
sortPlayers.clear();
int[] rollbackHashData1 = ConfigHandler.rollbackHash.get(finalUserString);
int itemCount1 = rollbackHashData1[0];
int blockCount1 = rollbackHashData1[1];
@@ -1562,7 +1580,8 @@ public class Rollback extends Queue {
}
}
static void modifyContainerItems(Material type, Object container, int slot, ItemStack itemstack, int action) {
static int modifyContainerItems(Material type, Object container, int slot, ItemStack itemstack, int action) {
int modifiedArmor = -1;
try {
ItemStack[] contents = null;
@@ -1615,13 +1634,34 @@ public class Rollback extends Queue {
else {
Inventory inventory = (Inventory) container;
if (inventory != null) {
boolean isPlayerInventory = (inventory instanceof PlayerInventory);
if (action == 1) {
int count = 0;
int amount = itemstack.getAmount();
itemstack.setAmount(1);
while (count < amount) {
inventory.addItem(itemstack);
boolean addedItem = false;
if (isPlayerInventory) {
int setArmor = Util.setPlayerArmor((PlayerInventory) inventory, itemstack);
addedItem = (setArmor > -1);
modifiedArmor = addedItem ? setArmor : modifiedArmor;
}
if (!addedItem) {
addedItem = (inventory.addItem(itemstack).size() == 0);
}
if (!addedItem && isPlayerInventory) {
PlayerInventory playerInventory = (PlayerInventory) inventory;
ItemStack offhand = playerInventory.getItemInOffHand();
if (offhand == null || offhand.getType() == Material.AIR || (itemstack.isSimilar(offhand) && offhand.getAmount() < offhand.getMaxStackSize())) {
ItemStack setOffhand = itemstack.clone();
if (itemstack.isSimilar(offhand)) {
setOffhand.setAmount(offhand.getAmount() + 1);
}
playerInventory.setItemInOffHand(setOffhand);
}
}
count++;
}
}
@@ -1630,7 +1670,7 @@ public class Rollback extends Queue {
ItemStack removeMatch = itemstack.clone();
removeMatch.setAmount(1);
ItemStack[] inventoryContents = inventory.getStorageContents().clone();
ItemStack[] inventoryContents = (isPlayerInventory ? inventory.getContents() : inventory.getStorageContents()).clone();
for (int i = inventoryContents.length - 1; i >= 0; i--) {
if (inventoryContents[i] != null) {
ItemStack itemStack = inventoryContents[i].clone();
@@ -1667,7 +1707,12 @@ public class Rollback extends Queue {
}
}
inventory.setStorageContents(inventoryContents);
if (isPlayerInventory) {
inventory.setContents(inventoryContents);
}
else {
inventory.setStorageContents(inventoryContents);
}
int count = 0;
while (count < removeAmount) {
@@ -1681,6 +1726,37 @@ public class Rollback extends Queue {
catch (Exception e) {
e.printStackTrace();
}
return modifiedArmor;
}
public static void sortContainerItems(PlayerInventory inventory, List<Integer> modifiedArmorSlots) {
try {
ItemStack[] armorContents = inventory.getArmorContents();
ItemStack[] storageContents = inventory.getStorageContents();
for (int armor = 0; armor < armorContents.length; armor++) {
ItemStack armorItem = armorContents[armor];
if (armorItem == null || !modifiedArmorSlots.contains(armor)) {
continue;
}
for (int storage = 0; storage < storageContents.length; storage++) {
ItemStack storageItem = storageContents[storage];
if (storageItem == null) {
storageContents[storage] = armorItem;
armorContents[armor] = null;
break;
}
}
}
inventory.setArmorContents(armorContents);
inventory.setStorageContents(storageContents);
}
catch (Exception e) {
e.printStackTrace();
}
}
private static void buildFireworkEffect(Builder effectBuilder, Material rowType, ItemStack itemstack) {
@@ -182,7 +182,7 @@ public class ContainerLogger extends Queue {
int y = location.getBlockY();
int z = location.getBlockZ();
int typeId = Util.getBlockId(item.getType().name(), true);
int data = item.getDurability();
int data = 0;
int amount = item.getAmount();
ContainerStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, typeId, data, amount, metadata, action, 0);
}
@@ -53,6 +53,9 @@ public final class BlockIgniteListener extends Queue implements Listener {
}
}
}
else if (event.getCause() == IgniteCause.ENDER_CRYSTAL && blockBelow == Material.AIR) {
return;
}
}
BlockState replacedBlock = null;
@@ -3,15 +3,12 @@ package net.coreprotect.listener.entity;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
@@ -38,15 +35,14 @@ public final class CreatureSpawnListener extends Queue implements Listener {
Location location = event.getEntity().getLocation();
String key = world.getName() + "-" + location.getBlockX() + "-" + location.getBlockY() + "-" + location.getBlockZ();
Iterator<Entry<UUID, Object[]>> it = ConfigHandler.entityBlockMapper.entrySet().iterator();
Iterator<Entry<String, Object[]>> it = ConfigHandler.entityBlockMapper.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<UUID, Object[]> pair = it.next();
UUID uuid = pair.getKey();
Map.Entry<String, Object[]> pair = it.next();
String name = pair.getKey();
Object[] data = pair.getValue();
if ((data[0].equals(key) || data[1].equals(key)) && Util.getEntityMaterial(event.getEntityType()) == ((ItemStack) data[2]).getType()) {
Player player = Bukkit.getServer().getPlayer(uuid);
Block gravityLocation = BlockUtil.gravityScan(location, Material.ARMOR_STAND, player.getName());
Queue.queueBlockPlace(player.getName(), gravityLocation.getState(), location.getBlock().getType(), location.getBlock().getState(), ((ItemStack) data[2]).getType(), (int) event.getEntity().getLocation().getYaw(), 1, null);
Block gravityLocation = BlockUtil.gravityScan(location, Material.ARMOR_STAND, name);
Queue.queueBlockPlace(name, gravityLocation.getState(), location.getBlock().getType(), location.getBlock().getState(), ((ItemStack) data[2]).getType(), (int) event.getEntity().getLocation().getYaw(), 1, null);
it.remove();
}
}
@@ -171,6 +171,7 @@ public final class CraftItemListener extends Queue implements Listener {
}
if (addItem.getAmount() > 0) {
Location location = (isTrade || event.getInventory().getLocation() == null) ? player.getLocation() : event.getInventory().getLocation();
for (ItemStack oldItem : oldItems) {
if (oldItem == null || oldItem.getType() == Material.AIR) {
continue;
@@ -181,10 +182,10 @@ public final class CraftItemListener extends Queue implements Listener {
return;
}
removedItem.setAmount(removedItem.getAmount() * amountMultiplier);
logCraftedItem(event.getInventory().getLocation(), player.getName(), removedItem, isTrade ? ItemLogger.ITEM_SELL : ItemLogger.ITEM_DESTROY);
logCraftedItem(location, player.getName(), removedItem, isTrade ? ItemLogger.ITEM_SELL : ItemLogger.ITEM_DESTROY);
}
logCraftedItem(event.getInventory().getLocation(), player.getName(), addItem, isTrade ? ItemLogger.ITEM_BUY : ItemLogger.ITEM_CREATE);
logCraftedItem(location, player.getName(), addItem, isTrade ? ItemLogger.ITEM_BUY : ItemLogger.ITEM_CREATE);
}
}
@@ -734,7 +734,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
String relativeBlockKey = world.getName() + "-" + relativeBlockLocation.getBlockX() + "-" + relativeBlockLocation.getBlockY() + "-" + relativeBlockLocation.getBlockZ();
String blockKey = world.getName() + "-" + blockLocation.getBlockX() + "-" + blockLocation.getBlockY() + "-" + blockLocation.getBlockZ();
Object[] keys = new Object[] { relativeBlockKey, blockKey, handItem };
ConfigHandler.entityBlockMapper.put(player.getUniqueId(), keys);
ConfigHandler.entityBlockMapper.put(player.getName(), keys);
}
}
}
@@ -9,13 +9,10 @@ import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.AbstractArrow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@@ -66,17 +63,15 @@ public final class ProjectileLaunchListener extends Queue implements Listener {
protected void onProjectileLaunch(ProjectileLaunchEvent event) {
Location location = event.getEntity().getLocation();
String key = location.getWorld().getName() + "-" + location.getBlockX() + "-" + location.getBlockY() + "-" + location.getBlockZ();
Iterator<Entry<UUID, Object[]>> it = ConfigHandler.entityBlockMapper.entrySet().iterator();
Iterator<Entry<String, Object[]>> it = ConfigHandler.entityBlockMapper.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<UUID, Object[]> pair = it.next();
UUID uuid = pair.getKey();
Map.Entry<String, Object[]> pair = it.next();
String name = pair.getKey();
Object[] data = pair.getValue();
ItemStack itemStack = (ItemStack) data[2];
Material entityMaterial = Util.getEntityMaterial(event.getEntityType());
boolean isBow = BOWS.contains(itemStack.getType());
if ((data[0].equals(key) || data[1].equals(key)) && (entityMaterial == itemStack.getType() || (itemStack.getType() == Material.LINGERING_POTION && entityMaterial == Material.SPLASH_POTION) || isBow)) {
Player player = Bukkit.getServer().getPlayer(uuid);
boolean thrownItem = (itemStack.getType() != Material.FIREWORK_ROCKET && !isBow);
if (isBow) {
if (itemStack.getType() == Material.CROSSBOW) {
@@ -95,7 +90,7 @@ public final class ProjectileLaunchListener extends Queue implements Listener {
}
}
playerLaunchProjectile(location, player.getName(), itemStack, 1, 1, 0, (thrownItem ? ItemLogger.ITEM_THROW : ItemLogger.ITEM_SHOOT));
playerLaunchProjectile(location, name, itemStack, 1, 1, 0, (thrownItem ? ItemLogger.ITEM_THROW : ItemLogger.ITEM_SHOOT));
it.remove();
}
}
@@ -40,7 +40,7 @@ public class __2_15_0 {
try {
if (Config.getGlobal().MYSQL) {
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "block MODIFY COLUMN rowid bigint(20) NOT NULL AUTO_INCREMENT, ADD COLUMN blockdata BLOB");
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "block MODIFY COLUMN rowid bigint NOT NULL AUTO_INCREMENT, ADD COLUMN blockdata BLOB");
}
else {
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "block ADD COLUMN blockdata BLOB");
@@ -10,7 +10,7 @@ public class __2_17_0 {
protected static boolean patch(Statement statement) {
try {
if (Config.getGlobal().MYSQL) {
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "sign ADD COLUMN color int(8)");
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "sign ADD COLUMN color int");
}
else {
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "sign ADD COLUMN color INTEGER");
@@ -24,7 +24,7 @@ public class __2_19_0 {
try {
if (Config.getGlobal().MYSQL) {
try {
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "sign ADD COLUMN action int(1)");
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "sign ADD COLUMN action int");
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "sign DROP INDEX wid");
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "sign ADD INDEX(wid,x,z,time), ADD INDEX(user,time), ADD INDEX(time)");
}
@@ -37,14 +37,14 @@ public class __2_19_0 {
}
try {
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "chat ADD COLUMN wid int(4), ADD COLUMN x int(8), ADD COLUMN y int(3), ADD COLUMN z int(8), ADD INDEX(wid,x,z,time)");
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "chat ADD COLUMN wid int, ADD COLUMN x int, ADD COLUMN y int, ADD COLUMN z int, ADD INDEX(wid,x,z,time)");
}
catch (Exception e) {
Chat.console(Phrase.build(Phrase.PATCH_SKIP_UPDATE, ConfigHandler.prefix + "chat", Selector.FIRST, Selector.FIRST));
}
try {
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "command ADD COLUMN wid int(4), ADD COLUMN x int(8), ADD COLUMN y int(3), ADD COLUMN z int(8), ADD INDEX(wid,x,z,time)");
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "command ADD COLUMN wid int, ADD COLUMN x int, ADD COLUMN y int, ADD COLUMN z int, ADD INDEX(wid,x,z,time)");
}
catch (Exception e) {
Chat.console(Phrase.build(Phrase.PATCH_SKIP_UPDATE, ConfigHandler.prefix + "command", Selector.FIRST, Selector.FIRST));
@@ -39,7 +39,7 @@ public class __2_20_0 {
}
try {
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "sign ADD COLUMN data tinyint(1)");
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "sign ADD COLUMN data TINYINT");
}
catch (Exception e) {
Chat.console(Phrase.build(Phrase.PATCH_SKIP_UPDATE, ConfigHandler.prefix + "sign", Selector.FIRST, Selector.FIRST));
@@ -16,7 +16,7 @@ public class __2_21_0 {
try {
if (Config.getGlobal().MYSQL) {
try {
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "item ADD COLUMN rolled_back tinyint(1) DEFAULT 0;");
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "item ADD COLUMN rolled_back TINYINT DEFAULT 0;");
}
catch (Exception e) {
Chat.console(Phrase.build(Phrase.PATCH_SKIP_UPDATE, ConfigHandler.prefix + "item", Selector.FIRST, Selector.FIRST));
@@ -11,10 +11,10 @@ public class __2_6_0 {
try {
if (Config.getGlobal().MYSQL) {
statement.executeUpdate("START TRANSACTION");
statement.executeUpdate("CREATE TEMPORARY TABLE " + ConfigHandler.prefix + "version_tmp(rowid int(8), time int(10), version varchar(16)) ENGINE=InnoDB");
statement.executeUpdate("CREATE TEMPORARY TABLE " + ConfigHandler.prefix + "version_tmp(rowid int, time int, version varchar(16)) ENGINE=InnoDB");
statement.executeUpdate("INSERT INTO " + ConfigHandler.prefix + "version_tmp SELECT rowid,time,version FROM " + ConfigHandler.prefix + "version;");
statement.executeUpdate("DROP TABLE " + ConfigHandler.prefix + "version;");
statement.executeUpdate("CREATE TABLE " + ConfigHandler.prefix + "version(rowid int(8) NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int(10),version varchar(16)) ENGINE=InnoDB");
statement.executeUpdate("CREATE TABLE " + ConfigHandler.prefix + "version(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int,version varchar(16)) ENGINE=InnoDB");
statement.executeUpdate("INSERT INTO " + ConfigHandler.prefix + "version SELECT rowid,time,version FROM " + ConfigHandler.prefix + "version_tmp;");
statement.executeUpdate("DROP TEMPORARY TABLE " + ConfigHandler.prefix + "version_tmp;");
statement.executeUpdate("COMMIT");
@@ -19,7 +19,6 @@ import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import org.bukkit.Art;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -45,6 +44,7 @@ import org.bukkit.inventory.BlockInventoryHolder;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.io.BukkitObjectOutputStream;
@@ -628,10 +628,6 @@ public class Util extends Queue {
return false;
}
public static int getArtId(Art art) {
return art.getId();
}
public static int getArtId(String name, boolean internal) {
int id = -1;
name = name.toLowerCase(Locale.ROOT).trim();
@@ -660,6 +656,33 @@ public class Util extends Queue {
return artname;
}
public static int setPlayerArmor(PlayerInventory inventory, ItemStack itemStack) {
String itemName = itemStack.getType().name();
boolean isHelmet = (itemName.endsWith("_HELMET") || itemName.endsWith("_HEAD") || itemName.endsWith("_SKULL") || itemName.endsWith("_PUMPKIN"));
boolean isChestplate = (itemName.endsWith("_CHESTPLATE"));
boolean isLeggings = (itemName.endsWith("_LEGGINGS"));
boolean isBoots = (itemName.endsWith("_BOOTS"));
if (isHelmet && inventory.getHelmet() == null) {
inventory.setHelmet(itemStack);
return 3;
}
else if (isChestplate && inventory.getChestplate() == null) {
inventory.setChestplate(itemStack);
return 2;
}
else if (isLeggings && inventory.getLeggings() == null) {
inventory.setLeggings(itemStack);
return 1;
}
else if (isBoots && inventory.getBoots() == null) {
inventory.setBoots(itemStack);
return 0;
}
return -1;
}
public static ItemStack[] getArmorStandContents(EntityEquipment equipment) {
ItemStack[] contents = new ItemStack[6];
if (equipment != null) {
@@ -1175,10 +1198,6 @@ public class Util extends Queue {
return new ItemStack(type, amount);
}
public static ItemStack newItemStack(Material type, int amount, short data) {
return new ItemStack(type, amount, data);
}
public static boolean isSpigot() {
try {
Class.forName("org.spigotmc.SpigotConfig");