Refactored view flag to be abstract class
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Dieser Commit ist enthalten in:
Ursprung
48175de8d8
Commit
c03fbb65e6
@ -101,18 +101,22 @@ public class TraceCommand extends SWCommand {
|
||||
return new TypeMapper<ViewFlag>() {
|
||||
@Override
|
||||
public ViewFlag map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
for(ViewFlag filter: ViewFlag.values()) {
|
||||
if (s.equals("--" + filter.toString().toLowerCase()))
|
||||
return filter;
|
||||
for(ViewFlag flag: ViewFlag.flags) {
|
||||
if (s.equals("--" + flag.name))
|
||||
return flag;
|
||||
|
||||
for(String alias: flag.aliases)
|
||||
if (s.equals("--" + alias))
|
||||
return flag;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||
return Arrays.stream(ViewFlag.values())
|
||||
.map(Enum::toString)
|
||||
.map(string -> "--" + string.toLowerCase())
|
||||
return ViewFlag.flags.stream()
|
||||
.map(viewFlag -> viewFlag.name)
|
||||
.map(name -> "--" + name)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
};
|
||||
|
@ -28,14 +28,7 @@ import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
public enum ViewFlag {
|
||||
EXPLOSION((List<TNTRecord> records) ->{
|
||||
List<TNTRecord> ret = new ArrayList<>();
|
||||
for(TNTRecord record : records)
|
||||
if(record.isExplosion())
|
||||
ret.add(record);
|
||||
return ret;
|
||||
}, (REntityServer server , List<TraceEntity> entities) -> {});
|
||||
public abstract class ViewFlag {
|
||||
|
||||
/**
|
||||
* The filtering part of the flag
|
||||
@ -47,8 +40,24 @@ public enum ViewFlag {
|
||||
*/
|
||||
public final BiConsumer<REntityServer, List<TraceEntity>> modify;
|
||||
|
||||
ViewFlag(UnaryOperator<List<TNTRecord>> filter, BiConsumer<REntityServer,List<TraceEntity>> modify) {
|
||||
/**
|
||||
* Name of the flag
|
||||
*/
|
||||
public final String name;
|
||||
|
||||
/**
|
||||
* Aliases of the flag
|
||||
*/
|
||||
public final String[] aliases;
|
||||
|
||||
public static final List<ViewFlag> flags = new ArrayList<>();
|
||||
|
||||
public ViewFlag(UnaryOperator<List<TNTRecord>> filter, BiConsumer<REntityServer,List<TraceEntity>> modify, boolean isStatic, String name, String... aliases) {
|
||||
this.filter = filter;
|
||||
this.modify = modify;
|
||||
this.name = name;
|
||||
this.aliases = aliases;
|
||||
if(isStatic)
|
||||
flags.add(this);
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren