Fix LinkageUtils
Dieser Commit ist enthalten in:
Ursprung
ac54f8ef17
Commit
b20ca2fd46
@ -36,7 +36,7 @@ public class NightVisionCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(help = true)
|
@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.");
|
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)
|
@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(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);
|
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<>();
|
private Map<Class<?>, Object> objectMap = new HashMap<>();
|
||||||
|
|
||||||
public void link() {
|
public void link() {
|
||||||
internalLinkOrUnlink(false);
|
internalLinkOrUnlink(false, Linked.class);
|
||||||
|
internalLinkOrUnlink(false, Linked.Linkages.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unlink() {
|
public void unlink() {
|
||||||
internalLinkOrUnlink(true);
|
internalLinkOrUnlink(true, Linked.Linkages.class);
|
||||||
|
internalLinkOrUnlink(true, Linked.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void internalLinkOrUnlink(boolean unlink) {
|
private void internalLinkOrUnlink(boolean unlink, Class<?> toLink) {
|
||||||
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(BauSystem.class.getResourceAsStream("/de.steamwar.bausystem/" + Linked.class.getTypeName())))) {
|
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(BauSystem.class.getResourceAsStream("/de.steamwar.bausystem/" + toLink.getTypeName().replace("$", "."))))) {
|
||||||
bufferedReader.lines().forEach(s -> {
|
bufferedReader.lines().forEach(s -> {
|
||||||
try {
|
try {
|
||||||
linkOrUnlink(Class.forName(s), unlink);
|
linkOrUnlink(Class.forName(s), unlink);
|
||||||
@ -76,13 +78,12 @@ public class LinkageUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
linkageTypeList.removeIf(linkageType -> linkageType.isUnlink() != unlink);
|
||||||
if (linkageTypeList.isEmpty()) {
|
if (linkageTypeList.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
linkageTypeList.removeIf(linkageType -> linkageType.isUnlink() != unlink);
|
|
||||||
linkageTypeList.sort(Comparator.comparingInt(LinkageType::getOrder));
|
linkageTypeList.sort(Comparator.comparingInt(LinkageType::getOrder));
|
||||||
|
|
||||||
Object object = objectMap.computeIfAbsent(clazz, LinkageUtils::constructInstance);
|
Object object = objectMap.computeIfAbsent(clazz, LinkageUtils::constructInstance);
|
||||||
linkageTypeList.forEach(linkageType -> linkageType.getLinkageConsumer().accept(object));
|
linkageTypeList.forEach(linkageType -> linkageType.getLinkageConsumer().accept(object));
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import java.lang.annotation.*;
|
|||||||
public @interface Linked {
|
public @interface Linked {
|
||||||
LinkageType value();
|
LinkageType value();
|
||||||
|
|
||||||
|
@IndexAnnotated
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ElementType.TYPE})
|
@Target({ElementType.TYPE})
|
||||||
@interface Linkages {
|
@interface Linkages {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren