Split up utility class
This commit is contained in:
parent
828af8443f
commit
e2c2505b2b
97 changed files with 2369 additions and 2104 deletions
|
|
@ -27,9 +27,10 @@ import net.coreprotect.thread.CacheHandler;
|
|||
import net.coreprotect.thread.NetworkHandler;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.ChatUtils;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Teleport;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.VersionUtils;
|
||||
|
||||
public final class CoreProtect extends JavaPlugin {
|
||||
|
||||
|
|
@ -87,7 +88,7 @@ public final class CoreProtect extends JavaPlugin {
|
|||
|
||||
if (start) {
|
||||
PluginDescriptionFile pluginDescription = this.getDescription();
|
||||
Util.sendConsoleComponentStartup(Bukkit.getServer().getConsoleSender(), Phrase.build(Phrase.ENABLE_SUCCESS, ConfigHandler.EDITION_NAME));
|
||||
ChatUtils.sendConsoleComponentStartup(Bukkit.getServer().getConsoleSender(), Phrase.build(Phrase.ENABLE_SUCCESS, ConfigHandler.EDITION_NAME));
|
||||
if (Config.getGlobal().MYSQL) {
|
||||
Chat.console(Phrase.build(Phrase.USING_MYSQL));
|
||||
}
|
||||
|
|
@ -137,16 +138,16 @@ public final class CoreProtect extends JavaPlugin {
|
|||
private static boolean performVersionChecks() {
|
||||
try {
|
||||
String[] bukkitVersion = Bukkit.getServer().getBukkitVersion().split("[-.]");
|
||||
if (Util.newVersion(bukkitVersion[0] + "." + bukkitVersion[1], ConfigHandler.MINECRAFT_VERSION)) {
|
||||
if (VersionUtils.newVersion(bukkitVersion[0] + "." + bukkitVersion[1], ConfigHandler.MINECRAFT_VERSION)) {
|
||||
Chat.console(Phrase.build(Phrase.VERSION_REQUIRED, "Minecraft", ConfigHandler.MINECRAFT_VERSION));
|
||||
return false;
|
||||
}
|
||||
if (Util.newVersion(ConfigHandler.LATEST_VERSION, bukkitVersion[0] + "." + bukkitVersion[1]) && Util.isBranch("master")) {
|
||||
if (VersionUtils.newVersion(ConfigHandler.LATEST_VERSION, bukkitVersion[0] + "." + bukkitVersion[1]) && VersionUtils.isBranch("master")) {
|
||||
Chat.console(Phrase.build(Phrase.VERSION_INCOMPATIBLE, "Minecraft", bukkitVersion[0] + "." + bukkitVersion[1]));
|
||||
return false;
|
||||
}
|
||||
String[] javaVersion = (System.getProperty("java.version").replaceAll("[^0-9.]", "") + ".0").split("\\.");
|
||||
if (Util.newVersion(javaVersion[0] + "." + javaVersion[1], ConfigHandler.JAVA_VERSION)) {
|
||||
if (VersionUtils.newVersion(javaVersion[0] + "." + javaVersion[1], ConfigHandler.JAVA_VERSION)) {
|
||||
Chat.console(Phrase.build(Phrase.VERSION_REQUIRED, "Java", ConfigHandler.JAVA_VERSION));
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,13 @@ import net.coreprotect.database.Lookup;
|
|||
import net.coreprotect.database.rollback.Rollback;
|
||||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.listener.player.InventoryChangeListener;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.EntityUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
import net.coreprotect.utility.StringUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class CoreProtectAPI extends Queue {
|
||||
|
||||
|
|
@ -102,14 +107,14 @@ public class CoreProtectAPI extends Queue {
|
|||
String typeName;
|
||||
|
||||
if (actionID == 3) {
|
||||
typeName = Util.getEntityType(type).name();
|
||||
typeName = EntityUtils.getEntityType(type).name();
|
||||
}
|
||||
else {
|
||||
typeName = Util.getType(type).name().toLowerCase(Locale.ROOT);
|
||||
typeName = Util.nameFilter(typeName, this.getData());
|
||||
typeName = MaterialUtils.getType(type).name().toLowerCase(Locale.ROOT);
|
||||
typeName = StringUtils.nameFilter(typeName, this.getData());
|
||||
}
|
||||
|
||||
return Util.getType(typeName);
|
||||
return MaterialUtils.getType(typeName);
|
||||
}
|
||||
|
||||
public BlockData getBlockData() {
|
||||
|
|
@ -145,7 +150,7 @@ public class CoreProtectAPI extends Queue {
|
|||
}
|
||||
|
||||
public String worldName() {
|
||||
return Util.getWorldName(Integer.parseInt(parse.length < 13 ? parse[5] : parse[9]));
|
||||
return WorldUtils.getWorldName(Integer.parseInt(parse.length < 13 ? parse[5] : parse[9]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -158,7 +163,7 @@ public class CoreProtectAPI extends Queue {
|
|||
result.put(value, false);
|
||||
}
|
||||
else if (value instanceof Integer) {
|
||||
Material material = Util.getType((Integer) value);
|
||||
Material material = MaterialUtils.getType((Integer) value);
|
||||
result.put(material, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ import net.coreprotect.config.ConfigHandler;
|
|||
import net.coreprotect.database.Database;
|
||||
import net.coreprotect.database.statement.UserStatement;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.StringUtils;
|
||||
|
||||
public class BlockAPI {
|
||||
|
||||
|
|
@ -27,7 +30,7 @@ public class BlockAPI {
|
|||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||
int worldId = Util.getWorldId(block.getWorld().getName());
|
||||
int worldId = WorldUtils.getWorldId(block.getWorld().getName());
|
||||
int checkTime = 0;
|
||||
if (offset > 0) {
|
||||
checkTime = time - offset;
|
||||
|
|
@ -38,7 +41,7 @@ public class BlockAPI {
|
|||
}
|
||||
|
||||
Statement statement = connection.createStatement();
|
||||
String query = "SELECT time,user,action,type,data,blockdata,rolled_back FROM " + ConfigHandler.prefix + "block " + Util.getWidIndex("block") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND time > '" + checkTime + "' ORDER BY rowid DESC";
|
||||
String query = "SELECT time,user,action,type,data,blockdata,rolled_back FROM " + ConfigHandler.prefix + "block " + WorldUtils.getWidIndex("block") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND time > '" + checkTime + "' ORDER BY rowid DESC";
|
||||
ResultSet results = statement.executeQuery(query);
|
||||
|
||||
while (results.next()) {
|
||||
|
|
@ -53,10 +56,10 @@ public class BlockAPI {
|
|||
UserStatement.loadName(connection, resultUserId);
|
||||
}
|
||||
String resultUser = ConfigHandler.playerIdCacheReversed.get(resultUserId);
|
||||
String blockData = Util.byteDataToString(resultBlockData, resultType);
|
||||
String blockData = BlockUtils.byteDataToString(resultBlockData, resultType);
|
||||
|
||||
String[] lookupData = new String[] { resultTime, resultUser, String.valueOf(x), String.valueOf(y), String.valueOf(z), String.valueOf(resultType), resultData, resultAction, resultRolledBack, String.valueOf(worldId), blockData };
|
||||
String[] lineData = Util.toStringArray(lookupData);
|
||||
String[] lineData = StringUtils.toStringArray(lookupData);
|
||||
result.add(lineData);
|
||||
}
|
||||
results.close();
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@ import net.coreprotect.config.Config;
|
|||
import net.coreprotect.consumer.Consumer;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.consumer.process.Process;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
import net.coreprotect.utility.StringUtils;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class QueueLookup extends Queue {
|
||||
|
||||
|
|
@ -68,12 +70,12 @@ public class QueueLookup extends Queue {
|
|||
String user = userData[0];
|
||||
BlockState blockState = (BlockState) objectData;
|
||||
Location location = blockState.getLocation();
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
int resultType = Util.getBlockId(blockType);
|
||||
int wid = WorldUtils.getWorldId(location.getWorld().getName());
|
||||
int resultType = MaterialUtils.getBlockId(blockType);
|
||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||
|
||||
String[] lookupData = new String[] { String.valueOf(time), user, String.valueOf(location.getBlockX()), String.valueOf(location.getBlockY()), String.valueOf(location.getBlockZ()), String.valueOf(resultType), String.valueOf(legacyData), String.valueOf(action), "0", String.valueOf(wid), blockData };
|
||||
String[] lineData = Util.toStringArray(lookupData);
|
||||
String[] lineData = StringUtils.toStringArray(lookupData);
|
||||
result.add(lineData);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import org.bukkit.potion.PotionEffect;
|
|||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class BukkitAdapter implements BukkitInterface {
|
||||
|
|
@ -171,7 +172,7 @@ public class BukkitAdapter implements BukkitInterface {
|
|||
|
||||
@Override
|
||||
public boolean isInvisible(Material material) {
|
||||
return Util.isAir(material);
|
||||
return BlockUtils.isAir(material);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ import org.bukkit.inventory.meta.BundleMeta;
|
|||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
|
||||
public class Bukkit_v1_17 extends BukkitAdapter implements BukkitInterface {
|
||||
|
||||
|
|
@ -59,7 +60,7 @@ public class Bukkit_v1_17 extends BukkitAdapter implements BukkitInterface {
|
|||
public int getLegacyBlockId(Material material) {
|
||||
switch (material) {
|
||||
case DIRT_PATH:
|
||||
return Util.getBlockId("GRASS_PATH", false);
|
||||
return MaterialUtils.getBlockId("GRASS_PATH", false);
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -123,7 +124,7 @@ public class Bukkit_v1_17 extends BukkitAdapter implements BukkitInterface {
|
|||
if (subMeta.hasItems()) {
|
||||
list = new ArrayList<>();
|
||||
for (ItemStack itemStack : subMeta.getItems()) {
|
||||
Map<String, Object> itemMap = Util.serializeItemStack(itemStack, null, slot);
|
||||
Map<String, Object> itemMap = ItemUtils.serializeItemStack(itemStack, null, slot);
|
||||
if (itemMap.size() > 0) {
|
||||
list.add(itemMap);
|
||||
}
|
||||
|
|
@ -146,7 +147,7 @@ public class Bukkit_v1_17 extends BukkitAdapter implements BukkitInterface {
|
|||
if ((rowType == Material.BUNDLE)) {
|
||||
BundleMeta meta = (BundleMeta) itemstack.getItemMeta();
|
||||
for (Map<String, Object> itemData : map) {
|
||||
ItemStack itemStack = Util.unserializeItemStack(itemData);
|
||||
ItemStack itemStack = ItemUtils.unserializeItemStack(itemData);
|
||||
if (itemStack != null) {
|
||||
meta.addItem(itemStack);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,10 @@ import net.coreprotect.model.BlockGroup;
|
|||
import net.coreprotect.thread.NetworkHandler;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.EntityUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
import net.coreprotect.utility.VersionUtils;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class CommandHandler implements CommandExecutor {
|
||||
private static CommandHandler instance;
|
||||
|
|
@ -210,7 +213,7 @@ public class CommandHandler implements CommandExecutor {
|
|||
}
|
||||
if (cCount > 1) {
|
||||
if (location == null && worldId > 0) {
|
||||
location = new Location(Bukkit.getWorld(Util.getWorldName(worldId)), 0, 0, 0);
|
||||
location = new Location(Bukkit.getWorld(WorldUtils.getWorldName(worldId)), 0, 0, 0);
|
||||
}
|
||||
if (location != null) {
|
||||
int worldMaxHeight = location.getWorld().getMaxHeight() - 1;
|
||||
|
|
@ -279,12 +282,12 @@ public class CommandHandler implements CommandExecutor {
|
|||
String[] i2 = argument.split(",");
|
||||
for (String i3 : i2) {
|
||||
if (!checkTags(i3, excluded)) {
|
||||
Material i3_material = Util.getType(i3);
|
||||
Material i3_material = MaterialUtils.getType(i3);
|
||||
if (i3_material != null && (i3_material.isBlock() || argAction.contains(4))) {
|
||||
excluded.put(i3_material, false);
|
||||
}
|
||||
else {
|
||||
EntityType i3_entity = Util.getEntityType(i3);
|
||||
EntityType i3_entity = EntityUtils.getEntityType(i3);
|
||||
if (i3_entity != null) {
|
||||
excluded.put(i3_entity, false);
|
||||
}
|
||||
|
|
@ -303,12 +306,12 @@ public class CommandHandler implements CommandExecutor {
|
|||
}
|
||||
else {
|
||||
if (!checkTags(argument, excluded)) {
|
||||
Material iMaterial = Util.getType(argument);
|
||||
Material iMaterial = MaterialUtils.getType(argument);
|
||||
if (iMaterial != null && (iMaterial.isBlock() || argAction.contains(4))) {
|
||||
excluded.put(iMaterial, false);
|
||||
}
|
||||
else {
|
||||
EntityType iEntity = Util.getEntityType(argument);
|
||||
EntityType iEntity = EntityUtils.getEntityType(argument);
|
||||
if (iEntity != null) {
|
||||
excluded.put(iEntity, false);
|
||||
}
|
||||
|
|
@ -354,12 +357,12 @@ public class CommandHandler implements CommandExecutor {
|
|||
isBlock = true;
|
||||
}
|
||||
else {
|
||||
Material i3_material = Util.getType(i3);
|
||||
Material i3_material = MaterialUtils.getType(i3);
|
||||
if (i3_material != null) {
|
||||
isBlock = true;
|
||||
}
|
||||
else {
|
||||
EntityType i3Entity = Util.getEntityType(i3);
|
||||
EntityType i3Entity = EntityUtils.getEntityType(i3);
|
||||
if (i3Entity != null) {
|
||||
isBlock = true;
|
||||
}
|
||||
|
|
@ -382,12 +385,12 @@ public class CommandHandler implements CommandExecutor {
|
|||
isBlock = true;
|
||||
}
|
||||
else {
|
||||
Material iMaterial = Util.getType(argument);
|
||||
Material iMaterial = MaterialUtils.getType(argument);
|
||||
if (iMaterial != null) {
|
||||
isBlock = true;
|
||||
}
|
||||
else {
|
||||
EntityType entityType = Util.getEntityType(argument);
|
||||
EntityType entityType = EntityUtils.getEntityType(argument);
|
||||
if (entityType != null) {
|
||||
isBlock = true;
|
||||
}
|
||||
|
|
@ -429,7 +432,7 @@ public class CommandHandler implements CommandExecutor {
|
|||
result = true;
|
||||
}
|
||||
else if (argument.startsWith("#")) {
|
||||
int worldId = Util.matchWorld(argument);
|
||||
int worldId = WorldUtils.matchWorld(argument);
|
||||
if (worldId > 0) {
|
||||
result = true;
|
||||
}
|
||||
|
|
@ -622,12 +625,12 @@ public class CommandHandler implements CommandExecutor {
|
|||
String[] i2 = argument.split(",");
|
||||
for (String i3 : i2) {
|
||||
if (!checkTags(argument, restricted)) {
|
||||
Material i3_material = Util.getType(i3);
|
||||
Material i3_material = MaterialUtils.getType(i3);
|
||||
if (i3_material != null && (i3_material.isBlock() || argAction.contains(4))) {
|
||||
restricted.add(i3_material);
|
||||
}
|
||||
else {
|
||||
EntityType i3_entity = Util.getEntityType(i3);
|
||||
EntityType i3_entity = EntityUtils.getEntityType(i3);
|
||||
if (i3_entity != null) {
|
||||
restricted.add(i3_entity);
|
||||
}
|
||||
|
|
@ -651,12 +654,12 @@ public class CommandHandler implements CommandExecutor {
|
|||
}
|
||||
else {
|
||||
if (!checkTags(argument, restricted)) {
|
||||
Material material = Util.getType(argument);
|
||||
Material material = MaterialUtils.getType(argument);
|
||||
if (material != null && (material.isBlock() || argAction.contains(4))) {
|
||||
restricted.add(material);
|
||||
}
|
||||
else {
|
||||
EntityType entityType = Util.getEntityType(argument);
|
||||
EntityType entityType = EntityUtils.getEntityType(argument);
|
||||
if (entityType != null) {
|
||||
restricted.add(entityType);
|
||||
}
|
||||
|
|
@ -1041,7 +1044,7 @@ public class CommandHandler implements CommandExecutor {
|
|||
world_id = 0;
|
||||
}
|
||||
else if (inputProcessed.startsWith("#")) {
|
||||
world_id = Util.matchWorld(inputProcessed);
|
||||
world_id = WorldUtils.matchWorld(inputProcessed);
|
||||
if (world_id == -1 && !requireLoaded) {
|
||||
world_id = ConfigHandler.worlds.getOrDefault(argument.replaceFirst("#", ""), -1);
|
||||
}
|
||||
|
|
@ -1275,7 +1278,7 @@ public class CommandHandler implements CommandExecutor {
|
|||
NetworkDebugCommand.runCommand(user, permission, argumentArray);
|
||||
}
|
||||
else if (corecommand.equals("migrate-db")) {
|
||||
if (!Util.validDonationKey()) {
|
||||
if (!VersionUtils.validDonationKey()) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DONATION_KEY_REQUIRED));
|
||||
}
|
||||
else {
|
||||
|
|
@ -1300,7 +1303,7 @@ public class CommandHandler implements CommandExecutor {
|
|||
public void run() {
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
Chat.sendMessage(user, Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.UPDATE_HEADER, "CoreProtect" + (Util.isCommunityEdition() ? " " + ConfigHandler.COMMUNITY_EDITION : "")) + Color.WHITE + " -----");
|
||||
Chat.sendMessage(user, Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.UPDATE_HEADER, "CoreProtect" + (VersionUtils.isCommunityEdition() ? " " + ConfigHandler.COMMUNITY_EDITION : "")) + Color.WHITE + " -----");
|
||||
if (latestVersion != null) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + Phrase.build(Phrase.UPDATE_NOTICE, Color.WHITE, "CoreProtect CE v" + latestVersion));
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + Phrase.build(Phrase.LINK_DOWNLOAD, Color.WHITE, "www.coreprotect.net/download/"));
|
||||
|
|
|
|||
|
|
@ -39,8 +39,14 @@ import net.coreprotect.listener.channel.PluginChannelHandshakeListener;
|
|||
import net.coreprotect.listener.channel.PluginChannelListener;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.ChatMessage;
|
||||
import net.coreprotect.utility.ChatUtils;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.EntityUtils;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
import net.coreprotect.utility.StringUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class LookupCommand {
|
||||
protected static void runCommand(CommandSender player, Command command, boolean permission, String[] args) {
|
||||
|
|
@ -341,7 +347,7 @@ public class LookupCommand {
|
|||
String bc = x + "." + y + "." + z + "." + wid + "." + x2 + "." + y2 + "." + z2 + "." + re;
|
||||
ConfigHandler.lookupCommand.put(player.getName(), bc);
|
||||
|
||||
String world = Util.getWorldName(wid);
|
||||
String world = WorldUtils.getWorldName(wid);
|
||||
double dx = 0.5 * (x + x2);
|
||||
double dy = 0.5 * (y + y2);
|
||||
double dz = 0.5 * (z + z2);
|
||||
|
|
@ -434,7 +440,7 @@ public class LookupCommand {
|
|||
String bc = x + "." + y + "." + z + "." + wid + "." + lookupType + "." + re;
|
||||
ConfigHandler.lookupCommand.put(player.getName(), bc);
|
||||
|
||||
String world = Util.getWorldName(wid);
|
||||
String world = WorldUtils.getWorldName(wid);
|
||||
final Block fblock = Bukkit.getServer().getWorld(world).getBlockAt(x, y, z);// .getLocation();
|
||||
final BlockState fblockstate = fblock.getState();
|
||||
final CommandSender player2 = player;
|
||||
|
|
@ -622,7 +628,7 @@ public class LookupCommand {
|
|||
if (lo != null) {
|
||||
x = lo.getBlockX();
|
||||
z = lo.getBlockZ();
|
||||
wid = Util.getWorldId(lo.getWorld().getName());
|
||||
wid = WorldUtils.getWorldId(lo.getWorld().getName());
|
||||
}
|
||||
|
||||
if (rollbackusers.size() == 1 && rollbackusers.contains("#global") && argAction.contains(9)) {
|
||||
|
|
@ -789,10 +795,10 @@ public class LookupCommand {
|
|||
}
|
||||
if (finalArgWid > 0) {
|
||||
restrict_world = true;
|
||||
location = new Location(Bukkit.getServer().getWorld(Util.getWorldName(finalArgWid)), finalX, finalY, finalZ);
|
||||
location = new Location(Bukkit.getServer().getWorld(WorldUtils.getWorldName(finalArgWid)), finalX, finalY, finalZ);
|
||||
}
|
||||
else if (location != null) {
|
||||
location = new Location(Bukkit.getServer().getWorld(Util.getWorldName(finalWid)), finalX, finalY, finalZ);
|
||||
location = new Location(Bukkit.getServer().getWorld(WorldUtils.getWorldName(finalWid)), finalX, finalY, finalZ);
|
||||
}
|
||||
|
||||
Long[] rowData = new Long[] { 0L, 0L, 0L, 0L };
|
||||
|
|
@ -828,7 +834,7 @@ public class LookupCommand {
|
|||
String time = data[0];
|
||||
String dplayer = data[1];
|
||||
String message = data[2];
|
||||
String timeago = Util.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
|
||||
String timeago = ChatUtils.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
|
||||
Chat.sendComponent(player2, timeago + " " + Color.WHITE + "- " + Color.DARK_AQUA + dplayer + ": " + Color.WHITE, message);
|
||||
if (PluginChannelHandshakeListener.getInstance().isPluginChannelPlayer(player2)) {
|
||||
int wid = Integer.parseInt(data[3]);
|
||||
|
|
@ -848,8 +854,8 @@ public class LookupCommand {
|
|||
int y = Integer.parseInt(data[4]);
|
||||
int z = Integer.parseInt(data[5]);
|
||||
int action = Integer.parseInt(data[6]);
|
||||
String timeago = Util.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
|
||||
int timeLength = 50 + (Util.getTimeSince(Integer.parseInt(time), unixtimestamp, false).replaceAll("[^0-9]", "").length() * 6);
|
||||
String timeago = ChatUtils.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
|
||||
int timeLength = 50 + (ChatUtils.getTimeSince(Integer.parseInt(time), unixtimestamp, false).replaceAll("[^0-9]", "").length() * 6);
|
||||
String leftPadding = Color.BOLD + Strings.padStart("", 10, ' ');
|
||||
if (timeLength % 4 == 0) {
|
||||
leftPadding = Strings.padStart("", timeLength / 4, ' ');
|
||||
|
|
@ -860,7 +866,7 @@ public class LookupCommand {
|
|||
|
||||
String tag = (action != 0 ? Color.GREEN + "+" : Color.RED + "-");
|
||||
Chat.sendComponent(player2, timeago + " " + tag + " " + Color.DARK_AQUA + Phrase.build(Phrase.LOOKUP_LOGIN, Color.DARK_AQUA + dplayer + Color.WHITE, (action != 0 ? Selector.FIRST : Selector.SECOND)));
|
||||
Chat.sendComponent(player2, Color.WHITE + leftPadding + Color.GREY + "^ " + Util.getCoordinates(command.getName(), wid, x, y, z, true, true) + "");
|
||||
Chat.sendComponent(player2, Color.WHITE + leftPadding + Color.GREY + "^ " + ChatUtils.getCoordinates(command.getName(), wid, x, y, z, true, true) + "");
|
||||
PluginChannelListener.getInstance().sendInfoData(player2, Integer.parseInt(time), Phrase.LOOKUP_LOGIN, (action != 0 ? Selector.FIRST : Selector.SECOND), dplayer, -1, x, y, z, wid);
|
||||
}
|
||||
}
|
||||
|
|
@ -869,7 +875,7 @@ public class LookupCommand {
|
|||
String time = data[0];
|
||||
String user = ConfigHandler.uuidCacheReversed.get(data[1]);
|
||||
String username = data[2];
|
||||
String timeago = Util.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
|
||||
String timeago = ChatUtils.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
|
||||
Chat.sendComponent(player2, timeago + " " + Color.WHITE + "- " + Phrase.build(Phrase.LOOKUP_USERNAME, Color.DARK_AQUA + user + Color.WHITE, Color.DARK_AQUA + username + Color.WHITE));
|
||||
PluginChannelListener.getInstance().sendUsernameData(player2, Integer.parseInt(time), user, username);
|
||||
}
|
||||
|
|
@ -883,8 +889,8 @@ public class LookupCommand {
|
|||
int y = Integer.parseInt(data[4]);
|
||||
int z = Integer.parseInt(data[5]);
|
||||
String message = data[6];
|
||||
String timeago = Util.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
|
||||
int timeLength = 50 + (Util.getTimeSince(Integer.parseInt(time), unixtimestamp, false).replaceAll("[^0-9]", "").length() * 6);
|
||||
String timeago = ChatUtils.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
|
||||
int timeLength = 50 + (ChatUtils.getTimeSince(Integer.parseInt(time), unixtimestamp, false).replaceAll("[^0-9]", "").length() * 6);
|
||||
String leftPadding = Color.BOLD + Strings.padStart("", 10, ' ');
|
||||
if (timeLength % 4 == 0) {
|
||||
leftPadding = Strings.padStart("", timeLength / 4, ' ');
|
||||
|
|
@ -894,7 +900,7 @@ public class LookupCommand {
|
|||
}
|
||||
|
||||
Chat.sendComponent(player2, timeago + " " + Color.WHITE + "- " + Color.DARK_AQUA + dplayer + ": " + Color.WHITE, message);
|
||||
Chat.sendComponent(player2, Color.WHITE + leftPadding + Color.GREY + "^ " + Util.getCoordinates(command.getName(), wid, x, y, z, true, true) + "");
|
||||
Chat.sendComponent(player2, Color.WHITE + leftPadding + Color.GREY + "^ " + ChatUtils.getCoordinates(command.getName(), wid, x, y, z, true, true) + "");
|
||||
PluginChannelListener.getInstance().sendMessageData(player2, Integer.parseInt(time), dplayer, message, true, x, y, z, wid);
|
||||
}
|
||||
}
|
||||
|
|
@ -911,11 +917,11 @@ public class LookupCommand {
|
|||
int y = Integer.parseInt(data[3]);
|
||||
int z = Integer.parseInt(data[4]);
|
||||
String rbd = ((Integer.parseInt(data[8]) == 2 || Integer.parseInt(data[8]) == 3) ? Color.STRIKETHROUGH : "");
|
||||
String timeago = Util.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
|
||||
Material blockType = Util.itemFilter(Util.getType(dtype), (Integer.parseInt(data[13]) == 0));
|
||||
String dname = Util.nameFilter(blockType.name().toLowerCase(Locale.ROOT), ddata);
|
||||
String timeago = ChatUtils.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
|
||||
Material blockType = ItemUtils.itemFilter(MaterialUtils.getType(dtype), (Integer.parseInt(data[13]) == 0));
|
||||
String dname = StringUtils.nameFilter(blockType.name().toLowerCase(Locale.ROOT), ddata);
|
||||
byte[] metadata = data[11] == null ? null : data[11].getBytes(StandardCharsets.ISO_8859_1);
|
||||
String tooltip = Util.getEnchantments(metadata, dtype, amount);
|
||||
String tooltip = ItemUtils.getEnchantments(metadata, dtype, amount);
|
||||
|
||||
String selector = Selector.FIRST;
|
||||
String tag = Color.WHITE + "-";
|
||||
|
|
@ -944,7 +950,7 @@ public class LookupCommand {
|
|||
tag = (daction == 0 ? Color.GREEN + "+" : Color.RED + "-");
|
||||
}
|
||||
|
||||
Chat.sendComponent(player2, timeago + " " + tag + " " + Phrase.build(Phrase.LOOKUP_CONTAINER, Color.DARK_AQUA + rbd + dplayer + Color.WHITE + rbd, "x" + amount, Util.createTooltip(Color.DARK_AQUA + rbd + dname, tooltip) + Color.WHITE, selector));
|
||||
Chat.sendComponent(player2, timeago + " " + tag + " " + Phrase.build(Phrase.LOOKUP_CONTAINER, Color.DARK_AQUA + rbd + dplayer + Color.WHITE + rbd, "x" + amount, ChatUtils.createTooltip(Color.DARK_AQUA + rbd + dname, tooltip) + Color.WHITE, selector));
|
||||
PluginChannelListener.getInstance().sendData(player2, Integer.parseInt(time), Phrase.LOOKUP_CONTAINER, selector, dplayer, dname, amount, x, y, z, wid, rbd, true, tag.contains("+"));
|
||||
}
|
||||
}
|
||||
|
|
@ -968,8 +974,8 @@ public class LookupCommand {
|
|||
int amount = Integer.parseInt(data[10]);
|
||||
String tag = Color.WHITE + "-";
|
||||
|
||||
String timeago = Util.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
|
||||
int timeLength = 50 + (Util.getTimeSince(Integer.parseInt(time), unixtimestamp, false).replaceAll("[^0-9]", "").length() * 6);
|
||||
String timeago = ChatUtils.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
|
||||
int timeLength = 50 + (ChatUtils.getTimeSince(Integer.parseInt(time), unixtimestamp, false).replaceAll("[^0-9]", "").length() * 6);
|
||||
String leftPadding = Color.BOLD + Strings.padStart("", 10, ' ');
|
||||
if (timeLength % 4 == 0) {
|
||||
leftPadding = Strings.padStart("", timeLength / 4, ' ');
|
||||
|
|
@ -989,12 +995,12 @@ public class LookupCommand {
|
|||
isPlayer = true;
|
||||
}
|
||||
else {
|
||||
dname = Util.getEntityType(dtype).name();
|
||||
dname = EntityUtils.getEntityType(dtype).name();
|
||||
}
|
||||
}
|
||||
else {
|
||||
dname = Util.getType(dtype).name().toLowerCase(Locale.ROOT);
|
||||
dname = Util.nameFilter(dname, ddata);
|
||||
dname = MaterialUtils.getType(dtype).name().toLowerCase(Locale.ROOT);
|
||||
dname = StringUtils.nameFilter(dname, ddata);
|
||||
}
|
||||
if (dname.length() > 0 && !isPlayer) {
|
||||
dname = "minecraft:" + dname.toLowerCase(Locale.ROOT) + "";
|
||||
|
|
@ -1013,7 +1019,7 @@ public class LookupCommand {
|
|||
String action = "a:block";
|
||||
if (finalArgAction.contains(4) || finalArgAction.contains(5) || finalArgAction.contains(11) || amount > -1) {
|
||||
byte[] metadata = data[11] == null ? null : data[11].getBytes(StandardCharsets.ISO_8859_1);
|
||||
String tooltip = Util.getEnchantments(metadata, dtype, amount);
|
||||
String tooltip = ItemUtils.getEnchantments(metadata, dtype, amount);
|
||||
|
||||
if (daction == 2 || daction == 3) {
|
||||
phrase = Phrase.LOOKUP_ITEM; // {picked up|dropped}
|
||||
|
|
@ -1040,7 +1046,7 @@ public class LookupCommand {
|
|||
action = "a:container";
|
||||
}
|
||||
|
||||
Chat.sendComponent(player2, timeago + " " + tag + " " + Phrase.build(phrase, Color.DARK_AQUA + rbd + dplayer + Color.WHITE + rbd, "x" + amount, Util.createTooltip(Color.DARK_AQUA + rbd + dname, tooltip) + Color.WHITE, selector));
|
||||
Chat.sendComponent(player2, timeago + " " + tag + " " + Phrase.build(phrase, Color.DARK_AQUA + rbd + dplayer + Color.WHITE + rbd, "x" + amount, ChatUtils.createTooltip(Color.DARK_AQUA + rbd + dname, tooltip) + Color.WHITE, selector));
|
||||
PluginChannelListener.getInstance().sendData(player2, Integer.parseInt(time), phrase, selector, dplayer, dname, (tag.contains("+") ? 1 : -1), x, y, z, wid, rbd, action.contains("container"), tag.contains("+"));
|
||||
}
|
||||
else {
|
||||
|
|
@ -1061,7 +1067,7 @@ public class LookupCommand {
|
|||
}
|
||||
|
||||
action = (finalArgAction.size() == 0 ? " (" + action + ")" : "");
|
||||
Chat.sendComponent(player2, Color.WHITE + leftPadding + Color.GREY + "^ " + Util.getCoordinates(command.getName(), wid, x, y, z, true, true) + Color.GREY + Color.ITALIC + action);
|
||||
Chat.sendComponent(player2, Color.WHITE + leftPadding + Color.GREY + "^ " + ChatUtils.getCoordinates(command.getName(), wid, x, y, z, true, true) + Color.GREY + Color.ITALIC + action);
|
||||
}
|
||||
}
|
||||
if (rows > displayResults) {
|
||||
|
|
@ -1069,7 +1075,7 @@ public class LookupCommand {
|
|||
if (finalArgAction.contains(6) || finalArgAction.contains(7) || finalArgAction.contains(9) || (finalArgAction.contains(4) && finalArgAction.contains(11))) {
|
||||
Chat.sendMessage(player2, "-----");
|
||||
}
|
||||
Chat.sendComponent(player2, Util.getPageNavigation(command.getName(), page, total_pages));
|
||||
Chat.sendComponent(player2, ChatUtils.getPageNavigation(command.getName(), page, total_pages));
|
||||
}
|
||||
}
|
||||
else if (rows > 0) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@ import net.coreprotect.patch.Patch;
|
|||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.ChatMessage;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.EntityUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
import net.coreprotect.utility.VersionUtils;
|
||||
|
||||
public class PurgeCommand extends Consumer {
|
||||
|
||||
|
|
@ -113,10 +115,10 @@ public class PurgeCommand extends Consumer {
|
|||
if (restrictTarget instanceof Material) {
|
||||
targetName = ((Material) restrictTarget).name();
|
||||
if (includeListMaterial.length() == 0) {
|
||||
includeListMaterial = includeListMaterial.append(Util.getBlockId(targetName, false));
|
||||
includeListMaterial = includeListMaterial.append(MaterialUtils.getBlockId(targetName, false));
|
||||
}
|
||||
else {
|
||||
includeListMaterial.append(",").append(Util.getBlockId(targetName, false));
|
||||
includeListMaterial.append(",").append(MaterialUtils.getBlockId(targetName, false));
|
||||
}
|
||||
|
||||
/* Include legacy IDs */
|
||||
|
|
@ -132,10 +134,10 @@ public class PurgeCommand extends Consumer {
|
|||
else if (restrictTarget instanceof EntityType) {
|
||||
targetName = ((EntityType) restrictTarget).name();
|
||||
if (includeListEntity.length() == 0) {
|
||||
includeListEntity = includeListEntity.append(Util.getEntityId(targetName, false));
|
||||
includeListEntity = includeListEntity.append(EntityUtils.getEntityId(targetName, false));
|
||||
}
|
||||
else {
|
||||
includeListEntity.append(",").append(Util.getEntityId(targetName, false));
|
||||
includeListEntity.append(",").append(EntityUtils.getEntityId(targetName, false));
|
||||
}
|
||||
|
||||
targetName = ((EntityType) restrictTarget).name().toLowerCase(Locale.ROOT);
|
||||
|
|
@ -234,7 +236,7 @@ public class PurgeCommand extends Consumer {
|
|||
}
|
||||
|
||||
Integer[] lastVersion = Patch.getDatabaseVersion(connection, true);
|
||||
boolean newVersion = Util.newVersion(lastVersion, Util.getInternalPluginVersion());
|
||||
boolean newVersion = VersionUtils.newVersion(lastVersion, VersionUtils.getInternalPluginVersion());
|
||||
if (newVersion && !ConfigHandler.EDITION_BRANCH.contains("-dev")) {
|
||||
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_FAILED));
|
||||
Consumer.isPaused = false;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import net.coreprotect.language.Selector;
|
|||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class RollbackRestoreCommand {
|
||||
protected static void runCommand(CommandSender player, Command command, boolean permission, String[] args, Location argLocation, long forceStart, long forceEnd) {
|
||||
|
|
@ -290,7 +291,7 @@ public class RollbackRestoreCommand {
|
|||
argAction.add(5);
|
||||
argRadius = null;
|
||||
argWid = 0;
|
||||
lo = new Location(Bukkit.getServer().getWorld(Util.getWorldName(wid)), x, y, z);
|
||||
lo = new Location(Bukkit.getServer().getWorld(WorldUtils.getWorldName(wid)), x, y, z);
|
||||
Block block = lo.getBlock();
|
||||
if (block.getState() instanceof Chest) {
|
||||
BlockFace[] blockFaces = new BlockFace[] { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
|
||||
|
|
@ -391,7 +392,7 @@ public class RollbackRestoreCommand {
|
|||
}
|
||||
if (finalArgWid > 0) {
|
||||
restrictWorld = true;
|
||||
location = new Location(Bukkit.getServer().getWorld(Util.getWorldName(finalArgWid)), 0, 0, 0);
|
||||
location = new Location(Bukkit.getServer().getWorld(WorldUtils.getWorldName(finalArgWid)), 0, 0, 0);
|
||||
}
|
||||
boolean verbose = false;
|
||||
if (noisy == 1) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import net.coreprotect.patch.Patch;
|
|||
import net.coreprotect.thread.NetworkHandler;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.VersionUtils;
|
||||
|
||||
public class StatusCommand {
|
||||
private static ConcurrentHashMap<String, Boolean> alert = new ConcurrentHashMap<>();
|
||||
|
|
@ -43,7 +43,7 @@ public class StatusCommand {
|
|||
}
|
||||
}
|
||||
|
||||
Chat.sendMessage(player, Color.WHITE + "----- " + Color.DARK_AQUA + "CoreProtect" + (Util.isCommunityEdition() ? " " + ConfigHandler.COMMUNITY_EDITION : "") + Color.WHITE + " -----");
|
||||
Chat.sendMessage(player, Color.WHITE + "----- " + Color.DARK_AQUA + "CoreProtect" + (VersionUtils.isCommunityEdition() ? " " + ConfigHandler.COMMUNITY_EDITION : "") + Color.WHITE + " -----");
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + Phrase.build(Phrase.STATUS_VERSION, Color.WHITE, ConfigHandler.EDITION_NAME + " v" + pdfFile.getVersion() + ".") + versionCheck);
|
||||
|
||||
String donationKey = NetworkHandler.donationKey();
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import net.coreprotect.utility.ChatMessage;
|
|||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Teleport;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class TeleportCommand {
|
||||
|
||||
|
|
@ -45,7 +46,7 @@ public class TeleportCommand {
|
|||
}
|
||||
|
||||
String worldName = args[1];
|
||||
int wid = Util.matchWorld(worldName);
|
||||
int wid = WorldUtils.matchWorld(worldName);
|
||||
if (wid == -1 && resultc >= 5) {
|
||||
Chat.sendMessage(player, new ChatMessage(Phrase.build(Phrase.WORLD_NOT_FOUND, worldName)).build());
|
||||
return;
|
||||
|
|
@ -54,7 +55,7 @@ public class TeleportCommand {
|
|||
Location location = ((Player) player).getLocation().clone();
|
||||
World world = location.getWorld();
|
||||
if (wid > -1) {
|
||||
world = Bukkit.getServer().getWorld(Util.getWorldName(wid));
|
||||
world = Bukkit.getServer().getWorld(WorldUtils.getWorldName(wid));
|
||||
}
|
||||
|
||||
String x = null;
|
||||
|
|
|
|||
|
|
@ -35,14 +35,15 @@ import net.coreprotect.patch.Patch;
|
|||
import net.coreprotect.spigot.SpigotAdapter;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.SystemUtils;
|
||||
import net.coreprotect.utility.VersionUtils;
|
||||
import oshi.hardware.CentralProcessor;
|
||||
|
||||
public class ConfigHandler extends Queue {
|
||||
public static int SERVER_VERSION = 0;
|
||||
public static final int EDITION_VERSION = 2;
|
||||
public static final String EDITION_BRANCH = Util.getBranch();
|
||||
public static final String EDITION_NAME = Util.getPluginName();
|
||||
public static final String EDITION_BRANCH = VersionUtils.getBranch();
|
||||
public static final String EDITION_NAME = VersionUtils.getPluginName();
|
||||
public static final String COMMUNITY_EDITION = "Community Edition";
|
||||
public static final String JAVA_VERSION = "11.0";
|
||||
public static final String MINECRAFT_VERSION = "1.16";
|
||||
|
|
@ -59,10 +60,10 @@ public class ConfigHandler extends Queue {
|
|||
public static int maximumPoolSize = 10;
|
||||
|
||||
public static HikariDataSource hikariDataSource = null;
|
||||
public static final CentralProcessor processorInfo = Util.getProcessorInfo();
|
||||
public static final boolean isSpigot = Util.isSpigot();
|
||||
public static final boolean isPaper = Util.isPaper();
|
||||
public static final boolean isFolia = Util.isFolia();
|
||||
public static final CentralProcessor processorInfo = SystemUtils.getProcessorInfo();
|
||||
public static final boolean isSpigot = VersionUtils.isSpigot();
|
||||
public static final boolean isPaper = VersionUtils.isPaper();
|
||||
public static final boolean isFolia = VersionUtils.isFolia();
|
||||
public static volatile boolean serverRunning = false;
|
||||
public static volatile boolean converterRunning = false;
|
||||
public static volatile boolean purgeRunning = false;
|
||||
|
|
@ -443,15 +444,15 @@ public class ConfigHandler extends Queue {
|
|||
ConfigHandler.loadTypes(statement); // Load material ID's into memory.
|
||||
|
||||
// Initialize WorldEdit logging
|
||||
if (Util.checkWorldEdit()) {
|
||||
if (VersionUtils.checkWorldEdit()) {
|
||||
PluginManager pluginManager = Bukkit.getServer().getPluginManager();
|
||||
Plugin worldEditPlugin = pluginManager.getPlugin("WorldEdit");
|
||||
if (worldEditPlugin != null && worldEditPlugin.isEnabled()) {
|
||||
Util.loadWorldEdit();
|
||||
VersionUtils.loadWorldEdit();
|
||||
}
|
||||
}
|
||||
else if (ConfigHandler.worldeditEnabled) {
|
||||
Util.unloadWorldEdit();
|
||||
VersionUtils.unloadWorldEdit();
|
||||
}
|
||||
|
||||
ConfigHandler.serverRunning = true; // Set as running before patching
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,10 @@ import net.coreprotect.database.rollback.RollbackComplete;
|
|||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class ContainerRollback extends Rollback {
|
||||
|
|
@ -68,14 +71,14 @@ public class ContainerRollback extends Rollback {
|
|||
List<ItemFrame> matchingFrames = new ArrayList<>();
|
||||
|
||||
if (BlockGroup.CONTAINERS.contains(type)) {
|
||||
container = Util.getContainerInventory(block.getState(), false);
|
||||
container = BlockUtils.getContainerInventory(block.getState(), false);
|
||||
}
|
||||
else {
|
||||
for (Entity entity : block.getChunk().getEntities()) {
|
||||
if (entity.getLocation().getBlockX() == location.getBlockX() && entity.getLocation().getBlockY() == location.getBlockY() && entity.getLocation().getBlockZ() == location.getBlockZ()) {
|
||||
if (entity instanceof ArmorStand) {
|
||||
type = Material.ARMOR_STAND;
|
||||
container = Util.getEntityEquipment((LivingEntity) entity);
|
||||
container = ItemUtils.getEntityEquipment((LivingEntity) entity);
|
||||
}
|
||||
else if (entity instanceof ItemFrame) {
|
||||
type = Material.ITEM_FRAME;
|
||||
|
|
@ -99,11 +102,11 @@ public class ContainerRollback extends Rollback {
|
|||
int rowTypeRaw = (Integer) lookupRow[6];
|
||||
int rowData = (Integer) lookupRow[7];
|
||||
int rowAction = (Integer) lookupRow[8];
|
||||
int rowRolledBack = Util.rolledBack((Integer) lookupRow[9], false);
|
||||
int rowRolledBack = MaterialUtils.rolledBack((Integer) lookupRow[9], false);
|
||||
// int rowWid = (Integer)lookupRow[10];
|
||||
int rowAmount = (Integer) lookupRow[11];
|
||||
byte[] rowMetadata = (byte[]) lookupRow[12];
|
||||
Material rowType = Util.getType(rowTypeRaw);
|
||||
Material rowType = MaterialUtils.getType(rowTypeRaw);
|
||||
|
||||
if ((rollbackType == 0 && rowRolledBack == 0) || (rollbackType == 1 && rowRolledBack == 1)) {
|
||||
modifyCount = modifyCount + rowAmount;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@ import net.coreprotect.language.Phrase;
|
|||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
|
||||
public class Database extends Queue {
|
||||
|
||||
|
|
@ -115,11 +116,11 @@ public class Database extends Queue {
|
|||
if (Config.getConfig(location.getWorld()).ITEM_TRANSACTIONS) {
|
||||
try {
|
||||
if (contents == null) {
|
||||
contents = Util.getContainerContents(type, container, location);
|
||||
contents = ItemUtils.getContainerContents(type, container, location);
|
||||
}
|
||||
if (contents != null) {
|
||||
List<ItemStack[]> forceList = new ArrayList<>();
|
||||
forceList.add(Util.getContainerState(contents));
|
||||
forceList.add(ItemUtils.getContainerState(contents));
|
||||
ConfigHandler.forceContainer.put(user.toLowerCase(Locale.ROOT) + "." + location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ(), forceList);
|
||||
Queue.queueContainerBreak(user, location, type, contents);
|
||||
}
|
||||
|
|
@ -200,7 +201,7 @@ public class Database extends Queue {
|
|||
|
||||
public static void performUpdate(Statement statement, long id, int rb, int table) {
|
||||
try {
|
||||
int rolledBack = Util.toggleRolledBack(rb, (table == 2 || table == 3 || table == 4)); // co_item, co_container, co_block
|
||||
int rolledBack = MaterialUtils.toggleRolledBack(rb, (table == 2 || table == 3 || table == 4)); // co_item, co_container, co_block
|
||||
if (table == 1 || table == 3) {
|
||||
statement.executeUpdate("UPDATE " + ConfigHandler.prefix + "container SET rolled_back='" + rolledBack + "' WHERE rowid='" + id + "'");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,11 @@ import net.coreprotect.database.logger.ItemLogger;
|
|||
import net.coreprotect.database.statement.UserStatement;
|
||||
import net.coreprotect.listener.channel.PluginChannelHandshakeListener;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.EntityUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class Lookup extends Queue {
|
||||
|
||||
|
|
@ -57,7 +61,7 @@ public class Lookup extends Queue {
|
|||
}
|
||||
}
|
||||
else if (i == 13 && map[i] instanceof byte[]) {
|
||||
results[newId] = Util.byteDataToString((byte[]) map[i], (int) map[6]);
|
||||
results[newId] = BlockUtils.byteDataToString((byte[]) map[i], (int) map[6]);
|
||||
}
|
||||
else if (i > 0) { // skip rowid
|
||||
if (map[i] instanceof Integer) {
|
||||
|
|
@ -402,10 +406,10 @@ public class Lookup extends Queue {
|
|||
if (restrictTarget instanceof Material) {
|
||||
targetName = ((Material) restrictTarget).name();
|
||||
if (includeListMaterial.length() == 0) {
|
||||
includeListMaterial = includeListMaterial.append(Util.getBlockId(targetName, false));
|
||||
includeListMaterial = includeListMaterial.append(MaterialUtils.getBlockId(targetName, false));
|
||||
}
|
||||
else {
|
||||
includeListMaterial.append(",").append(Util.getBlockId(targetName, false));
|
||||
includeListMaterial.append(",").append(MaterialUtils.getBlockId(targetName, false));
|
||||
}
|
||||
|
||||
/* Include legacy IDs */
|
||||
|
|
@ -417,10 +421,10 @@ public class Lookup extends Queue {
|
|||
else if (restrictTarget instanceof EntityType) {
|
||||
targetName = ((EntityType) restrictTarget).name();
|
||||
if (includeListEntity.length() == 0) {
|
||||
includeListEntity = includeListEntity.append(Util.getEntityId(targetName, false));
|
||||
includeListEntity = includeListEntity.append(EntityUtils.getEntityId(targetName, false));
|
||||
}
|
||||
else {
|
||||
includeListEntity.append(",").append(Util.getEntityId(targetName, false));
|
||||
includeListEntity.append(",").append(EntityUtils.getEntityId(targetName, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -439,10 +443,10 @@ public class Lookup extends Queue {
|
|||
if (restrictTarget instanceof Material) {
|
||||
targetName = ((Material) restrictTarget).name();
|
||||
if (excludeListMaterial.length() == 0) {
|
||||
excludeListMaterial = excludeListMaterial.append(Util.getBlockId(targetName, false));
|
||||
excludeListMaterial = excludeListMaterial.append(MaterialUtils.getBlockId(targetName, false));
|
||||
}
|
||||
else {
|
||||
excludeListMaterial.append(",").append(Util.getBlockId(targetName, false));
|
||||
excludeListMaterial.append(",").append(MaterialUtils.getBlockId(targetName, false));
|
||||
}
|
||||
|
||||
/* Include legacy IDs */
|
||||
|
|
@ -454,10 +458,10 @@ public class Lookup extends Queue {
|
|||
else if (restrictTarget instanceof EntityType) {
|
||||
targetName = ((EntityType) restrictTarget).name();
|
||||
if (excludeListEntity.length() == 0) {
|
||||
excludeListEntity = excludeListEntity.append(Util.getEntityId(targetName, false));
|
||||
excludeListEntity = excludeListEntity.append(EntityUtils.getEntityId(targetName, false));
|
||||
}
|
||||
else {
|
||||
excludeListEntity.append(",").append(Util.getEntityId(targetName, false));
|
||||
excludeListEntity.append(",").append(EntityUtils.getEntityId(targetName, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -560,7 +564,7 @@ public class Lookup extends Queue {
|
|||
}
|
||||
|
||||
if (restrictWorld) {
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(location.getWorld().getName());
|
||||
queryBlock = queryBlock + " wid=" + wid + " AND";
|
||||
}
|
||||
|
||||
|
|
@ -580,7 +584,7 @@ public class Lookup extends Queue {
|
|||
queryBlock = queryBlock + " x >= '" + xmin + "' AND x <= '" + xmax + "' AND z >= '" + zmin + "' AND z <= '" + zmax + "' AND" + queryY;
|
||||
}
|
||||
else if (actionList.contains(5)) {
|
||||
int worldId = Util.getWorldId(location.getWorld().getName());
|
||||
int worldId = WorldUtils.getWorldId(location.getWorld().getName());
|
||||
int x = (int) Math.floor(location.getX());
|
||||
int z = (int) Math.floor(location.getZ());
|
||||
int x2 = (int) Math.ceil(location.getX());
|
||||
|
|
@ -818,8 +822,8 @@ public class Lookup extends Queue {
|
|||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||
int worldId = Util.getWorldId(block.getWorld().getName());
|
||||
String query = "SELECT user,type FROM " + ConfigHandler.prefix + "block " + Util.getWidIndex("block") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND rolled_back IN(0,2) AND action='1' ORDER BY rowid DESC LIMIT 0, 1";
|
||||
int worldId = WorldUtils.getWorldId(block.getWorld().getName());
|
||||
String query = "SELECT user,type FROM " + ConfigHandler.prefix + "block " + WorldUtils.getWidIndex("block") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND rolled_back IN(0,2) AND action='1' ORDER BY rowid DESC LIMIT 0, 1";
|
||||
|
||||
ResultSet results = statement.executeQuery(query);
|
||||
while (results.next()) {
|
||||
|
|
@ -832,7 +836,7 @@ public class Lookup extends Queue {
|
|||
|
||||
result = ConfigHandler.playerIdCacheReversed.get(resultUserId);
|
||||
if (result.length() > 0) {
|
||||
Material resultMaterial = Util.getType(resultType);
|
||||
Material resultMaterial = MaterialUtils.getType(resultType);
|
||||
CacheHandler.lookupCache.put("" + x + "." + y + "." + z + "." + worldId + "", new Object[] { time, result, resultMaterial });
|
||||
}
|
||||
}
|
||||
|
|
@ -864,7 +868,7 @@ public class Lookup extends Queue {
|
|||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
int worldId = Util.getWorldId(block.getWorld().getName());
|
||||
int worldId = WorldUtils.getWorldId(block.getWorld().getName());
|
||||
|
||||
String cords = "" + x + "." + y + "." + z + "." + worldId + "";
|
||||
Object[] data = CacheHandler.lookupCache.get(cords);
|
||||
|
|
@ -891,7 +895,7 @@ public class Lookup extends Queue {
|
|||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
int worldId = Util.getWorldId(block.getWorld().getName());
|
||||
int worldId = WorldUtils.getWorldId(block.getWorld().getName());
|
||||
|
||||
String cords = "" + x + "." + y + "." + z + "." + worldId + "";
|
||||
Object[] data = CacheHandler.breakCache.get(cords);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import net.coreprotect.database.statement.UserStatement;
|
|||
import net.coreprotect.event.CoreProtectPreLogEvent;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class BlockBreakLogger {
|
||||
|
||||
|
|
@ -30,7 +31,7 @@ public class BlockBreakLogger {
|
|||
return;
|
||||
}
|
||||
|
||||
Material checkType = Util.getType(type);
|
||||
Material checkType = net.coreprotect.utility.MaterialUtils.getType(type);
|
||||
if (checkType == null) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -43,7 +44,7 @@ public class BlockBreakLogger {
|
|||
}
|
||||
|
||||
if (!user.startsWith("#")) {
|
||||
String cacheId = location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ() + "." + Util.getWorldId(location.getWorld().getName());
|
||||
String cacheId = location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ() + "." + WorldUtils.getWorldId(location.getWorld().getName());
|
||||
CacheHandler.spreadCache.remove(cacheId);
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +61,7 @@ public class BlockBreakLogger {
|
|||
}
|
||||
|
||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(location.getWorld().getName());
|
||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
|
|
|
|||
|
|
@ -16,7 +16,10 @@ import net.coreprotect.database.statement.BlockStatement;
|
|||
import net.coreprotect.database.statement.UserStatement;
|
||||
import net.coreprotect.event.CoreProtectPreLogEvent;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class BlockPlaceLogger {
|
||||
|
||||
|
|
@ -90,7 +93,7 @@ public class BlockPlaceLogger {
|
|||
}
|
||||
|
||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||
int wid = Util.getWorldId(block.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(block.getWorld().getName());
|
||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||
|
||||
if (event.getUser().length() > 0) {
|
||||
|
|
@ -101,8 +104,8 @@ public class BlockPlaceLogger {
|
|||
return;
|
||||
}
|
||||
|
||||
int internalType = Util.getBlockId(type.name(), true);
|
||||
if (replacedType > 0 && Util.getType(replacedType) != Material.AIR && Util.getType(replacedType) != Material.CAVE_AIR) {
|
||||
int internalType = MaterialUtils.getBlockId(type.name(), true);
|
||||
if (replacedType > 0 && MaterialUtils.getType(replacedType) != Material.AIR && MaterialUtils.getType(replacedType) != Material.CAVE_AIR) {
|
||||
BlockStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, replacedType, replacedData, null, replaceBlockData, 0, 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import org.bukkit.Location;
|
|||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.statement.ChatStatement;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class ChatLogger {
|
||||
|
||||
|
|
@ -23,7 +24,7 @@ public class ChatLogger {
|
|||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(location.getWorld().getName());
|
||||
int userId = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
|
||||
ChatStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, message);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import net.coreprotect.database.statement.CommandStatement;
|
|||
import net.coreprotect.database.statement.UserStatement;
|
||||
import net.coreprotect.event.CoreProtectPreLogEvent;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class CommandLogger {
|
||||
|
||||
|
|
@ -39,7 +40,7 @@ public class CommandLogger {
|
|||
}
|
||||
|
||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(location.getWorld().getName());
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import org.bukkit.Material;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class ContainerBreakLogger {
|
||||
|
|
@ -18,7 +19,7 @@ public class ContainerBreakLogger {
|
|||
|
||||
public static void log(PreparedStatement preparedStmt, int batchCount, String player, Location l, Material type, ItemStack[] oldInventory) {
|
||||
try {
|
||||
Util.mergeItems(type, oldInventory);
|
||||
ItemUtils.mergeItems(type, oldInventory);
|
||||
ContainerLogger.logTransaction(preparedStmt, batchCount, player, type, null, oldInventory, 0, l);
|
||||
String loggingContainerId = player.toLowerCase(Locale.ROOT) + "." + l.getBlockX() + "." + l.getBlockY() + "." + l.getBlockZ();
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,11 @@ import net.coreprotect.consumer.Queue;
|
|||
import net.coreprotect.database.statement.ContainerStatement;
|
||||
import net.coreprotect.database.statement.UserStatement;
|
||||
import net.coreprotect.event.CoreProtectPreLogEvent;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
import net.coreprotect.utility.serialize.ItemMetaHandler;
|
||||
|
||||
public class ContainerLogger extends Queue {
|
||||
|
|
@ -56,8 +60,8 @@ public class ContainerLogger extends Queue {
|
|||
String loggingContainerId = player.toLowerCase(Locale.ROOT) + "." + location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ();
|
||||
List<ItemStack[]> oldList = ConfigHandler.oldContainer.get(loggingContainerId);
|
||||
ItemStack[] oi1 = oldList.get(0);
|
||||
ItemStack[] oldInventory = Util.getContainerState(oi1);
|
||||
ItemStack[] newInventory = Util.getContainerState(contents);
|
||||
ItemStack[] oldInventory = ItemUtils.getContainerState(oi1);
|
||||
ItemStack[] newInventory = ItemUtils.getContainerState(contents);
|
||||
if (oldInventory == null || newInventory == null) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -66,7 +70,7 @@ public class ContainerLogger extends Queue {
|
|||
if (forceList != null) {
|
||||
int forceSize = 0;
|
||||
if (!forceList.isEmpty()) {
|
||||
newInventory = Util.getContainerState(forceList.get(0));
|
||||
newInventory = ItemUtils.getContainerState(forceList.get(0));
|
||||
forceSize = modifyForceContainer(loggingContainerId, null);
|
||||
}
|
||||
if (forceSize == 0) {
|
||||
|
|
@ -119,7 +123,7 @@ public class ContainerLogger extends Queue {
|
|||
for (ItemStack oldi : oldInventory) {
|
||||
for (ItemStack newi : newInventory) {
|
||||
if (oldi != null && newi != null) {
|
||||
if (oldi.isSimilar(newi) && !Util.isAir(oldi.getType())) { // Ignores amount
|
||||
if (oldi.isSimilar(newi) && !BlockUtils.isAir(oldi.getType())) { // Ignores amount
|
||||
int oldAmount = oldi.getAmount();
|
||||
int newAmount = newi.getAmount();
|
||||
if (newAmount >= oldAmount) {
|
||||
|
|
@ -137,8 +141,8 @@ public class ContainerLogger extends Queue {
|
|||
}
|
||||
}
|
||||
|
||||
Util.mergeItems(type, oldInventory);
|
||||
Util.mergeItems(type, newInventory);
|
||||
ItemUtils.mergeItems(type, oldInventory);
|
||||
ItemUtils.mergeItems(type, newInventory);
|
||||
|
||||
if (type != Material.ENDER_CHEST) {
|
||||
logTransaction(preparedStmtContainer, batchCount, player, type, faceData, oldInventory, 0, location);
|
||||
|
|
@ -166,7 +170,7 @@ public class ContainerLogger extends Queue {
|
|||
int slot = 0;
|
||||
for (ItemStack item : items) {
|
||||
if (item != null) {
|
||||
if (item.getAmount() > 0 && !Util.isAir(item.getType())) {
|
||||
if (item.getAmount() > 0 && !BlockUtils.isAir(item.getType())) {
|
||||
// Object[] metadata = new Object[] { slot, item.getItemMeta() };
|
||||
List<List<Map<String, Object>>> metadata = ItemMetaHandler.serialize(item, type, faceData, slot);
|
||||
if (metadata.size() == 0) {
|
||||
|
|
@ -183,12 +187,12 @@ public class ContainerLogger extends Queue {
|
|||
}
|
||||
|
||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(location.getWorld().getName());
|
||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
int typeId = Util.getBlockId(item.getType().name(), true);
|
||||
int typeId = MaterialUtils.getBlockId(item.getType().name(), true);
|
||||
int data = 0;
|
||||
int amount = item.getAmount();
|
||||
ContainerStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, typeId, data, amount, metadata, action, 0);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import net.coreprotect.database.statement.EntityStatement;
|
|||
import net.coreprotect.database.statement.UserStatement;
|
||||
import net.coreprotect.event.CoreProtectPreLogEvent;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class EntityKillLogger {
|
||||
|
||||
|
|
@ -40,7 +41,7 @@ public class EntityKillLogger {
|
|||
}
|
||||
|
||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||
int wid = Util.getWorldId(block.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(block.getWorld().getName());
|
||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
|
|
|
|||
|
|
@ -16,7 +16,11 @@ import net.coreprotect.config.ConfigHandler;
|
|||
import net.coreprotect.database.statement.ItemStatement;
|
||||
import net.coreprotect.database.statement.UserStatement;
|
||||
import net.coreprotect.event.CoreProtectPreLogEvent;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
import net.coreprotect.utility.serialize.ItemMetaHandler;
|
||||
|
||||
public class ItemLogger {
|
||||
|
|
@ -92,15 +96,15 @@ public class ItemLogger {
|
|||
itemBuys = buyList.toArray(itemBuys);
|
||||
buyList.clear();
|
||||
|
||||
Util.mergeItems(null, itemPickups);
|
||||
Util.mergeItems(null, itemDrops);
|
||||
Util.mergeItems(null, itemThrows);
|
||||
Util.mergeItems(null, itemShots);
|
||||
Util.mergeItems(null, itemBreaks);
|
||||
Util.mergeItems(null, itemDestroys);
|
||||
Util.mergeItems(null, itemCreates);
|
||||
Util.mergeItems(null, itemSells);
|
||||
Util.mergeItems(null, itemBuys);
|
||||
ItemUtils.mergeItems(null, itemPickups);
|
||||
ItemUtils.mergeItems(null, itemDrops);
|
||||
ItemUtils.mergeItems(null, itemThrows);
|
||||
ItemUtils.mergeItems(null, itemShots);
|
||||
ItemUtils.mergeItems(null, itemBreaks);
|
||||
ItemUtils.mergeItems(null, itemDestroys);
|
||||
ItemUtils.mergeItems(null, itemCreates);
|
||||
ItemUtils.mergeItems(null, itemSells);
|
||||
ItemUtils.mergeItems(null, itemBuys);
|
||||
logTransaction(preparedStmt, batchCount, offset, user, location, itemPickups, ITEM_PICKUP);
|
||||
logTransaction(preparedStmt, batchCount, offset, user, location, itemDrops, ITEM_DROP);
|
||||
logTransaction(preparedStmt, batchCount, offset, user, location, itemThrows, ITEM_THROW);
|
||||
|
|
@ -119,7 +123,7 @@ public class ItemLogger {
|
|||
protected static void logTransaction(PreparedStatement preparedStmt, int batchCount, int offset, String user, Location location, ItemStack[] items, int action) {
|
||||
try {
|
||||
for (ItemStack item : items) {
|
||||
if (item != null && item.getAmount() > 0 && !Util.isAir(item.getType())) {
|
||||
if (item != null && item.getAmount() > 0 && !BlockUtils.isAir(item.getType())) {
|
||||
// Object[] metadata = new Object[] { slot, item.getItemMeta() };
|
||||
List<List<Map<String, Object>>> data = ItemMetaHandler.serialize(item, null, null, 0);
|
||||
if (data.size() == 0) {
|
||||
|
|
@ -136,12 +140,12 @@ public class ItemLogger {
|
|||
}
|
||||
|
||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(location.getWorld().getName());
|
||||
int time = (int) (System.currentTimeMillis() / 1000L) - offset;
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
int typeId = Util.getBlockId(item.getType().name(), true);
|
||||
int typeId = MaterialUtils.getBlockId(item.getType().name(), true);
|
||||
int amount = item.getAmount();
|
||||
ItemStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, typeId, data, amount, action);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,10 @@ import net.coreprotect.config.ConfigHandler;
|
|||
import net.coreprotect.database.statement.BlockStatement;
|
||||
import net.coreprotect.database.statement.UserStatement;
|
||||
import net.coreprotect.event.CoreProtectPreLogEvent;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class PlayerInteractLogger {
|
||||
|
||||
|
|
@ -23,8 +26,8 @@ public class PlayerInteractLogger {
|
|||
|
||||
public static void log(PreparedStatement preparedStmt, int batchCount, String user, BlockState block, Material blockType) {
|
||||
try {
|
||||
int type = Util.getBlockId(blockType.name(), true);
|
||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null || Util.getType(type).equals(Material.AIR) || Util.getType(type).equals(Material.CAVE_AIR)) {
|
||||
int type = MaterialUtils.getBlockId(blockType.name(), true);
|
||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null || MaterialUtils.getType(type).equals(Material.AIR) || MaterialUtils.getType(type).equals(Material.CAVE_AIR)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -38,7 +41,7 @@ public class PlayerInteractLogger {
|
|||
}
|
||||
|
||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||
int wid = Util.getWorldId(block.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(block.getWorld().getName());
|
||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import net.coreprotect.database.statement.BlockStatement;
|
|||
import net.coreprotect.database.statement.UserStatement;
|
||||
import net.coreprotect.event.CoreProtectPreLogEvent;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class PlayerKillLogger {
|
||||
|
||||
|
|
@ -41,7 +42,7 @@ public class PlayerKillLogger {
|
|||
|
||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||
int playerId = ConfigHandler.playerIdCache.get(player.toLowerCase(Locale.ROOT));
|
||||
int wid = Util.getWorldId(block.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(block.getWorld().getName());
|
||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import org.bukkit.Location;
|
|||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.statement.SessionStatement;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class PlayerSessionLogger {
|
||||
|
||||
|
|
@ -23,7 +24,7 @@ public class PlayerSessionLogger {
|
|||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(location.getWorld().getName());
|
||||
int userId = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
|
||||
SessionStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, action);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import net.coreprotect.database.statement.SignStatement;
|
|||
import net.coreprotect.database.statement.UserStatement;
|
||||
import net.coreprotect.event.CoreProtectPreLogEvent;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class SignTextLogger {
|
||||
|
||||
|
|
@ -36,7 +37,7 @@ public class SignTextLogger {
|
|||
}
|
||||
|
||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(location.getWorld().getName());
|
||||
int time = (int) (System.currentTimeMillis() / 1000L) - timeOffset;
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ 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.MaterialUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class SkullBreakLogger {
|
||||
|
|
@ -25,7 +26,7 @@ public class SkullBreakLogger {
|
|||
return;
|
||||
}
|
||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||
int type = Util.getBlockId(block.getType().name(), true);
|
||||
int type = MaterialUtils.getBlockId(block.getType().name(), true);
|
||||
Skull skull = (Skull) block;
|
||||
String skullOwner = "";
|
||||
String skullSkin = null;
|
||||
|
|
|
|||
|
|
@ -13,8 +13,13 @@ import net.coreprotect.database.statement.UserStatement;
|
|||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.language.Selector;
|
||||
import net.coreprotect.listener.channel.PluginChannelListener;
|
||||
import net.coreprotect.utility.ChatUtils;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.EntityUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
import net.coreprotect.utility.StringUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class BlockLookup {
|
||||
|
||||
|
|
@ -46,7 +51,7 @@ public class BlockLookup {
|
|||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
long time = (System.currentTimeMillis() / 1000L);
|
||||
int worldId = Util.getWorldId(block.getWorld().getName());
|
||||
int worldId = WorldUtils.getWorldId(block.getWorld().getName());
|
||||
long checkTime = 0;
|
||||
int count = 0;
|
||||
int rowMax = page * limit;
|
||||
|
|
@ -57,7 +62,7 @@ public class BlockLookup {
|
|||
|
||||
String blockName = block.getType().name().toLowerCase(Locale.ROOT);
|
||||
|
||||
String query = "SELECT COUNT(*) as count from " + ConfigHandler.prefix + "block " + Util.getWidIndex("block") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND action IN(0,1) AND time >= '" + checkTime + "' LIMIT 0, 1";
|
||||
String query = "SELECT COUNT(*) as count from " + ConfigHandler.prefix + "block " + WorldUtils.getWidIndex("block") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND action IN(0,1) AND time >= '" + checkTime + "' LIMIT 0, 1";
|
||||
ResultSet results = statement.executeQuery(query);
|
||||
while (results.next()) {
|
||||
count = results.getInt("count");
|
||||
|
|
@ -65,7 +70,7 @@ public class BlockLookup {
|
|||
results.close();
|
||||
int totalPages = (int) Math.ceil(count / (limit + 0.0));
|
||||
|
||||
query = "SELECT time,user,action,type,data,rolled_back FROM " + ConfigHandler.prefix + "block " + Util.getWidIndex("block") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND action IN(0,1) AND time >= '" + checkTime + "' ORDER BY rowid DESC LIMIT " + page_start + ", " + limit + "";
|
||||
query = "SELECT time,user,action,type,data,rolled_back FROM " + ConfigHandler.prefix + "block " + WorldUtils.getWidIndex("block") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND action IN(0,1) AND time >= '" + checkTime + "' ORDER BY rowid DESC LIMIT " + page_start + ", " + limit + "";
|
||||
results = statement.executeQuery(query);
|
||||
|
||||
StringBuilder resultTextBuilder = new StringBuilder();
|
||||
|
|
@ -83,10 +88,10 @@ public class BlockLookup {
|
|||
}
|
||||
|
||||
String resultUser = ConfigHandler.playerIdCacheReversed.get(resultUserId);
|
||||
String timeAgo = Util.getTimeSince(resultTime, time, true);
|
||||
String timeAgo = ChatUtils.getTimeSince(resultTime, time, true);
|
||||
|
||||
if (!found) {
|
||||
resultTextBuilder = new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "----- " + Util.getCoordinates(command, worldId, x, y, z, false, false) + "\n");
|
||||
resultTextBuilder = new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "----- " + ChatUtils.getCoordinates(command, worldId, x, y, z, false, false) + "\n");
|
||||
}
|
||||
found = true;
|
||||
|
||||
|
|
@ -111,14 +116,14 @@ public class BlockLookup {
|
|||
|
||||
String target;
|
||||
if (resultAction == 3) {
|
||||
target = Util.getEntityType(resultType).name();
|
||||
target = EntityUtils.getEntityType(resultType).name();
|
||||
}
|
||||
else {
|
||||
Material resultMaterial = Util.getType(resultType);
|
||||
Material resultMaterial = MaterialUtils.getType(resultType);
|
||||
if (resultMaterial == null) {
|
||||
resultMaterial = Material.AIR;
|
||||
}
|
||||
target = Util.nameFilter(resultMaterial.name().toLowerCase(Locale.ROOT), resultData);
|
||||
target = StringUtils.nameFilter(resultMaterial.name().toLowerCase(Locale.ROOT), resultData);
|
||||
target = "minecraft:" + target.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
if (target.length() > 0) {
|
||||
|
|
@ -140,7 +145,7 @@ public class BlockLookup {
|
|||
if (found) {
|
||||
if (count > limit) {
|
||||
String pageInfo = Color.WHITE + "-----\n";
|
||||
pageInfo = pageInfo + Util.getPageNavigation(command, page, totalPages) + "\n";
|
||||
pageInfo = pageInfo + ChatUtils.getPageNavigation(command, page, totalPages) + "\n";
|
||||
resultText = resultText + pageInfo;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,13 @@ import net.coreprotect.database.statement.UserStatement;
|
|||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.language.Selector;
|
||||
import net.coreprotect.listener.channel.PluginChannelListener;
|
||||
import net.coreprotect.utility.ChatUtils;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
import net.coreprotect.utility.StringUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class ChestTransactionLookup {
|
||||
|
||||
|
|
@ -51,14 +56,14 @@ public class ChestTransactionLookup {
|
|||
int y2 = (int) Math.ceil(l.getY());
|
||||
int z2 = (int) Math.ceil(l.getZ());
|
||||
long time = (System.currentTimeMillis() / 1000L);
|
||||
int worldId = Util.getWorldId(l.getWorld().getName());
|
||||
int worldId = WorldUtils.getWorldId(l.getWorld().getName());
|
||||
int count = 0;
|
||||
int rowMax = page * limit;
|
||||
int pageStart = rowMax - limit;
|
||||
|
||||
String query = "SELECT COUNT(*) as count from " + ConfigHandler.prefix + "container " + Util.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + x + "' OR x = '" + x2 + "') AND (z = '" + z + "' OR z = '" + z2 + "') AND y = '" + y + "' LIMIT 0, 1";
|
||||
String query = "SELECT COUNT(*) as count from " + ConfigHandler.prefix + "container " + WorldUtils.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + x + "' OR x = '" + x2 + "') AND (z = '" + z + "' OR z = '" + z2 + "') AND y = '" + y + "' LIMIT 0, 1";
|
||||
if (exact) {
|
||||
query = "SELECT COUNT(*) as count from " + ConfigHandler.prefix + "container " + Util.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + l.getBlockX() + "') AND (z = '" + l.getBlockZ() + "') AND y = '" + y + "' LIMIT 0, 1";
|
||||
query = "SELECT COUNT(*) as count from " + ConfigHandler.prefix + "container " + WorldUtils.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + l.getBlockX() + "') AND (z = '" + l.getBlockZ() + "') AND y = '" + y + "' LIMIT 0, 1";
|
||||
}
|
||||
ResultSet results = statement.executeQuery(query);
|
||||
|
||||
|
|
@ -69,9 +74,9 @@ public class ChestTransactionLookup {
|
|||
|
||||
int totalPages = (int) Math.ceil(count / (limit + 0.0));
|
||||
|
||||
query = "SELECT time,user,action,type,data,amount,metadata,rolled_back FROM " + ConfigHandler.prefix + "container " + Util.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + x + "' OR x = '" + x2 + "') AND (z = '" + z + "' OR z = '" + z2 + "') AND y = '" + y + "' ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
||||
query = "SELECT time,user,action,type,data,amount,metadata,rolled_back FROM " + ConfigHandler.prefix + "container " + WorldUtils.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + x + "' OR x = '" + x2 + "') AND (z = '" + z + "' OR z = '" + z2 + "') AND y = '" + y + "' ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
||||
if (exact) {
|
||||
query = "SELECT time,user,action,type,data,amount,metadata,rolled_back FROM " + ConfigHandler.prefix + "container " + Util.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + l.getBlockX() + "') AND (z = '" + l.getBlockZ() + "') AND y = '" + y + "' ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
||||
query = "SELECT time,user,action,type,data,amount,metadata,rolled_back FROM " + ConfigHandler.prefix + "container " + WorldUtils.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + l.getBlockX() + "') AND (z = '" + l.getBlockZ() + "') AND y = '" + y + "' ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
||||
}
|
||||
results = statement.executeQuery(query);
|
||||
while (results.next()) {
|
||||
|
|
@ -83,17 +88,17 @@ public class ChestTransactionLookup {
|
|||
int resultAmount = results.getInt("amount");
|
||||
int resultRolledBack = results.getInt("rolled_back");
|
||||
byte[] resultMetadata = results.getBytes("metadata");
|
||||
String tooltip = Util.getEnchantments(resultMetadata, resultType, resultAmount);
|
||||
String tooltip = ItemUtils.getEnchantments(resultMetadata, resultType, resultAmount);
|
||||
|
||||
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
||||
UserStatement.loadName(statement.getConnection(), resultUserId);
|
||||
}
|
||||
|
||||
String resultUser = ConfigHandler.playerIdCacheReversed.get(resultUserId);
|
||||
String timeAgo = Util.getTimeSince(resultTime, time, true);
|
||||
String timeAgo = ChatUtils.getTimeSince(resultTime, time, true);
|
||||
|
||||
if (!found) {
|
||||
result.add(new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.CONTAINER_HEADER) + Color.WHITE + " ----- " + Util.getCoordinates(command, worldId, x, y, z, false, false)).toString());
|
||||
result.add(new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.CONTAINER_HEADER) + Color.WHITE + " ----- " + ChatUtils.getCoordinates(command, worldId, x, y, z, false, false)).toString());
|
||||
}
|
||||
found = true;
|
||||
|
||||
|
|
@ -104,12 +109,12 @@ public class ChestTransactionLookup {
|
|||
rbFormat = Color.STRIKETHROUGH;
|
||||
}
|
||||
|
||||
Material resultMaterial = Util.getType(resultType);
|
||||
Material resultMaterial = MaterialUtils.getType(resultType);
|
||||
if (resultMaterial == null) {
|
||||
resultMaterial = Material.AIR;
|
||||
}
|
||||
String target = resultMaterial.name().toLowerCase(Locale.ROOT);
|
||||
target = Util.nameFilter(target, resultData);
|
||||
target = StringUtils.nameFilter(target, resultData);
|
||||
if (target.length() > 0) {
|
||||
target = "minecraft:" + target.toLowerCase(Locale.ROOT) + "";
|
||||
}
|
||||
|
|
@ -119,7 +124,7 @@ public class ChestTransactionLookup {
|
|||
target = target.split(":")[1];
|
||||
}
|
||||
|
||||
result.add(new StringBuilder(timeAgo + " " + tag + " " + Phrase.build(Phrase.LOOKUP_CONTAINER, Color.DARK_AQUA + rbFormat + resultUser + Color.WHITE + rbFormat, "x" + resultAmount, Util.createTooltip(Color.DARK_AQUA + rbFormat + target, tooltip) + Color.WHITE, selector)).toString());
|
||||
result.add(new StringBuilder(timeAgo + " " + tag + " " + Phrase.build(Phrase.LOOKUP_CONTAINER, Color.DARK_AQUA + rbFormat + resultUser + Color.WHITE + rbFormat, "x" + resultAmount, ChatUtils.createTooltip(Color.DARK_AQUA + rbFormat + target, tooltip) + Color.WHITE, selector)).toString());
|
||||
PluginChannelListener.getInstance().sendData(commandSender, resultTime, Phrase.LOOKUP_CONTAINER, selector, resultUser, target, resultAmount, x, y, z, worldId, rbFormat, true, tag.contains("+"));
|
||||
}
|
||||
results.close();
|
||||
|
|
@ -127,7 +132,7 @@ public class ChestTransactionLookup {
|
|||
if (found) {
|
||||
if (count > limit) {
|
||||
result.add(Color.WHITE + "-----");
|
||||
result.add(Util.getPageNavigation(command, page, totalPages));
|
||||
result.add(ChatUtils.getPageNavigation(command, page, totalPages));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -13,8 +13,12 @@ import net.coreprotect.database.statement.UserStatement;
|
|||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.language.Selector;
|
||||
import net.coreprotect.listener.channel.PluginChannelListener;
|
||||
import net.coreprotect.utility.ChatUtils;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
import net.coreprotect.utility.StringUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class InteractionLookup {
|
||||
|
||||
|
|
@ -46,7 +50,7 @@ public class InteractionLookup {
|
|||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||
int worldId = Util.getWorldId(block.getWorld().getName());
|
||||
int worldId = WorldUtils.getWorldId(block.getWorld().getName());
|
||||
int checkTime = 0;
|
||||
int count = 0;
|
||||
int rowMax = page * limit;
|
||||
|
|
@ -55,7 +59,7 @@ public class InteractionLookup {
|
|||
checkTime = time - offset;
|
||||
}
|
||||
|
||||
String query = "SELECT COUNT(*) as count from " + ConfigHandler.prefix + "block " + Util.getWidIndex("block") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND action='2' AND time >= '" + checkTime + "' LIMIT 0, 1";
|
||||
String query = "SELECT COUNT(*) as count from " + ConfigHandler.prefix + "block " + WorldUtils.getWidIndex("block") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND action='2' AND time >= '" + checkTime + "' LIMIT 0, 1";
|
||||
ResultSet results = statement.executeQuery(query);
|
||||
|
||||
while (results.next()) {
|
||||
|
|
@ -64,7 +68,7 @@ public class InteractionLookup {
|
|||
results.close();
|
||||
int totalPages = (int) Math.ceil(count / (limit + 0.0));
|
||||
|
||||
query = "SELECT time,user,action,type,data,rolled_back FROM " + ConfigHandler.prefix + "block " + Util.getWidIndex("block") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND action='2' AND time >= '" + checkTime + "' ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
||||
query = "SELECT time,user,action,type,data,rolled_back FROM " + ConfigHandler.prefix + "block " + WorldUtils.getWidIndex("block") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND action='2' AND time >= '" + checkTime + "' ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
||||
results = statement.executeQuery(query);
|
||||
|
||||
StringBuilder resultBuilder = new StringBuilder();
|
||||
|
|
@ -81,10 +85,10 @@ public class InteractionLookup {
|
|||
}
|
||||
|
||||
String resultUser = ConfigHandler.playerIdCacheReversed.get(resultUserId);
|
||||
String timeAgo = Util.getTimeSince(resultTime, time, true);
|
||||
String timeAgo = ChatUtils.getTimeSince(resultTime, time, true);
|
||||
|
||||
if (!found) {
|
||||
resultBuilder = new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.INTERACTIONS_HEADER) + Color.WHITE + " ----- " + Util.getCoordinates(command, worldId, x, y, z, false, false) + "\n");
|
||||
resultBuilder = new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.INTERACTIONS_HEADER) + Color.WHITE + " ----- " + ChatUtils.getCoordinates(command, worldId, x, y, z, false, false) + "\n");
|
||||
}
|
||||
found = true;
|
||||
|
||||
|
|
@ -93,12 +97,12 @@ public class InteractionLookup {
|
|||
rbFormat = Color.STRIKETHROUGH;
|
||||
}
|
||||
|
||||
Material resultMaterial = Util.getType(resultType);
|
||||
Material resultMaterial = MaterialUtils.getType(resultType);
|
||||
if (resultMaterial == null) {
|
||||
resultMaterial = Material.AIR;
|
||||
}
|
||||
String target = resultMaterial.name().toLowerCase(Locale.ROOT);
|
||||
target = Util.nameFilter(target, resultData);
|
||||
target = StringUtils.nameFilter(target, resultData);
|
||||
if (target.length() > 0) {
|
||||
target = "minecraft:" + target.toLowerCase(Locale.ROOT) + "";
|
||||
}
|
||||
|
|
@ -117,7 +121,7 @@ public class InteractionLookup {
|
|||
if (found) {
|
||||
if (count > limit) {
|
||||
String pageInfo = Color.WHITE + "-----\n";
|
||||
pageInfo = pageInfo + Util.getPageNavigation(command, page, totalPages) + "\n";
|
||||
pageInfo = pageInfo + ChatUtils.getPageNavigation(command, page, totalPages) + "\n";
|
||||
result = result + pageInfo;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,10 @@ import net.coreprotect.database.statement.UserStatement;
|
|||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.language.Selector;
|
||||
import net.coreprotect.listener.channel.PluginChannelListener;
|
||||
import net.coreprotect.utility.ChatUtils;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class SignMessageLookup {
|
||||
|
||||
|
|
@ -50,12 +52,12 @@ public class SignMessageLookup {
|
|||
int y = l.getBlockY();
|
||||
int z = l.getBlockZ();
|
||||
long time = (System.currentTimeMillis() / 1000L);
|
||||
int worldId = Util.getWorldId(l.getWorld().getName());
|
||||
int worldId = WorldUtils.getWorldId(l.getWorld().getName());
|
||||
int count = 0;
|
||||
int rowMax = page * limit;
|
||||
int pageStart = rowMax - limit;
|
||||
|
||||
String query = "SELECT COUNT(*) as count from " + ConfigHandler.prefix + "sign " + Util.getWidIndex("sign") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND action = '1' AND (LENGTH(line_1) > 0 OR LENGTH(line_2) > 0 OR LENGTH(line_3) > 0 OR LENGTH(line_4) > 0 OR LENGTH(line_5) > 0 OR LENGTH(line_6) > 0 OR LENGTH(line_7) > 0 OR LENGTH(line_8) > 0) LIMIT 0, 1";
|
||||
String query = "SELECT COUNT(*) as count from " + ConfigHandler.prefix + "sign " + WorldUtils.getWidIndex("sign") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND action = '1' AND (LENGTH(line_1) > 0 OR LENGTH(line_2) > 0 OR LENGTH(line_3) > 0 OR LENGTH(line_4) > 0 OR LENGTH(line_5) > 0 OR LENGTH(line_6) > 0 OR LENGTH(line_7) > 0 OR LENGTH(line_8) > 0) LIMIT 0, 1";
|
||||
ResultSet results = statement.executeQuery(query);
|
||||
|
||||
while (results.next()) {
|
||||
|
|
@ -65,7 +67,7 @@ public class SignMessageLookup {
|
|||
|
||||
int totalPages = (int) Math.ceil(count / (limit + 0.0));
|
||||
|
||||
query = "SELECT time,user,face,line_1,line_2,line_3,line_4,line_5,line_6,line_7,line_8 FROM " + ConfigHandler.prefix + "sign " + Util.getWidIndex("sign") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND action = '1' AND (LENGTH(line_1) > 0 OR LENGTH(line_2) > 0 OR LENGTH(line_3) > 0 OR LENGTH(line_4) > 0 OR LENGTH(line_5) > 0 OR LENGTH(line_6) > 0 OR LENGTH(line_7) > 0 OR LENGTH(line_8) > 0) ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
||||
query = "SELECT time,user,face,line_1,line_2,line_3,line_4,line_5,line_6,line_7,line_8 FROM " + ConfigHandler.prefix + "sign " + WorldUtils.getWidIndex("sign") + "WHERE wid = '" + worldId + "' AND x = '" + x + "' AND z = '" + z + "' AND y = '" + y + "' AND action = '1' AND (LENGTH(line_1) > 0 OR LENGTH(line_2) > 0 OR LENGTH(line_3) > 0 OR LENGTH(line_4) > 0 OR LENGTH(line_5) > 0 OR LENGTH(line_6) > 0 OR LENGTH(line_7) > 0 OR LENGTH(line_8) > 0) ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
||||
results = statement.executeQuery(query);
|
||||
|
||||
while (results.next()) {
|
||||
|
|
@ -144,10 +146,10 @@ public class SignMessageLookup {
|
|||
}
|
||||
|
||||
String resultUser = ConfigHandler.playerIdCacheReversed.get(resultUserId);
|
||||
String timeAgo = Util.getTimeSince(resultTime, time, true);
|
||||
String timeAgo = ChatUtils.getTimeSince(resultTime, time, true);
|
||||
|
||||
if (!found) {
|
||||
result.add(new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.SIGN_HEADER) + Color.WHITE + " ----- " + Util.getCoordinates(command, worldId, x, y, z, false, false) + "").toString());
|
||||
result.add(new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.SIGN_HEADER) + Color.WHITE + " ----- " + ChatUtils.getCoordinates(command, worldId, x, y, z, false, false) + "").toString());
|
||||
}
|
||||
found = true;
|
||||
result.add(timeAgo + Color.WHITE + " - " + Color.DARK_AQUA + resultUser + ": " + Color.WHITE + "\n" + parsedMessage + Color.WHITE);
|
||||
|
|
@ -158,7 +160,7 @@ public class SignMessageLookup {
|
|||
if (found) {
|
||||
if (count > limit) {
|
||||
result.add(Color.WHITE + "-----");
|
||||
result.add(Util.getPageNavigation(command, page, totalPages));
|
||||
result.add(ChatUtils.getPageNavigation(command, page, totalPages));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -73,11 +73,17 @@ import net.coreprotect.model.BlockGroup;
|
|||
import net.coreprotect.paper.PaperAdapter;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.ChestTool;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.DatabaseUtils;
|
||||
import net.coreprotect.utility.EntityUtils;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
import net.coreprotect.utility.Teleport;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
import net.coreprotect.utility.entity.HangingUtil;
|
||||
|
||||
public class Rollback extends RollbackUtil {
|
||||
|
|
@ -173,7 +179,7 @@ public class Rollback extends RollbackUtil {
|
|||
// if (rowAction==11) result[8] = 1;
|
||||
|
||||
if (rowWorldId != worldId) {
|
||||
String world = Util.getWorldName(rowWorldId);
|
||||
String world = WorldUtils.getWorldName(rowWorldId);
|
||||
World bukkitWorld = Bukkit.getServer().getWorld(world);
|
||||
if (bukkitWorld != null) {
|
||||
worldMin = BukkitAdapter.ADAPTER.getMinHeight(bukkitWorld);
|
||||
|
|
@ -281,7 +287,7 @@ public class Rollback extends RollbackUtil {
|
|||
ConfigHandler.rollbackHash.put(userString, new int[] { 0, 0, 0, 0, 0 });
|
||||
|
||||
final String finalUserString = userString;
|
||||
for (Entry<Long, Integer> entry : Util.entriesSortedByValues(chunkList)) {
|
||||
for (Entry<Long, Integer> entry : DatabaseUtils.entriesSortedByValues(chunkList)) {
|
||||
chunkCount++;
|
||||
|
||||
int itemCount = 0;
|
||||
|
|
@ -301,7 +307,7 @@ public class Rollback extends RollbackUtil {
|
|||
|
||||
HashMap<Integer, World> worldMap = new HashMap<>();
|
||||
for (int rollbackWorldId : worldList) {
|
||||
String rollbackWorld = Util.getWorldName(rollbackWorldId);
|
||||
String rollbackWorld = WorldUtils.getWorldName(rollbackWorldId);
|
||||
if (rollbackWorld.length() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -349,12 +355,12 @@ public class Rollback extends RollbackUtil {
|
|||
int rowTypeRaw = (Integer) row[6];
|
||||
int rowData = (Integer) row[7];
|
||||
int rowAction = (Integer) row[8];
|
||||
int rowRolledBack = Util.rolledBack((Integer) row[9], false);
|
||||
int rowRolledBack = MaterialUtils.rolledBack((Integer) row[9], false);
|
||||
int rowWorldId = (Integer) row[10];
|
||||
byte[] rowMeta = (byte[]) row[12];
|
||||
byte[] rowBlockData = (byte[]) row[13];
|
||||
String blockDataString = Util.byteDataToString(rowBlockData, rowTypeRaw);
|
||||
Material rowType = Util.getType(rowTypeRaw);
|
||||
String blockDataString = BlockUtils.byteDataToString(rowBlockData, rowTypeRaw);
|
||||
Material rowType = MaterialUtils.getType(rowTypeRaw);
|
||||
|
||||
List<Object> meta = null;
|
||||
if (rowMeta != null) {
|
||||
|
|
@ -382,12 +388,12 @@ public class Rollback extends RollbackUtil {
|
|||
rawBlockData = blockData.clone();
|
||||
}
|
||||
if (rawBlockData == null && rowType != null && rowType.isBlock()) {
|
||||
rawBlockData = Util.createBlockData(rowType);
|
||||
rawBlockData = BlockUtils.createBlockData(rowType);
|
||||
}
|
||||
|
||||
String rowUser = ConfigHandler.playerIdCacheReversed.get(rowUserId);
|
||||
int oldTypeRaw = rowTypeRaw;
|
||||
Material oldTypeMaterial = Util.getType(oldTypeRaw);
|
||||
Material oldTypeMaterial = MaterialUtils.getType(oldTypeRaw);
|
||||
|
||||
if (rowAction == 1 && rollbackType == 0) { // block placement
|
||||
rowType = Material.AIR;
|
||||
|
|
@ -410,7 +416,7 @@ public class Rollback extends RollbackUtil {
|
|||
|
||||
if (preview > 0) {
|
||||
if (rowAction != 3) { // entity kill
|
||||
String world = Util.getWorldName(rowWorldId);
|
||||
String world = WorldUtils.getWorldName(rowWorldId);
|
||||
if (world.length() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -424,13 +430,13 @@ public class Rollback extends RollbackUtil {
|
|||
if (preview == 2) {
|
||||
Material blockType = block.getType();
|
||||
if (!BukkitAdapter.ADAPTER.isItemFrame(blockType) && !blockType.equals(Material.PAINTING) && !blockType.equals(Material.ARMOR_STAND) && !blockType.equals(Material.END_CRYSTAL)) {
|
||||
Util.prepareTypeAndData(chunkChanges, block, blockType, block.getBlockData(), true);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, blockType, block.getBlockData(), true);
|
||||
blockCount1++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((!BukkitAdapter.ADAPTER.isItemFrame(rowType)) && (rowType != Material.PAINTING) && (rowType != Material.ARMOR_STAND) && (rowType != Material.END_CRYSTAL)) {
|
||||
Util.prepareTypeAndData(chunkChanges, block, rowType, blockData, true);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, rowType, blockData, true);
|
||||
blockCount1++;
|
||||
}
|
||||
}
|
||||
|
|
@ -440,7 +446,7 @@ public class Rollback extends RollbackUtil {
|
|||
}
|
||||
}
|
||||
else if (rowAction == 3) { // entity kill
|
||||
String world = Util.getWorldName(rowWorldId);
|
||||
String world = WorldUtils.getWorldName(rowWorldId);
|
||||
if (world.length() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -457,7 +463,7 @@ public class Rollback extends RollbackUtil {
|
|||
if (rowTypeRaw > 0) {
|
||||
// spawn in entity
|
||||
if (rowRolledBack == 0) {
|
||||
EntityType entity_type = Util.getEntityType(rowTypeRaw);
|
||||
EntityType entity_type = EntityUtils.getEntityType(rowTypeRaw);
|
||||
Queue.queueEntitySpawn(rowUser, block.getState(), entity_type, rowData);
|
||||
entityCount1++;
|
||||
}
|
||||
|
|
@ -467,7 +473,7 @@ public class Rollback extends RollbackUtil {
|
|||
if (rowRolledBack == 1) {
|
||||
boolean removed = false;
|
||||
int entityId = -1;
|
||||
String entityName = Util.getEntityType(oldTypeRaw).name();
|
||||
String entityName = EntityUtils.getEntityType(oldTypeRaw).name();
|
||||
String token = "" + rowX + "." + rowY + "." + rowZ + "." + rowWorldId + "." + entityName + "";
|
||||
Object[] cachedEntity = CacheHandler.entityCache.get(token);
|
||||
|
||||
|
|
@ -493,7 +499,7 @@ public class Rollback extends RollbackUtil {
|
|||
}
|
||||
}
|
||||
else {
|
||||
if (entity.getType().equals(Util.getEntityType(oldTypeRaw))) {
|
||||
if (entity.getType().equals(EntityUtils.getEntityType(oldTypeRaw))) {
|
||||
Location entityLocation = entity.getLocation();
|
||||
int entityx = entityLocation.getBlockX();
|
||||
int entityY = entityLocation.getBlockY();
|
||||
|
|
@ -528,7 +534,7 @@ public class Rollback extends RollbackUtil {
|
|||
continue;
|
||||
}
|
||||
|
||||
String world = Util.getWorldName(rowWorldId);
|
||||
String world = WorldUtils.getWorldName(rowWorldId);
|
||||
if (world.length() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -659,10 +665,10 @@ public class Rollback extends RollbackUtil {
|
|||
if (pendingChangeData instanceof Waterlogged) {
|
||||
Waterlogged waterlogged = (Waterlogged) pendingChangeData;
|
||||
waterlogged.setWaterlogged(false);
|
||||
Util.prepareTypeAndData(chunkChanges, block, null, waterlogged, false);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, null, waterlogged, false);
|
||||
}
|
||||
else {
|
||||
Util.prepareTypeAndData(chunkChanges, block, rowType, blockData, true);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, rowType, blockData, true);
|
||||
}
|
||||
|
||||
if (countBlock) {
|
||||
|
|
@ -670,7 +676,7 @@ public class Rollback extends RollbackUtil {
|
|||
}
|
||||
}
|
||||
else if ((rowType == Material.AIR) && ((oldTypeMaterial == Material.SNOW))) {
|
||||
Util.prepareTypeAndData(chunkChanges, block, rowType, blockData, true);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, rowType, blockData, true);
|
||||
if (countBlock) {
|
||||
blockCount1++;
|
||||
}
|
||||
|
|
@ -690,7 +696,7 @@ public class Rollback extends RollbackUtil {
|
|||
else if ((rowType == Material.AIR) || (rowType == Material.TNT)) {
|
||||
if (clearInventories) {
|
||||
if (BlockGroup.CONTAINERS.contains(changeType)) {
|
||||
Inventory inventory = Util.getContainerInventory(block.getState(), false);
|
||||
Inventory inventory = BlockUtils.getContainerInventory(block.getState(), false);
|
||||
if (inventory != null) {
|
||||
inventory.clear();
|
||||
}
|
||||
|
|
@ -703,7 +709,7 @@ public class Rollback extends RollbackUtil {
|
|||
entityLocation.setY(entityLocation.getY() + 0.99);
|
||||
|
||||
if (entityLocation.getBlockX() == rowX && entityLocation.getBlockY() == rowY && entityLocation.getBlockZ() == rowZ) {
|
||||
EntityEquipment equipment = Util.getEntityEquipment((LivingEntity) entity);
|
||||
EntityEquipment equipment = ItemUtils.getEntityEquipment((LivingEntity) entity);
|
||||
if (equipment != null) {
|
||||
equipment.clear();
|
||||
}
|
||||
|
|
@ -723,7 +729,7 @@ public class Rollback extends RollbackUtil {
|
|||
if (pendingChangeData instanceof Waterlogged) {
|
||||
Waterlogged waterlogged = (Waterlogged) pendingChangeData;
|
||||
if (waterlogged.isWaterlogged()) {
|
||||
Util.prepareTypeAndData(chunkChanges, block, Material.WATER, Material.WATER.createBlockData(), true);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, Material.WATER, Material.WATER.createBlockData(), true);
|
||||
remove = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -756,7 +762,7 @@ public class Rollback extends RollbackUtil {
|
|||
int worldMinHeight = BukkitAdapter.ADAPTER.getMinHeight(bukkitWorld);
|
||||
if (bisectLocation.getBlockY() >= worldMinHeight && bisectLocation.getBlockY() < worldMaxHeight) {
|
||||
Block bisectBlock = block.getWorld().getBlockAt(bisectLocation);
|
||||
Util.prepareTypeAndData(chunkChanges, bisectBlock, rowType, null, false);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, bisectBlock, rowType, null, false);
|
||||
|
||||
if (countBlock) {
|
||||
blockCount1++;
|
||||
|
|
@ -767,11 +773,11 @@ public class Rollback extends RollbackUtil {
|
|||
Bed bed = (Bed) changeBlockData;
|
||||
if (bed.getPart() == Part.FOOT) {
|
||||
Block adjacentBlock = block.getRelative(bed.getFacing());
|
||||
Util.prepareTypeAndData(chunkChanges, adjacentBlock, rowType, null, false);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, adjacentBlock, rowType, null, false);
|
||||
}
|
||||
}
|
||||
|
||||
Util.prepareTypeAndData(chunkChanges, block, rowType, null, physics);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, rowType, null, physics);
|
||||
}
|
||||
|
||||
if (countBlock) {
|
||||
|
|
@ -780,9 +786,9 @@ public class Rollback extends RollbackUtil {
|
|||
}
|
||||
else if ((rowType == Material.SPAWNER)) {
|
||||
try {
|
||||
Util.prepareTypeAndData(chunkChanges, block, rowType, blockData, false);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, rowType, blockData, false);
|
||||
CreatureSpawner mobSpawner = (CreatureSpawner) block.getState();
|
||||
mobSpawner.setSpawnedType(Util.getSpawnerType(rowData));
|
||||
mobSpawner.setSpawnedType(EntityUtils.getSpawnerType(rowData));
|
||||
mobSpawner.update();
|
||||
|
||||
if (countBlock) {
|
||||
|
|
@ -794,7 +800,7 @@ public class Rollback extends RollbackUtil {
|
|||
}
|
||||
}
|
||||
else if ((rowType == Material.SKELETON_SKULL) || (rowType == Material.SKELETON_WALL_SKULL) || (rowType == Material.WITHER_SKELETON_SKULL) || (rowType == Material.WITHER_SKELETON_WALL_SKULL) || (rowType == Material.ZOMBIE_HEAD) || (rowType == Material.ZOMBIE_WALL_HEAD) || (rowType == Material.PLAYER_HEAD) || (rowType == Material.PLAYER_WALL_HEAD) || (rowType == Material.CREEPER_HEAD) || (rowType == Material.CREEPER_WALL_HEAD) || (rowType == Material.DRAGON_HEAD) || (rowType == Material.DRAGON_WALL_HEAD)) { // skull
|
||||
Util.prepareTypeAndData(chunkChanges, block, rowType, blockData, false);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, rowType, blockData, false);
|
||||
if (rowData > 0) {
|
||||
Queue.queueSkullUpdate(rowUser, block.getState(), rowData);
|
||||
}
|
||||
|
|
@ -804,7 +810,7 @@ public class Rollback extends RollbackUtil {
|
|||
}
|
||||
}
|
||||
else if (BukkitAdapter.ADAPTER.isSign(rowType)) {// sign
|
||||
Util.prepareTypeAndData(chunkChanges, block, rowType, blockData, false);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, rowType, blockData, false);
|
||||
Queue.queueSignUpdate(rowUser, block.getState(), rollbackType, rowTime);
|
||||
|
||||
if (countBlock) {
|
||||
|
|
@ -812,14 +818,14 @@ public class Rollback extends RollbackUtil {
|
|||
}
|
||||
}
|
||||
else if (BlockGroup.SHULKER_BOXES.contains(rowType)) {
|
||||
Util.prepareTypeAndData(chunkChanges, block, rowType, blockData, false);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, rowType, blockData, false);
|
||||
if (countBlock) {
|
||||
blockCount1++;
|
||||
}
|
||||
if (meta != null) {
|
||||
Inventory inventory = Util.getContainerInventory(block.getState(), false);
|
||||
Inventory inventory = BlockUtils.getContainerInventory(block.getState(), false);
|
||||
for (Object value : meta) {
|
||||
ItemStack item = Util.unserializeItemStackLegacy(value);
|
||||
ItemStack item = ItemUtils.unserializeItemStackLegacy(value);
|
||||
if (item != null) {
|
||||
modifyContainerItems(rowType, inventory, 0, item, 1);
|
||||
}
|
||||
|
|
@ -827,7 +833,7 @@ public class Rollback extends RollbackUtil {
|
|||
}
|
||||
}
|
||||
else if (rowType == Material.COMMAND_BLOCK || rowType == Material.REPEATING_COMMAND_BLOCK || rowType == Material.CHAIN_COMMAND_BLOCK) { // command block
|
||||
Util.prepareTypeAndData(chunkChanges, block, rowType, blockData, false);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, rowType, blockData, false);
|
||||
if (countBlock) {
|
||||
blockCount1++;
|
||||
}
|
||||
|
|
@ -847,10 +853,10 @@ public class Rollback extends RollbackUtil {
|
|||
if (pendingChangeData instanceof Waterlogged) {
|
||||
Waterlogged waterlogged = (Waterlogged) pendingChangeData;
|
||||
waterlogged.setWaterlogged(true);
|
||||
Util.prepareTypeAndData(chunkChanges, block, null, waterlogged, false);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, null, waterlogged, false);
|
||||
}
|
||||
else {
|
||||
Util.prepareTypeAndData(chunkChanges, block, rowType, blockData, false);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, rowType, blockData, false);
|
||||
}
|
||||
|
||||
if (countBlock) {
|
||||
|
|
@ -858,7 +864,7 @@ public class Rollback extends RollbackUtil {
|
|||
}
|
||||
}
|
||||
else if ((rowType == Material.NETHER_PORTAL) && rowAction == 0) {
|
||||
Util.prepareTypeAndData(chunkChanges, block, Material.FIRE, null, true);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, Material.FIRE, null, true);
|
||||
}
|
||||
else if (blockData == null && rowData > 0 && (rowType == Material.IRON_DOOR || BlockGroup.DOORS.contains(rowType))) {
|
||||
if (countBlock) {
|
||||
|
|
@ -929,7 +935,7 @@ public class Rollback extends RollbackUtil {
|
|||
block.setBlockData(bed, false);
|
||||
}
|
||||
else if (rowType.name().endsWith("_BANNER")) {
|
||||
Util.prepareTypeAndData(chunkChanges, block, rowType, blockData, false);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, rowType, blockData, false);
|
||||
if (countBlock) {
|
||||
blockCount1++;
|
||||
}
|
||||
|
|
@ -955,7 +961,7 @@ public class Rollback extends RollbackUtil {
|
|||
block.setType(Material.AIR); // Clear existing container to prevent errors
|
||||
|
||||
boolean isChest = (blockData instanceof Chest);
|
||||
Util.prepareTypeAndData(chunkChanges, block, rowType, blockData, (isChest));
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, rowType, blockData, (isChest));
|
||||
if (isChest) {
|
||||
ChestTool.updateDoubleChest(block, blockData, false);
|
||||
}
|
||||
|
|
@ -965,7 +971,7 @@ public class Rollback extends RollbackUtil {
|
|||
}
|
||||
}
|
||||
else if (BlockGroup.UPDATE_STATE.contains(rowType) || rowType.name().contains("CANDLE")) {
|
||||
Util.prepareTypeAndData(chunkChanges, block, rowType, blockData, true);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, rowType, blockData, true);
|
||||
ChestTool.updateDoubleChest(block, blockData, true);
|
||||
if (countBlock) {
|
||||
blockCount1++;
|
||||
|
|
@ -988,10 +994,10 @@ public class Rollback extends RollbackUtil {
|
|||
int worldMinHeight = BukkitAdapter.ADAPTER.getMinHeight(bukkitWorld);
|
||||
if (bisectLocation.getBlockY() >= worldMinHeight && bisectLocation.getBlockY() < worldMaxHeight) {
|
||||
Block bisectBlock = block.getWorld().getBlockAt(bisectLocation);
|
||||
Util.prepareTypeAndData(chunkChanges, bisectBlock, rowType, bisectData, false);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, bisectBlock, rowType, bisectData, false);
|
||||
}
|
||||
|
||||
Util.prepareTypeAndData(chunkChanges, block, rowType, blockData, false);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, rowType, blockData, false);
|
||||
if (countBlock) {
|
||||
blockCount1++;
|
||||
blockCount1++;
|
||||
|
|
@ -1003,13 +1009,13 @@ public class Rollback extends RollbackUtil {
|
|||
Block adjacentBlock = block.getRelative(bed.getFacing());
|
||||
Bed bedData = (Bed) rawBlockData.clone();
|
||||
bedData.setPart(Part.HEAD);
|
||||
Util.prepareTypeAndData(chunkChanges, adjacentBlock, rowType, bedData, false);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, adjacentBlock, rowType, bedData, false);
|
||||
if (countBlock) {
|
||||
blockCount1++;
|
||||
}
|
||||
}
|
||||
|
||||
Util.prepareTypeAndData(chunkChanges, block, rowType, blockData, true);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, rowType, blockData, true);
|
||||
if (countBlock) {
|
||||
blockCount1++;
|
||||
}
|
||||
|
|
@ -1022,7 +1028,7 @@ public class Rollback extends RollbackUtil {
|
|||
}
|
||||
*/
|
||||
|
||||
Util.prepareTypeAndData(chunkChanges, block, rowType, blockData, physics);
|
||||
BlockUtils.prepareTypeAndData(chunkChanges, block, rowType, blockData, physics);
|
||||
if (countBlock) {
|
||||
blockCount1++;
|
||||
}
|
||||
|
|
@ -1053,7 +1059,7 @@ public class Rollback extends RollbackUtil {
|
|||
Util.sendBlockChange((Player) finalUser, changeBlock.getLocation(), changeBlockData);
|
||||
}
|
||||
else {
|
||||
Util.setTypeAndData(changeBlock, null, changeBlockData, true);
|
||||
BlockUtils.setTypeAndData(changeBlock, null, changeBlockData, true);
|
||||
}
|
||||
}
|
||||
chunkChanges.clear();
|
||||
|
|
@ -1080,16 +1086,16 @@ public class Rollback extends RollbackUtil {
|
|||
int rowTypeRaw = (Integer) row[6];
|
||||
int rowData = (Integer) row[7];
|
||||
int rowAction = (Integer) row[8];
|
||||
int rowRolledBack = Util.rolledBack((Integer) row[9], false);
|
||||
int rowRolledBack = MaterialUtils.rolledBack((Integer) row[9], false);
|
||||
int rowWorldId = (Integer) row[10];
|
||||
int rowAmount = (Integer) row[11];
|
||||
byte[] rowMetadata = (byte[]) row[12];
|
||||
Material rowType = Util.getType(rowTypeRaw);
|
||||
Material rowType = MaterialUtils.getType(rowTypeRaw);
|
||||
|
||||
int rolledBackInventory = Util.rolledBack((Integer) row[9], true);
|
||||
int rolledBackInventory = MaterialUtils.rolledBack((Integer) row[9], true);
|
||||
if (rowType != null) {
|
||||
if (inventoryRollback && ((rollbackType == 0 && rolledBackInventory == 0) || (rollbackType == 1 && rolledBackInventory == 1))) {
|
||||
Material inventoryItem = Util.itemFilter(rowType, ((Integer) row[14] == 0));
|
||||
Material inventoryItem = ItemUtils.itemFilter(rowType, ((Integer) row[14] == 0));
|
||||
int rowUserId = (Integer) row[2];
|
||||
String rowUser = ConfigHandler.playerIdCacheReversed.get(rowUserId);
|
||||
if (rowUser == null) {
|
||||
|
|
@ -1148,7 +1154,7 @@ public class Rollback extends RollbackUtil {
|
|||
|
||||
if (!containerInit || rowX != lastX || rowY != lastY || rowZ != lastZ || rowWorldId != lastWorldId || !faceData.equals(lastFace)) {
|
||||
container = null; // container patch 2.14.0
|
||||
String world = Util.getWorldName(rowWorldId);
|
||||
String world = WorldUtils.getWorldName(rowWorldId);
|
||||
if (world.length() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1168,7 +1174,7 @@ public class Rollback extends RollbackUtil {
|
|||
container = blockState;
|
||||
}
|
||||
else {
|
||||
container = Util.getContainerInventory(blockState, false);
|
||||
container = BlockUtils.getContainerInventory(blockState, false);
|
||||
}
|
||||
|
||||
containerType = block.getType();
|
||||
|
|
@ -1177,7 +1183,7 @@ public class Rollback extends RollbackUtil {
|
|||
for (Entity entity : block.getChunk().getEntities()) {
|
||||
if (entity.getLocation().getBlockX() == rowX && entity.getLocation().getBlockY() == rowY && entity.getLocation().getBlockZ() == rowZ) {
|
||||
if (entity instanceof ArmorStand) {
|
||||
container = Util.getEntityEquipment((LivingEntity) entity);
|
||||
container = ItemUtils.getEntityEquipment((LivingEntity) entity);
|
||||
containerType = Material.ARMOR_STAND;
|
||||
}
|
||||
else if (entity instanceof ItemFrame) {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import org.bukkit.util.io.BukkitObjectInputStream;
|
|||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.database.Lookup;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
|
||||
public class RollbackUtil extends Lookup {
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ public class RollbackUtil extends Lookup {
|
|||
while (count < amount) {
|
||||
boolean addedItem = false;
|
||||
if (isPlayerInventory) {
|
||||
int setArmor = Util.setPlayerArmor((PlayerInventory) inventory, itemstack);
|
||||
int setArmor = ItemUtils.setPlayerArmor((PlayerInventory) inventory, itemstack);
|
||||
addedItem = (setArmor > -1);
|
||||
modifiedArmor = addedItem ? setArmor : modifiedArmor;
|
||||
}
|
||||
|
|
@ -303,7 +303,7 @@ public class RollbackUtil extends Lookup {
|
|||
BlockStateMeta meta = (BlockStateMeta) itemstack.getItemMeta();
|
||||
ShulkerBox shulkerBox = (ShulkerBox) meta.getBlockState();
|
||||
for (Object value : metaList) {
|
||||
ItemStack item = Util.unserializeItemStackLegacy(value);
|
||||
ItemStack item = ItemUtils.unserializeItemStackLegacy(value);
|
||||
if (item != null) {
|
||||
shulkerBox.getInventory().addItem(item);
|
||||
}
|
||||
|
|
@ -369,7 +369,7 @@ public class RollbackUtil extends Lookup {
|
|||
itemstack.setItemMeta(itemMeta);
|
||||
}
|
||||
else if (itemCount == 0) {
|
||||
ItemMeta meta = Util.deserializeItemMeta(itemstack.getItemMeta().getClass(), map.get(0));
|
||||
ItemMeta meta = ItemUtils.deserializeItemMeta(itemstack.getItemMeta().getClass(), map.get(0));
|
||||
itemstack.setItemMeta(meta);
|
||||
|
||||
if (map.size() > 1 && (rowType == Material.POTION)) {
|
||||
|
|
@ -407,7 +407,7 @@ public class RollbackUtil extends Lookup {
|
|||
else if ((rowType == Material.CROSSBOW)) {
|
||||
CrossbowMeta meta = (CrossbowMeta) itemstack.getItemMeta();
|
||||
for (Map<String, Object> itemData : map) {
|
||||
ItemStack crossbowItem = Util.unserializeItemStack(itemData);
|
||||
ItemStack crossbowItem = ItemUtils.unserializeItemStack(itemData);
|
||||
if (crossbowItem != null) {
|
||||
meta.addChargedProjectile(crossbowItem);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import java.sql.PreparedStatement;
|
|||
import java.util.List;
|
||||
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
|
||||
public class BlockStatement {
|
||||
|
||||
|
|
@ -13,11 +15,11 @@ public class BlockStatement {
|
|||
|
||||
public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int id, int wid, int x, int y, int z, int type, int data, List<Object> meta, String blockData, int action, int rolledBack) {
|
||||
try {
|
||||
byte[] bBlockData = Util.stringToByteData(blockData, type);
|
||||
byte[] bBlockData = BlockUtils.stringToByteData(blockData, type);
|
||||
byte[] byteData = null;
|
||||
|
||||
if (meta != null) {
|
||||
byteData = Util.convertByteData(meta);
|
||||
byteData = ItemUtils.convertByteData(meta);
|
||||
}
|
||||
|
||||
preparedStmt.setInt(1, time);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package net.coreprotect.database.statement;
|
|||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class ContainerStatement {
|
||||
|
|
@ -12,7 +13,7 @@ public class ContainerStatement {
|
|||
|
||||
public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int id, int wid, int x, int y, int z, int type, int data, int amount, Object metadata, int action, int rolledBack) {
|
||||
try {
|
||||
byte[] byteData = Util.convertByteData(metadata);
|
||||
byte[] byteData = ItemUtils.convertByteData(metadata);
|
||||
preparedStmt.setInt(1, time);
|
||||
preparedStmt.setInt(2, id);
|
||||
preparedStmt.setInt(3, wid);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package net.coreprotect.database.statement;
|
|||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class ItemStatement {
|
||||
|
|
@ -12,7 +13,7 @@ public class ItemStatement {
|
|||
|
||||
public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int id, int wid, int x, int y, int z, int type, Object data, int amount, int action) {
|
||||
try {
|
||||
byte[] byteData = Util.convertByteData(data);
|
||||
byte[] byteData = ItemUtils.convertByteData(data);
|
||||
preparedStmt.setInt(1, time);
|
||||
preparedStmt.setInt(2, id);
|
||||
preparedStmt.setInt(3, wid);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import org.bukkit.block.BlockState;
|
|||
import org.bukkit.block.Sign;
|
||||
|
||||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
|
||||
public class SignStatement {
|
||||
|
||||
|
|
@ -80,8 +80,8 @@ public class SignStatement {
|
|||
BukkitAdapter.ADAPTER.setColor(sign, false, colorSecondary);
|
||||
}
|
||||
|
||||
boolean frontGlowing = Util.isSideGlowing(true, data);
|
||||
boolean backGlowing = Util.isSideGlowing(false, data);
|
||||
boolean frontGlowing = BlockUtils.isSideGlowing(true, data);
|
||||
boolean backGlowing = BlockUtils.isSideGlowing(false, data);
|
||||
BukkitAdapter.ADAPTER.setGlowing(sign, true, frontGlowing);
|
||||
BukkitAdapter.ADAPTER.setGlowing(sign, false, backGlowing);
|
||||
BukkitAdapter.ADAPTER.setLine(sign, 0, line1);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import java.util.regex.Pattern;
|
|||
|
||||
import net.coreprotect.utility.ChatMessage;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.StringUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public enum Phrase {
|
||||
|
|
@ -242,7 +243,7 @@ public enum Phrase {
|
|||
String color = "";
|
||||
|
||||
if (HEADERS.contains(phrase)) {
|
||||
output = Util.capitalize(output, true);
|
||||
output = StringUtils.capitalize(output, true);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import net.coreprotect.consumer.Queue;
|
|||
import net.coreprotect.database.Database;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.paper.PaperAdapter;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public final class BlockBreakListener extends Queue implements Listener {
|
||||
|
|
@ -305,7 +306,7 @@ public final class BlockBreakListener extends Queue implements Listener {
|
|||
Database.containerBreakCheck(user, blockType, blockLog, null, blockLog.getLocation());
|
||||
Queue.queueBlockBreak(user, blockState, blockType, blockState.getBlockData().getAsString(), type, physics, blockNumber);
|
||||
|
||||
if (player != null && Util.iceBreakCheck(blockState, user, blockType)) {
|
||||
if (player != null && BlockUtils.iceBreakCheck(blockState, user, blockType)) {
|
||||
ItemStack handItem = player.getInventory().getItemInMainHand();
|
||||
if (!(player.getGameMode().equals(GameMode.CREATIVE)) && !(handItem != null && handItem.containsEnchantment(Enchantment.SILK_TOUCH))) {
|
||||
Queue.queueBlockPlaceValidate(user, blockState, blockLog, null, Material.WATER, -1, 0, null, 0);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import net.coreprotect.consumer.Queue;
|
|||
import net.coreprotect.database.Lookup;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public final class BlockFormListener extends Queue implements Listener {
|
||||
|
||||
|
|
@ -26,7 +27,7 @@ public final class BlockFormListener extends Queue implements Listener {
|
|||
boolean log = false;
|
||||
if (Config.getConfig(world).LIQUID_TRACKING && (newState.getType().equals(Material.OBSIDIAN) || newState.getType().equals(Material.COBBLESTONE) || block.getType().name().endsWith("_CONCRETE_POWDER"))) {
|
||||
String player = Lookup.whoPlacedCache(block);
|
||||
int wid = Util.getWorldId(world.getName());
|
||||
int wid = WorldUtils.getWorldId(world.getName());
|
||||
if (!(player.length() > 0)) {
|
||||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import net.coreprotect.consumer.Queue;
|
|||
import net.coreprotect.database.Lookup;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public final class BlockFromToListener extends Queue implements Listener {
|
||||
|
||||
|
|
@ -66,7 +67,7 @@ public final class BlockFromToListener extends Queue implements Listener {
|
|||
int x = toBlock.getX();
|
||||
int y = toBlock.getY();
|
||||
int z = toBlock.getZ();
|
||||
int wid = Util.getWorldId(block.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(block.getWorld().getName());
|
||||
if (Config.getConfig(world).LIQUID_TRACKING) {
|
||||
String p = Lookup.whoPlacedCache(block);
|
||||
if (p.length() > 0) {
|
||||
|
|
@ -75,7 +76,7 @@ public final class BlockFromToListener extends Queue implements Listener {
|
|||
}
|
||||
|
||||
if (f.startsWith("#")) {
|
||||
String cacheId = toBlock.getX() + "." + toBlock.getY() + "." + toBlock.getZ() + "." + Util.getWorldId(toBlock.getWorld().getName());
|
||||
String cacheId = toBlock.getX() + "." + toBlock.getY() + "." + toBlock.getZ() + "." + WorldUtils.getWorldId(toBlock.getWorld().getName());
|
||||
int timestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
Object[] cacheData = CacheHandler.spreadCache.get(cacheId);
|
||||
CacheHandler.spreadCache.put(cacheId, new Object[] { timestamp, type });
|
||||
|
|
@ -89,7 +90,7 @@ public final class BlockFromToListener extends Queue implements Listener {
|
|||
}
|
||||
else if (type.equals(Material.DRAGON_EGG)) {
|
||||
Location location = block.getLocation();
|
||||
int worldId = Util.getWorldId(location.getWorld().getName());
|
||||
int worldId = WorldUtils.getWorldId(location.getWorld().getName());
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import net.coreprotect.listener.player.ProjectileLaunchListener;
|
|||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public final class BlockIgniteListener extends Queue implements Listener {
|
||||
|
||||
|
|
@ -137,7 +138,7 @@ public final class BlockIgniteListener extends Queue implements Listener {
|
|||
Player player = event.getPlayer();
|
||||
Queue.queueBlockPlace(player.getName(), block.getState(), block.getType(), replacedBlock, blockIgnited, -1, 0, forceBlockData.getAsString());
|
||||
int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
int world_id = Util.getWorldId(block.getWorld().getName());
|
||||
int world_id = WorldUtils.getWorldId(block.getWorld().getName());
|
||||
CacheHandler.lookupCache.put("" + block.getX() + "." + block.getY() + "." + block.getZ() + "." + world_id + "", new Object[] { unixtimestamp, player.getName(), block.getType() });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import net.coreprotect.config.Config;
|
|||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public final class BlockPistonListener extends Queue implements Listener {
|
||||
|
||||
|
|
@ -45,7 +46,7 @@ public final class BlockPistonListener extends Queue implements Listener {
|
|||
Block b = event.getBlock();
|
||||
BlockFace d = event.getDirection();
|
||||
Block bm = b.getRelative(d);
|
||||
int wid = Util.getWorldId(bm.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(bm.getWorld().getName());
|
||||
|
||||
int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
int log = 0;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ import net.coreprotect.consumer.Queue;
|
|||
import net.coreprotect.listener.player.InventoryChangeListener;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.paper.PaperAdapter;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
|
||||
public final class BlockPlaceListener extends Queue implements Listener {
|
||||
|
||||
|
|
@ -51,9 +52,9 @@ public final class BlockPlaceListener extends Queue implements Listener {
|
|||
InventoryChangeListener.inventoryTransaction(player.getName(), blockLogged.getLocation(), new ItemStack[1]);
|
||||
abort = true;
|
||||
}
|
||||
else if (Util.listContains(BlockGroup.CONTAINERS, blockType) || Util.listContains(BlockGroup.DIRECTIONAL_BLOCKS, blockType) || blockType.name().toUpperCase(Locale.ROOT).endsWith("_STAIRS")) {
|
||||
else if (MaterialUtils.listContains(BlockGroup.CONTAINERS, blockType) || MaterialUtils.listContains(BlockGroup.DIRECTIONAL_BLOCKS, blockType) || blockType.name().toUpperCase(Locale.ROOT).endsWith("_STAIRS")) {
|
||||
BlockData blockData = blockPlaced.getBlockData();
|
||||
Waterlogged waterlogged = Util.checkWaterlogged(blockData, blockReplaced);
|
||||
Waterlogged waterlogged = BlockUtils.checkWaterlogged(blockData, blockReplaced);
|
||||
if (waterlogged != null) {
|
||||
bBlockData = waterlogged.getAsString();
|
||||
blockReplaced = null;
|
||||
|
|
@ -88,7 +89,7 @@ public final class BlockPlaceListener extends Queue implements Listener {
|
|||
}
|
||||
|
||||
BlockData blockData = blockLogged.getBlockData();
|
||||
Waterlogged waterlogged = Util.checkWaterlogged(blockData, blockReplaced);
|
||||
Waterlogged waterlogged = BlockUtils.checkWaterlogged(blockData, blockReplaced);
|
||||
if (waterlogged != null) {
|
||||
bBlockData = waterlogged.getAsString();
|
||||
blockReplaced = null;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import net.coreprotect.consumer.Queue;
|
|||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public final class BlockSpreadListener extends Queue implements Listener {
|
||||
|
||||
|
|
@ -82,7 +83,7 @@ public final class BlockSpreadListener extends Queue implements Listener {
|
|||
}
|
||||
|
||||
private boolean checkCacheData(Block block, Material type) {
|
||||
String cacheId = block.getX() + "." + block.getY() + "." + block.getZ() + "." + Util.getWorldId(block.getWorld().getName());
|
||||
String cacheId = block.getX() + "." + block.getY() + "." + block.getZ() + "." + WorldUtils.getWorldId(block.getWorld().getName());
|
||||
Location location = block.getLocation();
|
||||
int timestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
Object[] cacheData = CacheHandler.spreadCache.get(cacheId);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import net.coreprotect.bukkit.BukkitAdapter;
|
|||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class BlockUtil {
|
||||
|
||||
|
|
@ -48,7 +49,7 @@ public class BlockUtil {
|
|||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
World world = location.getWorld();
|
||||
int wid = Util.getWorldId(world.getName());
|
||||
int wid = WorldUtils.getWorldId(world.getName());
|
||||
int yc = y - 1;
|
||||
// user placing sand/gravel. Find the bottom block
|
||||
int bottomfound = 0;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import net.coreprotect.consumer.Queue;
|
|||
import net.coreprotect.listener.player.PlayerDropItemListener;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public final class CampfireStartListener extends Queue implements Listener {
|
||||
|
||||
|
|
@ -21,7 +22,7 @@ public final class CampfireStartListener extends Queue implements Listener {
|
|||
protected void onCampfireStart(CampfireStartEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Location location = block.getLocation();
|
||||
int worldId = Util.getWorldId(location.getWorld().getName());
|
||||
int worldId = WorldUtils.getWorldId(location.getWorld().getName());
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import net.coreprotect.language.Selector;
|
|||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class PluginChannelListener implements Listener {
|
||||
|
||||
|
|
@ -36,7 +37,7 @@ public class PluginChannelListener implements Listener {
|
|||
}
|
||||
|
||||
String phraseSelector = Phrase.getPhraseSelector(phrase, selector);
|
||||
String worldName = Util.getWorldName(worldId);
|
||||
String worldName = WorldUtils.getWorldName(worldId);
|
||||
|
||||
ByteArrayOutputStream msgBytes = new ByteArrayOutputStream();
|
||||
DataOutputStream msgOut = new DataOutputStream(msgBytes);
|
||||
|
|
@ -78,7 +79,7 @@ public class PluginChannelListener implements Listener {
|
|||
}
|
||||
|
||||
String phraseSelector = Phrase.getPhraseSelector(phrase, selector);
|
||||
String worldName = Util.getWorldName(worldId);
|
||||
String worldName = WorldUtils.getWorldName(worldId);
|
||||
|
||||
ByteArrayOutputStream msgBytes = new ByteArrayOutputStream();
|
||||
DataOutputStream msgOut = new DataOutputStream(msgBytes);
|
||||
|
|
@ -112,7 +113,7 @@ public class PluginChannelListener implements Listener {
|
|||
return;
|
||||
}
|
||||
|
||||
String worldName = Util.getWorldName(worldId);
|
||||
String worldName = WorldUtils.getWorldName(worldId);
|
||||
|
||||
ByteArrayOutputStream msgBytes = new ByteArrayOutputStream();
|
||||
DataOutputStream msgOut = new DataOutputStream(msgBytes);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import net.coreprotect.config.Config;
|
|||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.listener.block.BlockUtil;
|
||||
import net.coreprotect.utility.EntityUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public final class CreatureSpawnListener extends Queue implements Listener {
|
||||
|
|
@ -40,7 +41,7 @@ public final class CreatureSpawnListener extends Queue implements Listener {
|
|||
Map.Entry<String, Object[]> pair = it.next();
|
||||
String name = pair.getKey();
|
||||
Object[] data = pair.getValue();
|
||||
if ((data[1].equals(key) || data[2].equals(key)) && Util.getEntityMaterial(event.getEntityType()) == ((ItemStack) data[3]).getType()) {
|
||||
if ((data[1].equals(key) || data[2].equals(key)) && EntityUtils.getEntityMaterial(event.getEntityType()) == ((ItemStack) data[3]).getType()) {
|
||||
Block gravityLocation = BlockUtil.gravityScan(location, Material.ARMOR_STAND, name);
|
||||
Queue.queueBlockPlace(name, gravityLocation.getState(), location.getBlock().getType(), location.getBlock().getState(), ((ItemStack) data[3]).getType(), (int) event.getEntity().getLocation().getYaw(), 1, null);
|
||||
it.remove();
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import net.coreprotect.consumer.Queue;
|
|||
import net.coreprotect.database.Database;
|
||||
import net.coreprotect.listener.player.PlayerInteractEntityListener;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public final class EntityDamageByEntityListener extends Queue implements Listener {
|
||||
|
|
@ -126,7 +127,7 @@ public final class EntityDamageByEntityListener extends Queue implements Listene
|
|||
// Do this here, as we're unable to read armor stand contents on EntityDeathEvent (in survival mode)
|
||||
if (Config.getConfig(entityLocation.getWorld()).ITEM_TRANSACTIONS) {
|
||||
String killer = user;
|
||||
ItemStack[] contents = Util.getContainerContents(Material.ARMOR_STAND, entity, block.getLocation());
|
||||
ItemStack[] contents = ItemUtils.getContainerContents(Material.ARMOR_STAND, entity, block.getLocation());
|
||||
Scheduler.runTask(CoreProtect.getInstance(), () -> {
|
||||
if (entity != null && entity.isDead()) {
|
||||
entityLocation.setY(entityLocation.getY() + 0.99);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import net.coreprotect.language.Phrase;
|
|||
import net.coreprotect.listener.player.PlayerInteractEntityListener;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
|
||||
public final class HangingBreakByEntityListener extends Queue implements Listener {
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ public final class HangingBreakByEntityListener extends Queue implements Listene
|
|||
material = Material.PAINTING;
|
||||
Painting painting = (Painting) entity;
|
||||
blockData = "FACING=" + painting.getFacing().name();
|
||||
itemData = Util.getArtId(painting.getArt().toString(), true);
|
||||
itemData = MaterialUtils.getArtId(painting.getArt().toString(), true);
|
||||
}
|
||||
|
||||
if (!event.isCancelled() && Config.getConfig(blockEvent.getWorld()).BLOCK_BREAK && !inspecting) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import net.coreprotect.config.Config;
|
|||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.database.Lookup;
|
||||
import net.coreprotect.listener.player.PlayerInteractEntityListener;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
|
||||
public final class HangingBreakListener extends Queue implements Listener {
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ public final class HangingBreakListener extends Queue implements Listener {
|
|||
material = Material.PAINTING;
|
||||
Painting painting = (Painting) entity;
|
||||
blockData = "FACING=" + painting.getFacing().name();
|
||||
itemData = Util.getArtId(painting.getArt().toString(), true);
|
||||
itemData = MaterialUtils.getArtId(painting.getArt().toString(), true);
|
||||
}
|
||||
|
||||
if (!event.isCancelled() && Config.getConfig(blockEvent.getWorld()).NATURAL_BREAK) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import net.coreprotect.bukkit.BukkitAdapter;
|
|||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
|
||||
public final class HangingPlaceListener extends Queue implements Listener {
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ public final class HangingPlaceListener extends Queue implements Listener {
|
|||
material = Material.PAINTING;
|
||||
Painting painting = (Painting) entity;
|
||||
blockData = "FACING=" + painting.getFacing().name();
|
||||
artId = Util.getArtId(painting.getArt().toString(), true);
|
||||
artId = MaterialUtils.getArtId(painting.getArt().toString(), true);
|
||||
}
|
||||
|
||||
int inspect = 0;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import net.coreprotect.language.Phrase;
|
|||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public final class ArmorStandManipulateListener extends Queue implements Listener {
|
||||
|
|
@ -84,7 +85,7 @@ public final class ArmorStandManipulateListener extends Queue implements Listene
|
|||
Player player = event.getPlayer();
|
||||
final ArmorStand armorStand = event.getRightClicked();
|
||||
EntityEquipment equipment = armorStand.getEquipment();
|
||||
ItemStack[] oldContents = Util.getArmorStandContents(equipment);
|
||||
ItemStack[] oldContents = ItemUtils.getArmorStandContents(equipment);
|
||||
ItemStack[] newContents = oldContents.clone();
|
||||
ItemStack item = event.getArmorStandItem();
|
||||
ItemStack playerItem = event.getPlayerItem();
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import net.coreprotect.consumer.Queue;
|
|||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public final class FoodLevelChangeListener extends Queue implements Listener {
|
||||
|
||||
|
|
@ -29,7 +30,7 @@ public final class FoodLevelChangeListener extends Queue implements Listener {
|
|||
int changeLevel = event.getFoodLevel() - player.getFoodLevel();
|
||||
if (changeLevel == 2) { // cake...
|
||||
Location location = player.getLocation();
|
||||
int worldId = Util.getWorldId(location.getWorld().getName());
|
||||
int worldId = WorldUtils.getWorldId(location.getWorld().getName());
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import net.coreprotect.CoreProtect;
|
|||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public final class HopperPullListener {
|
||||
|
|
@ -28,7 +29,7 @@ public final class HopperPullListener {
|
|||
}
|
||||
}
|
||||
|
||||
ItemStack[] destinationContainer = Util.getContainerState(destinationHolder.getInventory().getContents());
|
||||
ItemStack[] destinationContainer = ItemUtils.getContainerState(destinationHolder.getInventory().getContents());
|
||||
ItemStack movedItem = item.clone();
|
||||
|
||||
final long taskStarted = InventoryChangeListener.tasksStarted.incrementAndGet();
|
||||
|
|
@ -39,7 +40,7 @@ public final class HopperPullListener {
|
|||
}
|
||||
|
||||
boolean abort = false;
|
||||
boolean addedInventory = Util.canAddContainer(destinationContainer, movedItem, destinationHolder.getInventory().getMaxStackSize());
|
||||
boolean addedInventory = ItemUtils.canAddContainer(destinationContainer, movedItem, destinationHolder.getInventory().getMaxStackSize());
|
||||
if (!addedInventory) {
|
||||
abort = true;
|
||||
}
|
||||
|
|
@ -52,7 +53,7 @@ public final class HopperPullListener {
|
|||
}
|
||||
movedItems.add(movedItem);
|
||||
|
||||
ConfigHandler.hopperAbort.put(loggingChestId, new Object[] { movedItems, Util.getContainerState(destinationContents) });
|
||||
ConfigHandler.hopperAbort.put(loggingChestId, new Object[] { movedItems, ItemUtils.getContainerState(destinationContents) });
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import net.coreprotect.CoreProtect;
|
|||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public final class HopperPushListener {
|
||||
|
|
@ -33,7 +34,7 @@ public final class HopperPushListener {
|
|||
}
|
||||
}
|
||||
|
||||
ItemStack[] destinationContainer = Util.getContainerState(destinationHolder.getInventory().getContents());
|
||||
ItemStack[] destinationContainer = ItemUtils.getContainerState(destinationHolder.getInventory().getContents());
|
||||
ItemStack movedItem = item.clone();
|
||||
|
||||
final long taskStarted = InventoryChangeListener.tasksStarted.incrementAndGet();
|
||||
|
|
@ -44,7 +45,7 @@ public final class HopperPushListener {
|
|||
}
|
||||
|
||||
boolean abort = false;
|
||||
boolean addedInventory = Util.canAddContainer(destinationContainer, movedItem, destinationHolder.getInventory().getMaxStackSize());
|
||||
boolean addedInventory = ItemUtils.canAddContainer(destinationContainer, movedItem, destinationHolder.getInventory().getMaxStackSize());
|
||||
if (!addedInventory) {
|
||||
abort = true;
|
||||
}
|
||||
|
|
@ -57,7 +58,7 @@ public final class HopperPushListener {
|
|||
}
|
||||
movedItems.add(movedItem);
|
||||
|
||||
ConfigHandler.hopperAbort.put(loggingChestId, new Object[] { movedItems, Util.getContainerState(destinationContents) });
|
||||
ConfigHandler.hopperAbort.put(loggingChestId, new Object[] { movedItems, ItemUtils.getContainerState(destinationContents) });
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import net.coreprotect.consumer.Queue;
|
|||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.paper.PaperAdapter;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.Validate;
|
||||
|
||||
|
|
@ -124,7 +125,7 @@ public final class InventoryChangeListener extends Queue implements Listener {
|
|||
List<ItemStack[]> list = ConfigHandler.forceContainer.get(loggingChestIdViewer);
|
||||
|
||||
if (list != null && list.size() < sizeOld) {
|
||||
ItemStack[] containerState = Util.getContainerState(inventoryData);
|
||||
ItemStack[] containerState = ItemUtils.getContainerState(inventoryData);
|
||||
|
||||
// If items have been removed by a hopper, merge into containerState
|
||||
List<Object> transactingChest = ConfigHandler.transactingChest.get(transactingChestId);
|
||||
|
|
@ -183,14 +184,14 @@ public final class InventoryChangeListener extends Queue implements Listener {
|
|||
List<ItemStack[]> list = ConfigHandler.oldContainer.get(loggingChestId);
|
||||
|
||||
if (list != null && list.size() <= forceSize) {
|
||||
list.add(Util.getContainerState(inventoryData));
|
||||
list.add(ItemUtils.getContainerState(inventoryData));
|
||||
ConfigHandler.oldContainer.put(loggingChestId, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
List<ItemStack[]> list = new ArrayList<>();
|
||||
list.add(Util.getContainerState(inventoryData));
|
||||
list.add(ItemUtils.getContainerState(inventoryData));
|
||||
ConfigHandler.oldContainer.put(loggingChestId, list);
|
||||
}
|
||||
|
||||
|
|
@ -225,7 +226,7 @@ public final class InventoryChangeListener extends Queue implements Listener {
|
|||
}
|
||||
|
||||
Location inventoryLocation = location;
|
||||
ItemStack[] containerState = Util.getContainerState(inventory.getContents());
|
||||
ItemStack[] containerState = ItemUtils.getContainerState(inventory.getContents());
|
||||
|
||||
String loggingChestId = player.getName() + "." + location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ();
|
||||
Boolean lastTransaction = inventoryProcessing.get(loggingChestId);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import net.coreprotect.config.ConfigHandler;
|
|||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public final class PlayerBucketEmptyListener extends Queue implements Listener {
|
||||
|
||||
|
|
@ -54,7 +55,7 @@ public final class PlayerBucketEmptyListener extends Queue implements Listener {
|
|||
}
|
||||
|
||||
BlockState blockState = block.getState();
|
||||
int worldId = Util.getWorldId(block.getWorld().getName());
|
||||
int worldId = WorldUtils.getWorldId(block.getWorld().getName());
|
||||
int unixTimestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
|
||||
if (type.equals(Material.WATER)) {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import net.coreprotect.config.ConfigHandler;
|
|||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.database.logger.ItemLogger;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public final class PlayerInteractEntityListener extends Queue implements Listener {
|
||||
|
|
@ -128,14 +129,14 @@ public final class PlayerInteractEntityListener extends Queue implements Listene
|
|||
List<ItemStack[]> list = ConfigHandler.oldContainer.get(loggingChestId);
|
||||
|
||||
if (list.size() <= forceSize) {
|
||||
list.add(Util.getContainerState(contents));
|
||||
list.add(ItemUtils.getContainerState(contents));
|
||||
ConfigHandler.oldContainer.put(loggingChestId, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
List<ItemStack[]> list = new ArrayList<>();
|
||||
list.add(Util.getContainerState(contents));
|
||||
list.add(ItemUtils.getContainerState(contents));
|
||||
ConfigHandler.oldContainer.put(loggingChestId, list);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,9 @@ import net.coreprotect.thread.CacheHandler;
|
|||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public final class PlayerInteractListener extends Queue implements Listener {
|
||||
|
||||
|
|
@ -490,7 +492,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
Thread thread = new Thread(runnable);
|
||||
thread.start();
|
||||
|
||||
Util.updateInventory(event.getPlayer());
|
||||
ItemUtils.updateInventory(event.getPlayer());
|
||||
lastInspectorEvent.put(uuid, new Object[] { systemTime, eventHand });
|
||||
|
||||
if (event.hasItem()) {
|
||||
|
|
@ -659,7 +661,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
if (player.getGameMode() != GameMode.CREATIVE) {
|
||||
Location location = block.getLocation();
|
||||
long time = System.currentTimeMillis();
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(location.getWorld().getName());
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
|
|
@ -822,7 +824,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
String userUUID = player.getUniqueId().toString();
|
||||
Location location = player.getLocation();
|
||||
long time = System.currentTimeMillis();
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(location.getWorld().getName());
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
|
|
@ -946,7 +948,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||
private void clickedDragonEgg(Player player, Block block) {
|
||||
Location location = block.getLocation();
|
||||
long time = System.currentTimeMillis();
|
||||
int wid = Util.getWorldId(location.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(location.getWorld().getName());
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import net.coreprotect.config.Config;
|
|||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.database.logger.ItemLogger;
|
||||
import net.coreprotect.utility.EntityUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public final class ProjectileLaunchListener extends Queue implements Listener {
|
||||
|
|
@ -68,7 +69,7 @@ public final class ProjectileLaunchListener extends Queue implements Listener {
|
|||
String name = pair.getKey();
|
||||
Object[] data = pair.getValue();
|
||||
ItemStack itemStack = (ItemStack) data[3];
|
||||
Material entityMaterial = Util.getEntityMaterial(event.getEntityType());
|
||||
Material entityMaterial = EntityUtils.getEntityMaterial(event.getEntityType());
|
||||
boolean isBow = BOWS.contains(itemStack.getType());
|
||||
if ((data[1].equals(key) || data[2].equals(key)) && (entityMaterial == itemStack.getType() || (itemStack.getType() == Material.LINGERING_POTION && entityMaterial == Material.SPLASH_POTION) || isBow)) {
|
||||
boolean thrownItem = (itemStack.getType() != Material.FIREWORK_ROCKET && !isBow);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import org.bukkit.event.world.PortalCreateEvent;
|
|||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.database.Lookup;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
|
||||
public final class PortalCreateListener extends Queue implements Listener {
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ public final class PortalCreateListener extends Queue implements Listener {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (Util.isAir(type)) {
|
||||
if (BlockUtils.isAir(type)) {
|
||||
Queue.queueBlockBreak(user, oldBlock, oldBlock.getType(), oldBlock.getBlockData().getAsString(), 0);
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import net.coreprotect.database.Database;
|
|||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.VersionUtils;
|
||||
|
||||
public class Patch {
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ public class Patch {
|
|||
String result = "";
|
||||
if (firstVersion != null) {
|
||||
if ((firstVersion[0] + "." + firstVersion[1] + "." + firstVersion[2]).equals("0.0.0")) {
|
||||
result = Util.getPluginVersion();
|
||||
result = VersionUtils.getPluginVersion();
|
||||
}
|
||||
else {
|
||||
result = firstVersion[1] + "." + firstVersion[2];
|
||||
|
|
@ -105,7 +105,7 @@ public class Patch {
|
|||
if (className.startsWith("net/coreprotect/patch/script/__") && className.endsWith(".class")) {
|
||||
Class<?> patchClass = Class.forName(className.substring(0, className.length() - 6).replaceAll("/", "."));
|
||||
String patchVersion = getClassVersion(patchClass.getName());
|
||||
if (!Util.newVersion(Util.getInternalPluginVersion(), patchVersion)) {
|
||||
if (!VersionUtils.newVersion(VersionUtils.getInternalPluginVersion(), patchVersion)) {
|
||||
patches.add(patchVersion);
|
||||
}
|
||||
}
|
||||
|
|
@ -114,10 +114,10 @@ public class Patch {
|
|||
}
|
||||
|
||||
Collections.sort(patches, (o1, o2) -> {
|
||||
if (Util.newVersion(o1, o2)) {
|
||||
if (VersionUtils.newVersion(o1, o2)) {
|
||||
return -1;
|
||||
}
|
||||
else if (Util.newVersion(o2, o1)) {
|
||||
else if (VersionUtils.newVersion(o2, o1)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -171,7 +171,7 @@ public class Patch {
|
|||
int patchRevision = Integer.parseInt(thePatch[2]);
|
||||
Integer[] patchVersion = new Integer[] { patchMajor, patchMinor, patchRevision };
|
||||
|
||||
boolean performPatch = Util.newVersion(newVersion, patchVersion);
|
||||
boolean performPatch = VersionUtils.newVersion(newVersion, patchVersion);
|
||||
if (performPatch) {
|
||||
boolean success = false;
|
||||
try {
|
||||
|
|
@ -231,14 +231,14 @@ public class Patch {
|
|||
|
||||
public static boolean versionCheck(Statement statement) {
|
||||
try {
|
||||
Integer[] currentVersion = Util.getInternalPluginVersion();
|
||||
Integer[] currentVersion = VersionUtils.getInternalPluginVersion();
|
||||
firstVersion = getDatabaseVersion(statement.getConnection(), false);
|
||||
Integer[] lastVersion = getDatabaseVersion(statement.getConnection(), true);
|
||||
|
||||
boolean newVersion = Util.newVersion(lastVersion, currentVersion);
|
||||
boolean newVersion = VersionUtils.newVersion(lastVersion, currentVersion);
|
||||
if (newVersion && lastVersion[0] > 0 && !ConfigHandler.converterRunning) {
|
||||
Integer[] minimumVersion = new Integer[] { 2, 0, 0 };
|
||||
if (Util.newVersion(lastVersion, minimumVersion)) {
|
||||
if (VersionUtils.newVersion(lastVersion, minimumVersion)) {
|
||||
Chat.sendConsoleMessage("§c[CoreProtect] " + Phrase.build(Phrase.PATCH_OUTDATED_1, "v" + minimumVersion[0] + "." + minimumVersion[1] + "." + minimumVersion[2]));
|
||||
Chat.sendConsoleMessage("§c[CoreProtect] " + Phrase.build(Phrase.PATCH_OUTDATED_2));
|
||||
return false;
|
||||
|
|
@ -312,7 +312,7 @@ public class Patch {
|
|||
else {
|
||||
currentVersion[2] = 0;
|
||||
lastVersion[2] = 0;
|
||||
if (Util.newVersion(currentVersion, lastVersion)) {
|
||||
if (VersionUtils.newVersion(currentVersion, lastVersion)) {
|
||||
Chat.sendConsoleMessage(Color.RED + "[CoreProtect] " + Phrase.build(Phrase.VERSION_REQUIRED, "CoreProtect", "v" + lastVersion[1] + "." + lastVersion[2]));
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import net.coreprotect.config.ConfigHandler;
|
|||
import net.coreprotect.database.Database;
|
||||
import net.coreprotect.patch.Patch;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
|
||||
public class __2_18_0 {
|
||||
|
||||
|
|
@ -88,7 +90,7 @@ public class __2_18_0 {
|
|||
}
|
||||
|
||||
Material material = Material.matchMaterial(materialName, legacy);
|
||||
int newID = Util.getBlockId(material);
|
||||
int newID = MaterialUtils.getBlockId(material);
|
||||
|
||||
preparedBlockStatement.setInt(1, oldID);
|
||||
ResultSet blockResults = preparedBlockStatement.executeQuery();
|
||||
|
|
@ -101,7 +103,7 @@ public class __2_18_0 {
|
|||
int validatedID = newID;
|
||||
if (validatedMaterial == Material.WHITE_WOOL) {
|
||||
validatedMaterial = getWoolColor(blockData);
|
||||
validatedID = Util.getBlockId(validatedMaterial);
|
||||
validatedID = MaterialUtils.getBlockId(validatedMaterial);
|
||||
}
|
||||
|
||||
if (blockBlockData == null && validatedMaterial.isBlock()) {
|
||||
|
|
@ -123,7 +125,7 @@ public class __2_18_0 {
|
|||
BlockFace newRotation = getLegacyRotation(blockData);
|
||||
rotatable.setRotation(newRotation);
|
||||
}
|
||||
blockBlockData = Util.stringToByteData(newBlockData.getAsString(), validatedID);
|
||||
blockBlockData = BlockUtils.stringToByteData(newBlockData.getAsString(), validatedID);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import net.coreprotect.language.Phrase;
|
|||
import net.coreprotect.language.Selector;
|
||||
import net.coreprotect.patch.Patch;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class __2_19_0 {
|
||||
|
|
@ -118,7 +119,7 @@ public class __2_19_0 {
|
|||
|
||||
List<Integer> signList = new ArrayList<>();
|
||||
for (Material material : Tag.SIGNS.getValues()) {
|
||||
int id = Util.getBlockId(material.name(), false);
|
||||
int id = MaterialUtils.getBlockId(material.name(), false);
|
||||
if (id > -1) {
|
||||
signList.add(id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import net.coreprotect.language.Phrase;
|
|||
import net.coreprotect.language.Selector;
|
||||
import net.coreprotect.patch.Patch;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.EntityUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class __2_20_0 {
|
||||
|
|
@ -90,7 +91,7 @@ public class __2_20_0 {
|
|||
break;
|
||||
}
|
||||
|
||||
preparedStatementUpdate.setInt(1, Util.getSpawnerType(entityType));
|
||||
preparedStatementUpdate.setInt(1, EntityUtils.getSpawnerType(entityType));
|
||||
preparedStatementUpdate.setInt(2, resultSet.getInt("rowid"));
|
||||
preparedStatementUpdate.executeUpdate();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import org.bukkit.command.ConsoleCommandSender;
|
|||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.StringUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
|
|
@ -107,7 +108,7 @@ public class SpigotHandler extends SpigotAdapter implements SpigotInterface {
|
|||
if (data[0].equals(Chat.COMPONENT_COMMAND)) {
|
||||
TextComponent component = new TextComponent(TextComponent.fromLegacyText(data[2]));
|
||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, data[1]));
|
||||
SpigotAdapter.ADAPTER.setHoverEvent(component, Util.hoverCommandFilter(data[1]));
|
||||
SpigotAdapter.ADAPTER.setHoverEvent(component, StringUtils.hoverCommandFilter(data[1]));
|
||||
message.addExtra(component);
|
||||
}
|
||||
else if (data[0].equals(Chat.COMPONENT_POPUP)) {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import net.coreprotect.config.ConfigHandler;
|
|||
import net.coreprotect.language.Language;
|
||||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.VersionUtils;
|
||||
|
||||
public class NetworkHandler extends Language implements Runnable {
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ public class NetworkHandler extends Language implements Runnable {
|
|||
try {
|
||||
String lang = Config.getGlobal().LANGUAGE;
|
||||
String languageCode = lang.trim().toLowerCase();
|
||||
String pluginVersion = Util.getPluginVersion();
|
||||
String pluginVersion = VersionUtils.getPluginVersion();
|
||||
|
||||
if (!languageCode.startsWith("en") && languageCode.length() > 1) {
|
||||
boolean validCache = false;
|
||||
|
|
@ -290,7 +290,7 @@ public class NetworkHandler extends Language implements Runnable {
|
|||
int statusEdge = 0;
|
||||
HttpURLConnection connection = null;
|
||||
HttpURLConnection connectionEdge = null;
|
||||
String version = Util.getPluginVersion();
|
||||
String version = VersionUtils.getPluginVersion();
|
||||
|
||||
try {
|
||||
// CoreProtect Community Edition
|
||||
|
|
@ -329,7 +329,7 @@ public class NetworkHandler extends Language implements Runnable {
|
|||
if (response.length() > 0 && response.length() < 10) {
|
||||
String remoteVersion = response.replaceAll("[^0-9.]", "");
|
||||
if (remoteVersion.contains(".")) {
|
||||
boolean newVersion = Util.newVersion(version, remoteVersion);
|
||||
boolean newVersion = VersionUtils.newVersion(version, remoteVersion);
|
||||
if (newVersion) {
|
||||
latestVersion = remoteVersion;
|
||||
if (startup) {
|
||||
|
|
@ -361,7 +361,7 @@ public class NetworkHandler extends Language implements Runnable {
|
|||
if (response.length() > 0 && response.length() < 10) {
|
||||
String remoteVersion = response.replaceAll("[^0-9.]", "");
|
||||
if (remoteVersion.contains(".")) {
|
||||
boolean newVersion = Util.newVersion(version, remoteVersion);
|
||||
boolean newVersion = VersionUtils.newVersion(version, remoteVersion);
|
||||
if (newVersion) {
|
||||
latestEdgeVersion = remoteVersion;
|
||||
}
|
||||
|
|
|
|||
296
src/main/java/net/coreprotect/utility/BlockUtils.java
Normal file
296
src/main/java/net/coreprotect/utility/BlockUtils.java
Normal file
|
|
@ -0,0 +1,296 @@
|
|||
package net.coreprotect.utility;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Banner;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.block.Jukebox;
|
||||
import org.bukkit.block.ShulkerBox;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.inventory.BlockInventoryHolder;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
|
||||
public class BlockUtils {
|
||||
|
||||
private static final String NAMESPACE = "minecraft:";
|
||||
|
||||
private BlockUtils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static byte[] stringToByteData(String string, int type) {
|
||||
byte[] result = null;
|
||||
if (string != null) {
|
||||
Material material = MaterialUtils.getType(type);
|
||||
if (material == null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (material.isBlock() && !createBlockData(material).getAsString().equals(string) && string.startsWith(NAMESPACE + material.name().toLowerCase(Locale.ROOT) + "[") && string.endsWith("]")) {
|
||||
String substring = string.substring(material.name().length() + 11, string.length() - 1);
|
||||
String[] blockDataSplit = substring.split(",");
|
||||
ArrayList<String> blockDataArray = new ArrayList<>();
|
||||
for (String data : blockDataSplit) {
|
||||
int id = MaterialUtils.getBlockdataId(data, true);
|
||||
if (id > -1) {
|
||||
blockDataArray.add(Integer.toString(id));
|
||||
}
|
||||
}
|
||||
string = String.join(",", blockDataArray);
|
||||
}
|
||||
else if (!string.contains(":") && (material == Material.PAINTING || BukkitAdapter.ADAPTER.isItemFrame(material))) {
|
||||
int id = MaterialUtils.getBlockdataId(string, true);
|
||||
if (id > -1) {
|
||||
string = Integer.toString(id);
|
||||
}
|
||||
else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = string.getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String byteDataToString(byte[] data, int type) {
|
||||
String result = "";
|
||||
if (data != null) {
|
||||
Material material = MaterialUtils.getType(type);
|
||||
if (material == null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = new String(data, StandardCharsets.UTF_8);
|
||||
if (result.length() > 0) {
|
||||
if (result.matches("\\d+")) {
|
||||
result = result + ",";
|
||||
}
|
||||
if (result.contains(",")) {
|
||||
String[] blockDataSplit = result.split(",");
|
||||
ArrayList<String> blockDataArray = new ArrayList<>();
|
||||
for (String blockData : blockDataSplit) {
|
||||
String block = MaterialUtils.getBlockDataString(Integer.parseInt(blockData));
|
||||
if (block.length() > 0) {
|
||||
blockDataArray.add(block);
|
||||
}
|
||||
}
|
||||
|
||||
if (material == Material.PAINTING || BukkitAdapter.ADAPTER.isItemFrame(material)) {
|
||||
result = String.join(",", blockDataArray);
|
||||
}
|
||||
else {
|
||||
result = NAMESPACE + material.name().toLowerCase(Locale.ROOT) + "[" + String.join(",", blockDataArray) + "]";
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Waterlogged checkWaterlogged(BlockData blockData, BlockState blockReplacedState) {
|
||||
if (blockReplacedState.getType().equals(Material.WATER) && blockData instanceof Waterlogged) {
|
||||
if (blockReplacedState.getBlockData().equals(Material.WATER.createBlockData())) {
|
||||
Waterlogged waterlogged = (Waterlogged) blockData;
|
||||
waterlogged.setWaterlogged(true);
|
||||
return waterlogged;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isAir(Material type) {
|
||||
return (type == Material.AIR || type == Material.CAVE_AIR || type == Material.VOID_AIR);
|
||||
}
|
||||
|
||||
public static boolean solidBlock(Material type) {
|
||||
return type.isSolid();
|
||||
}
|
||||
|
||||
public static boolean passableBlock(Block block) {
|
||||
return block.isPassable();
|
||||
}
|
||||
|
||||
public static Material getType(Block block) {
|
||||
// Temp code
|
||||
return block.getType();
|
||||
}
|
||||
|
||||
public static boolean iceBreakCheck(BlockState block, String user, Material type) {
|
||||
if (type.equals(Material.ICE)) { // Ice block
|
||||
int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
int wid = WorldUtils.getWorldId(block.getWorld().getName());
|
||||
net.coreprotect.thread.CacheHandler.lookupCache.put("" + block.getX() + "." + block.getY() + "." + block.getZ() + "." + wid + "", new Object[] { unixtimestamp, user, Material.WATER });
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static BlockData createBlockData(Material material) {
|
||||
try {
|
||||
BlockData result = material.createBlockData();
|
||||
if (result instanceof Waterlogged) {
|
||||
((Waterlogged) result).setWaterlogged(false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void prepareTypeAndData(Map<Block, BlockData> map, Block block, Material type, BlockData blockData, boolean update) {
|
||||
if (blockData == null) {
|
||||
blockData = createBlockData(type);
|
||||
}
|
||||
|
||||
if (!update) {
|
||||
setTypeAndData(block, type, blockData, update);
|
||||
map.remove(block);
|
||||
}
|
||||
else {
|
||||
map.put(block, blockData);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setTypeAndData(Block block, Material type, BlockData blockData, boolean update) {
|
||||
if (blockData == null && type != null) {
|
||||
blockData = createBlockData(type);
|
||||
}
|
||||
|
||||
if (blockData != null) {
|
||||
block.setBlockData(blockData, update);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateBlock(final BlockState block) {
|
||||
Scheduler.runTask(CoreProtect.getInstance(), () -> {
|
||||
try {
|
||||
if (block.getBlockData() instanceof Waterlogged) {
|
||||
Block currentBlock = block.getBlock();
|
||||
if (currentBlock.getType().equals(block.getType())) {
|
||||
block.setBlockData(currentBlock.getBlockData());
|
||||
}
|
||||
}
|
||||
block.update();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, block.getLocation());
|
||||
}
|
||||
|
||||
public static Inventory getContainerInventory(BlockState blockState, boolean singleBlock) {
|
||||
Inventory inventory = null;
|
||||
try {
|
||||
if (blockState instanceof BlockInventoryHolder) {
|
||||
if (singleBlock) {
|
||||
List<Material> chests = java.util.Arrays.asList(Material.CHEST, Material.TRAPPED_CHEST);
|
||||
Material type = blockState.getType();
|
||||
if (chests.contains(type)) {
|
||||
inventory = ((org.bukkit.block.Chest) blockState).getBlockInventory();
|
||||
}
|
||||
}
|
||||
if (inventory == null) {
|
||||
inventory = ((BlockInventoryHolder) blockState).getInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public static List<Object> processMeta(BlockState block) {
|
||||
List<Object> meta = new ArrayList<>();
|
||||
try {
|
||||
if (block instanceof CommandBlock) {
|
||||
CommandBlock commandBlock = (CommandBlock) block;
|
||||
String command = commandBlock.getCommand();
|
||||
if (command.length() > 0) {
|
||||
meta.add(command);
|
||||
}
|
||||
}
|
||||
else if (block instanceof Banner) {
|
||||
Banner banner = (Banner) block;
|
||||
meta.add(banner.getBaseColor());
|
||||
List<Pattern> patterns = banner.getPatterns();
|
||||
for (Pattern pattern : patterns) {
|
||||
meta.add(pattern.serialize());
|
||||
}
|
||||
}
|
||||
else if (block instanceof ShulkerBox) {
|
||||
ShulkerBox shulkerBox = (ShulkerBox) block;
|
||||
ItemStack[] inventory = shulkerBox.getSnapshotInventory().getStorageContents();
|
||||
int slot = 0;
|
||||
for (ItemStack itemStack : inventory) {
|
||||
Map<Integer, Object> itemMap = ItemUtils.serializeItemStackLegacy(itemStack, null, slot);
|
||||
if (itemMap.size() > 0) {
|
||||
meta.add(itemMap);
|
||||
}
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (meta.isEmpty()) {
|
||||
meta = null;
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
|
||||
public static ItemStack[] getJukeboxItem(Jukebox blockState) {
|
||||
ItemStack[] contents = null;
|
||||
try {
|
||||
contents = new ItemStack[] { blockState.getRecord() };
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return contents;
|
||||
}
|
||||
|
||||
public static int getSignData(boolean frontGlowing, boolean backGlowing) {
|
||||
if (frontGlowing && backGlowing) {
|
||||
return 3;
|
||||
}
|
||||
else if (backGlowing) {
|
||||
return 2;
|
||||
}
|
||||
else if (frontGlowing) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean isSideGlowing(boolean isFront, int data) {
|
||||
return ((isFront && (data == 1 || data == 3)) || (!isFront && (data == 2 || data == 3)));
|
||||
}
|
||||
}
|
||||
190
src/main/java/net/coreprotect/utility/ChatUtils.java
Normal file
190
src/main/java/net/coreprotect/utility/ChatUtils.java
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
package net.coreprotect.utility;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
|
||||
import net.coreprotect.language.Phrase;
|
||||
|
||||
public class ChatUtils {
|
||||
|
||||
private ChatUtils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static String getCoordinates(String command, int worldId, int x, int y, int z, boolean displayWorld, boolean italic) {
|
||||
StringBuilder message = new StringBuilder(Chat.COMPONENT_TAG_OPEN + Chat.COMPONENT_COMMAND);
|
||||
|
||||
StringBuilder worldDisplay = new StringBuilder();
|
||||
if (displayWorld) {
|
||||
worldDisplay.append("/" + WorldUtils.getWorldName(worldId));
|
||||
}
|
||||
|
||||
// command
|
||||
DecimalFormat decimalFormat = new DecimalFormat("#.##", new DecimalFormatSymbols(Locale.ROOT));
|
||||
message.append("|/" + command + " teleport wid:" + worldId + " " + decimalFormat.format(x + 0.50) + " " + y + " " + decimalFormat.format(z + 0.50) + "|");
|
||||
|
||||
// chat output
|
||||
message.append(Color.GREY + (italic ? Color.ITALIC : "") + "(x" + x + "/y" + y + "/z" + z + worldDisplay.toString() + ")");
|
||||
|
||||
return message.append(Chat.COMPONENT_TAG_CLOSE).toString();
|
||||
}
|
||||
|
||||
public static String getPageNavigation(String command, int page, int totalPages) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
|
||||
// back arrow
|
||||
String backArrow = "";
|
||||
if (page > 1) {
|
||||
backArrow = "◀ ";
|
||||
backArrow = Chat.COMPONENT_TAG_OPEN + Chat.COMPONENT_COMMAND + "|/" + command + " l " + (page - 1) + "|" + backArrow + Chat.COMPONENT_TAG_CLOSE;
|
||||
}
|
||||
|
||||
// next arrow
|
||||
String nextArrow = " ";
|
||||
if (page < totalPages) {
|
||||
nextArrow = " ▶ ";
|
||||
nextArrow = Chat.COMPONENT_TAG_OPEN + Chat.COMPONENT_COMMAND + "|/" + command + " l " + (page + 1) + "|" + nextArrow + Chat.COMPONENT_TAG_CLOSE;
|
||||
}
|
||||
|
||||
StringBuilder pagination = new StringBuilder();
|
||||
if (totalPages > 1) {
|
||||
pagination.append(Color.GREY + "(");
|
||||
if (page > 3) {
|
||||
pagination.append(Color.WHITE + Chat.COMPONENT_TAG_OPEN + Chat.COMPONENT_COMMAND + "|/" + command + " l " + 1 + "|" + "1 " + Chat.COMPONENT_TAG_CLOSE);
|
||||
if (page > 4 && totalPages > 7) {
|
||||
pagination.append(Color.GREY + "... ");
|
||||
}
|
||||
else {
|
||||
pagination.append(Color.GREY + "| ");
|
||||
}
|
||||
}
|
||||
|
||||
int displayStart = (page - 2) < 1 ? 1 : (page - 2);
|
||||
int displayEnd = (page + 2) > totalPages ? totalPages : (page + 2);
|
||||
if (page > 999 || (page > 101 && totalPages > 99999)) { // limit to max 5 page numbers
|
||||
displayStart = (displayStart + 1) < displayEnd ? (displayStart + 1) : displayStart;
|
||||
displayEnd = (displayEnd - 1) > displayStart ? (displayEnd - 1) : displayEnd;
|
||||
if (displayStart > (totalPages - 3)) {
|
||||
displayStart = (totalPages - 3) < 1 ? 1 : (totalPages - 3);
|
||||
}
|
||||
}
|
||||
else { // display at least 7 page numbers
|
||||
if (displayStart > (totalPages - 5)) {
|
||||
displayStart = (totalPages - 5) < 1 ? 1 : (totalPages - 5);
|
||||
}
|
||||
if (displayEnd < 6) {
|
||||
displayEnd = 6 > totalPages ? totalPages : 6;
|
||||
}
|
||||
}
|
||||
|
||||
if (page > 99999) { // limit to max 3 page numbers
|
||||
displayStart = (displayStart + 1) < displayEnd ? (displayStart + 1) : displayStart;
|
||||
displayEnd = (displayEnd - 1) >= displayStart ? (displayEnd - 1) : displayEnd;
|
||||
if (page == (totalPages - 1)) {
|
||||
displayEnd = totalPages - 1;
|
||||
}
|
||||
if (displayStart < displayEnd) {
|
||||
displayStart = displayEnd;
|
||||
}
|
||||
}
|
||||
|
||||
if (page > 3 && displayStart == 1) {
|
||||
displayStart = 2;
|
||||
}
|
||||
|
||||
for (int displayPage = displayStart; displayPage <= displayEnd; displayPage++) {
|
||||
if (page != displayPage) {
|
||||
pagination.append(Color.WHITE + Chat.COMPONENT_TAG_OPEN + Chat.COMPONENT_COMMAND + "|/" + command + " l " + displayPage + "|" + displayPage + (displayPage < totalPages ? " " : "") + Chat.COMPONENT_TAG_CLOSE);
|
||||
}
|
||||
else {
|
||||
pagination.append(Color.WHITE + Color.UNDERLINE + displayPage + Color.RESET + (displayPage < totalPages ? " " : ""));
|
||||
}
|
||||
if (displayPage < displayEnd) {
|
||||
pagination.append(Color.GREY + "| ");
|
||||
}
|
||||
}
|
||||
|
||||
if (displayEnd < totalPages) {
|
||||
if (displayEnd < (totalPages - 1)) {
|
||||
pagination.append(Color.GREY + "... ");
|
||||
}
|
||||
else {
|
||||
pagination.append(Color.GREY + "| ");
|
||||
}
|
||||
if (page != totalPages) {
|
||||
pagination.append(Color.WHITE + Chat.COMPONENT_TAG_OPEN + Chat.COMPONENT_COMMAND + "|/" + command + " l " + totalPages + "|" + totalPages + Chat.COMPONENT_TAG_CLOSE);
|
||||
}
|
||||
else {
|
||||
pagination.append(Color.WHITE + Color.UNDERLINE + totalPages);
|
||||
}
|
||||
}
|
||||
|
||||
pagination.append(Color.GREY + ")");
|
||||
}
|
||||
|
||||
return message.append(Color.WHITE + backArrow + Color.DARK_AQUA + Phrase.build(Phrase.LOOKUP_PAGE, Color.WHITE + page + "/" + totalPages) + nextArrow + pagination).toString();
|
||||
}
|
||||
|
||||
public static String getTimeSince(long resultTime, long currentTime, boolean component) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
double timeSince = currentTime - (resultTime + 0.00);
|
||||
if (timeSince < 0.00) {
|
||||
timeSince = 0.00;
|
||||
}
|
||||
|
||||
// minutes
|
||||
timeSince = timeSince / 60;
|
||||
if (timeSince < 60.0) {
|
||||
message.append(Phrase.build(Phrase.LOOKUP_TIME, new DecimalFormat("0.00").format(timeSince) + "/m"));
|
||||
}
|
||||
|
||||
// hours
|
||||
if (message.length() == 0) {
|
||||
timeSince = timeSince / 60;
|
||||
if (timeSince < 24.0) {
|
||||
message.append(Phrase.build(Phrase.LOOKUP_TIME, new DecimalFormat("0.00").format(timeSince) + "/h"));
|
||||
}
|
||||
}
|
||||
|
||||
// days
|
||||
if (message.length() == 0) {
|
||||
timeSince = timeSince / 24;
|
||||
message.append(Phrase.build(Phrase.LOOKUP_TIME, new DecimalFormat("0.00").format(timeSince) + "/d"));
|
||||
}
|
||||
|
||||
if (component) {
|
||||
Date logDate = new Date(resultTime * 1000L);
|
||||
String formattedTimestamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z").format(logDate);
|
||||
|
||||
return Chat.COMPONENT_TAG_OPEN + Chat.COMPONENT_POPUP + "|" + Color.GREY + formattedTimestamp + "|" + Color.GREY + message.toString() + Chat.COMPONENT_TAG_CLOSE;
|
||||
}
|
||||
|
||||
return message.toString();
|
||||
}
|
||||
|
||||
public static String createTooltip(String phrase, String tooltip) {
|
||||
if (tooltip.isEmpty()) {
|
||||
return phrase;
|
||||
}
|
||||
|
||||
StringBuilder message = new StringBuilder(Chat.COMPONENT_TAG_OPEN + Chat.COMPONENT_POPUP);
|
||||
|
||||
// tooltip
|
||||
message.append("|" + tooltip.replace("|", Chat.COMPONENT_PIPE) + "|");
|
||||
|
||||
// chat output
|
||||
message.append(phrase);
|
||||
|
||||
return message.append(Chat.COMPONENT_TAG_CLOSE).toString();
|
||||
}
|
||||
|
||||
// This theoretically initializes the component code, to prevent gson adapter errors
|
||||
public static void sendConsoleComponentStartup(ConsoleCommandSender consoleSender, String string) {
|
||||
Chat.sendComponent(consoleSender, Color.RESET + "[CoreProtect] " + string + Chat.COMPONENT_TAG_OPEN + Chat.COMPONENT_POPUP + "| | " + Chat.COMPONENT_TAG_CLOSE);
|
||||
}
|
||||
}
|
||||
42
src/main/java/net/coreprotect/utility/DatabaseUtils.java
Normal file
42
src/main/java/net/coreprotect/utility/DatabaseUtils.java
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
package net.coreprotect.utility;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Map;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
public class DatabaseUtils {
|
||||
|
||||
private DatabaseUtils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static <K, V extends Comparable<? super V>> SortedSet<Map.Entry<K, V>> entriesSortedByValues(Map<K, V> map) {
|
||||
SortedSet<Map.Entry<K, V>> sortedEntries = new TreeSet<>((e1, e2) -> {
|
||||
int res = e1.getValue().compareTo(e2.getValue());
|
||||
return res != 0 ? res : 1;
|
||||
});
|
||||
sortedEntries.addAll(map.entrySet());
|
||||
return sortedEntries;
|
||||
}
|
||||
|
||||
public static boolean successfulQuery(Connection connection, String query) {
|
||||
boolean result = false;
|
||||
try {
|
||||
PreparedStatement preparedStmt = connection.prepareStatement(query);
|
||||
ResultSet resultSet = preparedStmt.executeQuery();
|
||||
if (resultSet.isBeforeFirst()) {
|
||||
result = true;
|
||||
}
|
||||
resultSet.close();
|
||||
preparedStmt.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
134
src/main/java/net/coreprotect/utility/EntityUtils.java
Normal file
134
src/main/java/net/coreprotect/utility/EntityUtils.java
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
package net.coreprotect.utility;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
|
||||
public class EntityUtils extends Queue {
|
||||
|
||||
private static final String NAMESPACE = "minecraft:";
|
||||
|
||||
private EntityUtils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static int getEntityId(EntityType type) {
|
||||
if (type == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return getEntityId(type.name(), true);
|
||||
}
|
||||
|
||||
public static int getEntityId(String name, boolean internal) {
|
||||
int id = -1;
|
||||
name = name.toLowerCase(Locale.ROOT).trim();
|
||||
|
||||
if (ConfigHandler.entities.get(name) != null) {
|
||||
id = ConfigHandler.entities.get(name);
|
||||
}
|
||||
else if (internal) {
|
||||
int entityID = ConfigHandler.entityId + 1;
|
||||
ConfigHandler.entities.put(name, entityID);
|
||||
ConfigHandler.entitiesReversed.put(entityID, name);
|
||||
ConfigHandler.entityId = entityID;
|
||||
Queue.queueEntityInsert(entityID, name);
|
||||
id = ConfigHandler.entities.get(name);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public static Material getEntityMaterial(EntityType type) {
|
||||
switch (type.name()) {
|
||||
case "ARMOR_STAND":
|
||||
return Material.ARMOR_STAND;
|
||||
case "ITEM_FRAME":
|
||||
return Material.ITEM_FRAME;
|
||||
case "END_CRYSTAL":
|
||||
case "ENDER_CRYSTAL":
|
||||
return Material.END_CRYSTAL;
|
||||
case "ENDER_PEARL":
|
||||
return Material.ENDER_PEARL;
|
||||
case "POTION":
|
||||
case "SPLASH_POTION":
|
||||
return Material.SPLASH_POTION;
|
||||
case "EXPERIENCE_BOTTLE":
|
||||
case "THROWN_EXP_BOTTLE":
|
||||
return Material.EXPERIENCE_BOTTLE;
|
||||
case "TRIDENT":
|
||||
return Material.TRIDENT;
|
||||
case "FIREWORK_ROCKET":
|
||||
case "FIREWORK":
|
||||
return Material.FIREWORK_ROCKET;
|
||||
case "EGG":
|
||||
return Material.EGG;
|
||||
case "SNOWBALL":
|
||||
return Material.SNOWBALL;
|
||||
case "WIND_CHARGE":
|
||||
return Material.valueOf("WIND_CHARGE");
|
||||
default:
|
||||
return BukkitAdapter.ADAPTER.getFrameType(type);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getEntityName(int id) {
|
||||
// Internal ID pulled from DB
|
||||
String entityName = "";
|
||||
if (ConfigHandler.entitiesReversed.get(id) != null) {
|
||||
entityName = ConfigHandler.entitiesReversed.get(id);
|
||||
}
|
||||
return entityName;
|
||||
}
|
||||
|
||||
public static EntityType getEntityType(int id) {
|
||||
// Internal ID pulled from DB
|
||||
EntityType entitytype = null;
|
||||
if (ConfigHandler.entitiesReversed.get(id) != null) {
|
||||
String name = ConfigHandler.entitiesReversed.get(id);
|
||||
if (name.contains(NAMESPACE)) {
|
||||
name = name.split(":")[1];
|
||||
}
|
||||
entitytype = EntityType.valueOf(name.toUpperCase(Locale.ROOT));
|
||||
}
|
||||
return entitytype;
|
||||
}
|
||||
|
||||
public static EntityType getEntityType(String name) {
|
||||
// Name entered by user
|
||||
EntityType type = null;
|
||||
name = name.toLowerCase(Locale.ROOT).trim();
|
||||
if (name.contains(NAMESPACE)) {
|
||||
name = (name.split(":"))[1];
|
||||
}
|
||||
|
||||
if (ConfigHandler.entities.get(name) != null) {
|
||||
type = EntityType.valueOf(name.toUpperCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
public static int getSpawnerType(EntityType type) {
|
||||
int result = getEntityId(type);
|
||||
if (result == -1) {
|
||||
result = 0; // default to pig
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static EntityType getSpawnerType(int type) {
|
||||
EntityType result = getEntityType(type);
|
||||
if (result == null) {
|
||||
result = EntityType.PIG;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
459
src/main/java/net/coreprotect/utility/ItemUtils.java
Normal file
459
src/main/java/net/coreprotect/utility/ItemUtils.java
Normal file
|
|
@ -0,0 +1,459 @@
|
|||
package net.coreprotect.utility;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
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.util.io.BukkitObjectOutputStream;
|
||||
|
||||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.utility.serialize.ItemMetaHandler;
|
||||
|
||||
public class ItemUtils {
|
||||
|
||||
private ItemUtils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static void mergeItems(Material material, ItemStack[] items) {
|
||||
if (material != null && (material.equals(Material.ARMOR_STAND) || BukkitAdapter.ADAPTER.isItemFrame(material))) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
int c1 = 0;
|
||||
for (ItemStack o1 : items) {
|
||||
if (o1 != null && o1.getAmount() > 0) {
|
||||
int c2 = 0;
|
||||
for (ItemStack o2 : items) {
|
||||
if (o2 != null && c2 > c1 && o1.isSimilar(o2) && !BlockUtils.isAir(o1.getType())) { // Ignores amount
|
||||
int namount = o1.getAmount() + o2.getAmount();
|
||||
o1.setAmount(namount);
|
||||
o2.setAmount(0);
|
||||
}
|
||||
c2++;
|
||||
}
|
||||
}
|
||||
c1++;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack[] getContainerState(ItemStack[] array) {
|
||||
ItemStack[] result = array == null ? null : array.clone();
|
||||
if (result == null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for (ItemStack itemStack : array) {
|
||||
ItemStack clonedItem = null;
|
||||
if (itemStack != null) {
|
||||
clonedItem = itemStack.clone();
|
||||
}
|
||||
result[count] = clonedItem;
|
||||
count++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ItemStack[] sortContainerState(ItemStack[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack[] sorted = new ItemStack[array.length];
|
||||
Map<String, ItemStack> map = new HashMap<>();
|
||||
for (ItemStack itemStack : array) {
|
||||
if (itemStack == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
map.put(itemStack.toString(), itemStack);
|
||||
}
|
||||
|
||||
ArrayList<String> sortedKeys = new ArrayList<>(map.keySet());
|
||||
Collections.sort(sortedKeys);
|
||||
|
||||
int i = 0;
|
||||
for (String key : sortedKeys) {
|
||||
sorted[i] = map.get(key);
|
||||
i++;
|
||||
}
|
||||
|
||||
return sorted;
|
||||
}
|
||||
|
||||
/* return true if ItemStack[] contents are identical */
|
||||
public static boolean compareContainers(ItemStack[] oldContainer, ItemStack[] newContainer) {
|
||||
if (oldContainer.length != newContainer.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < oldContainer.length; i++) {
|
||||
ItemStack oldItem = oldContainer[i];
|
||||
ItemStack newItem = newContainer[i];
|
||||
|
||||
if (oldItem == null && newItem == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (oldItem == null || !oldItem.equals(newItem)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* return true if newContainer contains new items */
|
||||
public static boolean addedContainer(ItemStack[] oldContainer, ItemStack[] newContainer) {
|
||||
if (oldContainer.length != newContainer.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < oldContainer.length; i++) {
|
||||
ItemStack oldItem = oldContainer[i];
|
||||
ItemStack newItem = newContainer[i];
|
||||
|
||||
if (oldItem == null && newItem == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (oldItem != null && newItem == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (oldItem == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!newItem.equals(oldItem)) {
|
||||
return (newItem.isSimilar(oldItem) && newItem.getAmount() > oldItem.getAmount());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* return true if item can be added to container */
|
||||
public static boolean canAddContainer(ItemStack[] container, ItemStack item, int forceMaxStack) {
|
||||
for (ItemStack containerItem : container) {
|
||||
if (containerItem == null || containerItem.getType() == Material.AIR) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int maxStackSize = containerItem.getMaxStackSize();
|
||||
if (forceMaxStack > 0 && (forceMaxStack < maxStackSize || maxStackSize == -1)) {
|
||||
maxStackSize = forceMaxStack;
|
||||
}
|
||||
|
||||
if (maxStackSize == -1) {
|
||||
maxStackSize = 1;
|
||||
}
|
||||
|
||||
if (containerItem.isSimilar(item) && containerItem.getAmount() < maxStackSize) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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) {
|
||||
// 0: BOOTS, 1: LEGGINGS, 2: CHESTPLATE, 3: HELMET
|
||||
ItemStack[] armorContent = equipment.getArmorContents();
|
||||
System.arraycopy(armorContent, 0, contents, 0, 4);
|
||||
contents[4] = equipment.getItemInMainHand();
|
||||
contents[5] = equipment.getItemInOffHand();
|
||||
}
|
||||
else {
|
||||
Arrays.fill(contents, new ItemStack(Material.AIR));
|
||||
}
|
||||
|
||||
return contents;
|
||||
}
|
||||
|
||||
public static ItemStack[] getContainerContents(Material type, Object container, Location location) {
|
||||
ItemStack[] contents = null;
|
||||
if (Config.getConfig(location.getWorld()).ITEM_TRANSACTIONS && BlockGroup.CONTAINERS.contains(type)) {
|
||||
try {
|
||||
// container may be null if called from within WorldEdit logger
|
||||
if (container == null) {
|
||||
container = location.getBlock();
|
||||
}
|
||||
|
||||
if (type == Material.ARMOR_STAND) {
|
||||
LivingEntity entity = (LivingEntity) container;
|
||||
EntityEquipment equipment = getEntityEquipment(entity);
|
||||
if (equipment != null) {
|
||||
contents = getArmorStandContents(equipment);
|
||||
}
|
||||
}
|
||||
else if (type == Material.ITEM_FRAME) {
|
||||
ItemFrame entity = (ItemFrame) container;
|
||||
contents = getItemFrameItem(entity);
|
||||
}
|
||||
else if (type == Material.JUKEBOX) {
|
||||
org.bukkit.block.Jukebox blockState = (org.bukkit.block.Jukebox) ((Block) container).getState();
|
||||
contents = BlockUtils.getJukeboxItem(blockState);
|
||||
}
|
||||
else {
|
||||
Block block = (Block) container;
|
||||
Inventory inventory = BlockUtils.getContainerInventory(block.getState(), true);
|
||||
if (inventory != null) {
|
||||
contents = inventory.getContents();
|
||||
}
|
||||
}
|
||||
|
||||
if (type == Material.ARMOR_STAND || type == Material.ITEM_FRAME) {
|
||||
boolean hasItem = false;
|
||||
for (ItemStack item : contents) {
|
||||
if (item != null && !item.getType().equals(Material.AIR)) {
|
||||
hasItem = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasItem) {
|
||||
contents = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (contents != null) {
|
||||
contents = getContainerState(contents);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return contents;
|
||||
}
|
||||
|
||||
public static EntityEquipment getEntityEquipment(LivingEntity entity) {
|
||||
EntityEquipment equipment = null;
|
||||
try {
|
||||
equipment = entity.getEquipment();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return equipment;
|
||||
}
|
||||
|
||||
public static ItemStack[] getItemFrameItem(ItemFrame entity) {
|
||||
ItemStack[] contents = null;
|
||||
try {
|
||||
contents = new ItemStack[] { entity.getItem() };
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return contents;
|
||||
}
|
||||
|
||||
public static int getItemStackHashCode(ItemStack item) {
|
||||
try {
|
||||
return item.hashCode();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public static Material itemFilter(Material material, boolean blockTable) {
|
||||
if (material == null || (!blockTable && material.isItem())) {
|
||||
return material;
|
||||
}
|
||||
|
||||
material = BukkitAdapter.ADAPTER.getPlantSeeds(material);
|
||||
if (material.name().contains("WALL_")) {
|
||||
material = Material.valueOf(material.name().replace("WALL_", ""));
|
||||
}
|
||||
|
||||
return material;
|
||||
}
|
||||
|
||||
public static ItemStack newItemStack(Material type, int amount) {
|
||||
return new ItemStack(type, amount);
|
||||
}
|
||||
|
||||
public static void updateInventory(org.bukkit.entity.Player player) {
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
public static byte[] convertByteData(Object data) {
|
||||
byte[] result = null;
|
||||
if (data == null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
BukkitObjectOutputStream oos = new BukkitObjectOutputStream(bos);
|
||||
oos.writeObject(data);
|
||||
oos.flush();
|
||||
oos.close();
|
||||
bos.close();
|
||||
result = bos.toByteArray();
|
||||
}
|
||||
catch (Exception e) { // only display exception on development branch
|
||||
if (!ConfigHandler.EDITION_BRANCH.contains("-dev")) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ItemMeta deserializeItemMeta(Class<? extends ItemMeta> itemMetaClass, Map<String, Object> args) {
|
||||
try {
|
||||
org.bukkit.configuration.serialization.DelegateDeserialization delegate = itemMetaClass.getAnnotation(org.bukkit.configuration.serialization.DelegateDeserialization.class);
|
||||
return (ItemMeta) org.bukkit.configuration.serialization.ConfigurationSerialization.deserializeObject(args, delegate.value());
|
||||
}
|
||||
catch (Exception e) { // only display exception on development branch
|
||||
if (!ConfigHandler.EDITION_BRANCH.contains("-dev")) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getEnchantments(byte[] metadata, int type, int amount) {
|
||||
if (metadata == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
ItemStack item = new ItemStack(MaterialUtils.getType(type), amount);
|
||||
item = (ItemStack) net.coreprotect.database.rollback.Rollback.populateItemStack(item, metadata)[2];
|
||||
String displayName = item.hasItemMeta() && item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : "";
|
||||
StringBuilder message = new StringBuilder(Color.ITALIC + displayName + Color.GREY);
|
||||
|
||||
List<String> enchantments = ItemMetaHandler.getEnchantments(item, displayName);
|
||||
for (String enchantment : enchantments) {
|
||||
if (message.length() > 0) {
|
||||
message.append("\n");
|
||||
}
|
||||
message.append(enchantment);
|
||||
}
|
||||
|
||||
if (!displayName.isEmpty()) {
|
||||
message.insert(0, enchantments.isEmpty() ? Color.WHITE : Color.AQUA);
|
||||
}
|
||||
else if (!enchantments.isEmpty()) {
|
||||
String name = StringUtils.capitalize(item.getType().name().replace("_", " "), true);
|
||||
message.insert(0, Color.AQUA + Color.ITALIC + name);
|
||||
}
|
||||
|
||||
return message.toString();
|
||||
}
|
||||
|
||||
public static Map<Integer, Object> serializeItemStackLegacy(ItemStack itemStack, String faceData, int slot) {
|
||||
Map<Integer, Object> result = new HashMap<>();
|
||||
Map<String, Object> itemMap = serializeItemStack(itemStack, faceData, slot);
|
||||
if (itemMap.size() > 1) {
|
||||
result.put(0, itemMap.get("0"));
|
||||
result.put(1, itemMap.get("1"));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ItemStack unserializeItemStackLegacy(Object value) {
|
||||
ItemStack result = null;
|
||||
if (value instanceof Map) {
|
||||
Map<String, Object> newMap = new HashMap<>();
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<Integer, Object> itemMap = (Map<Integer, Object>) value;
|
||||
newMap.put("0", itemMap.get(0));
|
||||
newMap.put("1", itemMap.get(1));
|
||||
result = unserializeItemStack(newMap);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Map<String, Object> serializeItemStack(ItemStack itemStack, String faceData, int slot) {
|
||||
Map<String, Object> itemMap = new HashMap<>();
|
||||
if (itemStack != null && !itemStack.getType().equals(Material.AIR)) {
|
||||
ItemStack item = itemStack.clone();
|
||||
List<List<Map<String, Object>>> metadata = ItemMetaHandler.serialize(item, null, faceData, slot);
|
||||
item.setItemMeta(null);
|
||||
itemMap.put("0", item.serialize());
|
||||
itemMap.put("1", metadata);
|
||||
}
|
||||
|
||||
return itemMap;
|
||||
}
|
||||
|
||||
public static ItemStack unserializeItemStack(Object value) {
|
||||
ItemStack result = null;
|
||||
if (value instanceof Map) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> itemMap = (Map<String, Object>) value;
|
||||
@SuppressWarnings("unchecked")
|
||||
ItemStack item = ItemStack.deserialize((Map<String, Object>) itemMap.get("0"));
|
||||
@SuppressWarnings("unchecked")
|
||||
List<List<Map<String, Object>>> metadata = (List<List<Map<String, Object>>>) itemMap.get("1");
|
||||
|
||||
Object[] populatedStack = net.coreprotect.database.rollback.Rollback.populateItemStack(item, metadata);
|
||||
result = (ItemStack) populatedStack[2];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
198
src/main/java/net/coreprotect/utility/MaterialUtils.java
Normal file
198
src/main/java/net/coreprotect/utility/MaterialUtils.java
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
package net.coreprotect.utility;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
|
||||
public class MaterialUtils extends Queue {
|
||||
|
||||
private static final String NAMESPACE = "minecraft:";
|
||||
|
||||
private MaterialUtils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static int getBlockId(Material material) {
|
||||
if (material == null) {
|
||||
material = Material.AIR;
|
||||
}
|
||||
return getBlockId(material.name(), true);
|
||||
}
|
||||
|
||||
public static int getBlockId(String name, boolean internal) {
|
||||
int id = -1;
|
||||
|
||||
name = name.toLowerCase(Locale.ROOT).trim();
|
||||
if (!name.contains(":")) {
|
||||
name = NAMESPACE + name;
|
||||
}
|
||||
|
||||
if (ConfigHandler.materials.get(name) != null) {
|
||||
id = ConfigHandler.materials.get(name);
|
||||
}
|
||||
else if (internal) {
|
||||
int mid = ConfigHandler.materialId + 1;
|
||||
ConfigHandler.materials.put(name, mid);
|
||||
ConfigHandler.materialsReversed.put(mid, name);
|
||||
ConfigHandler.materialId = mid;
|
||||
Queue.queueMaterialInsert(mid, name);
|
||||
id = ConfigHandler.materials.get(name);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public static int getBlockdataId(String data, boolean internal) {
|
||||
int id = -1;
|
||||
data = data.toLowerCase(Locale.ROOT).trim();
|
||||
|
||||
if (ConfigHandler.blockdata.get(data) != null) {
|
||||
id = ConfigHandler.blockdata.get(data);
|
||||
}
|
||||
else if (internal) {
|
||||
int bid = ConfigHandler.blockdataId + 1;
|
||||
ConfigHandler.blockdata.put(data, bid);
|
||||
ConfigHandler.blockdataReversed.put(bid, data);
|
||||
ConfigHandler.blockdataId = bid;
|
||||
Queue.queueBlockDataInsert(bid, data);
|
||||
id = ConfigHandler.blockdata.get(data);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public static String getBlockDataString(int id) {
|
||||
// Internal ID pulled from DB
|
||||
String blockdata = "";
|
||||
if (ConfigHandler.blockdataReversed.get(id) != null) {
|
||||
blockdata = ConfigHandler.blockdataReversed.get(id);
|
||||
}
|
||||
return blockdata;
|
||||
}
|
||||
|
||||
public static String getBlockName(int id) {
|
||||
String name = "";
|
||||
if (ConfigHandler.materialsReversed.get(id) != null) {
|
||||
name = ConfigHandler.materialsReversed.get(id);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public static String getBlockNameShort(int id) {
|
||||
String name = getBlockName(id);
|
||||
if (name.contains(":")) {
|
||||
name = name.split(":")[1];
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public static Material getType(int id) {
|
||||
// Internal ID pulled from DB
|
||||
Material material = null;
|
||||
if (ConfigHandler.materialsReversed.get(id) != null && id > 0) {
|
||||
String name = ConfigHandler.materialsReversed.get(id).toUpperCase(Locale.ROOT);
|
||||
if (name.contains(NAMESPACE.toUpperCase(Locale.ROOT))) {
|
||||
name = name.split(":")[1];
|
||||
}
|
||||
|
||||
name = net.coreprotect.bukkit.BukkitAdapter.ADAPTER.parseLegacyName(name);
|
||||
material = Material.getMaterial(name);
|
||||
|
||||
if (material == null) {
|
||||
material = Material.getMaterial(name, true);
|
||||
}
|
||||
}
|
||||
|
||||
return material;
|
||||
}
|
||||
|
||||
public static Material getType(String name) {
|
||||
// Name entered by user
|
||||
Material material = null;
|
||||
name = name.toUpperCase(Locale.ROOT).trim();
|
||||
if (!name.startsWith("#")) {
|
||||
if (name.contains(NAMESPACE.toUpperCase(Locale.ROOT))) {
|
||||
name = name.split(":")[1];
|
||||
}
|
||||
|
||||
name = net.coreprotect.bukkit.BukkitAdapter.ADAPTER.parseLegacyName(name);
|
||||
material = Material.matchMaterial(name);
|
||||
}
|
||||
|
||||
return material;
|
||||
}
|
||||
|
||||
public static int getArtId(String name, boolean internal) {
|
||||
int id = -1;
|
||||
name = name.toLowerCase(Locale.ROOT).trim();
|
||||
|
||||
if (ConfigHandler.art.get(name) != null) {
|
||||
id = ConfigHandler.art.get(name);
|
||||
}
|
||||
else if (internal) {
|
||||
int artID = ConfigHandler.artId + 1;
|
||||
ConfigHandler.art.put(name, artID);
|
||||
ConfigHandler.artReversed.put(artID, name);
|
||||
ConfigHandler.artId = artID;
|
||||
Queue.queueArtInsert(artID, name);
|
||||
id = ConfigHandler.art.get(name);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public static String getArtName(int id) {
|
||||
// Internal ID pulled from DB
|
||||
String artname = "";
|
||||
if (ConfigHandler.artReversed.get(id) != null) {
|
||||
artname = ConfigHandler.artReversed.get(id);
|
||||
}
|
||||
return artname;
|
||||
}
|
||||
|
||||
public static int getMaterialId(Material material) {
|
||||
return getBlockId(material.name(), true);
|
||||
}
|
||||
|
||||
public static boolean listContains(Set<Material> list, Material value) {
|
||||
boolean result = false;
|
||||
for (Material list_value : list) {
|
||||
if (list_value.equals(value)) {
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static int rolledBack(int rolledBack, boolean isInventory) {
|
||||
switch (rolledBack) {
|
||||
case 1: // just block rolled back
|
||||
return isInventory ? 0 : 1;
|
||||
case 2: // just inventory rolled back
|
||||
return isInventory ? 1 : 0;
|
||||
case 3: // block and inventory rolled back
|
||||
return 1;
|
||||
default: // no rollbacks
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static int toggleRolledBack(int rolledBack, boolean isInventory) {
|
||||
switch (rolledBack) {
|
||||
case 1: // just block rolled back
|
||||
return isInventory ? 3 : 0;
|
||||
case 2: // just inventory rolled back
|
||||
return isInventory ? 0 : 3;
|
||||
case 3: // block and inventory rolled back
|
||||
return isInventory ? 1 : 2;
|
||||
default: // no rollbacks
|
||||
return isInventory ? 2 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
138
src/main/java/net/coreprotect/utility/StringUtils.java
Normal file
138
src/main/java/net/coreprotect/utility/StringUtils.java
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
package net.coreprotect.utility;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class StringUtils {
|
||||
|
||||
private StringUtils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static String capitalize(String string, boolean allWords) {
|
||||
if (string == null || string.isEmpty()) {
|
||||
return string;
|
||||
}
|
||||
|
||||
if (string.length() <= 1) {
|
||||
return string.toUpperCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
string = string.toLowerCase(Locale.ROOT);
|
||||
|
||||
if (allWords) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (String substring : string.split(" ")) {
|
||||
if (substring.length() >= 3 && !substring.equals("and") && !substring.equals("the")) {
|
||||
substring = substring.substring(0, 1).toUpperCase(Locale.ROOT) + substring.substring(1);
|
||||
}
|
||||
if (builder.length() > 0) {
|
||||
builder.append(" ");
|
||||
}
|
||||
builder.append(substring);
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
return string.substring(0, 1).toUpperCase(Locale.ROOT) + string.substring(1);
|
||||
}
|
||||
|
||||
public static String nameFilter(String name, int data) {
|
||||
if (name.equals("stone")) {
|
||||
switch (data) {
|
||||
case 1:
|
||||
name = "granite";
|
||||
break;
|
||||
case 2:
|
||||
name = "polished_granite";
|
||||
break;
|
||||
case 3:
|
||||
name = "diorite";
|
||||
break;
|
||||
case 4:
|
||||
name = "polished_diorite";
|
||||
break;
|
||||
case 5:
|
||||
name = "andesite";
|
||||
break;
|
||||
case 6:
|
||||
name = "polished_andesite";
|
||||
break;
|
||||
default:
|
||||
name = "stone";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public static String[] toStringArray(String[] array) {
|
||||
int size = array.length;
|
||||
if (size == 11) {
|
||||
String time = array[0];
|
||||
String user = array[1];
|
||||
String x = array[2];
|
||||
String y = array[3];
|
||||
String z = array[4];
|
||||
String type = array[5];
|
||||
String data = array[6];
|
||||
String action = array[7];
|
||||
String rolledBack = array[8];
|
||||
String wid = array[9];
|
||||
String blockData = array[10];
|
||||
return new String[] { time, user, x, y, z, type, data, action, rolledBack, wid, "", "", blockData };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String hoverCommandFilter(String string) {
|
||||
StringBuilder command = new StringBuilder();
|
||||
|
||||
String[] data = string.toLowerCase().split(" ");
|
||||
if (data.length > 2) {
|
||||
if (data[1].equals("l")) {
|
||||
data[1] = "page";
|
||||
}
|
||||
|
||||
if (data[2].startsWith("wid:")) {
|
||||
String nameWid = data[2].replaceFirst("wid:", "");
|
||||
if (nameWid.length() > 0 && nameWid.equals(nameWid.replaceAll("[^0-9]", ""))) {
|
||||
nameWid = WorldUtils.getWorldName(Integer.parseInt(nameWid));
|
||||
if (nameWid.length() > 0) {
|
||||
data[2] = nameWid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (data[1].equals("teleport") && data.length > 5) {
|
||||
data[3] = Integer.toString((int) (Double.parseDouble(data[3]) - 0.50));
|
||||
data[4] = Integer.toString(Integer.parseInt(data[4]));
|
||||
data[5] = Integer.toString((int) (Double.parseDouble(data[5]) - 0.50));
|
||||
}
|
||||
}
|
||||
|
||||
for (String s : data) {
|
||||
if (s.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (command.length() > 0) {
|
||||
command.append(" ");
|
||||
}
|
||||
|
||||
command.append(s);
|
||||
}
|
||||
|
||||
return command.toString();
|
||||
}
|
||||
|
||||
public static Integer[] convertArray(String[] array) {
|
||||
java.util.List<Integer> list = new java.util.ArrayList<>();
|
||||
for (String item : array) {
|
||||
list.add(Integer.parseInt(item));
|
||||
}
|
||||
return list.toArray(new Integer[list.size()]);
|
||||
}
|
||||
}
|
||||
35
src/main/java/net/coreprotect/utility/SystemUtils.java
Normal file
35
src/main/java/net/coreprotect/utility/SystemUtils.java
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package net.coreprotect.utility;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.core.config.Configurator;
|
||||
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.CentralProcessor;
|
||||
|
||||
public class SystemUtils {
|
||||
|
||||
private SystemUtils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static CentralProcessor getProcessorInfo() {
|
||||
CentralProcessor result = null;
|
||||
try {
|
||||
Class.forName("com.sun.jna.Platform");
|
||||
if (System.getProperty("os.name").startsWith("Windows") && !System.getProperty("sun.arch.data.model").equals("64")) {
|
||||
Class.forName("com.sun.jna.platform.win32.Win32Exception");
|
||||
}
|
||||
else if (System.getProperty("os.name").toLowerCase().contains("android") || System.getProperty("java.runtime.name").toLowerCase().contains("android")) {
|
||||
return null;
|
||||
}
|
||||
Configurator.setLevel("oshi.hardware.common.AbstractCentralProcessor", Level.OFF);
|
||||
SystemInfo systemInfo = new SystemInfo();
|
||||
result = systemInfo.getHardware().getProcessor();
|
||||
}
|
||||
catch (Exception e) {
|
||||
// unable to read processor information
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@ import net.coreprotect.language.Phrase;
|
|||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.paper.PaperAdapter;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
|
||||
public class Teleport {
|
||||
|
||||
|
|
@ -52,7 +53,7 @@ public class Teleport {
|
|||
Material type1 = block1.getType();
|
||||
Material type2 = block2.getType();
|
||||
|
||||
if (Util.passableBlock(block1) && Util.passableBlock(block2)) {
|
||||
if (BlockUtils.passableBlock(block1) && BlockUtils.passableBlock(block2)) {
|
||||
if (unsafeBlocks.contains(type1)) {
|
||||
placeSafe = true;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
260
src/main/java/net/coreprotect/utility/VersionUtils.java
Normal file
260
src/main/java/net/coreprotect/utility/VersionUtils.java
Normal file
|
|
@ -0,0 +1,260 @@
|
|||
package net.coreprotect.utility;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.thread.NetworkHandler;
|
||||
import net.coreprotect.worldedit.CoreProtectEditSessionEvent;
|
||||
|
||||
public class VersionUtils {
|
||||
|
||||
private VersionUtils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static String getPluginVersion() {
|
||||
String version = CoreProtect.getInstance().getDescription().getVersion();
|
||||
if (version.contains("-")) {
|
||||
version = version.split("-")[0];
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
public static Integer[] getInternalPluginVersion() {
|
||||
int major = ConfigHandler.EDITION_VERSION;
|
||||
int minor = 0;
|
||||
int revision = 0;
|
||||
|
||||
String pluginVersion = getPluginVersion();
|
||||
if (pluginVersion.contains(".")) {
|
||||
String[] versionSplit = pluginVersion.split("\\.");
|
||||
minor = Integer.parseInt(versionSplit[0]);
|
||||
revision = Integer.parseInt(versionSplit[1]);
|
||||
}
|
||||
else {
|
||||
minor = Integer.parseInt(pluginVersion);
|
||||
}
|
||||
|
||||
return new Integer[] { major, minor, revision };
|
||||
}
|
||||
|
||||
public static String getPluginName() {
|
||||
String name = CoreProtect.getInstance().getDescription().getName();
|
||||
String branch = ConfigHandler.EDITION_BRANCH;
|
||||
|
||||
if (branch.startsWith("-edge")) {
|
||||
name = name + " " + branch.substring(1, 2).toUpperCase() + branch.substring(2, 5);
|
||||
}
|
||||
else if (isCommunityEdition()) {
|
||||
name = name + " " + ConfigHandler.COMMUNITY_EDITION;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public static boolean isSpigot() {
|
||||
try {
|
||||
Class.forName("org.spigotmc.SpigotConfig");
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isPaper() {
|
||||
try {
|
||||
Class.forName("com.destroystokyo.paper.PaperConfig");
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isFolia() {
|
||||
try {
|
||||
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isCommunityEdition() {
|
||||
return !isBranch("edge") && !isBranch("coreprotect") && !validDonationKey();
|
||||
}
|
||||
|
||||
public static boolean isBranch(String branch) {
|
||||
return ConfigHandler.EDITION_BRANCH.contains("-" + branch);
|
||||
}
|
||||
|
||||
public static boolean validDonationKey() {
|
||||
return NetworkHandler.donationKey() != null;
|
||||
}
|
||||
|
||||
public static String getBranch() {
|
||||
String branch = "";
|
||||
try {
|
||||
InputStreamReader reader = new InputStreamReader(CoreProtect.getInstance().getClass().getResourceAsStream("/plugin.yml"));
|
||||
branch = YamlConfiguration.loadConfiguration(reader).getString("branch");
|
||||
reader.close();
|
||||
|
||||
if (branch == null || branch.equals("${project.branch}")) {
|
||||
branch = "";
|
||||
}
|
||||
if (branch.startsWith("-")) {
|
||||
branch = branch.substring(1);
|
||||
}
|
||||
if (branch.length() > 0) {
|
||||
branch = "-" + branch;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return branch;
|
||||
}
|
||||
|
||||
public static boolean newVersion(Integer[] oldVersion, Integer[] currentVersion) {
|
||||
if (oldVersion[0] < currentVersion[0]) {
|
||||
// Major version
|
||||
return true;
|
||||
}
|
||||
else if (oldVersion[0].equals(currentVersion[0]) && oldVersion[1] < currentVersion[1]) {
|
||||
// Minor version
|
||||
return true;
|
||||
}
|
||||
else if (oldVersion.length < 3 && currentVersion.length >= 3 && oldVersion[0].equals(currentVersion[0]) && oldVersion[1].equals(currentVersion[1]) && 0 < currentVersion[2]) {
|
||||
// Revision version (#.# vs #.#.#)
|
||||
return true;
|
||||
}
|
||||
else if (oldVersion.length >= 3 && currentVersion.length >= 3 && oldVersion[0].equals(currentVersion[0]) && oldVersion[1].equals(currentVersion[1]) && oldVersion[2] < currentVersion[2]) {
|
||||
// Revision version (#.#.# vs #.#.#)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean newVersion(Integer[] oldVersion, String currentVersion) {
|
||||
String[] currentVersionSplit = currentVersion.split("\\.");
|
||||
return newVersion(oldVersion, StringUtils.convertArray(currentVersionSplit));
|
||||
}
|
||||
|
||||
public static boolean newVersion(String oldVersion, Integer[] currentVersion) {
|
||||
String[] oldVersionSplit = oldVersion.split("\\.");
|
||||
return newVersion(StringUtils.convertArray(oldVersionSplit), currentVersion);
|
||||
}
|
||||
|
||||
public static boolean newVersion(String oldVersion, String currentVersion) {
|
||||
if (!oldVersion.contains(".") || !currentVersion.contains(".")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String[] oldVersionSplit = oldVersion.split("\\.");
|
||||
String[] currentVersionSplit = currentVersion.split("\\.");
|
||||
return newVersion(StringUtils.convertArray(oldVersionSplit), StringUtils.convertArray(currentVersionSplit));
|
||||
}
|
||||
|
||||
public static void loadWorldEdit() {
|
||||
try {
|
||||
boolean validVersion = true;
|
||||
String version = Bukkit.getServer().getPluginManager().getPlugin("WorldEdit").getDescription().getVersion();
|
||||
if (version.contains(";") || version.contains("+")) {
|
||||
if (version.contains("-beta-")) {
|
||||
version = version.split(";")[0];
|
||||
version = version.split("-beta-")[1];
|
||||
long value = Long.parseLong(version.replaceAll("[^0-9]", ""));
|
||||
if (value < 6) {
|
||||
validVersion = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (version.contains("+")) {
|
||||
version = version.split("\\+")[1];
|
||||
}
|
||||
else {
|
||||
version = version.split(";")[1];
|
||||
}
|
||||
|
||||
if (version.contains("-")) {
|
||||
long value = Long.parseLong(((version.split("-"))[0]).replaceAll("[^0-9]", ""));
|
||||
if (value > 0 && value < 4268) {
|
||||
validVersion = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (version.contains(".")) {
|
||||
String[] worldEditVersion = version.split("-|\\.");
|
||||
if (worldEditVersion.length >= 2) {
|
||||
worldEditVersion[0] = worldEditVersion[0].replaceAll("[^0-9]", "");
|
||||
worldEditVersion[1] = worldEditVersion[1].replaceAll("[^0-9]", "");
|
||||
if (worldEditVersion[0].length() == 0 || worldEditVersion[1].length() == 0 || newVersion(worldEditVersion[0] + "." + worldEditVersion[1], "7.1")) {
|
||||
validVersion = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (version.equals("unspecified")) { // FAWE
|
||||
validVersion = false;
|
||||
Plugin fawe = Bukkit.getServer().getPluginManager().getPlugin("FastAsyncWorldEdit");
|
||||
if (fawe != null) {
|
||||
String apiVersion = Bukkit.getServer().getPluginManager().getPlugin("WorldEdit").getDescription().getAPIVersion();
|
||||
String faweVersion = fawe.getDescription().getVersion();
|
||||
double apiDouble = Double.parseDouble(apiVersion);
|
||||
double faweDouble = Double.parseDouble(faweVersion);
|
||||
if (apiDouble >= 1.13 && faweDouble >= 1.0) {
|
||||
validVersion = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
validVersion = false;
|
||||
}
|
||||
|
||||
if (validVersion) {
|
||||
CoreProtectEditSessionEvent.register();
|
||||
}
|
||||
else {
|
||||
Chat.console(Phrase.build(Phrase.INTEGRATION_VERSION, "WorldEdit"));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void unloadWorldEdit() {
|
||||
try {
|
||||
CoreProtectEditSessionEvent.unregister();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean checkWorldEdit() {
|
||||
boolean result = false;
|
||||
for (org.bukkit.World world : Bukkit.getServer().getWorlds()) {
|
||||
if (net.coreprotect.config.Config.getConfig(world).WORLDEDIT) {
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
124
src/main/java/net/coreprotect/utility/WorldUtils.java
Normal file
124
src/main/java/net/coreprotect/utility/WorldUtils.java
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
package net.coreprotect.utility;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
|
||||
public class WorldUtils extends Queue {
|
||||
|
||||
private WorldUtils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static int getWorldId(String name) {
|
||||
int id = -1;
|
||||
try {
|
||||
if (ConfigHandler.worlds.get(name) == null) {
|
||||
int wid = ConfigHandler.worldId + 1;
|
||||
ConfigHandler.worlds.put(name, wid);
|
||||
ConfigHandler.worldsReversed.put(wid, name);
|
||||
ConfigHandler.worldId = wid;
|
||||
Queue.queueWorldInsert(wid, name);
|
||||
}
|
||||
id = ConfigHandler.worlds.get(name);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public static String getWorldName(int id) {
|
||||
String name = "";
|
||||
try {
|
||||
if (ConfigHandler.worldsReversed.get(id) != null) {
|
||||
name = ConfigHandler.worldsReversed.get(id);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public static int matchWorld(String name) {
|
||||
int id = -1;
|
||||
try {
|
||||
// Parse wid:# parameter used internally for /co tp click events
|
||||
if (name.startsWith("wid:")) {
|
||||
String nameWid = name.replaceFirst("wid:", "");
|
||||
if (nameWid.length() > 0 && nameWid.equals(nameWid.replaceAll("[^0-9]", ""))) {
|
||||
nameWid = getWorldName(Integer.parseInt(nameWid));
|
||||
if (nameWid.length() > 0) {
|
||||
name = nameWid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Determine closest match on world name
|
||||
String result = "";
|
||||
name = name.replaceFirst("#", "").toLowerCase(java.util.Locale.ROOT).trim();
|
||||
for (World world : Bukkit.getServer().getWorlds()) {
|
||||
String worldName = world.getName();
|
||||
if (worldName.toLowerCase(java.util.Locale.ROOT).equals(name)) {
|
||||
result = world.getName();
|
||||
break;
|
||||
}
|
||||
else if (worldName.toLowerCase(java.util.Locale.ROOT).endsWith(name)) {
|
||||
result = world.getName();
|
||||
}
|
||||
else if (worldName.toLowerCase(java.util.Locale.ROOT).replaceAll("[^a-zA-Z0-9]", "").endsWith(name)) {
|
||||
result = world.getName();
|
||||
}
|
||||
}
|
||||
|
||||
if (result.length() > 0) {
|
||||
id = getWorldId(result);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public static String getWidIndex(String queryTable) {
|
||||
String index = "";
|
||||
boolean isMySQL = net.coreprotect.config.Config.getGlobal().MYSQL;
|
||||
if (isMySQL) {
|
||||
index = "USE INDEX(wid) ";
|
||||
}
|
||||
else {
|
||||
switch (queryTable) {
|
||||
case "block":
|
||||
index = "INDEXED BY block_index ";
|
||||
break;
|
||||
case "container":
|
||||
index = "INDEXED BY container_index ";
|
||||
break;
|
||||
case "item":
|
||||
index = "INDEXED BY item_index ";
|
||||
break;
|
||||
case "sign":
|
||||
index = "INDEXED BY sign_index ";
|
||||
break;
|
||||
case "chat":
|
||||
index = "INDEXED BY chat_wid_index ";
|
||||
break;
|
||||
case "command":
|
||||
index = "INDEXED BY command_wid_index ";
|
||||
break;
|
||||
case "session":
|
||||
index = "INDEXED BY session_index ";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
|
@ -63,6 +63,7 @@ import net.coreprotect.database.rollback.Rollback;
|
|||
import net.coreprotect.thread.CacheHandler;
|
||||
import net.coreprotect.thread.Scheduler;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.WorldUtils;
|
||||
|
||||
public class EntityUtil {
|
||||
|
||||
|
|
@ -98,7 +99,7 @@ public class EntityUtil {
|
|||
}
|
||||
|
||||
int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
int wid = Util.getWorldId(block.getWorld().getName());
|
||||
int wid = WorldUtils.getWorldId(block.getWorld().getName());
|
||||
String token = "" + block.getX() + "." + block.getY() + "." + block.getZ() + "." + wid + "." + type.name() + "";
|
||||
CacheHandler.entityCache.put(token, new Object[] { unixtimestamp, entity.getEntityId() });
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ import org.bukkit.inventory.ItemStack;
|
|||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.MaterialUtils;
|
||||
|
||||
public class HangingUtil {
|
||||
|
||||
|
|
@ -79,16 +81,16 @@ public class HangingUtil {
|
|||
block = c4;
|
||||
}
|
||||
|
||||
if (!Util.solidBlock(Util.getType(block.getRelative(BlockFace.EAST)))) {
|
||||
if (!BlockUtils.solidBlock(BlockUtils.getType(block.getRelative(BlockFace.EAST)))) {
|
||||
face = BlockFace.EAST;
|
||||
}
|
||||
else if (!Util.solidBlock(Util.getType(block.getRelative(BlockFace.NORTH)))) {
|
||||
else if (!BlockUtils.solidBlock(BlockUtils.getType(block.getRelative(BlockFace.NORTH)))) {
|
||||
face = BlockFace.NORTH;
|
||||
}
|
||||
else if (!Util.solidBlock(Util.getType(block.getRelative(BlockFace.WEST)))) {
|
||||
else if (!BlockUtils.solidBlock(BlockUtils.getType(block.getRelative(BlockFace.WEST)))) {
|
||||
face = BlockFace.WEST;
|
||||
}
|
||||
else if (!Util.solidBlock(Util.getType(block.getRelative(BlockFace.SOUTH)))) {
|
||||
else if (!BlockUtils.solidBlock(BlockUtils.getType(block.getRelative(BlockFace.SOUTH)))) {
|
||||
face = BlockFace.SOUTH;
|
||||
}
|
||||
}
|
||||
|
|
@ -99,7 +101,7 @@ public class HangingUtil {
|
|||
|
||||
if (faceSet != null && face != null) {
|
||||
if (rowType.equals(Material.PAINTING)) {
|
||||
String name = Util.getArtName(rowData);
|
||||
String name = MaterialUtils.getArtName(rowData);
|
||||
Art painting = Art.getByName(name.toUpperCase(Locale.ROOT));
|
||||
int height = painting.getBlockHeight();
|
||||
int width = painting.getBlockWidth();
|
||||
|
|
@ -123,7 +125,7 @@ public class HangingUtil {
|
|||
}
|
||||
Block spawnBlock = hangingFace != null ? block : block.getRelative(face);
|
||||
if (hangingFace == null) {
|
||||
Util.setTypeAndData(spawnBlock, Material.AIR, null, true);
|
||||
BlockUtils.setTypeAndData(spawnBlock, Material.AIR, null, true);
|
||||
}
|
||||
Painting hanging = null;
|
||||
try {
|
||||
|
|
@ -141,7 +143,7 @@ public class HangingUtil {
|
|||
try {
|
||||
Block spawnBlock = hangingFace != null ? block : block.getRelative(face);
|
||||
if (hangingFace == null) {
|
||||
Util.setTypeAndData(spawnBlock, Material.AIR, null, true);
|
||||
BlockUtils.setTypeAndData(spawnBlock, Material.AIR, null, true);
|
||||
}
|
||||
Class itemFrame = BukkitAdapter.ADAPTER.getFrameClass(rowType);
|
||||
Entity entity = block.getWorld().spawn(spawnBlock.getLocation(), itemFrame);
|
||||
|
|
@ -150,7 +152,7 @@ public class HangingUtil {
|
|||
hanging.teleport(block.getWorld().getBlockAt(x, y, z).getLocation());
|
||||
hanging.setFacingDirection(faceSet, true);
|
||||
|
||||
Material type = Util.getType(rowData);
|
||||
Material type = MaterialUtils.getType(rowData);
|
||||
if (type != null) {
|
||||
ItemStack istack = new ItemStack(type, 1);
|
||||
hanging.setItem(istack);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ import org.bukkit.potion.PotionEffect;
|
|||
|
||||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.StringUtils;
|
||||
|
||||
public class ItemMetaHandler {
|
||||
|
||||
|
|
@ -43,7 +44,7 @@ public class ItemMetaHandler {
|
|||
name = "Curse of Binding";
|
||||
break;
|
||||
default:
|
||||
name = Util.capitalize(name.replace("_", " "), true);
|
||||
name = StringUtils.capitalize(name.replace("_", " "), true);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +217,7 @@ public class ItemMetaHandler {
|
|||
list = new ArrayList<>();
|
||||
|
||||
for (ItemStack chargedProjectile : subMeta.getChargedProjectiles()) {
|
||||
Map<String, Object> itemMap = Util.serializeItemStack(chargedProjectile, null, slot);
|
||||
Map<String, Object> itemMap = ItemUtils.serializeItemStack(chargedProjectile, null, slot);
|
||||
if (itemMap.size() > 0) {
|
||||
list.add(itemMap);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import com.sk89q.worldedit.world.block.BlockState;
|
|||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.utility.ItemUtils;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class CoreProtectLogger extends AbstractDelegateExtent {
|
||||
|
|
@ -54,7 +55,7 @@ public class CoreProtectLogger extends AbstractDelegateExtent {
|
|||
// No clear way to get container content data from within the WorldEdit API
|
||||
// Data may be available by converting oldBlock.toBaseBlock().getNbtData()
|
||||
// e.g. BaseBlock block = eventWorld.getBlock(position);
|
||||
ItemStack[] containerData = CoreProtectEditSessionEvent.isFAWE() ? null : Util.getContainerContents(oldType, null, location);
|
||||
ItemStack[] containerData = CoreProtectEditSessionEvent.isFAWE() ? null : ItemUtils.getContainerContents(oldType, null, location);
|
||||
|
||||
if (CoreProtectEditSessionEvent.isFAWE()) {
|
||||
if (eventExtent.setBlock(position.getX(), position.getY(), position.getZ(), block)) {
|
||||
|
|
@ -107,7 +108,7 @@ public class CoreProtectLogger extends AbstractDelegateExtent {
|
|||
// No clear way to get container content data from within the WorldEdit API
|
||||
// Data may be available by converting oldBlock.toBaseBlock().getNbtData()
|
||||
// e.g. BaseBlock block = eventWorld.getBlock(position);
|
||||
ItemStack[] containerData = CoreProtectEditSessionEvent.isFAWE() ? null : Util.getContainerContents(oldType, null, location);
|
||||
ItemStack[] containerData = CoreProtectEditSessionEvent.isFAWE() ? null : ItemUtils.getContainerContents(oldType, null, location);
|
||||
WorldEditLogger.postProcess(eventExtent, eventActor, position, location, pattern.applyBlock(position), baseBlock, oldType, oldBlock, containerData);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|||
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.utility.Util;
|
||||
import net.coreprotect.utility.BlockUtils;
|
||||
import net.coreprotect.utility.EntityUtils;
|
||||
|
||||
public class WorldEditLogger extends Queue {
|
||||
|
||||
|
|
@ -88,7 +89,7 @@ public class WorldEditLogger extends Queue {
|
|||
if (mobType != null) {
|
||||
try {
|
||||
EntityType entityType = EntityType.valueOf(mobType);
|
||||
oldBlockExtraData = Util.getSpawnerType(entityType);
|
||||
oldBlockExtraData = EntityUtils.getSpawnerType(entityType);
|
||||
}
|
||||
catch (IllegalArgumentException exception) {
|
||||
// mobType isn't a valid enum (EntityType.class)
|
||||
|
|
@ -114,7 +115,7 @@ public class WorldEditLogger extends Queue {
|
|||
}
|
||||
else if ((!oldType.equals(Material.AIR) && !oldType.equals(Material.CAVE_AIR)) && (!newType.equals(Material.AIR) && !newType.equals(Material.CAVE_AIR))) {
|
||||
// replaced a block
|
||||
Waterlogged waterlogged = Util.checkWaterlogged(newBlockData, oldBlock);
|
||||
Waterlogged waterlogged = BlockUtils.checkWaterlogged(newBlockData, oldBlock);
|
||||
if (waterlogged != null) {
|
||||
newBlockDataString = waterlogged.getAsString();
|
||||
oldBlock = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue