Split up utility class
This commit is contained in:
parent
828af8443f
commit
e2c2505b2b
97 changed files with 2369 additions and 2104 deletions
|
|
@ -25,7 +25,8 @@ import net.coreprotect.consumer.process.Process;
|
|||
import net.coreprotect.listener.block.BlockUtil;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.EntityUtils;
|
||||
|
||||
public class Queue {
|
||||
|
||||
|
|
@ -101,7 +102,7 @@ public class Queue {
|
|||
protected static void queueBlockBreak(String user, BlockState block, Material type, String blockData, Material breakType, int extraData, int blockNumber) {
|
||||
if (type == Material.SPAWNER && block instanceof CreatureSpawner) { // Mob spawner
|
||||
CreatureSpawner mobSpawner = (CreatureSpawner) block;
|
||||
extraData = Util.getSpawnerType(mobSpawner.getSpawnedType());
|
||||
extraData = EntityUtils.getSpawnerType(mobSpawner.getSpawnedType());
|
||||
}
|
||||
else if (type == Material.IRON_DOOR || BlockGroup.DOORS.contains(type) || type.equals(Material.SUNFLOWER) || type.equals(Material.LILAC) || type.equals(Material.TALL_GRASS) || type.equals(Material.LARGE_FERN) || type.equals(Material.ROSE_BUSH) || type.equals(Material.PEONY)) { // Double plant
|
||||
if (block.getBlockData() instanceof Bisected) {
|
||||
|
|
@ -142,7 +143,7 @@ public class Queue {
|
|||
|
||||
if (type == Material.SPAWNER && blockLocation instanceof CreatureSpawner) { // Mob spawner
|
||||
CreatureSpawner mobSpawner = (CreatureSpawner) blockLocation;
|
||||
data = Util.getSpawnerType(mobSpawner.getSpawnedType());
|
||||
data = EntityUtils.getSpawnerType(mobSpawner.getSpawnedType());
|
||||
forceData = 1;
|
||||
}
|
||||
|
||||
|
|
@ -361,7 +362,7 @@ public class Queue {
|
|||
int currentConsumer = Consumer.currentConsumer;
|
||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||
addConsumer(currentConsumer, new Object[] { consumerId, Process.SIGN_TEXT, null, color, null, action, offset, null });
|
||||
Consumer.consumerSigns.get(currentConsumer).put(consumerId, new Object[] { colorSecondary, Util.getSignData(frontGlowing, backGlowing), isWaxed, isFront, line1, line2, line3, line4, line5, line6, line7, line8 });
|
||||
Consumer.consumerSigns.get(currentConsumer).put(consumerId, new Object[] { colorSecondary, BlockUtils.getSignData(frontGlowing, backGlowing), isWaxed, isFront, line1, line2, line3, line4, line5, line6, line7, line8 });
|
||||
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, location);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,19 +9,20 @@ import org.bukkit.block.Skull;
|
|||
|
||||
import net.coreprotect.database.logger.BlockBreakLogger;
|
||||
import net.coreprotect.database.logger.SkullBreakLogger;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
|
||||
class BlockBreakProcess {
|
||||
|
||||
static void process(PreparedStatement preparedStmt, PreparedStatement preparedStmtSkulls, int batchCount, int processId, int id, Material blockType, int blockDataId, Material replaceType, int forceData, String user, Object object, String blockData) {
|
||||
if (object instanceof BlockState) {
|
||||
BlockState block = (BlockState) object;
|
||||
List<Object> meta = Util.processMeta(block);
|
||||
List<Object> meta = BlockUtils.processMeta(block);
|
||||
if (block instanceof Skull) {
|
||||
SkullBreakLogger.log(preparedStmt, preparedStmtSkulls, batchCount, user, block);
|
||||
}
|
||||
else {
|
||||
BlockBreakLogger.log(preparedStmt, batchCount, user, block.getLocation(), Util.getBlockId(blockType), blockDataId, meta, block.getBlockData().getAsString(), blockData);
|
||||
BlockBreakLogger.log(preparedStmt, batchCount, user, block.getLocation(), MaterialUtils.getBlockId(blockType), blockDataId, meta, block.getBlockData().getAsString(), blockData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,22 +8,23 @@ import org.bukkit.block.BlockState;
|
|||
|
||||
import net.coreprotect.database.logger.BlockPlaceLogger;
|
||||
import net.coreprotect.database.logger.SkullPlaceLogger;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
|
||||
class BlockPlaceProcess {
|
||||
|
||||
static void process(PreparedStatement preparedStmt, PreparedStatement preparedStmtSkulls, int batchCount, Material blockType, int blockData, Material replaceType, int replaceData, int forceData, String user, Object object, String newBlockData, String replacedBlockData) {
|
||||
if (object instanceof BlockState) {
|
||||
BlockState block = (BlockState) object;
|
||||
List<Object> meta = Util.processMeta(block);
|
||||
List<Object> meta = BlockUtils.processMeta(block);
|
||||
if (blockType.equals(Material.SKELETON_SKULL) || blockType.equals(Material.SKELETON_WALL_SKULL) || blockType.equals(Material.WITHER_SKELETON_SKULL) || blockType.equals(Material.WITHER_SKELETON_WALL_SKULL) || blockType.equals(Material.ZOMBIE_HEAD) || blockType.equals(Material.ZOMBIE_WALL_HEAD) || blockType.equals(Material.PLAYER_HEAD) || blockType.equals(Material.PLAYER_WALL_HEAD) || blockType.equals(Material.CREEPER_HEAD) || blockType.equals(Material.CREEPER_WALL_HEAD) || blockType.equals(Material.DRAGON_HEAD) || blockType.equals(Material.DRAGON_WALL_HEAD)) {
|
||||
SkullPlaceLogger.log(preparedStmt, preparedStmtSkulls, batchCount, user, block, Util.getBlockId(replaceType), replaceData);
|
||||
SkullPlaceLogger.log(preparedStmt, preparedStmtSkulls, batchCount, user, block, MaterialUtils.getBlockId(replaceType), replaceData);
|
||||
}
|
||||
else if (forceData == 1) {
|
||||
BlockPlaceLogger.log(preparedStmt, batchCount, user, block, Util.getBlockId(replaceType), replaceData, blockType, blockData, true, meta, newBlockData, replacedBlockData);
|
||||
BlockPlaceLogger.log(preparedStmt, batchCount, user, block, MaterialUtils.getBlockId(replaceType), replaceData, blockType, blockData, true, meta, newBlockData, replacedBlockData);
|
||||
}
|
||||
else {
|
||||
BlockPlaceLogger.log(preparedStmt, batchCount, user, block, Util.getBlockId(replaceType), replaceData, blockType, blockData, false, meta, newBlockData, replacedBlockData);
|
||||
BlockPlaceLogger.log(preparedStmt, batchCount, user, block, MaterialUtils.getBlockId(replaceType), replaceData, blockType, blockData, false, meta, newBlockData, replacedBlockData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import org.bukkit.entity.EntityType;
|
|||
|
||||
import net.coreprotect.consumer.Consumer;
|
||||
import net.coreprotect.database.logger.EntityKillLogger;
|
||||
import net.coreprotect.utility.EntityUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
class EntityKillProcess {
|
||||
|
|
@ -20,7 +21,7 @@ class EntityKillProcess {
|
|||
Map<Integer, List<Object>> objectLists = Consumer.consumerObjectList.get(processId);
|
||||
if (objectLists.get(id) != null) {
|
||||
List<Object> objectList = objectLists.get(id);
|
||||
int entityId = Util.getEntityId(type);
|
||||
int entityId = EntityUtils.getEntityId(type);
|
||||
EntityKillLogger.log(preparedStmt, preparedStmtEntities, batchCount, user, block, objectList, entityId);
|
||||
objectLists.remove(id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import org.bukkit.block.BlockState;
|
|||
import net.coreprotect.consumer.Consumer;
|
||||
import net.coreprotect.database.Lookup;
|
||||
import net.coreprotect.database.logger.BlockBreakLogger;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
class NaturalBlockBreakProcess {
|
||||
|
|
@ -28,7 +29,7 @@ class NaturalBlockBreakProcess {
|
|||
}
|
||||
}
|
||||
blockLists.remove(id);
|
||||
BlockBreakLogger.log(preparedStmt, batchCount, user, block.getLocation(), Util.getBlockId(blockType), blockData, null, block.getBlockData().getAsString(), overrideData);
|
||||
BlockBreakLogger.log(preparedStmt, batchCount, user, block.getLocation(), MaterialUtils.getBlockId(blockType), blockData, null, block.getBlockData().getAsString(), overrideData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import java.util.Map;
|
|||
|
||||
import net.coreprotect.consumer.Consumer;
|
||||
import net.coreprotect.database.Database;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
|
||||
class RollbackUpdateProcess {
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ class RollbackUpdateProcess {
|
|||
for (Object[] listRow : list) {
|
||||
long rowid = (Long) listRow[0];
|
||||
int rolledBack = (Integer) listRow[9];
|
||||
if (Util.rolledBack(rolledBack, (table == 2 || table == 3 || table == 4)) == action) { // 1 = restore, 0 = rollback
|
||||
if (MaterialUtils.rolledBack(rolledBack, (table == 2 || table == 3 || table == 4)) == action) { // 1 = restore, 0 = rollback
|
||||
Database.performUpdate(statement, rowid, rolledBack, table);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ import org.bukkit.block.BlockState;
|
|||
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.statement.SignStatement;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
class SignUpdateProcess {
|
||||
|
||||
|
|
@ -22,7 +23,7 @@ class SignUpdateProcess {
|
|||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
int wid = Util.getWorldId(block.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(block.getWorld().getName());
|
||||
int userid = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
|
||||
String query = "";
|
||||
if (action == 0) {
|
||||
|
|
@ -32,7 +33,7 @@ class SignUpdateProcess {
|
|||
query = "SELECT color, color_secondary, data, waxed, face, line_1, line_2, line_3, line_4, line_5, line_6, line_7, line_8 FROM " + ConfigHandler.prefix + "sign WHERE user='" + userid + "' AND wid='" + wid + "' AND x='" + x + "' AND z='" + z + "' AND y='" + y + "' AND time >= '" + time + "' ORDER BY rowid ASC LIMIT 0, 1";
|
||||
}
|
||||
SignStatement.getData(statement, block, query);
|
||||
Util.updateBlock(block);
|
||||
BlockUtils.updateBlock(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import org.bukkit.block.BlockState;
|
|||
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.statement.SkullStatement;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
|
||||
class SkullUpdateProcess {
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ class SkullUpdateProcess {
|
|||
BlockState block = (BlockState) object;
|
||||
String query = "SELECT owner, skin FROM " + ConfigHandler.prefix + "skull WHERE rowid='" + rowId + "' LIMIT 0, 1";
|
||||
SkullStatement.getData(statement, block, query);
|
||||
Util.updateBlock(block);
|
||||
BlockUtils.updateBlock(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import net.coreprotect.consumer.Consumer;
|
|||
import net.coreprotect.database.Lookup;
|
||||
import net.coreprotect.database.logger.BlockBreakLogger;
|
||||
import net.coreprotect.database.logger.BlockPlaceLogger;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
class StructureGrowthProcess {
|
||||
|
|
@ -31,7 +32,7 @@ class StructureGrowthProcess {
|
|||
int count = 0;
|
||||
for (BlockState blockState : blockStates) {
|
||||
if (count < replaceBlockCount) {
|
||||
BlockBreakLogger.log(preparedStmt, batchCount, user, blockState.getLocation(), Util.getBlockId(blockState.getType()), 0, null, blockState.getBlockData().getAsString(), null);
|
||||
BlockBreakLogger.log(preparedStmt, batchCount, user, blockState.getLocation(), MaterialUtils.getBlockId(blockState.getType()), 0, null, blockState.getBlockData().getAsString(), null);
|
||||
}
|
||||
else {
|
||||
BlockPlaceLogger.log(preparedStmt, batchCount, user, blockState, 0, 0, null, -1, false, null, null, null);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue