Fix SWCommand
Dieser Commit ist enthalten in:
Ursprung
e09fc62bb2
Commit
6859d9bc10
@ -28,6 +28,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.IntPredicate;
|
||||
@ -151,16 +152,19 @@ public abstract class SWCommand {
|
||||
if (!field.getType().getTypeName().equals("de.steamwar.message.Message")) {
|
||||
return;
|
||||
}
|
||||
Object o = Modifier.isStatic(field.getModifiers()) ? field.get(null) : field.get(this);
|
||||
AtomicReference<Object> o = new AtomicReference<>(null);
|
||||
Method method = o.getClass().getMethod("parse");
|
||||
message = (s, commandSender) -> {
|
||||
try {
|
||||
return (String) method.invoke(o, s, commandSender);
|
||||
if (o.get() == null) {
|
||||
o.set(Modifier.isStatic(field.getModifiers()) ? field.get(null) : field.get(this));
|
||||
}
|
||||
return (String) method.invoke(o.get(), s, commandSender);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
return s;
|
||||
}
|
||||
};
|
||||
} catch (NoSuchFieldException | IllegalAccessException | NoSuchMethodException e) {
|
||||
} catch (NoSuchFieldException | NoSuchMethodException e) {
|
||||
// Ignored
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren