CommandFramework3 #94
@ -61,7 +61,7 @@ class SWCommandUtils {
|
||||
};
|
||||
|
||||
static {
|
||||
MAPPER_FUNCTIONS.put(boolean.class, new TypeMapper<Boolean>() {
|
||||
addMapper(boolean.class, Boolean.class, new TypeMapper<Boolean>() {
|
||||
@Override
|
||||
public Boolean map(String s) {
|
||||
return Boolean.parseBoolean(s);
|
||||
@ -72,18 +72,7 @@ class SWCommandUtils {
|
||||
return Arrays.asList("true", "false");
|
||||
}
|
||||
});
|
||||
MAPPER_FUNCTIONS.put(Boolean.class, new TypeMapper<Boolean>() {
|
||||
@Override
|
||||
public Boolean map(String s) {
|
||||
return Boolean.parseBoolean(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabCompletes(String s) {
|
||||
return Arrays.asList("true", "false");
|
||||
}
|
||||
});
|
||||
MAPPER_FUNCTIONS.put(float.class, new TypeMapper<Float>() {
|
||||
addMapper(float.class, Float.class, new TypeMapper<Float>() {
|
||||
@Override
|
||||
public Float map(String s) {
|
||||
return Float.parseFloat(s);
|
||||
@ -99,23 +88,7 @@ class SWCommandUtils {
|
||||
}
|
||||
}
|
||||
});
|
||||
MAPPER_FUNCTIONS.put(Float.class, new TypeMapper<Float>() {
|
||||
@Override
|
||||
public Float map(String s) {
|
||||
return Float.parseFloat(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabCompletes(String s) {
|
||||
try {
|
||||
Float.parseFloat(s);
|
||||
return Collections.singletonList(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
});
|
||||
MAPPER_FUNCTIONS.put(double.class, new TypeMapper<Double>() {
|
||||
addMapper(double.class, Double.class, new TypeMapper<Double>() {
|
||||
@Override
|
||||
public Double map(String s) {
|
||||
return Double.parseDouble(s);
|
||||
@ -131,39 +104,7 @@ class SWCommandUtils {
|
||||
}
|
||||
}
|
||||
});
|
||||
MAPPER_FUNCTIONS.put(Double.class, new TypeMapper<Double>() {
|
||||
@Override
|
||||
public Double map(String s) {
|
||||
return Double.parseDouble(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabCompletes(String s) {
|
||||
try {
|
||||
Double.parseDouble(s);
|
||||
return Collections.singletonList(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
});
|
||||
MAPPER_FUNCTIONS.put(int.class, new TypeMapper<Integer>() {
|
||||
@Override
|
||||
public Integer map(String s) {
|
||||
return Integer.parseInt(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabCompletes(String s) {
|
||||
try {
|
||||
Integer.parseInt(s);
|
||||
return Collections.singletonList(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
});
|
||||
MAPPER_FUNCTIONS.put(Integer.class, new TypeMapper<Integer>() {
|
||||
addMapper(int.class, Integer.class, new TypeMapper<Integer>() {
|
||||
@Override
|
||||
public Integer map(String s) {
|
||||
return Integer.parseInt(s);
|
||||
@ -214,6 +155,11 @@ class SWCommandUtils {
|
||||
});
|
||||
}
|
||||
|
||||
private static void addMapper(Class<?> clazz, Class<?> alternativeClazz, TypeMapper<?> mapper) {
|
||||
MAPPER_FUNCTIONS.put(clazz, mapper);
|
||||
MAPPER_FUNCTIONS.put(alternativeClazz, mapper);
|
||||
}
|
||||
|
||||
static final CommandMap commandMap;
|
||||
|
||||
static {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren