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
|
|
@ -3,8 +3,10 @@ package net.coreprotect.command;
|
|||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
|
@ -255,9 +257,9 @@ public class CommandHandler implements CommandExecutor {
|
|||
return result;
|
||||
}
|
||||
|
||||
protected static List<Object> parseExcluded(CommandSender player, String[] inputArguments, List<Integer> argAction) {
|
||||
protected static Map<Object, Boolean> parseExcluded(CommandSender player, String[] inputArguments, List<Integer> argAction) {
|
||||
String[] argumentArray = inputArguments.clone();
|
||||
List<Object> excluded = new ArrayList<>();
|
||||
Map<Object, Boolean> excluded = new HashMap<>();
|
||||
int count = 0;
|
||||
int next = 0;
|
||||
for (String argument : argumentArray) {
|
||||
|
|
@ -276,20 +278,22 @@ public class CommandHandler implements CommandExecutor {
|
|||
String[] i2 = argument.split(",");
|
||||
for (String i3 : i2) {
|
||||
if (i3.equals("#natural")) {
|
||||
excluded.addAll(naturalBlocks);
|
||||
for (Material block : naturalBlocks) {
|
||||
excluded.put(block, false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Material i3_material = Util.getType(i3);
|
||||
if (i3_material != null && (i3_material.isBlock() || argAction.contains(4))) {
|
||||
excluded.add(i3_material);
|
||||
excluded.put(i3_material, false);
|
||||
}
|
||||
else {
|
||||
EntityType i3_entity = Util.getEntityType(i3);
|
||||
if (i3_entity != null) {
|
||||
excluded.add(i3_entity);
|
||||
excluded.put(i3_entity, false);
|
||||
}
|
||||
else if (i3_material != null) {
|
||||
excluded.add(i3_material);
|
||||
excluded.put(i3_material, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -303,20 +307,22 @@ public class CommandHandler implements CommandExecutor {
|
|||
}
|
||||
else {
|
||||
if (argument.equals("#natural")) {
|
||||
excluded.addAll(naturalBlocks);
|
||||
for (Material block : naturalBlocks) {
|
||||
excluded.put(block, false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Material iMaterial = Util.getType(argument);
|
||||
if (iMaterial != null && (iMaterial.isBlock() || argAction.contains(4))) {
|
||||
excluded.add(iMaterial);
|
||||
excluded.put(iMaterial, false);
|
||||
}
|
||||
else {
|
||||
EntityType iEntity = Util.getEntityType(argument);
|
||||
if (iEntity != null) {
|
||||
excluded.add(iEntity);
|
||||
excluded.put(iEntity, false);
|
||||
}
|
||||
else if (iMaterial != null) {
|
||||
excluded.add(iMaterial);
|
||||
excluded.put(iMaterial, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import java.text.NumberFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
|
@ -49,7 +50,7 @@ public class LookupCommand {
|
|||
int argNoisy = CommandHandler.parseNoisy(args);
|
||||
List<Integer> argAction = CommandHandler.parseAction(args);
|
||||
List<Object> argBlocks = CommandHandler.parseRestricted(player, args, argAction);
|
||||
List<Object> argExclude = CommandHandler.parseExcluded(player, args, argAction);
|
||||
Map<Object, Boolean> argExclude = CommandHandler.parseExcluded(player, args, argAction);
|
||||
List<String> argExcludeUsers = CommandHandler.parseExcludedUsers(player, args);
|
||||
String ts = CommandHandler.parseTimeString(args);
|
||||
long[] argTime = CommandHandler.parseTime(args);
|
||||
|
|
@ -94,7 +95,7 @@ public class LookupCommand {
|
|||
}
|
||||
|
||||
/* check for invalid block/entity combinations (exclude) */
|
||||
for (Object arg : argExclude) {
|
||||
for (Object arg : argExclude.keySet()) {
|
||||
if (arg instanceof Material) {
|
||||
hasBlock = true;
|
||||
}
|
||||
|
|
@ -266,9 +267,9 @@ public class LookupCommand {
|
|||
}
|
||||
|
||||
if (argAction.contains(4) && argAction.contains(11)) { // a:inventory
|
||||
argExclude.add(Material.FIRE);
|
||||
argExclude.add(Material.WATER);
|
||||
argExclude.add(Material.FARMLAND);
|
||||
argExclude.put(Material.FIRE, false);
|
||||
argExclude.put(Material.WATER, false);
|
||||
argExclude.put(Material.FARMLAND, false);
|
||||
argExcludeUsers.add("#hopper");
|
||||
}
|
||||
|
||||
|
|
@ -695,7 +696,7 @@ public class LookupCommand {
|
|||
final int restricted = argRestricted;
|
||||
// final List<String> uuid_list = arg_uuids;
|
||||
final List<Object> blist = argBlocks;
|
||||
final List<Object> elist = argExclude;
|
||||
final Map<Object, Boolean> elist = argExclude;
|
||||
final List<String> euserlist = argExcludeUsers;
|
||||
final int page = pa;
|
||||
final int displayResults = re;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import java.sql.Statement;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
|
@ -39,7 +40,7 @@ public class RollbackRestoreCommand {
|
|||
int argNoisy = CommandHandler.parseNoisy(args);
|
||||
List<Integer> argAction = CommandHandler.parseAction(args);
|
||||
List<Object> argBlocks = CommandHandler.parseRestricted(player, args, argAction);
|
||||
List<Object> argExclude = CommandHandler.parseExcluded(player, args, argAction);
|
||||
Map<Object, Boolean> argExclude = CommandHandler.parseExcluded(player, args, argAction);
|
||||
List<String> argExcludeUsers = CommandHandler.parseExcludedUsers(player, args);
|
||||
String ts = CommandHandler.parseTimeString(args);
|
||||
long[] argTime = CommandHandler.parseTime(args);
|
||||
|
|
@ -76,7 +77,7 @@ public class RollbackRestoreCommand {
|
|||
}
|
||||
|
||||
/* check for invalid block/entity combinations (exclude) */
|
||||
for (Object arg : argExclude) {
|
||||
for (Object arg : argExclude.keySet()) {
|
||||
if (arg instanceof Material) {
|
||||
hasBlock = true;
|
||||
}
|
||||
|
|
@ -186,11 +187,14 @@ public class RollbackRestoreCommand {
|
|||
return;
|
||||
}
|
||||
|
||||
argExclude.add(Material.FIRE);
|
||||
argExclude.add(Material.WATER);
|
||||
argExclude.add(Material.FARMLAND);
|
||||
argExclude.put(Material.FIRE, false);
|
||||
argExclude.put(Material.WATER, false);
|
||||
argExclude.put(Material.FARMLAND, false);
|
||||
argExcludeUsers.add("#hopper");
|
||||
}
|
||||
else if (!argAction.contains(4) && Config.getGlobal().EXCLUDE_TNT && !argExclude.containsKey(Material.TNT) && !argBlocks.contains(Material.TNT)) {
|
||||
argExclude.put(Material.TNT, true);
|
||||
}
|
||||
|
||||
if (g == 1 && (argUsers.size() > 0 || (argUsers.size() == 0 && argRadius != null))) {
|
||||
Integer MAX_RADIUS = Config.getGlobal().MAX_RADIUS;
|
||||
|
|
@ -329,7 +333,7 @@ public class RollbackRestoreCommand {
|
|||
final String rtime = ts;
|
||||
final List<String> uuidList = argUuids;
|
||||
final List<Object> blist = argBlocks;
|
||||
final List<Object> elist = argExclude;
|
||||
final Map<Object, Boolean> elist = argExclude;
|
||||
final List<String> euserlist = argExcludeUsers;
|
||||
final Location locationFinal = lo;
|
||||
final int finalArgWid = argWid;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue