forked from LogBlock/LogBlock
Fix cloning of QueryParams and using them async
This commit is contained in:
@ -405,7 +405,7 @@ public class CommandsHandler implements CommandExecutor {
|
|||||||
|
|
||||||
protected AbstractCommand(CommandSender sender, QueryParams params, boolean async) throws Exception {
|
protected AbstractCommand(CommandSender sender, QueryParams params, boolean async) throws Exception {
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.params = params;
|
this.params = params == null ? null : params.clone();
|
||||||
if (async) {
|
if (async) {
|
||||||
scheduler.runTaskAsynchronously(logblock, this);
|
scheduler.runTaskAsynchronously(logblock, this);
|
||||||
} else {
|
} else {
|
||||||
|
@ -534,7 +534,7 @@ public final class QueryParams implements Cloneable {
|
|||||||
final String param = args.get(i).toLowerCase();
|
final String param = args.get(i).toLowerCase();
|
||||||
final String[] values = getValues(args, i + 1);
|
final String[] values = getValues(args, i + 1);
|
||||||
if (param.equals("last")) {
|
if (param.equals("last")) {
|
||||||
if (session.lastQuery == null) {
|
if (session == null || session.lastQuery == null) {
|
||||||
throw new IllegalArgumentException("This is your first command, you can't use last.");
|
throw new IllegalArgumentException("This is your first command, you can't use last.");
|
||||||
}
|
}
|
||||||
merge(session.lastQuery);
|
merge(session.lastQuery);
|
||||||
@ -787,12 +787,16 @@ public final class QueryParams implements Cloneable {
|
|||||||
try {
|
try {
|
||||||
final QueryParams params = (QueryParams) super.clone();
|
final QueryParams params = (QueryParams) super.clone();
|
||||||
params.players = new ArrayList<String>(players);
|
params.players = new ArrayList<String>(players);
|
||||||
|
params.killers = new ArrayList<String>(killers);
|
||||||
|
params.victims = new ArrayList<String>(victims);
|
||||||
params.typeIds = new ArrayList<Integer>(typeIds);
|
params.typeIds = new ArrayList<Integer>(typeIds);
|
||||||
params.types = new ArrayList<Material>(types);
|
params.types = new ArrayList<Material>(types);
|
||||||
|
params.loc = loc == null ? null : loc.clone();
|
||||||
|
params.sel = sel == null ? null : sel.clone();
|
||||||
return params;
|
return params;
|
||||||
} catch (final CloneNotSupportedException ex) {
|
} catch (final CloneNotSupportedException ex) {
|
||||||
|
throw new Error("QueryParams should be cloneable", ex);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String[] getValues(List<String> args, int offset) {
|
private static String[] getValues(List<String> args, int offset) {
|
||||||
@ -825,13 +829,15 @@ public final class QueryParams implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void merge(QueryParams p) {
|
public void merge(QueryParams p) {
|
||||||
players = p.players;
|
players.addAll(p.players);
|
||||||
|
killers.addAll(p.killers);
|
||||||
|
victims.addAll(p.victims);
|
||||||
excludePlayersMode = p.excludePlayersMode;
|
excludePlayersMode = p.excludePlayersMode;
|
||||||
typeIds = p.typeIds;
|
typeIds.addAll(p.typeIds);
|
||||||
types = p.types;
|
types.addAll(p.types);
|
||||||
loc = p.loc;
|
loc = p.loc == null ? null : p.loc.clone();
|
||||||
radius = p.radius;
|
radius = p.radius;
|
||||||
sel = p.sel;
|
sel = p.sel == null ? null : p.sel.clone();
|
||||||
if (p.since != 0 || since != defaultTime) {
|
if (p.since != 0 || since != defaultTime) {
|
||||||
since = p.since;
|
since = p.since;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public class RegionContainer {
|
public class RegionContainer implements Cloneable {
|
||||||
|
|
||||||
private Region selection;
|
private Region selection;
|
||||||
|
|
||||||
@ -57,4 +57,14 @@ public class RegionContainer {
|
|||||||
public void setSelection(Region selection) {
|
public void setSelection(Region selection) {
|
||||||
this.selection = selection;
|
this.selection = selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RegionContainer clone() {
|
||||||
|
try {
|
||||||
|
RegionContainer clone = (RegionContainer) super.clone();
|
||||||
|
return clone;
|
||||||
|
} catch (final CloneNotSupportedException ex) {
|
||||||
|
throw new Error("RegionContainer should be cloneable", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user