Added hidden "exclude-tnt" rollback option to exclude TNT blocks (default: false)
This commit is contained in:
parent
2b96daa422
commit
02dcc873d6
9 changed files with 68 additions and 41 deletions
|
|
@ -4,6 +4,7 @@ import java.sql.Statement;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
|
@ -28,7 +29,7 @@ import net.coreprotect.utility.Util;
|
|||
|
||||
public class ContainerRollback extends Queue {
|
||||
|
||||
public static void performContainerRollbackRestore(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, String timeString, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, final Location location, Integer[] radius, long startTime, long endTime, boolean restrictWorld, boolean lookup, boolean verbose, final int rollbackType) {
|
||||
public static void performContainerRollbackRestore(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, String timeString, List<Object> restrictList, Map<Object, Boolean> excludeList, List<String> excludeUserList, List<Integer> actionList, final Location location, Integer[] radius, long startTime, long endTime, boolean restrictWorld, boolean lookup, boolean verbose, final int rollbackType) {
|
||||
try {
|
||||
long timeStart = System.currentTimeMillis();
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
|
@ -75,7 +76,7 @@ public class Lookup extends Queue {
|
|||
return newList;
|
||||
}
|
||||
|
||||
public static long countLookupRows(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, Long[] rowData, long startTime, long endTime, boolean restrictWorld, boolean lookup) {
|
||||
public static long countLookupRows(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, Map<Object, Boolean> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, Long[] rowData, long startTime, long endTime, boolean restrictWorld, boolean lookup) {
|
||||
Long rows = 0L;
|
||||
|
||||
try {
|
||||
|
|
@ -102,7 +103,7 @@ public class Lookup extends Queue {
|
|||
return rows;
|
||||
}
|
||||
|
||||
public static List<String[]> performLookup(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, long startTime, long endTime, boolean restrictWorld, boolean lookup) {
|
||||
public static List<String[]> performLookup(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, Map<Object, Boolean> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, long startTime, long endTime, boolean restrictWorld, boolean lookup) {
|
||||
List<String[]> newList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
|
|
@ -116,7 +117,7 @@ public class Lookup extends Queue {
|
|||
return newList;
|
||||
}
|
||||
|
||||
static List<Object[]> performLookupRaw(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, Long[] rowData, long startTime, long endTime, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup) {
|
||||
static List<Object[]> performLookupRaw(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, Map<Object, Boolean> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, Long[] rowData, long startTime, long endTime, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup) {
|
||||
List<Object[]> list = new ArrayList<>();
|
||||
List<Integer> invalidRollbackActions = new ArrayList<>();
|
||||
invalidRollbackActions.add(2);
|
||||
|
|
@ -272,7 +273,7 @@ public class Lookup extends Queue {
|
|||
return list;
|
||||
}
|
||||
|
||||
public static List<String[]> performPartialLookup(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, Long[] rowData, long startTime, long endTime, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup) {
|
||||
public static List<String[]> performPartialLookup(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, Map<Object, Boolean> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, Long[] rowData, long startTime, long endTime, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup) {
|
||||
List<String[]> newList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
|
|
@ -286,7 +287,7 @@ public class Lookup extends Queue {
|
|||
return newList;
|
||||
}
|
||||
|
||||
private static ResultSet rawLookupResultSet(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, Long[] rowData, long startTime, long endTime, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup, boolean count) {
|
||||
private static ResultSet rawLookupResultSet(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, Map<Object, Boolean> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, Long[] rowData, long startTime, long endTime, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup, boolean count) {
|
||||
ResultSet results = null;
|
||||
|
||||
try {
|
||||
|
|
@ -391,7 +392,7 @@ public class Lookup extends Queue {
|
|||
StringBuilder excludeListMaterial = new StringBuilder();
|
||||
StringBuilder excludeListEntity = new StringBuilder();
|
||||
|
||||
for (Object restrictTarget : excludeList) {
|
||||
for (Object restrictTarget : excludeList.keySet()) {
|
||||
String targetName = "";
|
||||
|
||||
if (restrictTarget instanceof Material) {
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ import net.coreprotect.utility.entity.HangingUtil;
|
|||
|
||||
public class Rollback extends Queue {
|
||||
|
||||
public static List<String[]> performRollbackRestore(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, String timeString, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, long startTime, long endTime, boolean restrictWorld, boolean lookup, boolean verbose, final int rollbackType, final int preview) {
|
||||
public static List<String[]> performRollbackRestore(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, String timeString, List<Object> restrictList, Map<Object, Boolean> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, long startTime, long endTime, boolean restrictWorld, boolean lookup, boolean verbose, final int rollbackType, final int preview) {
|
||||
List<String[]> list = new ArrayList<>();
|
||||
|
||||
try {
|
||||
|
|
@ -112,12 +112,12 @@ public class Rollback extends Queue {
|
|||
|
||||
boolean ROLLBACK_ITEMS = false;
|
||||
List<Object> itemRestrictList = new ArrayList<>(restrictList);
|
||||
List<Object> itemExcludeList = new ArrayList<>(excludeList);
|
||||
Map<Object, Boolean> itemExcludeList = new HashMap<>(excludeList);
|
||||
|
||||
if (actionList.contains(1)) {
|
||||
for (Object target : restrictList) {
|
||||
if (target instanceof Material) {
|
||||
if (!excludeList.contains(target)) {
|
||||
if (!excludeList.containsKey(target)) {
|
||||
if (BlockGroup.CONTAINERS.contains(target)) {
|
||||
ROLLBACK_ITEMS = true;
|
||||
itemRestrictList.clear();
|
||||
|
|
@ -137,6 +137,7 @@ public class Rollback extends Queue {
|
|||
itemActionList.add(4);
|
||||
}
|
||||
|
||||
itemExcludeList.entrySet().removeIf(entry -> Boolean.TRUE.equals(entry.getValue()));
|
||||
itemList = Lookup.performLookupRaw(statement, user, checkUuids, checkUsers, itemRestrictList, itemExcludeList, excludeUserList, itemActionList, location, radius, null, startTime, endTime, -1, -1, restrictWorld, lookup);
|
||||
}
|
||||
|
||||
|
|
@ -1277,7 +1278,7 @@ public class Rollback extends Queue {
|
|||
return null;
|
||||
}
|
||||
|
||||
static void finishRollbackRestore(CommandSender user, Location location, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, String timeString, Integer chunkCount, Double seconds, Integer itemCount, Integer blockCount, Integer entityCount, int rollbackType, Integer[] radius, boolean verbose, boolean restrictWorld, int preview) {
|
||||
static void finishRollbackRestore(CommandSender user, Location location, List<String> checkUsers, List<Object> restrictList, Map<Object, Boolean> excludeList, List<String> excludeUserList, List<Integer> actionList, String timeString, Integer chunkCount, Double seconds, Integer itemCount, Integer blockCount, Integer entityCount, int rollbackType, Integer[] radius, boolean verbose, boolean restrictWorld, int preview) {
|
||||
try {
|
||||
if (preview == 2) {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PREVIEW_CANCELLED));
|
||||
|
|
@ -1418,7 +1419,15 @@ public class Rollback extends Queue {
|
|||
boolean entity = false;
|
||||
|
||||
int excludeCount = 0;
|
||||
for (Object excludeTarget : excludeList) {
|
||||
for (Map.Entry<Object, Boolean> entry : excludeList.entrySet()) {
|
||||
Object excludeTarget = entry.getKey();
|
||||
Boolean excludeTargetInternal = entry.getValue();
|
||||
|
||||
// don't display default block excludes
|
||||
if (Boolean.TRUE.equals(excludeTargetInternal)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// don't display that excluded water/fire/farmland in inventory rollbacks
|
||||
if (actionList.contains(4) && actionList.contains(11)) {
|
||||
if (excludeTarget.equals(Material.FIRE) || excludeTarget.equals(Material.WATER) || excludeTarget.equals(Material.FARMLAND)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue