Make sure all instances are CloseablePluginResults
This commit is contained in:
parent
37823c34c5
commit
bfce868145
1 changed files with 13 additions and 7 deletions
|
|
@ -2,16 +2,24 @@ package net.frankheijden.serverutils.common.entities.results;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CloseablePluginResults<T> extends PluginResults<T> implements Closeable {
|
public class CloseablePluginResults<T> extends PluginResults<T> implements Closeable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CloseablePluginResults<T> addResult(PluginResult<T> pluginResult) {
|
public CloseablePluginResults<T> addResult(PluginResult<T> pluginResult) {
|
||||||
if (!(pluginResult instanceof CloseablePluginResult)) {
|
if (pluginResult instanceof CloseablePluginResult) {
|
||||||
throw new IllegalArgumentException("Not an instance of CloseablePluginResult: " + pluginResult);
|
results.add(pluginResult);
|
||||||
|
} else {
|
||||||
|
results.add(new CloseablePluginResult<>(
|
||||||
|
pluginResult.getPluginId(),
|
||||||
|
pluginResult.getPlugin(),
|
||||||
|
pluginResult.getResult(),
|
||||||
|
Collections.emptyList(),
|
||||||
|
pluginResult.getPlaceholders()
|
||||||
|
));
|
||||||
}
|
}
|
||||||
results.add(pluginResult);
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -28,10 +36,8 @@ public class CloseablePluginResults<T> extends PluginResults<T> implements Close
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CloseablePluginResults<T> addResult(String pluginId, T plugin, Result result, String... placeholders
|
protected CloseablePluginResults<T> addResult(String pluginId, T plugin, Result result, String... placeholders) {
|
||||||
) {
|
return addResult(new CloseablePluginResult<>(pluginId, plugin, result, Collections.emptyList(), placeholders));
|
||||||
super.addResult(pluginId, plugin, result, placeholders);
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CloseablePluginResults<T> addResult(
|
public CloseablePluginResults<T> addResult(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue