Fix LinkageUtils
Dieser Commit ist enthalten in:
Ursprung
ac54f8ef17
Commit
b20ca2fd46
@ -36,7 +36,7 @@ public class NightVisionCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String[] args) {
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(ChatColor.DARK_GRAY + "/" + ChatColor.YELLOW + "nightvision " + ChatColor.DARK_GRAY + "-" + ChatColor.GRAY + " Schalte Nightvision an oder aus.");
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class SpeedCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String[] args) {
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(ChatColor.DARK_GRAY + "/" + ChatColor.YELLOW + "speed " + ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "1" + ChatColor.DARK_GRAY + "-" + ChatColor.YELLOW + "10" + ChatColor.DARK_GRAY + "] - " + ChatColor.GRAY + "Setzte deine Flug- und Laufgeschindigkeit.");
|
||||
p.sendMessage(BauSystem.PREFIX + "Aktuelle geschwindigkeit: " + ChatColor.YELLOW + p.getFlySpeed() * 10F);
|
||||
}
|
||||
|
@ -36,15 +36,17 @@ public class LinkageUtils {
|
||||
private Map<Class<?>, Object> objectMap = new HashMap<>();
|
||||
|
||||
public void link() {
|
||||
internalLinkOrUnlink(false);
|
||||
internalLinkOrUnlink(false, Linked.class);
|
||||
internalLinkOrUnlink(false, Linked.Linkages.class);
|
||||
}
|
||||
|
||||
public void unlink() {
|
||||
internalLinkOrUnlink(true);
|
||||
internalLinkOrUnlink(true, Linked.Linkages.class);
|
||||
internalLinkOrUnlink(true, Linked.class);
|
||||
}
|
||||
|
||||
private void internalLinkOrUnlink(boolean unlink) {
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(BauSystem.class.getResourceAsStream("/de.steamwar.bausystem/" + Linked.class.getTypeName())))) {
|
||||
private void internalLinkOrUnlink(boolean unlink, Class<?> toLink) {
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(BauSystem.class.getResourceAsStream("/de.steamwar.bausystem/" + toLink.getTypeName().replace("$", "."))))) {
|
||||
bufferedReader.lines().forEach(s -> {
|
||||
try {
|
||||
linkOrUnlink(Class.forName(s), unlink);
|
||||
@ -75,14 +77,13 @@ public class LinkageUtils {
|
||||
linkageTypeList.add(linked.value());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
linkageTypeList.removeIf(linkageType -> linkageType.isUnlink() != unlink);
|
||||
if (linkageTypeList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
linkageTypeList.removeIf(linkageType -> linkageType.isUnlink() != unlink);
|
||||
linkageTypeList.sort(Comparator.comparingInt(LinkageType::getOrder));
|
||||
|
||||
Object object = objectMap.computeIfAbsent(clazz, LinkageUtils::constructInstance);
|
||||
linkageTypeList.forEach(linkageType -> linkageType.getLinkageConsumer().accept(object));
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import java.lang.annotation.*;
|
||||
public @interface Linked {
|
||||
LinkageType value();
|
||||
|
||||
@IndexAnnotated
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE})
|
||||
@interface Linkages {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren